diff --git a/src/main/java/com/gis3c/common/json/JsonUtil.java b/src/main/java/com/gis3c/common/json/JsonUtil.java index 2bcca34..74ff544 100644 --- a/src/main/java/com/gis3c/common/json/JsonUtil.java +++ b/src/main/java/com/gis3c/common/json/JsonUtil.java @@ -1,12 +1,16 @@ package com.gis3c.common.json; +import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.DeserializationConfig; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationConfig; +import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.core.annotation.AnnotationUtils; + import java.io.OutputStream; /** @@ -28,25 +32,59 @@ public class JsonUtil { public static String Stringify(Object object){ try { return objectMapper.writeValueAsString(object); - } catch (JsonProcessingException e) { + } catch (Exception e) { log.error(e.getMessage(), e); } return null; } public static String Stringify(Object object, String... properties){ + try { + return objectMapper + .writer(new SimpleFilterProvider().addFilter( + AnnotationUtils.getValue( + AnnotationUtils.findAnnotation(object.getClass(), JsonFilter.class)).toString(), + SimpleBeanPropertyFilter.filterOutAllExcept(properties))) + .writeValueAsString(object); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + return null; } public static void Stringify(OutputStream out, Object objec){ - + try { + objectMapper.writeValue(out, objec); + } catch (Exception e) { + log.error(e.getMessage(), e); + } } public static void Stringify(OutputStream out, Object object, String... properties){ - + try { + objectMapper + .writer(new SimpleFilterProvider().addFilter( + AnnotationUtils.getValue( + AnnotationUtils.findAnnotation(object.getClass(), JsonFilter.class)).toString(), + SimpleBeanPropertyFilter.filterOutAllExcept(properties))) + .writeValue(out, object); + } catch (Exception e) { + log.error(e.getMessage(), e); + } } public static T Parse(String json, Class clazz){ + if (json == null || json.length() == 0) { + return null; + } + + try { + return objectMapper.readValue(json, clazz); + } catch (Exception e) { + log.error(e.getMessage(), e); + } + return null; } } diff --git a/src/main/java/com/gis3c/ol/dao/LayerDao.java b/src/main/java/com/gis3c/ol/dao/LayerDao.java index 27c585b..8837046 100644 --- a/src/main/java/com/gis3c/ol/dao/LayerDao.java +++ b/src/main/java/com/gis3c/ol/dao/LayerDao.java @@ -1,23 +1,15 @@ package com.gis3c.ol.dao; import com.gis3c.common.persistence.annotation.C3olDao; -import com.gis3c.ol.entity.layer.TileLayer; -import com.gis3c.ol.entity.layer.VectorLayer; +import com.gis3c.ol.entity.Layer; /** * Created by hukekuan on 2017/12/15. */ @C3olDao public interface LayerDao { - public TileLayer findeTileLayerById(String layerId); - public TileLayer findeTileLayerByName(String layerName); + public Layer findeLayerById(String layerId); + public Layer findeLayerByName(String layerName); - public int insertTileLayer(TileLayer tileLayer); - - - - public VectorLayer findeVectorLayerById(String layerId); - public VectorLayer findeVectorLayerByName(String layerName); - - public int insertVectorLayer(VectorLayer vectorLayer); + public Integer insertLayer(Layer layer); } diff --git a/src/main/java/com/gis3c/ol/dao/SourceDao.java b/src/main/java/com/gis3c/ol/dao/SourceDao.java index 7e4bb0a..8a9fe79 100644 --- a/src/main/java/com/gis3c/ol/dao/SourceDao.java +++ b/src/main/java/com/gis3c/ol/dao/SourceDao.java @@ -1,11 +1,14 @@ package com.gis3c.ol.dao; import com.gis3c.common.persistence.annotation.C3olDao; +import com.gis3c.ol.entity.Source; import com.gis3c.ol.entity.source.TileArcGISRest; import com.gis3c.ol.entity.source.TileSuperMapRest; import com.gis3c.ol.entity.source.Vector; import com.gis3c.ol.entity.source.Wmts; +import java.util.List; + /** * Created by hukekuan on 2017/12/15. */ @@ -36,4 +39,7 @@ public interface SourceDao { public Wmts findWmtsByName(String sourceName); public Integer insertWmts(Wmts wmts); + + public List findAllSources(); + public void insertSource(Source source); } diff --git a/src/main/java/com/gis3c/ol/dao/ViewDao.java b/src/main/java/com/gis3c/ol/dao/ViewDao.java deleted file mode 100644 index d3c5cc6..0000000 --- a/src/main/java/com/gis3c/ol/dao/ViewDao.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.gis3c.ol.dao; - -import com.gis3c.common.persistence.annotation.C3olDao; -import com.gis3c.ol.entity.View; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * Created by hukekuan on 2017/12/15. - */ -@C3olDao -public interface ViewDao { - public List findViewsByByPage( - @Param("pageSize") Integer pageSize, - @Param("currentPage") Integer currentPage); - - public View findeViewById(String viewId); - public View findeViewByName(String viewName); - - public Integer insertView(View view); -} diff --git a/src/main/java/com/gis3c/ol/entity/layer/BaseLayer.java b/src/main/java/com/gis3c/ol/entity/Layer.java similarity index 58% rename from src/main/java/com/gis3c/ol/entity/layer/BaseLayer.java rename to src/main/java/com/gis3c/ol/entity/Layer.java index b5740c3..839369e 100644 --- a/src/main/java/com/gis3c/ol/entity/layer/BaseLayer.java +++ b/src/main/java/com/gis3c/ol/entity/Layer.java @@ -1,17 +1,24 @@ -package com.gis3c.ol.entity.layer; +package com.gis3c.ol.entity; + +import java.util.*; +import java.util.Map; /** - * Created by hukekuan on 2017/12/14. + * Created by hukekuan on 2018/1/27. */ -public abstract class BaseLayer { +public class Layer { private String layerId; private String layerName; - private Double opacity; + private String aliasName; + private Double opacity = 1.0; + private String source; private Boolean visible = Boolean.TRUE; private Double[] extent; + private Integer zIndex = 0; private Double maxResolution; private Double minResolution; - + private String type; + private java.util.Map options; private String description; public String getLayerId() { @@ -30,6 +37,14 @@ public abstract class BaseLayer { this.layerName = layerName; } + public String getAliasName() { + return aliasName; + } + + public void setAliasName(String aliasName) { + this.aliasName = aliasName; + } + public Double getOpacity() { return opacity; } @@ -38,6 +53,14 @@ public abstract class BaseLayer { this.opacity = opacity; } + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + public Boolean getVisible() { return visible; } @@ -54,6 +77,14 @@ public abstract class BaseLayer { this.extent = extent; } + public Integer getzIndex() { + return zIndex; + } + + public void setzIndex(Integer zIndex) { + this.zIndex = zIndex; + } + public Double getMaxResolution() { return maxResolution; } @@ -70,6 +101,22 @@ public abstract class BaseLayer { this.minResolution = minResolution; } + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Map getOptions() { + return options; + } + + public void setOptions(Map options) { + this.options = options; + } + public String getDescription() { return description; } @@ -77,4 +124,6 @@ public abstract class BaseLayer { public void setDescription(String description) { this.description = description; } + + } diff --git a/src/main/java/com/gis3c/ol/entity/Map.java b/src/main/java/com/gis3c/ol/entity/Map.java index 201bc7d..ab8ade6 100644 --- a/src/main/java/com/gis3c/ol/entity/Map.java +++ b/src/main/java/com/gis3c/ol/entity/Map.java @@ -6,7 +6,7 @@ package com.gis3c.ol.entity; public class Map { private String mapId; private String mapName; - private String view; + private java.util.Map view; private String[][] controls; private Integer pixelRatio; private String[][] interactions; @@ -31,11 +31,11 @@ public class Map { this.mapName = mapName; } - public String getView() { + public java.util.Map getView() { return view; } - public void setView(String view) { + public void setView(java.util.Map view) { this.view = view; } diff --git a/src/main/java/com/gis3c/ol/entity/Source.java b/src/main/java/com/gis3c/ol/entity/Source.java index 27b2be5..c5d1414 100644 --- a/src/main/java/com/gis3c/ol/entity/Source.java +++ b/src/main/java/com/gis3c/ol/entity/Source.java @@ -9,6 +9,7 @@ import java.util.Map; public class Source { private String sourceId; private String sourceName; + private String url; private java.util.Map params; private String description; @@ -43,4 +44,12 @@ public class Source { public void setDescription(String description) { this.description = description; } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } } diff --git a/src/main/java/com/gis3c/ol/entity/View.java b/src/main/java/com/gis3c/ol/entity/View.java deleted file mode 100644 index d86bb99..0000000 --- a/src/main/java/com/gis3c/ol/entity/View.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.gis3c.ol.entity; - -/** - * Created by hukekuan on 2017/12/14. - */ -public class View { - private String viewId; - private String viewName; - private Double[] center; - private Double[] extent; - private String maxResolution; - private String minResolution; - private Integer maxZoom; - private Integer minZoom; - private Integer zoom; - private String projection; - private String resolution; - private String[] resolutions; - private Double rotation; - private String description; - - public String getViewId() { - return viewId; - } - - public void setViewId(String viewId) { - this.viewId = viewId; - } - - public String getViewName() { - return viewName; - } - - public void setViewName(String viewName) { - this.viewName = viewName; - } - - public Double[] getCenter() { - return center; - } - - public void setCenter(Double[] center) { - this.center = center; - } - - public Double[] getExtent() { - return extent; - } - - public void setExtent(Double[] extent) { - this.extent = extent; - } - - public String getMaxResolution() { - return maxResolution; - } - - public void setMaxResolution(String maxResolution) { - this.maxResolution = maxResolution; - } - - public String getMinResolution() { - return minResolution; - } - - public void setMinResolution(String minResolution) { - this.minResolution = minResolution; - } - - public Integer getMaxZoom() { - return maxZoom; - } - - public void setMaxZoom(Integer maxZoom) { - this.maxZoom = maxZoom; - } - - public Integer getMinZoom() { - return minZoom; - } - - public void setMinZoom(Integer minZoom) { - this.minZoom = minZoom; - } - - public Integer getZoom() { - return zoom; - } - - public void setZoom(Integer zoom) { - this.zoom = zoom; - } - - public String getProjection() { - return projection; - } - - public void setProjection(String projection) { - this.projection = projection; - } - - public String getResolution() { - return resolution; - } - - public void setResolution(String resolution) { - this.resolution = resolution; - } - - public String[] getResolutions() { - return resolutions; - } - - public void setResolutions(String[] resolutions) { - this.resolutions = resolutions; - } - - public Double getRotation() { - return rotation; - } - - public void setRotation(Double rotation) { - this.rotation = rotation; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/src/main/java/com/gis3c/ol/entity/layer/TileLayer.java b/src/main/java/com/gis3c/ol/entity/layer/TileLayer.java deleted file mode 100644 index f7691b5..0000000 --- a/src/main/java/com/gis3c/ol/entity/layer/TileLayer.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.gis3c.ol.entity.layer; - -/** - * Created by hukekuan on 2017/12/14. - */ -public class TileLayer extends BaseLayer { - private String[] source; - - public String[] getSource() { - return source; - } - - public void setSource(String[] source) { - this.source = source; - } -} diff --git a/src/main/java/com/gis3c/ol/entity/layer/VectorLayer.java b/src/main/java/com/gis3c/ol/entity/layer/VectorLayer.java deleted file mode 100644 index d3ab077..0000000 --- a/src/main/java/com/gis3c/ol/entity/layer/VectorLayer.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.gis3c.ol.entity.layer; - -/** - * Created by hukekuan on 2017/12/14. - */ -public class VectorLayer extends BaseLayer { - private String source; - private Integer zIndex; - private String styleType; - private String styleValue; - - public String getStyleType() { - return styleType; - } - - public void setStyleType(String styleType) { - this.styleType = styleType; - } - - public String getStyleValue() { - return styleValue; - } - - public void setStyleValue(String styleValue) { - this.styleValue = styleValue; - } - - public Integer getzIndex() { - return zIndex; - } - - public void setzIndex(Integer zIndex) { - this.zIndex = zIndex; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } -} diff --git a/src/main/java/com/gis3c/ol/service/LayerService.java b/src/main/java/com/gis3c/ol/service/LayerService.java index 182fb7b..beccdb9 100644 --- a/src/main/java/com/gis3c/ol/service/LayerService.java +++ b/src/main/java/com/gis3c/ol/service/LayerService.java @@ -1,22 +1,14 @@ package com.gis3c.ol.service; -import com.gis3c.ol.entity.layer.TileLayer; -import com.gis3c.ol.entity.layer.VectorLayer; +import com.gis3c.ol.entity.Layer; /** * Created by hukekuan on 2017/12/15. */ public interface LayerService { - public TileLayer findeTileLayerById(String layerId); - public TileLayer findeTileLayerByName(String layerName); + public Layer findeLayerById(String layerId); + public Layer findeLayerByName(String layerName); - public Integer insertTileLayer(TileLayer tileLayer); - - - - public VectorLayer findeVectorLayerById(String layerId); - public VectorLayer findeVectorLayerByName(String layerName); - - public Integer insertVectorLayer(VectorLayer vectorLayer); + public Integer insertLayer(Layer layer); } diff --git a/src/main/java/com/gis3c/ol/service/SourceService.java b/src/main/java/com/gis3c/ol/service/SourceService.java index a2b92dc..4c25227 100644 --- a/src/main/java/com/gis3c/ol/service/SourceService.java +++ b/src/main/java/com/gis3c/ol/service/SourceService.java @@ -1,10 +1,13 @@ package com.gis3c.ol.service; +import com.gis3c.ol.entity.Source; import com.gis3c.ol.entity.source.TileArcGISRest; import com.gis3c.ol.entity.source.TileSuperMapRest; import com.gis3c.ol.entity.source.Vector; import com.gis3c.ol.entity.source.Wmts; +import java.util.List; + /** * Created by hukekuan on 2017/12/15. */ @@ -34,4 +37,8 @@ public interface SourceService { public Wmts findWmtsByName(String sourceName); public Integer insertWmts(Wmts wmts); + + + public List findAllSources(); + public void insertSource(Source source); } diff --git a/src/main/java/com/gis3c/ol/service/ViewService.java b/src/main/java/com/gis3c/ol/service/ViewService.java deleted file mode 100644 index 3323b42..0000000 --- a/src/main/java/com/gis3c/ol/service/ViewService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.gis3c.ol.service; - -import com.gis3c.ol.entity.View; - -import java.util.List; - -/** - * Created by hukekuan on 2017/12/14. - */ -public interface ViewService { - public List findViewsByByPage(Integer pageSize,Integer currentPage); - - public View findeViewById(String viewId); - public View findeViewByName(String viewName); - - public Integer insertView(View view); -} 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 ca74479..b7d87c3 100644 --- a/src/main/java/com/gis3c/ol/service/impl/LayerServiceImpl.java +++ b/src/main/java/com/gis3c/ol/service/impl/LayerServiceImpl.java @@ -1,8 +1,7 @@ package com.gis3c.ol.service.impl; import com.gis3c.ol.dao.LayerDao; -import com.gis3c.ol.entity.layer.TileLayer; -import com.gis3c.ol.entity.layer.VectorLayer; +import com.gis3c.ol.entity.Layer; import com.gis3c.ol.service.LayerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -16,32 +15,17 @@ public class LayerServiceImpl implements LayerService { private LayerDao layerDao; @Override - public TileLayer findeTileLayerById(String layerId) { - return layerDao.findeTileLayerById(layerId); + public Layer findeLayerById(String layerId) { + return layerDao.findeLayerById(layerId); } @Override - public TileLayer findeTileLayerByName(String layerName) { - return layerDao.findeTileLayerByName(layerName); + public Layer findeLayerByName(String layerName) { + return layerDao.findeLayerByName(layerName); } @Override - public Integer insertTileLayer(TileLayer tileLayer) { - return layerDao.insertTileLayer(tileLayer); - } - - @Override - public VectorLayer findeVectorLayerById(String layerId) { - return layerDao.findeVectorLayerById(layerId); - } - - @Override - public VectorLayer findeVectorLayerByName(String layerName) { - return layerDao.findeVectorLayerByName(layerName); - } - - @Override - public Integer insertVectorLayer(VectorLayer vectorLayer) { - return layerDao.insertVectorLayer(vectorLayer); + public Integer insertLayer(Layer layer) { + return layerDao.insertLayer(layer); } } 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 59498e1..4ef05b4 100644 --- a/src/main/java/com/gis3c/ol/service/impl/SourceServiceImpl.java +++ b/src/main/java/com/gis3c/ol/service/impl/SourceServiceImpl.java @@ -1,6 +1,7 @@ package com.gis3c.ol.service.impl; import com.gis3c.ol.dao.SourceDao; +import com.gis3c.ol.entity.Source; import com.gis3c.ol.entity.source.TileArcGISRest; import com.gis3c.ol.entity.source.TileSuperMapRest; import com.gis3c.ol.entity.source.Vector; @@ -9,6 +10,8 @@ import com.gis3c.ol.service.SourceService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + /** * Created by hukekuan on 2017/12/15. */ @@ -77,4 +80,13 @@ public class SourceServiceImpl implements SourceService { return sourceDao.insertWmts(wmts); } + @Override + public List findAllSources() { + return sourceDao.findAllSources(); + } + + @Override + public void insertSource(Source source) { + sourceDao.insertSource(source); + } } diff --git a/src/main/java/com/gis3c/ol/service/impl/ViewServiceImpl.java b/src/main/java/com/gis3c/ol/service/impl/ViewServiceImpl.java deleted file mode 100644 index 69e7227..0000000 --- a/src/main/java/com/gis3c/ol/service/impl/ViewServiceImpl.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.gis3c.ol.service.impl; - -import com.gis3c.ol.dao.ViewDao; -import com.gis3c.ol.entity.View; -import com.gis3c.ol.service.ViewService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - * Created by hukekuan on 2017/12/14. - */ -@Service -public class ViewServiceImpl implements ViewService { - @Autowired - private ViewDao viewDao; - - @Override - public List findViewsByByPage(Integer pageSize, Integer currentPage) { - return viewDao.findViewsByByPage(pageSize,currentPage); - } - - @Override - public View findeViewById(String viewId) { - return viewDao.findeViewById(viewId); - } - - @Override - public View findeViewByName(String viewName) { - return viewDao.findeViewByName(viewName); - } - - @Override - public Integer insertView(View view) { - return viewDao.insertView(view); - } -} diff --git a/src/main/resources/init.sql b/src/main/resources/init.sql index 03b4105..e57af0d 100644 --- a/src/main/resources/init.sql +++ b/src/main/resources/init.sql @@ -2,7 +2,8 @@ create table c3gis_ol_map( mapid varchar(50) not null PRIMARY KEY, mapname varchar(50) not null, - view varchar(50) not null, + --view varchar(50) not null, + view jsonb not null, controls varchar(50) [2][], pixelRatio integer, interactions varchar(50) [2][], @@ -66,6 +67,24 @@ create table c3gis_ol_layer_tile( description varchar(50) ); + +--图层表 +create table c3gis_ol_layer( + layerId varchar(50) not null PRIMARY KEY, + layerName varchar(50) not null, + aliasName varchar(50), + opacity real, + source varchar(50), + visible boolean, + extent decimal ARRAY[4], + zIndex integer, + minResolution decimal, + maxResolution decimal, + type varchar(50), + options jsonb, + description varchar(50) +); + --ArcGIS切片服务 create table c3gis_ol_source_tilearcgisrest( sourceid varchar(50) not null PRIMARY KEY, diff --git a/src/test/java/com/gis3c/spatial/App.java b/src/test/java/com/gis3c/spatial/App.java index 413cebb..13c1c13 100644 --- a/src/test/java/com/gis3c/spatial/App.java +++ b/src/test/java/com/gis3c/spatial/App.java @@ -1,18 +1,15 @@ package com.gis3c.spatial; -import com.gis3c.ol.entity.Map; +import com.gis3c.ol.entity.Layer; import com.gis3c.ol.service.LayerService; import com.gis3c.ol.service.MapService; import com.gis3c.ol.service.SourceService; -import com.gis3c.ol.service.ViewService; -import com.gis3c.spatial.common.FeatureUtilities; -import com.gis3c.spatial.entity.Test; import com.gis3c.spatial.service.TestService; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import java.io.IOException; -import java.util.List; +import java.util.UUID; /** * Created by hukekuan on 2017/12/14. @@ -23,16 +20,34 @@ public class App { } public static void main(String[] args) throws IllegalAccessException, IOException { ApplicationContext context = ApplicationInit(); - ViewService viewService = context.getBean(ViewService.class); + SourceService sourceService = context.getBean(SourceService.class); LayerService layerService = context.getBean(LayerService.class); MapService mapService = context.getBean(MapService.class); TestService testService = context.getBean(TestService.class); +// List sources = sourceService.findAllSources(); +// System.out.println(sources.get(0).getParams()); +// +// Source newSource = new Source(); +// newSource.setSourceId("44"); +// newSource.setSourceName("44"); +// newSource.setUrl("444"); +// java.util.Map params = new HashMap<>(); +// params.put("bar","444"); +// params.put("active",true); +// params.put("balance",4.444); +// params.put("center",new Integer[]{1,2}); +// newSource.setParams(params); +// newSource.setDescription("555"); +// +// sourceService.insertSource(newSource); + + // List mapList = mapService.findMapsByByPage(10,0); - Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9"); - System.out.println(map); +// Map map = mapService.findMapById("fc813a1f-6a31-4202-9419-8d125ba203c9"); +// System.out.println(map); // List result = testService.allList(); @@ -49,7 +64,14 @@ public class App { // Map map = new Map(); // map.setMapId(UUID.randomUUID().toString()); // map.setMapName("综合GIS系统"); -// map.setView("ee2f96a0-097a-4f0a-9767-f52b8dae28e0"); +// +// java.util.Map view = new HashMap<>(); +// view.put("center",new Double[]{117.089151,36.738693}); +// view.put("projection","EPSG:4326"); +// view.put("minZoom",8); +// view.put("maxZoom",18); +// view.put("zoom",9); +// map.setView(view); // map.setLogo(false); // map.setLayers(new String[][]{ // {"TileLayer","182a8b18-d26f-43da-9b3a-6f90af4825ed"}, @@ -61,12 +83,14 @@ public class App { // System.out.println("插入成功"); //图层接口 -// TileLayer wmtsLayer = new TileLayer(); -// wmtsLayer.setLayerId(UUID.randomUUID().toString()); -// wmtsLayer.setLayerName("全国行政区图层"); -// wmtsLayer.setSource(new String[]{"Wmts","b2729474-5988-410c-b6a0-8834b19d5832"}); -// layerService.insertTileLayer(wmtsLayer); -// System.out.println("插入成功"); + Layer wmtsLayer = new Layer(); + wmtsLayer.setLayerId(UUID.randomUUID().toString()); + wmtsLayer.setLayerName("cva"); + wmtsLayer.setAliasName("全国行政区图层"); + wmtsLayer.setSource("b2729474-5988-410c-b6a0-8834b19d5832"); + wmtsLayer.setType("ol.layer.Tile"); + layerService.insertLayer(wmtsLayer); + System.out.println("插入成功"); //资源接口 diff --git a/src/test/resources/init.sql b/src/test/resources/init.sql deleted file mode 100644 index 540414a..0000000 --- a/src/test/resources/init.sql +++ /dev/null @@ -1,154 +0,0 @@ ---地图表 -create table c3gis_ol_map( - mapid varchar(50) not null PRIMARY KEY, - mapname varchar(50) not null, - view varchar(50) not null, - controls varchar(50) [2][], - pixelRatio integer, - interactions varchar(50) [2][], - layers varchar(50) [2][], - logo boolean, - overlays varchar(50) [2][], - description varchar(50) -); - ---视图图层 -create table c3gis_ol_view( - viewid varchar(50) not null PRIMARY KEY, - viewname varchar(50) not null, - center double precision ARRAY[2], - extent double precision ARRAY[4], - maxresolution varchar(50), - minresolution varchar(50), - maxzoom int, - minzoom int, - zoom int, - projection varchar(50), - resolution varchar(50), - resolutions varchar(50) ARRAY, - rotation NUMERIC(7,4), - description varchar(50) -); - ---样式类型枚举值 -CREATE TYPE c3gis_ol_vectorstyletype AS ENUM('entity', 'function'); - - ---矢量图层表 -create table c3gis_ol_layer_vector( - layerid varchar(50) not null PRIMARY KEY, - layername varchar(50) not null, - opacity real, - visible boolean, - extent decimal ARRAY[4], - zIndex integer, - minResolution decimal, - maxResolution decimal, - - source varchar(50) not null, - styletype c3gis_ol_vectorstyletype not null,, - stylevalue varchar(50) not null, - - description varchar(50) -); - - ---切片图层表 -create table c3gis_ol_layer_tile( - layerid varchar(50) not null PRIMARY KEY, - layername varchar(50) not null, - opacity real, - visible boolean, - extent decimal ARRAY[4], - minResolution decimal, - maxResolution decimal, - source varchar(50) ARRAY[2] not null, - description varchar(50) -); - ---ArcGIS切片服务 -create table c3gis_ol_source_tilearcgisrest( - sourceid varchar(50) not null PRIMARY KEY, - sourcename varchar(50) not null, - crossOrigin varchar(50), - projection varchar(20), - url varchar(100) not null, - wrapX boolean, - description varchar(50) -); - ---SuperMap切片服务 -create table c3gis_ol_source_tilesupermaprest( - sourceid varchar(50) not null PRIMARY KEY, - sourcename varchar(50) not null, - url varchar(100) not null, - wrapX boolean, - opaque boolean, - description varchar(50) -); - ---矢量数据 -create table c3gis_ol_source_vector( - sourceid varchar(50) not null PRIMARY KEY, - sourcename varchar(50) not null, - logo boolean, - url varchar(50), - useSpatialIndex boolean, - wrapX boolean, - description varchar(50) -); - ---wmts服务 -create table c3gis_ol_source_wmts( - sourceid varchar(50) not null PRIMARY KEY, - sourcename varchar(50) not null, - url varchar(50) not null, - layer varchar(50) not null, - style varchar(50) not null, - format varchar(50) not null, - matrixSet varchar(50) not null, - description varchar(50) -); - ---样式表 -create table c3gis_ol_style_style( - styleid varchar(50) not null, - stylename varchar(50) not null, - fill varchar(50), - image varchar(50), - stroke varchar(50), - text varchar(50), - description varchar(50) -); - ---填充面样式 -create table c3gis_ol_style_fill( - styleid varchar(50) not null, - stylename varchar(50) not null, - color varchar(50) not null, - description varchar(50) -); - ---边框样式 -create table c3gis_ol_style_stroke( - styleid varchar(50) not null, - stylename varchar(50) not null, - color varchar(50) not null, - width integer, - lineCap varchar(50), - lineJoin varchar(50), - description varchar(50) -); - ---图标样式 -create table c3gis_ol_style_icon( - styleid varchar(50) not null, - stylename varchar(50) not null, - anchor real ARRAY, - anchorOrigin varchar(20), - anchorXUnits varchar(20), - anchorYUnits varchar(20), - color varchar(20), - crossOrigin real, - description varchar(50) -); \ No newline at end of file diff --git a/src/test/resources/mappings/ol/LayerDao.xml b/src/test/resources/mappings/ol/LayerDao.xml index 28294e2..358dc7c 100644 --- a/src/test/resources/mappings/ol/LayerDao.xml +++ b/src/test/resources/mappings/ol/LayerDao.xml @@ -1,137 +1,81 @@ - - - - - - - - - - - - - - + + + + + - - - + + - - layerid - , layername + + layerId + , layerName + , aliasName , opacity + , source , visible , extent + , zIndex , minResolution , maxResolution - , source + , type + , options , description - - layerid - , layername - , opacity - , visible - , extent - , zIndex - , minResolution - , maxResolution - , source - , styletype - , stylevalue - , description - - SELECT - - FROM c3gis_ol_layer_tile - WHERE layerid = #{layerId, javaType=java.lang.String}; + + FROM c3gis_ol_layer + WHERE layerId = #{layerId, javaType=java.lang.String}; - SELECT - - FROM c3gis_ol_layer_tile - WHERE layername = #{layerName, javaType=java.lang.String}; + + FROM c3gis_ol_layer + WHERE layerName = #{layerName, javaType=java.lang.String}; - - INSERT INTO c3gis_ol_layer_tile( - layerid - , layername - , opacity - , visible - , extent - , minResolution - , maxResolution - , source - , description + + INSERT INTO c3gis_ol_layer(layerId + , layerName + , aliasName + , opacity + , source + , visible + , extent + , zIndex + , minResolution + , maxResolution + , type + , options + , description ) - VALUES( - #{layerId} - , #{layerName} - , #{opacity} - , #{visible} - , #{extent, javaType=ObjectArray} - , #{maxResolution} - , #{minResolution} - , #{source, javaType=ObjectArray} - , #{description}); - - - - - - - - INSERT INTO c3gis_ol_layer_tile( - layerid - , layername - , opacity - , visible - , extent - , zIndex - , minResolution - , maxResolution - , source - , styletype - , stylevalue - , description - ) - VALUES( - #{layerId} - , #{layerName} - , #{opacity} - , #{visible} - , #{extent, javaType=ObjectArray} - , #{zIndex} - , #{maxResolution} - , #{minResolution} - , #{source} - , #{styleType} - , #{styleValue} - , #{description}); + VALUES(#{layerId} + , #{layerName} + , #{aliasName} + , #{opacity} + , #{source} + , #{visible} + , #{extent, javaType=ObjectArray} + , #{zIndex} + , #{maxResolution} + , #{minResolution} + , #{type} + , #{options, javaType=ObjectJSON}::jsonb + , #{description} + ); \ No newline at end of file diff --git a/src/test/resources/mappings/ol/MapDao.xml b/src/test/resources/mappings/ol/MapDao.xml index 7c82125..6d691bd 100644 --- a/src/test/resources/mappings/ol/MapDao.xml +++ b/src/test/resources/mappings/ol/MapDao.xml @@ -4,7 +4,7 @@ - + @@ -54,20 +54,19 @@ WHERE mapname = #{mapName, javaType=java.lang.String}; - INSERT INTO c3gis_ol_map( - mapid - , mapname - , view - , controls - , pixelRatio - , interactions - , layers - , logo - , overlays - , description) VALUES ( - #{mapId} + INSERT INTO c3gis_ol_map( mapid + , mapname + , view + , controls + , pixelRatio + , interactions + , layers + , logo + , overlays + , description) + VALUES ( #{mapId} , #{mapName} - , #{view} + , #{view, javaType=ObjectJSON}::jsonb , #{controls, javaType=ObjectArray} , #{pixelRatio} , #{interactions, javaType=ObjectArray} diff --git a/src/test/resources/mappings/ol/SourceDao.xml b/src/test/resources/mappings/ol/SourceDao.xml index 98dc687..a63bcd2 100644 --- a/src/test/resources/mappings/ol/SourceDao.xml +++ b/src/test/resources/mappings/ol/SourceDao.xml @@ -37,6 +37,14 @@ + + + + + + + + sourceid @@ -217,4 +225,24 @@ ); + + + INSERT INTO c3gis_ol_source( + sourceid + , sourcename + , url + , params + , description + ) + VALUES( + #{sourceId} + , #{sourceName} + , #{url} + , #{params, javaType=ObjectJSON}::jsonb + , #{description} + ); + \ 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 883da73..fec7bf2 100644 --- a/src/test/resources/sql-map-config-mybatis.xml +++ b/src/test/resources/sql-map-config-mybatis.xml @@ -47,7 +47,7 @@ - +