Administrator пре 2 година
родитељ
комит
d840d5d8da

+ 47 - 4
src/main/java/com/sysu/admin/controller/geo/CityLand.java

@@ -1,7 +1,7 @@
 package com.sysu.admin.controller.geo;
 
 import com.alibaba.fastjson.annotation.JSONField;
-import com.sysu.admin.controller.geo.land.FieldPoint;
+import com.sysu.admin.controller.geo.land.point.FieldPoint;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -9,14 +9,17 @@ import lombok.experimental.FieldNameConstants;
 import org.hibernate.annotations.DynamicInsert;
 import org.hibernate.annotations.DynamicUpdate;
 import org.locationtech.jts.geom.MultiPolygon;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
 
 import javax.persistence.*;
+import java.util.Date;
 
 @Data
 @Accessors(chain = true)
 @EqualsAndHashCode(callSuper = false)
 @FieldNameConstants(innerTypeName = "FIELDS")
-@Table(name = "gdcityland30")
+@Table(name = "p_crop")
 @Entity
 @DynamicInsert
 @DynamicUpdate
@@ -37,9 +40,49 @@ public class CityLand {
 
     @Transient
     private String wkt;
+    /**
+     * 耕地类型
+     */
+    @Column
+    private Integer cropType;
+    /**
+     * 生长期
+     */
+    @Column
+    private Integer growingPeriod;
 
-    @Transient
-    private FieldPoint[] fieldPoints;
+    /**
+     * 产量
+     */
+    @Column
+    private Integer yield;
+
+    @Column(nullable = false)
+    private Date createDate;
+
+    @Column(nullable = false)
+    private Date receiveDate;
+
+    @Column(nullable = false)
+    private Date finishDate;
+
+    /**
+     * 创建人
+     */
+    @Column(updatable = false, nullable = false)
+    private Long creator;
+
+    /**
+     * 创建人
+     */
+    @Column(updatable = false, nullable = false)
+    private Long executor;
+
+    /**
+     * 状态
+     */
+    @Column
+    private Integer status;
 
 
 }

+ 1 - 1
src/main/java/com/sysu/admin/controller/geo/CityLandRepository.java

@@ -9,7 +9,7 @@ import java.util.List;
 public interface CityLandRepository extends JpaPlusRepository<CityLand, Long> {
 
 
-    @Query(value = "SELECT * FROM \"gdcityland30\" where St_within(st_geomfromtext(?1,4526), geom) limit 1", nativeQuery = true)
+    @Query(value = "SELECT * FROM \"p_crop\" where St_within(st_geomfromtext(?1), geom) limit 1", nativeQuery = true)
     CityLand findIdByPoint(String pointWKT);
 
 }

+ 62 - 0
src/main/java/com/sysu/admin/controller/geo/CityLandVo.java

@@ -0,0 +1,62 @@
+package com.sysu.admin.controller.geo;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import lombok.experimental.FieldNameConstants;
+import org.hibernate.annotations.DynamicInsert;
+import org.hibernate.annotations.DynamicUpdate;
+import org.locationtech.jts.geom.MultiPolygon;
+import org.springframework.data.annotation.CreatedBy;
+import org.springframework.data.annotation.CreatedDate;
+
+import javax.persistence.*;
+import java.util.Date;
+
+@Data
+@Accessors(chain = true)
+public class CityLandVo {
+    /**
+     * 主键
+     */
+    private Long id;
+
+    private Long gridcode;
+    /**
+     * 耕地类型
+     */
+    private Integer cropType;
+    /**
+     * 生长期
+     */
+    private Integer growingPeriod;
+
+    /**
+     * 产量
+     */
+    private Integer yield;
+
+    private Date createDate;
+
+    private Date receiveDate;
+
+    private Date finishDate;
+
+    /**
+     * 创建人
+     */
+    private Long creator;
+
+    /**
+     * 创建人
+     */
+    private Long executor;
+
+    /**
+     * 状态
+     */
+    private Integer status;
+
+
+}

+ 39 - 7
src/main/java/com/sysu/admin/controller/geo/PostGisInfoController.java

@@ -1,13 +1,18 @@
 package com.sysu.admin.controller.geo;
 
-import com.sysu.admin.controller.geo.land.FieldPoint;
-import com.sysu.admin.controller.geo.land.FieldPointService;
+import com.sysu.admin.controller.geo.land.LandTaskStatus;
+import com.sysu.admin.controller.geo.land.point.FieldPointService;
+import com.sysu.admin.support.shiro.ShiroService;
 import com.sysu.admin.utils.shape.GeoCastUtil;
 import com.xiesx.fastboot.base.result.BaseResult;
 import com.xiesx.fastboot.base.result.R;
