diff --git a/src/main/java/com/gis3c/spatial/dao/RegionDao.java b/src/main/java/com/gis3c/spatial/dao/RegionDao.java index 0ba4139..2df3706 100644 --- a/src/main/java/com/gis3c/spatial/dao/RegionDao.java +++ b/src/main/java/com/gis3c/spatial/dao/RegionDao.java @@ -2,6 +2,8 @@ package com.gis3c.spatial.dao; import com.gis3c.common.persistence.annotation.C3SpatialDao; import com.gis3c.spatial.entity.Region; +import com.gis3c.spatial.entity.RegionCenter; +import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; @@ -11,9 +13,28 @@ import java.util.Map; */ @C3SpatialDao public interface RegionDao { - public Region findRegionByCode(String reginTable, String reginCode); - public String findRgionCenterByCode(String reginTable, String reginCode); - public List findAroundRegions(String reginTable, String reginCode); - public List findRegionsByParentCode(String reginTable, String parentCode); - public List> findRegionCentersByParentCode(String reginTable, String parentCode); + public Region findRegionByCode( + @Param("reginTable") String reginTable, + @Param("reginCode") String reginCode + ); + + public String findRgionCenterByCode( + @Param("reginTable") String reginTable, + @Param("reginCode") String reginCode + ); + + public List findAroundRegions( + @Param("reginTable") String reginTable, + @Param("reginCode") String reginCode + ); + + public List findRegionsByParentCode( + @Param("reginTable") String reginTable, + @Param("parentCode") String parentCode + ); + + public List findRegionCentersByParentCode( + @Param("reginTable") String reginTable, + @Param("parentCode") String parentCode + ); } diff --git a/src/main/java/com/gis3c/spatial/entity/RegionCenter.java b/src/main/java/com/gis3c/spatial/entity/RegionCenter.java new file mode 100644 index 0000000..834476e --- /dev/null +++ b/src/main/java/com/gis3c/spatial/entity/RegionCenter.java @@ -0,0 +1,25 @@ +package com.gis3c.spatial.entity; + +/** + * Created by hukekuan on 2018/3/10. + */ +public class RegionCenter { + private String regionCode; + private String center; + + public String getRegionCode() { + return regionCode; + } + + public void setRegionCode(String regionCode) { + this.regionCode = regionCode; + } + + public String getCenter() { + return center; + } + + public void setCenter(String center) { + this.center = center; + } +} diff --git a/src/main/java/com/gis3c/spatial/service/RegionService.java b/src/main/java/com/gis3c/spatial/service/RegionService.java index fa31928..74f0ee7 100644 --- a/src/main/java/com/gis3c/spatial/service/RegionService.java +++ b/src/main/java/com/gis3c/spatial/service/RegionService.java @@ -1,6 +1,7 @@ package com.gis3c.spatial.service; import com.gis3c.spatial.entity.Region; +import com.gis3c.spatial.entity.RegionCenter; import java.util.List; import java.util.Map; @@ -41,5 +42,5 @@ public interface RegionService { * @param parentCode * @return */ - public List> findRegionCentersByParentCode(String parentCode); + public List findRegionCentersByParentCode(String parentCode); } diff --git a/src/main/java/com/gis3c/spatial/service/impl/RegionServiceImpl.java b/src/main/java/com/gis3c/spatial/service/impl/RegionServiceImpl.java index 937373b..7093513 100644 --- a/src/main/java/com/gis3c/spatial/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/gis3c/spatial/service/impl/RegionServiceImpl.java @@ -2,6 +2,7 @@ package com.gis3c.spatial.service.impl; import com.gis3c.spatial.dao.RegionDao; import com.gis3c.spatial.entity.Region; +import com.gis3c.spatial.entity.RegionCenter; import com.gis3c.spatial.entity.RegionType; import com.gis3c.spatial.service.RegionService; import org.springframework.beans.factory.annotation.Autowired; @@ -57,7 +58,7 @@ public class RegionServiceImpl implements RegionService { } @Override - public List> findRegionCentersByParentCode(String parentCode) { + public List findRegionCentersByParentCode(String parentCode) { RegionType parentType = regionTableByCode(parentCode); RegionType regionType = parentType.ChildType(); if (regionType == null) { diff --git a/src/test/java/com/gis3c/spatial/App.java b/src/test/java/com/gis3c/spatial/App.java index 50451c8..0282ee8 100644 --- a/src/test/java/com/gis3c/spatial/App.java +++ b/src/test/java/com/gis3c/spatial/App.java @@ -6,8 +6,12 @@ import com.gis3c.ol.entity.Map; import com.gis3c.ol.service.LayerService; import com.gis3c.ol.service.MapService; import com.gis3c.ol.service.SourceService; +import com.gis3c.spatial.common.FeatureUtilities; +import com.gis3c.spatial.entity.Region; import com.gis3c.spatial.entity.RegionType; +import com.gis3c.spatial.service.RegionService; import com.gis3c.spatial.service.TestService; +import org.opengis.feature.simple.SimpleFeature; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -30,11 +34,15 @@ public class App { // LayerService layerService = context.getBean(LayerService.class); // MapService mapService = context.getBean(MapService.class); // TestService testService = context.getBean(TestService.class); + RegionService regionService = context.getBean(RegionService.class); - - String code = "370300"; - System.out.println(code.substring(0,4)); - +// List regionList = regionService.findRegionsByParentCode("370000"); +// String region = regionService.findRegionCentersByParentCode("370100"); + System.out.println(regionService.findRegionCentersByParentCode("370100").get(0).getCenter()); +// +// List featureList = FeatureUtilities.JavaBeans2Features(regionList); +// +// System.out.println(FeatureUtilities.Features2GeoJSON(featureList)); // RegionType r1 = RegionType.CITY; // RegionType r2 = RegionType.CITY; // diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties new file mode 100644 index 0000000..72b15e3 --- /dev/null +++ b/src/test/resources/log4j.properties @@ -0,0 +1,27 @@ +### 设置### +log4j.rootLogger = debug,stdout,E + +### 输出信息到控制抬 ### +log4j.appender.stdout = org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target = System.out +log4j.appender.stdout.layout = org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern = [%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n + + +### 输出ERROR 级别以上的日志到=E://logs/error.log ### +log4j.appender.E = org.apache.log4j.DailyRollingFileAppender +#log4j.appender.E.File = ${webapp.root}/WEB-INF/logs/error.html +log4j.appender.E.File = E://logs/error.html +log4j.appender.E.Append = true +log4j.appender.E.Threshold = ERROR +log4j.appender.E.layout = org.apache.log4j.HTMLLayout +log4j.appender.E.layout.ConversionPattern = [%d{yyy MMM dd HH:mm:ss,SSS}] [Log-1] [%-5p] [%c{1}] %m%n + + +log4j.logger.com.ibatis=DEBUG +log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG +log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG +log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG +log4j.logger.java.sql.Connection=DEBUG +log4j.logger.java.sql.Statement=DEBUG +log4j.logger.java.sql.PreparedStatement=DEBUG \ No newline at end of file diff --git a/src/test/resources/mappings/spatial/RegionDao.xml b/src/test/resources/mappings/spatial/RegionDao.xml index 612c87e..ad13112 100644 --- a/src/test/resources/mappings/spatial/RegionDao.xml +++ b/src/test/resources/mappings/spatial/RegionDao.xml @@ -6,6 +6,10 @@ + + + + - + SELECT st_astext(st_centroid(t.geom)) FROM ${reginTable} t where t.code = #{reginCode, javaType=java.lang.String}; @@ -26,4 +30,16 @@ ) t2 where ST_Disjoint(t2.geom,t1.geom) = false; + + + + \ No newline at end of file diff --git a/src/test/resources/sql-map-config-mybatis.xml b/src/test/resources/sql-map-config-mybatis.xml index fec7bf2..1408add 100644 --- a/src/test/resources/sql-map-config-mybatis.xml +++ b/src/test/resources/sql-map-config-mybatis.xml @@ -35,6 +35,8 @@ + +