diff --git a/src/main/java/com/gis3c/ol/dao/LayerDao.java b/src/main/java/com/gis3c/ol/dao/LayerDao.java index 7fba7e1..1d685fb 100644 --- a/src/main/java/com/gis3c/ol/dao/LayerDao.java +++ b/src/main/java/com/gis3c/ol/dao/LayerDao.java @@ -20,7 +20,7 @@ public interface LayerDao { public Layer findeLayerById(String layerId); public Layer findeLayerByName(String layerName); public List findLayerByIds(String[] layerIds); - + public Integer findLayerCount(); public Integer insertLayer(Layer layer); public Integer bindSource( diff --git a/src/main/java/com/gis3c/ol/dao/MapDao.java b/src/main/java/com/gis3c/ol/dao/MapDao.java index 4d001de..9d16584 100644 --- a/src/main/java/com/gis3c/ol/dao/MapDao.java +++ b/src/main/java/com/gis3c/ol/dao/MapDao.java @@ -19,6 +19,7 @@ public interface MapDao { public Map findMapById(String mapId); public Map findMapByName(String mapName); + public Integer findMapCount(); public Integer insertMap(Map map); public Integer deleteMapsById(Set mapIds); diff --git a/src/main/java/com/gis3c/ol/dao/SourceDao.java b/src/main/java/com/gis3c/ol/dao/SourceDao.java index 0eccabf..e5c3f64 100644 --- a/src/main/java/com/gis3c/ol/dao/SourceDao.java +++ b/src/main/java/com/gis3c/ol/dao/SourceDao.java @@ -22,6 +22,7 @@ public interface SourceDao { public List findSourceByType( @Param("sourceTypes") String[] sourceTypes, @Param("projection") String projection); + public Integer findSourceCount(); public Integer insertSource(Source source); public Integer deleteSourcesById(Set sourceIds); diff --git a/src/main/java/com/gis3c/ol/service/LayerService.java b/src/main/java/com/gis3c/ol/service/LayerService.java index daf16e3..100013d 100644 --- a/src/main/java/com/gis3c/ol/service/LayerService.java +++ b/src/main/java/com/gis3c/ol/service/LayerService.java @@ -25,7 +25,7 @@ public interface LayerService { public Layer findeLayerById(String layerId); public Layer findeLayerByName(String layerName); public List findLayerByIds(String[] layerIds); - + public Integer findLayerCount(); public Integer insertLayer(Layer layer); public Integer bindSource(String layerId,String sourceId,java.util.Map options); public Integer deleteLayersById(Set layerIds); diff --git a/src/main/java/com/gis3c/ol/service/MapService.java b/src/main/java/com/gis3c/ol/service/MapService.java index d298da3..9c1245d 100644 --- a/src/main/java/com/gis3c/ol/service/MapService.java +++ b/src/main/java/com/gis3c/ol/service/MapService.java @@ -14,6 +14,7 @@ public interface MapService { public Map findMapById(String mapId); public Map findMapByName(String mapName); + public Integer findMapCount(); public Integer insertMap(Map map); public Integer deleteMapsById(Set mapIds); diff --git a/src/main/java/com/gis3c/ol/service/SourceService.java b/src/main/java/com/gis3c/ol/service/SourceService.java index 6f9c76c..62c654a 100644 --- a/src/main/java/com/gis3c/ol/service/SourceService.java +++ b/src/main/java/com/gis3c/ol/service/SourceService.java @@ -15,7 +15,7 @@ public interface SourceService { public Source findSourceById(String sourceId); public Source findSourceByName(String sourceName); public List findSourceByType(String[] sourceTypes,String projection); - + public Integer findSourceCount(); public Integer insertSource(Source source); diff --git a/src/main/java/com/gis3c/ol/service/impl/LayerServiceImpl.java b/src/main/java/com/gis3c/ol/service/impl/LayerServiceImpl.java index 19271fd..44ddf6c 100644 --- a/src/main/java/com/gis3c/ol/service/impl/LayerServiceImpl.java +++ b/src/main/java/com/gis3c/ol/service/impl/LayerServiceImpl.java @@ -98,6 +98,11 @@ public class LayerServiceImpl implements LayerService { return result; } + @Override + public Integer findLayerCount() { + return layerDao.findLayerCount(); + } + @Override public Integer insertLayer(Layer layer) { layer.setLayerId(UUID.randomUUID().toString()); diff --git a/src/main/java/com/gis3c/ol/service/impl/MapServiceImpl.java b/src/main/java/com/gis3c/ol/service/impl/MapServiceImpl.java index d1bb782..d498935 100644 --- a/src/main/java/com/gis3c/ol/service/impl/MapServiceImpl.java +++ b/src/main/java/com/gis3c/ol/service/impl/MapServiceImpl.java @@ -47,6 +47,11 @@ public class MapServiceImpl implements MapService { return mapDao.findMapByName(mapName); } + @Override + public Integer findMapCount() { + return mapDao.findMapCount(); + } + @Override public Integer insertMap(Map map) { map.setMapId(UUID.randomUUID().toString()); diff --git a/src/main/java/com/gis3c/ol/service/impl/SourceServiceImpl.java b/src/main/java/com/gis3c/ol/service/impl/SourceServiceImpl.java index 4316d16..525ff33 100644 --- a/src/main/java/com/gis3c/ol/service/impl/SourceServiceImpl.java +++ b/src/main/java/com/gis3c/ol/service/impl/SourceServiceImpl.java @@ -52,6 +52,11 @@ public class SourceServiceImpl implements SourceService { return sourceDao.findSourceByType(sourceTypes,projection); } + @Override + public Integer findSourceCount() { + return sourceDao.findSourceCount(); + } + @Override public Integer insertSource(Source source) { source.setSourceId(UUID.randomUUID().toString()); diff --git a/src/main/java/com/gis3c/spatial/dao/RegionDao.java b/src/main/java/com/gis3c/spatial/dao/RegionDao.java new file mode 100644 index 0000000..8ccb990 --- /dev/null +++ b/src/main/java/com/gis3c/spatial/dao/RegionDao.java @@ -0,0 +1,17 @@ +package com.gis3c.spatial.dao; + +import com.gis3c.spatial.entity.Region; + +import java.util.List; +import java.util.Map; + +/** + * Created by hukekuan on 2018/3/9. + */ +public interface RegionDao { + public Region findRegionByCode(String reginType, String reginCode); + public String findRgionCenterByCode(String reginType, String reginCode); + public List findAroundRegions(String reginType, String reginCode); + public List findRegionsByParentCode(String parentCode); + public List> findRegionCentersByParentCode(String parentCode); +} diff --git a/src/main/java/com/gis3c/spatial/entity/feature/BaseFeature.java b/src/main/java/com/gis3c/spatial/entity/BaseFeature.java similarity index 87% rename from src/main/java/com/gis3c/spatial/entity/feature/BaseFeature.java rename to src/main/java/com/gis3c/spatial/entity/BaseFeature.java index f83685b..bca7e20 100644 --- a/src/main/java/com/gis3c/spatial/entity/feature/BaseFeature.java +++ b/src/main/java/com/gis3c/spatial/entity/BaseFeature.java @@ -1,19 +1,13 @@ -package com.gis3c.spatial.entity.feature; +package com.gis3c.spatial.entity; import com.vividsolutions.jts.geom.Geometry; -import org.geotools.data.DataUtilities; -import org.geotools.data.simple.SimpleFeatureCollection; import org.geotools.feature.simple.SimpleFeatureBuilder; import org.geotools.feature.simple.SimpleFeatureTypeBuilder; -import org.geotools.geojson.feature.FeatureJSON; import org.geotools.referencing.crs.DefaultGeographicCRS; import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.referencing.crs.CoordinateReferenceSystem; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.StringWriter; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; @@ -24,7 +18,7 @@ import java.util.List; * @Description 具有空间字段的基类 * @date 2017-07-10 下午3:43 */ -public class BaseFeature implements IFeature { +public class BaseFeature { private Geometry geometry; public Geometry getGeometry() { @@ -38,8 +32,7 @@ public class BaseFeature implements IFeature { /** * 获取所有字段信息 */ - @Override - public List AllFieldes(){ + public List AllFieldes(){ List fieldList = new ArrayList<>(); Class superClass = BaseFeature.class; @@ -68,7 +61,7 @@ public class BaseFeature implements IFeature { if(!geometryChecked()){ throw new NullPointerException("空间字段为空"); } - //CoordinateReferenceSystem crs = this.geometry..GetCRS(); + CoordinateReferenceSystem crs = null; build.setCRS(crs !=null? crs:DefaultGeographicCRS.WGS84); build.setName(this.getClass().getSimpleName()); @@ -111,7 +104,7 @@ public class BaseFeature implements IFeature { - /***************************************************************************************************/ +/***************************************************************************************************/ /** * @author hukekuan diff --git a/src/main/java/com/gis3c/spatial/entity/Region.java b/src/main/java/com/gis3c/spatial/entity/Region.java new file mode 100644 index 0000000..4ade849 --- /dev/null +++ b/src/main/java/com/gis3c/spatial/entity/Region.java @@ -0,0 +1,34 @@ +package com.gis3c.spatial.entity; + +/** + * Created by hukekuan on 2018/3/9. + */ +public class Region extends BaseFeature { + private String reginCode; + private String regionName; + private String style; + + public String getReginCode() { + return reginCode; + } + + public void setReginCode(String reginCode) { + this.reginCode = reginCode; + } + + public String getRegionName() { + return regionName; + } + + public void setRegionName(String regionName) { + this.regionName = regionName; + } + + public String getStyle() { + return style; + } + + public void setStyle(String style) { + this.style = style; + } +} diff --git a/src/main/java/com/gis3c/spatial/entity/feature/IFeature.java b/src/main/java/com/gis3c/spatial/entity/feature/IFeature.java deleted file mode 100644 index ec8a96e..0000000 --- a/src/main/java/com/gis3c/spatial/entity/feature/IFeature.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gis3c.spatial.entity.feature; - -import java.lang.reflect.Field; -import java.util.List; - -/** - * Created by hukekuan on 17-7-10. - */ -public interface IFeature { - /** - * @author hukekuan - * @Description 获取所有的Field,前提是要有Geometry属性 - * @date 2017-07-10 下午4:36 - * @return 返回所有的Field - */ - public List AllFieldes(); -} diff --git a/src/main/java/com/gis3c/spatial/service/RegionService.java b/src/main/java/com/gis3c/spatial/service/RegionService.java new file mode 100644 index 0000000..4b96dd5 --- /dev/null +++ b/src/main/java/com/gis3c/spatial/service/RegionService.java @@ -0,0 +1,48 @@ +package com.gis3c.spatial.service; + +import com.gis3c.spatial.entity.Region; + +import java.util.List; +import java.util.Map; + +/** + * Created by hukekuan on 2018/3/9. + */ +public interface RegionService { + /** + * 获取区域实体 + * @param reginType + * @param reginCode + */ + public Region findRegionByCode(String reginType, String reginCode); + + /** + * 获取区域中心点 + * @param reginType + * @param reginCode + * @return 中心点wkt字符串 + */ + public String findRgionCenterByCode(String reginType, String reginCode); + + /** + * 获取区域周边区域 + * @param reginType + * @param reginCode + * @return + */ + public List findAroundRegions(String reginType, String reginCode); + + /** + * 获取区域内部的所有子区域 + * @param parentCode + * @return + */ + public List findRegionsByParentCode(String parentCode); + + /** + * 获取子区域内部的所有子区域的中心点 + * @param parentCode + * @return + */ + 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 new file mode 100644 index 0000000..96e1428 --- /dev/null +++ b/src/main/java/com/gis3c/spatial/service/impl/RegionServiceImpl.java @@ -0,0 +1,37 @@ +package com.gis3c.spatial.service.impl; + +import com.gis3c.spatial.entity.Region; +import com.gis3c.spatial.service.RegionService; + +import java.util.List; +import java.util.Map; + +/** + * Created by hukekuan on 2018/3/9. + */ +public class RegionServiceImpl implements RegionService { + @Override + public Region findRegionByCode(String reginType, String reginCode) { + return null; + } + + @Override + public String findRgionCenterByCode(String reginType, String reginCode) { + return null; + } + + @Override + public List findAroundRegions(String reginType, String reginCode) { + return null; + } + + @Override + public List findRegionsByParentCode(String parentCode) { + return null; + } + + @Override + public List> findRegionCentersByParentCode(String parentCode) { + return null; + } +} diff --git a/src/test/java/com/gis3c/spatial/App.java b/src/test/java/com/gis3c/spatial/App.java index b42498f..f1c8a34 100644 --- a/src/test/java/com/gis3c/spatial/App.java +++ b/src/test/java/com/gis3c/spatial/App.java @@ -30,11 +30,19 @@ public class App { MapService mapService = context.getBean(MapService.class); TestService testService = context.getBean(TestService.class); - List layerSources - = layerService.findLayerByIds(new String[]{"aabb842e-239e-491d-9c70-a2cec1f65886"}); - System.out.println(layerSources); + + + + + + + + + +// List layerSources +// = layerService.findLayerByIds(new String[]{"aabb842e-239e-491d-9c70-a2cec1f65886"}); // List layerIdList = new ArrayList<>(Arrays.asList(new String[]{ // "a2d69fcd-fa4a-4fe5-8696-ae3e30042126", // "aabb842e-239e-491d-9c70-a2cec1f65886" @@ -54,13 +62,6 @@ public class App { // System.out.println(testList.get(0)); - - - - - - - // List layerSources = layerService.findLayerList(); // System.out.println(layerSources.get(0)); @@ -97,8 +98,6 @@ public class App { // System.out.println("".equals(source)); - - // Layer layer = layerService.findeLayerById("d804360f-eb5f-4e29-94ab-fdafbf224e02"); // System.out.println(layer.getExtent()); @@ -117,12 +116,10 @@ public class App { // sourceService.insertSource(newSource); // System.out.println("插入成功"); - // List mapList = mapService.findMapsByByPage(10,0); // Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9"); // System.out.println(map); - // List result = testService.allList(); // Test test = result.get(0); // SimpleFeatureType type = test.createFeatureType(); @@ -196,7 +193,6 @@ public class App { // System.out.println(wmts.getUrl()); - // 视图接口 // View view = viewService.findeViewById("ee2f96a0-097a-4f0a-9767-f52b8dae28e0"); // System.out.println("["+ ((Double[])view.getCenter())[0] + ", " + ((Double[])view.getCenter())[1] + "]"); diff --git a/src/test/resources/mappings/ol/LayerDao.xml b/src/test/resources/mappings/ol/LayerDao.xml index 7c1ea21..33b54cf 100644 --- a/src/test/resources/mappings/ol/LayerDao.xml +++ b/src/test/resources/mappings/ol/LayerDao.xml @@ -66,6 +66,10 @@ ; + + + INSERT INTO c3gis_ol_map( mapid , mapname diff --git a/src/test/resources/mappings/ol/SourceDao.xml b/src/test/resources/mappings/ol/SourceDao.xml index a987264..0a9c26d 100644 --- a/src/test/resources/mappings/ol/SourceDao.xml +++ b/src/test/resources/mappings/ol/SourceDao.xml @@ -55,7 +55,9 @@ and projection = #{projection, javaType=java.lang.String} ORDER BY sourceName; - + INSERT INTO c3gis_ol_source(sourceId , sourceName diff --git a/src/test/resources/resources.properties b/src/test/resources/resources.properties index 2fb6cb7..b1c1c10 100644 --- a/src/test/resources/resources.properties +++ b/src/test/resources/resources.properties @@ -1,6 +1,6 @@ sys.driverClassName=org.postgresql.Driver -sys.url=jdbc:postgresql:gisdata +sys.url=jdbc:postgresql://172.16.6.13:5432/gisdata sys.username=gis sys.password=gis