|
@@ -23,16 +23,17 @@ CityLandAction.prototype = {
|
|
that.clickLock = false
|
|
that.clickLock = false
|
|
},
|
|
},
|
|
buttons:[
|
|
buttons:[
|
|
- {"name":"发布任务","click":"pubTask"}
|
|
|
|
|
|
+ {"name":"发布任务","click":"pubTask"},{"name":"放大到合适","click":"fit"}
|
|
],
|
|
],
|
|
listener: {
|
|
listener: {
|
|
info(){
|
|
info(){
|
|
window.location = "/field_point/info"
|
|
window.location = "/field_point/info"
|
|
},
|
|
},
|
|
- pubTask(popup, event, ext){
|
|
|
|
|
|
+ fit(popup, event, ext){
|
|
that.context.currentView.fit(ext.getGeometry(),{duration:1000})
|
|
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)
|
|
let layerName = that.obj.wmsData.params.LAYER.substring(that.obj.wmsData.params.LAYER.indexOf(":") + 1)
|
|
that.context.getInfo(layerName, event.coordinate, function(res){
|
|
that.context.getInfo(layerName, event.coordinate, function(res){
|
|
try {
|
|
try {
|
|
|
|
+ if(res.code == -1){
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
console.log(res.data)
|
|
console.log(res.data)
|
|
let geometry = that.context.wkt.readGeometry(res.data.wkt)
|
|
let geometry = that.context.wkt.readGeometry(res.data.wkt)
|
|
let area = geometry.getArea()
|
|
let area = geometry.getArea()
|
|
area = (area + area / 2) / 1000
|
|
area = (area + area / 2) / 1000
|
|
res.data["area"] = area.toFixed(2)
|
|
res.data["area"] = area.toFixed(2)
|
|
let feature = new ol.Feature({
|
|
let feature = new ol.Feature({
|
|
- geometry: geometry.transform("EPSG:4526","EPSG:4326")
|
|
|
|
|
|
+ geometry: geometry
|
|
});
|
|
});
|
|
for(let key in res.data){
|
|
for(let key in res.data){
|
|
if(key != "wkt"){
|
|
if(key != "wkt"){
|
|
@@ -86,9 +90,8 @@ CityLandAction.prototype = {
|
|
}
|
|
}
|
|
that.tempVectorLayer.getSource().clear()
|
|
that.tempVectorLayer.getSource().clear()
|
|
that.tempVectorLayer.getSource().addFeature(feature)
|
|
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)
|
|
that.popup.show(ol.extent.getCenter(feature.getGeometry().getExtent()), that.getInfoHtml(feature), feature)
|
|
}catch (e){
|
|
}catch (e){
|
|
@@ -101,13 +104,14 @@ CityLandAction.prototype = {
|
|
that.clickLock = false
|
|
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({
|
|
let point = new ol.Feature({
|
|
- geometry: pointGem
|
|
|
|
|
|
+ geometry: new ol.geom.Point(extent)
|
|
});
|
|
});
|
|
point.set("isPoint",1)
|
|
point.set("isPoint",1)
|
|
- point.set("id",fieldPoint.id)
|
|
|
|
|
|
+ point.set("id",cityLand.id)
|
|
let source = this.tempVectorLayer.getSource();
|
|
let source = this.tempVectorLayer.getSource();
|
|
source.addFeature(point)
|
|
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>"
|
|
html += "<div class='layui-row'><div class='lab' >"+key+"</div><div class='val' >"+data[key]+"</div></div>"
|
|
}
|
|
}
|
|
return html
|
|
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){
|
|
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){
|
|
if(res.code == 0){
|
|
that.addFieldPointOfTempLayer(res.data)
|
|
that.addFieldPointOfTempLayer(res.data)
|
|
}
|
|
}
|
|
@@ -224,21 +208,19 @@ CityLandAction.prototype = {
|
|
function CityLand(opt){
|
|
function CityLand(opt){
|
|
|
|
|
|
this.name = "CityLand"
|
|
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 = {
|
|
this.wmsData = {
|
|
url: opt.url,
|
|
url: opt.url,
|
|
projection: new ol.proj.Projection({
|
|
projection: new ol.proj.Projection({
|
|
- code: 'EPSG:3857',
|
|
|
|
- units: 'm',
|
|
|
|
|
|
+ code: 'EPSG:4326',
|
|
|
|
+ units: 'degrees',
|
|
axisOrientation: 'neu'
|
|
axisOrientation: 'neu'
|
|
}),
|
|
}),
|
|
params:{
|
|
params:{
|
|
'VERSION': '1.0.0',
|
|
'VERSION': '1.0.0',
|
|
- 'LAYER': "wuhan:gdcityland30",
|
|
|
|
|
|
+ 'LAYER': "wuhan:p_crop",
|
|
'STYLE': "wuhan:city_land",
|
|
'STYLE': "wuhan:city_land",
|
|
'TILEMATRIX': gridNames,
|
|
'TILEMATRIX': gridNames,
|
|
'TILEMATRIXSET': gridsetName,
|
|
'TILEMATRIXSET': gridsetName,
|
|
@@ -256,7 +238,7 @@ function CityLand(opt){
|
|
|
|
|
|
CityLand.prototype = {
|
|
CityLand.prototype = {
|
|
getTileLayer(){
|
|
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 baseUrl = this.wmsData.url;
|
|
var baseParams = ['VERSION','LAYER','STYLE','TILEMATRIX','TILEMATRIXSET','SERVICE','FORMAT'];
|
|
var baseParams = ['VERSION','LAYER','STYLE','TILEMATRIX','TILEMATRIXSET','SERVICE','FORMAT'];
|
|
var url = baseUrl+'?'
|
|
var url = baseUrl+'?'
|
|
@@ -274,8 +256,8 @@ CityLand.prototype = {
|
|
projection: this.wmsData.projection,
|
|
projection: this.wmsData.projection,
|
|
tileGrid: new ol.tilegrid.WMTS({
|
|
tileGrid: new ol.tilegrid.WMTS({
|
|
tileSize: [256,256],
|
|
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,
|
|
resolutions: resolutions,
|
|
matrixIds: this.wmsData.params['TILEMATRIX']
|
|
matrixIds: this.wmsData.params['TILEMATRIX']
|
|
}),
|
|
}),
|
|
@@ -287,7 +269,7 @@ CityLand.prototype = {
|
|
source: this.layerData.source,
|
|
source: this.layerData.source,
|
|
zIndex: 2,
|
|
zIndex: 2,
|
|
minZoom: 7,
|
|
minZoom: 7,
|
|
- maxZoom: 15
|
|
|
|
|
|
+ maxZoom: 30
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|