+import com.xiesx.fastboot.utils.CopyUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
+import java.util.Date;
 
 /**
  * 读取地图数据信息
@@ -20,17 +25,44 @@ public class PostGisInfoController {
     CityLandService cityLandService;
     @Autowired
     FieldPointService fieldPointService;
+    @Autowired
+    ShiroService shiroService;
 
     @RequestMapping("/getInfo")
     public BaseResult getInfo(String layerName, Double x, Double y){
         CityLand cityLand = cityLandService.findByPoint(x,y);
-        cityLand.setWkt(GeoCastUtil.geomToWkt(cityLand.getGeom()));
-        FieldPoint[] fieldPoints = fieldPointService.findAllByLandId(cityLand.getId());
-        for(FieldPoint fieldPoint : fieldPoints){
-            fieldPoint.setWkt(GeoCastUtil.geomToWkt(fieldPoint.getGeom()));
+        if(cityLand == null){
+            return R.fail();
         }
-        cityLand.setFieldPoints(fieldPoints);
+        cityLand.setWkt(GeoCastUtil.geomToWkt(cityLand.getGeom()));
         return R.succ(cityLand);
     }
 
+    @RequestMapping("/save")
+    @ResponseBody
+    public BaseResult save(CityLandVo vo){
+        CityLand bean = cityLandService.findOne(vo.getId());
+        if(bean.getStatus().intValue() == LandTaskStatus.unpublished.ordinal()){
+            bean.setCreator(shiroService.getPrincipalId());
+            bean.setCreateDate(new Date());
+        }
+        BeanUtils.copyProperties(vo, bean, CopyUtils.nullNames(vo));
+        bean.setWkt(GeoCastUtil.geomToWkt(bean.getGeom()));
+        cityLandService.save(bean);
+        return R.succ(bean);
+    }
+
 }
+
+
+
+
+
+
+
+
+
+
+
+
+

+ 3 - 2
src/main/java/com/sysu/admin/controller/geo/land/FieldPointStatus.java → src/main/java/com/sysu/admin/controller/geo/land/LandTaskStatus.java

@@ -1,7 +1,8 @@
 package com.sysu.admin.controller.geo.land;
 
-public enum FieldPointStatus {
-    publish,//发布
+public enum LandTaskStatus {
+    unpublished,
+    published,//发布
     receive,//接收
     finish//完成
 }

+ 1 - 1
src/main/java/com/sysu/admin/controller/geo/land/FieldPoint.java → src/main/java/com/sysu/admin/controller/geo/land/point/FieldPoint.java

@@ -1,4 +1,4 @@
-package com.sysu.admin.controller.geo.land;
+package com.sysu.admin.controller.geo.land.point;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;

+ 3 - 2
src/main/java/com/sysu/admin/controller/geo/land/FieldPointController.java → src/main/java/com/sysu/admin/controller/geo/land/point/FieldPointController.java

@@ -1,7 +1,8 @@
-package com.sysu.admin.controller.geo.land;
+package com.sysu.admin.controller.geo.land.point;
 
 import com.sysu.admin.controller.geo.CityLand;
 import com.sysu.admin.controller.geo.CityLandService;
+import com.sysu.admin.controller.geo.land.LandTaskStatus;
 import com.sysu.admin.controller.geo.land.images.FieldPointImageService;
 import com.sysu.admin.utils.shape.GeoCastUtil;
 import com.xiesx.fastboot.base.result.BaseResult;
@@ -37,7 +38,7 @@ public class FieldPointController {
             bean = new FieldPoint()
                     .setCropType(cityLand.getGridcode().intValue())
                     .setGeom((Point)GeoCastUtil.wktToGeom(vo.getWkt()))
-                    .setStatus(FieldPointStatus.publish.ordinal())
+                    .setStatus(LandTaskStatus.unpublished.ordinal())
                     .setLandId(cityLand.getId());
         }else{
             bean = mFieldPointService.findOne(vo.getId());

+ 1 - 1
src/main/java/com/sysu/admin/controller/geo/land/FieldPointRepository.java → src/main/java/com/sysu/admin/controller/geo/land/point/FieldPointRepository.java

@@ -1,4 +1,4 @@
-package com.sysu.admin.controller.geo.land;
+package com.sysu.admin.controller.geo.land.point;
 
 import com.xiesx.fastboot.core.jpa.JpaPlusRepository;
 

+ 1 - 1
src/main/java/com/sysu/admin/controller/geo/land/FieldPointService.java → src/main/java/com/sysu/admin/controller/geo/land/point/FieldPointService.java

@@ -1,4 +1,4 @@
-package com.sysu.admin.controller.geo.land;
+package com.sysu.admin.controller.geo.land.point;
 
 import com.querydsl.core.types.Predicate;
 import com.sysu.admin.support.base.BaseService;

+ 1 - 1
src/main/java/com/sysu/admin/controller/geo/land/FieldPointVo.java → src/main/java/com/sysu/admin/controller/geo/land/point/FieldPointVo.java

@@ -1,4 +1,4 @@
-package com.sysu.admin.controller.geo.land;
+package com.sysu.admin.controller.geo.land.point;
 
 import com.alibaba.fastjson.annotation.JSONField;
 import lombok.Data;

+ 1 - 1
src/main/java/com/sysu/admin/support/base/RepositoryContext.java

@@ -2,7 +2,7 @@ package com.sysu.admin.support.base;
 
 
 import com.sysu.admin.controller.geo.CityLandRepository;
-import com.sysu.admin.controller.geo.land.FieldPointRepository;
+import com.sysu.admin.controller.geo.land.point.FieldPointRepository;
 import com.sysu.admin.controller.geo.land.images.FieldPointImageRepository;
 import com.sysu.admin.controller.geo.qyz.QyzRepository;
 import com.sysu.admin.support.system.user_role.UserRoleRepository;

+ 21 - 14
src/main/webapp/WEB-INF/jsp/comm/admin2.jsp

@@ -31,6 +31,9 @@
     <fb:script src="${base}/static/package/zsjc.js"></fb:script>
     <fb:script src="${base}/static/package/qyz.js"></fb:script>
     <fb:script src="${base}/static/package/cityland.js"></fb:script>
+    <fb:script src="${base}/static/package/task_action.js"></fb:script>
+    <fb:script src="${base}/static/package/style.js"></fb:script>
+    <fb:script src="${base}/static/package/publish_task_action.js"></fb:script>
 
 
     <fb:script type="text/javascript">
@@ -57,9 +60,9 @@
                 var target = "map"
 
                 view1 = new ol.View({
-                    center: [117.0498, 23.4073],
+                    center: [112.9986, 23.6789],
                     projection: projection,
-                    zoom: 18
+                    zoom: 12
                 })
 
                 map = new ol.Map({
@@ -126,7 +129,7 @@
                             }
                             let action;
                             if(treeNode.Action){
-                                action = geoServerContext.createAction(treeNode.id, treeNode.Action)
+                                action = geoServerContext.createAction(treeNode.id, treeNode.Action, treeNode)
                                 geoServerContext.stopActions()
                                 action.start()
                             }
@@ -136,17 +139,21 @@
 
                 var zNodes =[
                     { id:1, pId:0, name:"耕地地块",icon :"${base}/static/images/cloudy20x20.png", Action: CityLandAction},
-                    { id:2, pId:0, name:"作物类型", icon :"${base}/static/images/cloudy20x20.png"},
-                    { id:21, pId:2, name:"种植结构",icon :"${base}/static/images/tree-point.png", Action: QyzAction},
-                    { id:22, pId:2, name:"水稻",icon :"${base}/static/images/tree-point.png"},
-                    { id:23, pId:2, name:"油菜",icon :"${base}/static/images/tree-point.png"},
-                    { id:24, pId:2, name:"玉米",icon :"${base}/static/images/tree-point.png"},
-                    { id:25, pId:2, name:"柑橘",icon :"${base}/static/images/tree-point.png"},
-                    { id:3, pId:0, name:"长势检测",icon :"${base}/static/images/cloudy20x20.png", Action: ZsjcAction},
-                    { id:4, pId:0, name:"产量预估",icon :"${base}/static/images/cloudy20x20.png"},
-                    { id:5, pId:0, name:"农业灾害风险",icon :"${base}/static/images/cloudy20x20.png"},
-                    { id:6, pId:0, name:"土壤要素",icon :"${base}/static/images/cloudy20x20.png"},
-                    { id:7, pId:0, name:"适应性评估",icon :"${base}/static/images/cloudy20x20.png"}
+                    <%--{ id:2, pId:0, name:"作物类型", icon :"${base}/static/images/cloudy20x20.png"},--%>
+                    <%--{ id:21, pId:2, name:"种植结构",icon :"${base}/static/images/tree-point.png", Action: QyzAction},--%>
+                    <%--{ id:22, pId:2, name:"水稻",icon :"${base}/static/images/tree-point.png"},--%>
+                    <%--{ id:23, pId:2, name:"油菜",icon :"${base}/static/images/tree-point.png"},--%>
+                    <%--{ id:24, pId:2, name:"玉米",icon :"${base}/static/images/tree-point.png"},--%>
+                    <%--{ id:25, pId:2, name:"柑橘",icon :"${base}/static/images/tree-point.png"},--%>
+                    { id:3, pId:0,  name:"任务管理",icon :"${base}/static/images/cloudy20x20.png",open:true},
+                    { id:31, pId:3, status:1, name:"已发布的",icon :"${base}/static/images/cloudy20x20.png", Action:TaskLandAction},
+                    { id:32, pId:3, status:2, name:"已接受的",icon :"${base}/static/images/cloudy20x20.png", Action:TaskLandAction},
+                    { id:33, pId:3, status:3, name:"已完成的",icon :"${base}/static/images/cloudy20x20.png", Action:TaskLandAction},
+                    { id:34, pId:3, name:"批量发布",icon :"${base}/static/images/cloudy20x20.png", Action: PublishTaskAction},
+                    <%--{ id:4, pId:0, name:"产量预估",icon :"${base}/static/images/cloudy20x20.png"},--%>
+                    <%--{ id:5, pId:0, name:"农业灾害风险",icon :"${base}/static/images/cloudy20x20.png"},--%>
+                    <%--{ id:6, pId:0, name:"土壤要素",icon :"${base}/static/images/cloudy20x20.png"},--%>
+                    <%--{ id:7, pId:0, name:"适应性评估",icon :"${base}/static/images/cloudy20x20.png"}--%>
                 ];
                 var zTree = $.fn.zTree.init($("#treeDemo"), setting, zNodes);
                 // 城市赋值

+ 1 - 1
src/main/webapp/static/css/admin2.css

@@ -43,7 +43,7 @@
     bottom: 0px;
     left: 0px;
     right: 0px;
-    background: url(../images/bg.png) no-repeat;
+    /*background: url(../images/bg.png) no-repeat;*/
     background-size:100% 100%;
     filter:alpha(opacity=80);
     -moz-opacity:0.8;

+ 1 - 1
src/main/webapp/static/js/tools/openLayers.js

@@ -101,7 +101,6 @@ Popup.prototype = {
     initTitleHtml(title){
         let html = (title || "提示信息") + this.getButtonsHtml()
         this.title.innerHTML = html;
-        this.title.style.display = 'block';
     },
     getButtonsHtml(){
         let html = ""
@@ -126,6 +125,7 @@ Popup.prototype = {
         }
     },
     show(coordinate, html, ext){
+        this.title.style.display = 'block';
         this.overlay.setPosition(coordinate);
         this.ext = ext || {}
         this.flashHtml(html)

+ 39 - 57
src/main/webapp/static/package/cityland.js

@@ -23,16 +23,17 @@ CityLandAction.prototype = {
                 that.clickLock = false
             },
             buttons:[
-                {"name":"发布任务","click":"pubTask"}
+                {"name":"发布任务","click":"pubTask"},{"name":"放大到合适","click":"fit"}
             ],
             listener: {
                 info(){
                     window.location = "/field_point/info"
                 },
-                pubTask(popup, event, ext){
+                fit(popup, event, ext){
                     that.context.currentView.fit(ext.getGeometry(),{duration:1000})
-                    popup.flashHtml(that.getPubTaskHtml(ext))
-                    that.initSelectPoint(ext)
+                },
+                pubTask(popup, event, ext){
+                    that.saveTask(that, ext)
                 }
             }
         });
@@ -71,13 +72,16 @@ CityLandAction.prototype = {
         let layerName = that.obj.wmsData.params.LAYER.substring(that.obj.wmsData.params.LAYER.indexOf(":") + 1)
         that.context.getInfo(layerName, event.coordinate, function(res){
             try {
+                if(res.code == -1){
+                    return;
+                }
                 console.log(res.data)
                 let geometry = that.context.wkt.readGeometry(res.data.wkt)
                 let area = geometry.getArea()
                 area = (area + area / 2) / 1000
                 res.data["area"] = area.toFixed(2)
                 let feature = new ol.Feature({
-                    geometry: geometry.transform("EPSG:4526","EPSG:4326")
+                    geometry: geometry
                 });
                 for(let key in res.data){
                     if(key != "wkt"){
@@ -86,9 +90,8 @@ CityLandAction.prototype = {
                 }
                 that.tempVectorLayer.getSource().clear()
                 that.tempVectorLayer.getSource().addFeature(feature)
-                let fieldPoints = res.data.fieldPoints;
-                for(let fieldPoint of fieldPoints){
-                    that.addFieldPointOfTempLayer(fieldPoint)
+                if(res.data.status > 0){
+                    that.addFieldPointOfTempLayer(res.data)
                 }
                 that.popup.show(ol.extent.getCenter(feature.getGeometry().getExtent()), that.getInfoHtml(feature), feature)
             }catch (e){
@@ -101,13 +104,14 @@ CityLandAction.prototype = {
             that.clickLock = false
         })
     },
-    addFieldPointOfTempLayer(fieldPoint){
-        let pointGem = this.context.wkt.readGeometry(fieldPoint.wkt)
+    addFieldPointOfTempLayer(cityLand){
+        let geometry = this.context.wkt.readGeometry(cityLand.wkt)
+        let extent = ol.extent.getCenter(geometry.getExtent());
         let point = new ol.Feature({
-            geometry: pointGem
+            geometry: new ol.geom.Point(extent)
         });
         point.set("isPoint",1)
-        point.set("id",fieldPoint.id)
+        point.set("id",cityLand.id)
         let source = this.tempVectorLayer.getSource();
         source.addFeature(point)
     },
@@ -178,41 +182,21 @@ CityLandAction.prototype = {
             html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
         }
         return html
-    },getPubTaskHtml(feature){
-        let html = this.getInfoHtml(feature)
-        html += "<div class='layui-row'><div class='lab' >位置信息</div><div class='val' ><a id='selectPoint' href='#' style='color: white'>点击选取</a>:<input readonly style='width:150px' id='point'  /></div></div>"
-        html += "<div><button class='button' id='saveTask'>保存</button></div>"
-        return html;
-    },
-    initSelectPoint(feature){
-        let that = this
-        $("#selectPoint").on("click", function(){that.selectPoint(that)})
-        $("#saveTask").on("click",function(){
-            that.saveTask(that, feature)
-        })
-        this.clickLock = true
-    },
-    selectPoint(that){
-        document.body.style.cursor = "crosshair";
-        that.popup.showOrHide(false)
-        this.context.clicks["selectPoint"] = {
-            click(event, action){
-                $("#point").val(event.coordinate[0].toFixed(7)+","+event.coordinate[1].toFixed(7))
-                that.context.clicks["selectPoint"] = undefined
-                document.body.style.cursor = "default";
-                that.popup.showOrHide(true)
-            }
-        }
     },
+    // selectPoint(that){
+    //     document.body.style.cursor = "crosshair";
+    //     that.popup.showOrHide(false)
+    //     this.context.clicks["selectPoint"] = {
+    //         click(event, action){
+    //             $("#point").val(event.coordinate[0].toFixed(7)+","+event.coordinate[1].toFixed(7))
+    //             that.context.clicks["selectPoint"] = undefined
+    //             document.body.style.cursor = "default";
+    //             that.popup.showOrHide(true)
+    //         }
+    //     }
+    // },
     saveTask(that, feature){
-        let wkt = $("#point").val()
-        if(wkt.indexOf(",") < 0){
-            layui.notice.error("请先选择点!");
-            return;
-        }
-        wkt = wkt.split(",")
-        wkt = "POINT ("+wkt[0]+" "+wkt[1]+")"
-        layui.tool.submit("/field_point/save",{"wkt":wkt,"landId":feature.get("id")},function(res){
+        layui.tool.submit("/postGisInfo/save",{"status":1,"id":feature.get("id")},function(res){
             if(res.code == 0){
                 that.addFieldPointOfTempLayer(res.data)
             }
@@ -224,21 +208,19 @@ CityLandAction.prototype = {
 function CityLand(opt){
 
     this.name = "CityLand"
-    var gridsetName = 'EPSG:3857';
-    var gridNames = [];
-    for(let i=0;i<=30;i++){
-        gridNames.push(i)
-    }
+    var gridsetName = 'EPSG:4326';
+    var gridNames = ['EPSG:4326:0', 'EPSG:4326:1', 'EPSG:4326:2', 'EPSG:4326:3', 'EPSG:4326:4', 'EPSG:4326:5', 'EPSG:4326:6', 'EPSG:4326:7', 'EPSG:4326:8', 'EPSG:4326:9', 'EPSG:4326:10', 'EPSG:4326:11', 'EPSG:4326:12', 'EPSG:4326:13', 'EPSG:4326:14', 'EPSG:4326:15', 'EPSG:4326:16', 'EPSG:4326:17', 'EPSG:4326:18', 'EPSG:4326:19', 'EPSG:4326:20', 'EPSG:4326:21'];
+
     this.wmsData = {
         url: opt.url,
         projection: new ol.proj.Projection({
-            code: 'EPSG:3857',
-            units: 'm',
+            code: 'EPSG:4326',
+            units: 'degrees',
             axisOrientation: 'neu'
         }),
         params:{
             'VERSION': '1.0.0',
-            'LAYER': "wuhan:gdcityland30",
+            'LAYER': "wuhan:p_crop",
             'STYLE': "wuhan:city_land",
             'TILEMATRIX': gridNames,
             'TILEMATRIXSET': gridsetName,
@@ -256,7 +238,7 @@ function CityLand(opt){
 
 CityLand.prototype = {
     getTileLayer(){
-        var resolutions = [156543.03390625, 78271.516953125, 39135.7584765625, 19567.87923828125, 9783.939619140625, 4891.9698095703125, 2445.9849047851562, 1222.9924523925781, 611.4962261962891, 305.74811309814453, 152.87405654907226, 76.43702827453613, 38.218514137268066, 19.109257068634033, 9.554628534317017, 4.777314267158508, 2.388657133579254, 1.194328566789627, 0.5971642833948135];
+        var resolutions = [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 6.866455078125E-4, 3.4332275390625E-4, 1.71661376953125E-4, 8.58306884765625E-5, 4.291534423828125E-5, 2.1457672119140625E-5, 1.0728836059570312E-5, 5.364418029785156E-6, 2.682209014892578E-6, 1.341104507446289E-6, 6.705522537231445E-7, 3.3527612686157227E-7];
         var baseUrl = this.wmsData.url;
         var baseParams = ['VERSION','LAYER','STYLE','TILEMATRIX','TILEMATRIXSET','SERVICE','FORMAT'];
         var url = baseUrl+'?'
@@ -274,8 +256,8 @@ CityLand.prototype = {
             projection: this.wmsData.projection,
             tileGrid: new ol.tilegrid.WMTS({
                 tileSize: [256,256],
-                extent: [-2.003750834E7,-2.003750834E7,2.003750834E7,2.003750834E7],
-                origin: [-2.003750834E7, 2.003750834E7],
+                extent: [-180.0,-90.0,180.0,90.0],
+                origin: [-180.0, 90.0],
                 resolutions: resolutions,
                 matrixIds: this.wmsData.params['TILEMATRIX']
             }),
@@ -287,7 +269,7 @@ CityLand.prototype = {
             source: this.layerData.source,
             zIndex: 2,
             minZoom: 7,
-            maxZoom: 15
+            maxZoom: 30
         });
     }
 }

+ 30 - 4
src/main/webapp/static/package/geo_server_context.js

@@ -20,9 +20,9 @@ function GeoServerContext(opt,geoserver_path){
 }
 
 GeoServerContext.prototype = {
-    createAction(key, Action){
+    createAction(key, Action, ext){
         if(!this.actions[key]){
-            this.actions[key] = new Action(this, key)
+            this.actions[key] = new Action(this, key, ext)
             this.actions[key].create()
         }
         return this.actions[key]
@@ -35,7 +35,7 @@ GeoServerContext.prototype = {
         }
     },
     getInfo(layerName , coordinate, callback, error) {
-        coordinate = ol.proj.transform([coordinate[0],coordinate[1]],"EPSG:4326","EPSG:4526")
+        // coordinate = ol.proj.transform([coordinate[0],coordinate[1]],"EPSG:4326","EPSG:4526")
         console.log(layerName, coordinate)
         $.ajax({
             type : 'POST',
@@ -88,11 +88,37 @@ function MyGeoJsonLayer(option){
         zIndex: this.zIndex,
         source: this.source
     });
-
 }
 
 MyGeoJsonLayer.prototype = {
+}
 
+function TipLayer(option){
+    this.features = option.features || [];
+    this.style = option.style
+    this.zIndex = option.zIndex || 0
+    this.source = new ol.source.Vector({
+        projection: 'EPSG:4326'
+    })
+    for(let feature of this.features){
+        let point = new ol.geom.Point(ol.extent.getCenter(feature.getGeometry().getExtent()))
+        let pointFeature = new ol.Feature({geometry:point})
+        let keys = feature.getKeys();
+        for(let key of keys){
+            if(key === "geometry"){
+                continue
+            }
+            pointFeature.set(key,feature.get(key))
+        }
+        this.source.addFeature(pointFeature)
+        console.log(pointFeature.getKeys())
+    }
+    this.vector = new ol.layer.Vector({
+        style: this.style,
+        zIndex: this.zIndex,
+        source: this.source,
+        maxZoom: 14
+    });
 }
 
 

+ 151 - 0
src/main/webapp/static/package/publish_task_action.js

@@ -0,0 +1,151 @@
+function PublishTaskAction(context, id, ext){
+    this.context = context
+    this.id = id
+    this.selected = {}
+    this.popup = null
+    this.tipLayer = null
+    this.obj = new TaskLand({
+        url : context.local_wfs_path,
+        status : ext.status
+    })
+}
+
+PublishTaskAction.prototype = {
+    clickLock:false,
+    startStatus : false,
+    createStatus : false,
+    create(){
+        let that = this
+        this.obj.getTileLayer()
+        this.popup = new Popup({map: this.context.currentMap,
+            close(){
+                that.clickLock = false
+            },
+            buttons:[
+                {"name":"放大到合适","click":"fit"}
+            ],
+            listener: {
+                info(){
+                    window.location = "/field_point/info"
+                },
+                fit(popup, event, ext){
+                    that.context.currentView.fit(ext.getGeometry(),{duration:1000})
+                }
+            }
+        });
+        this.createStatus = true;
+    },
+    start(){
+        if(this.startStatus){
+            console.log("startStatus is true")
+            return
+        }
+        this.context.clicks[this.id] = this
+        this.context.currentMap.addLayer(this.obj.layerData.layer)
+        let source = this.obj.layerData.layer.getSource();
+        let that = this;
+
+        if(that.tipLayer){
+            that.context.currentMap.addLayer(that.tipLayer.vector)
+            that.context.currentView.fit(source.getExtent(),{duration:1000})
+        }else{
+            source.on("featuresloadend",function(){
+                that.tipLayer = new TipLayer({features: source.getFeatures(), zIndex:3, style: globalStyle.pointStyle })
+                that.context.currentMap.addLayer(that.tipLayer.vector)
+                that.context.currentView.fit(source.getExtent(),{duration:1000})
+            })
+        }
+
+        this.context.getSldStyleSign(this.obj.wmsData.params.STYLE)
+        this.startStatus = true;
+    },
+    stop(){
+        if(!this.startStatus){
+            console.log("startStatus is false")
+            return
+        }
+        this.context.currentMap.removeLayer(this.obj.layerData.layer)
+        this.context.currentMap.removeLayer(this.tipLayer.vector)
+        console.log("tempVectorLayer cleared")
+        this.context.clicks[this.id] = null
+        console.log("remove click")
+        this.popup._close()
+        console.log("close popup")
+        this.startStatus = false;
+    },
+    addFieldPointOfTempLayer(TaskLand){
+        let geometry = this.context.wkt.readGeometry(TaskLand.wkt)
+        let extent = ol.extent.getCenter(geometry.getExtent());
+        let point = new ol.Feature({
+            geometry: new ol.geom.Point(extent)
+        });
+        point.set("isPoint",1)
+        point.set("id",TaskLand.id)
+        let source = this.tempVectorLayer.getSource();
+        source.addFeature(point)
+    }
+    ,
+    landType:{
+        0:"其他",
+        1:"湿地",
+        2:"耕地",
+        3:"种植",
+        4:"林地",
+        5:"草地",
+        6:"水域",
+    },getInfoHtml(feature){
+        let html = ""
+        let data = {
+            "地块类别":this.landType[feature.get("gridcode")],
+            "地块图斑编号":feature.get("id"),
+            "地块面积(亩)":feature.get("area"),
+            "地块周长(米)":"10000",
+        }
+        for(let key in data){
+            html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
+        }
+        return html
+    }
+
+}
+
+function TaskLand(opt){
+
+    this.name = "TaskLand"
+
+    this.wmsData = {
+        url: opt.url,
+        projection: new ol.proj.Projection({
+            code: 'EPSG:4326',
+            units: 'degrees',
+            axisOrientation: 'neu'
+        }),
+        params:{
+            'LAYER': "wuhan:p_crop",
+            'STATUS': opt.status,
+            'STYLE': "wuhan:city_land",
+        }
+    }
+    this.layerData = {
+        layer : null,
+        source : null,
+        select : null,
+        always : false
+    }
+}
+
+TaskLand.prototype = {
+    getTileLayer(){
+        let url = this.wmsData.url +
+            "?service=WFS&version=1.0.0&request=GetFeature&typeName="+this.wmsData.params["LAYER"]+"&maxFeatures=1000&outputFormat=application/json"
+        url+="&Filter=(<Filter>" +
+            "<ogc:PropertyIsEqualTo  xmlns:ogc=\"http://www.opengis.net/ogc\" ><ogc:PropertyName>status</ogc:PropertyName>" +
+            "<ogc:Literal>"+this.wmsData.params["STATUS"]+"</ogc:Literal></ogc:PropertyIsEqualTo></Filter>)"
+        console.log(url)
+        let myGeoJsonLayer = new MyGeoJsonLayer({url: url, zIndex:2, style: this.style})
+        this.layerData.layer = myGeoJsonLayer.vector;
+    },style(f){
+        return globalStyle.cityLand(f.get("gridcode"))
+    },
+
+}

+ 39 - 0
src/main/webapp/static/package/style.js

@@ -0,0 +1,39 @@
+let globalStyle = {
+    cityLand(gridcode) {
+        let fillColor = ["#6E7F8580","#7B9CFB80","#979B4980","#E9920980","#182F1380","#30791380","#0D53AF80"];
+        return new ol.style.Style({
+            fill: new ol.style.Fill({
+                color: fillColor[gridcode],
+            })
+        });
+    },
+    pointStyle(f){
+        console.log(f.get("id"))
+        return new ol.style.Style({
+            text:new ol.style.Text({
+                text:f.get("id")+"",
+                stroke: new ol.style.Stroke({
+                    color: 'rgba(239,236,236)',
+                    width: 1,
+                }),
+                fill: new ol.style.Fill({
+                    color: 'rgba(239,236,236)',
+                }),
+                font:"16px sans-serif"
+            }),
+            image: new ol.style.RegularShape({
+                stroke: new ol.style.Stroke({
+                    color: 'rgb(7,31,250)',
+                    width: 2,
+                }),
+                fill: new ol.style.Fill({
+                    color: 'rgb(7,72,238)',
+                }),
+                radius: 15,
+                points:20,
+                angle: 0
+            })
+        });
+    }
+
+}

+ 151 - 0
src/main/webapp/static/package/task_action.js

@@ -0,0 +1,151 @@
+function TaskLandAction(context, id, ext){
+    this.context = context
+    this.id = id
+    this.selected = {}
+    this.popup = null
+    this.tipLayer = null
+    this.obj = new TaskLand({
+        url : context.local_wfs_path,
+        status : ext.status
+    })
+}
+
+TaskLandAction.prototype = {
+    clickLock:false,
+    startStatus : false,
+    createStatus : false,
+    create(){
+        let that = this
+        this.obj.getTileLayer()
+        this.popup = new Popup({map: this.context.currentMap,
+            close(){
+                that.clickLock = false
+            },
+            buttons:[
+                {"name":"放大到合适","click":"fit"}
+            ],
+            listener: {
+                info(){
+                    window.location = "/field_point/info"
+                },
+                fit(popup, event, ext){
+                    that.context.currentView.fit(ext.getGeometry(),{duration:1000})
+                }
+            }
+        });
+        this.createStatus = true;
+    },
+    start(){
+        if(this.startStatus){
+            console.log("startStatus is true")
+            return
+        }
+        this.context.clicks[this.id] = this
+        this.context.currentMap.addLayer(this.obj.layerData.layer)
+        let source = this.obj.layerData.layer.getSource();
+        let that = this;
+
+        if(that.tipLayer){
+            that.context.currentMap.addLayer(that.tipLayer.vector)
+            that.context.currentView.fit(source.getExtent(),{duration:1000})
+        }else{
+            source.on("featuresloadend",function(){
+                that.tipLayer = new TipLayer({features: source.getFeatures(), zIndex:3, style: globalStyle.pointStyle })
+                that.context.currentMap.addLayer(that.tipLayer.vector)
+                that.context.currentView.fit(source.getExtent(),{duration:1000})
+            })
+        }
+
+        this.context.getSldStyleSign(this.obj.wmsData.params.STYLE)
+        this.startStatus = true;
+    },
+    stop(){
+        if(!this.startStatus){
+            console.log("startStatus is false")
+            return
+        }
+        this.context.currentMap.removeLayer(this.obj.layerData.layer)
+        this.context.currentMap.removeLayer(this.tipLayer.vector)
+        console.log("tempVectorLayer cleared")
+        this.context.clicks[this.id] = null
+        console.log("remove click")
+        this.popup._close()
+        console.log("close popup")
+        this.startStatus = false;
+    },
+    addFieldPointOfTempLayer(TaskLand){
+        let geometry = this.context.wkt.readGeometry(TaskLand.wkt)
+        let extent = ol.extent.getCenter(geometry.getExtent());
+        let point = new ol.Feature({
+            geometry: new ol.geom.Point(extent)
+        });
+        point.set("isPoint",1)
+        point.set("id",TaskLand.id)
+        let source = this.tempVectorLayer.getSource();
+        source.addFeature(point)
+    }
+    ,
+    landType:{
+        0:"其他",
+        1:"湿地",
+        2:"耕地",
+        3:"种植",
+        4:"林地",
+        5:"草地",
+        6:"水域",
+    },getInfoHtml(feature){
+        let html = ""
+        let data = {
+            "地块类别":this.landType[feature.get("gridcode")],
+            "地块图斑编号":feature.get("id"),
+            "地块面积(亩)":feature.get("area"),
+            "地块周长(米)":"10000",
+        }
+        for(let key in data){
+            html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
+        }
+        return html
+    }
+
+}
+
+function TaskLand(opt){
+
+    this.name = "TaskLand"
+
+    this.wmsData = {
+        url: opt.url,
+        projection: new ol.proj.Projection({
+            code: 'EPSG:4326',
+            units: 'degrees',
+            axisOrientation: 'neu'
+        }),
+        params:{
+            'LAYER': "wuhan:p_crop",
+            'STATUS': opt.status,
+            'STYLE': "wuhan:city_land",
+        }
+    }
+    this.layerData = {
+        layer : null,
+        source : null,
+        select : null,
+        always : false
+    }
+}
+
+TaskLand.prototype = {
+    getTileLayer(){
+        let url = this.wmsData.url +
+            "?service=WFS&version=1.0.0&request=GetFeature&typeName="+this.wmsData.params["LAYER"]+"&maxFeatures=1000&outputFormat=application/json"
+        url+="&Filter=(<Filter>" +
+            "<ogc:PropertyIsEqualTo  xmlns:ogc=\"http://www.opengis.net/ogc\" ><ogc:PropertyName>status</ogc:PropertyName>" +
+            "<ogc:Literal>"+this.wmsData.params["STATUS"]+"</ogc:Literal></ogc:PropertyIsEqualTo></Filter>)"
+        console.log(url)
+        let myGeoJsonLayer = new MyGeoJsonLayer({url: url, zIndex:2, style: this.style})
+        this.layerData.layer = myGeoJsonLayer.vector;
+    },style(f){
+        return globalStyle.cityLand(f.get("gridcode"))
+    },
+
+}