4cd04f02 by 杨威

gis重叠分析功能实现

1 parent 3f9a05d3
...@@ -23,7 +23,15 @@ ...@@ -23,7 +23,15 @@
23 "color": "#f50325", 23 "color": "#f50325",
24 "width": 1 24 "width": 1
25 } 25 }
26 },
27 "importSymbol": {
28 "type": "simple-fill",
29 "color": [ 245,3, 37, 0.4 ],
30 "style": "none",
31 "outline": {
32 "color": "#006cff",
33 "width": 2
34 }
26 } 35 }
27
28 } 36 }
29 } 37 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -101,7 +101,8 @@ ...@@ -101,7 +101,8 @@
101 <li v-show="zdData.type == 'zdy'" @click="deleteZdy">删除</li> 101 <li v-show="zdData.type == 'zdy'" @click="deleteZdy">删除</li>
102 </ul> 102 </ul>
103 103
104 <el-dialog title="导入图形" :visible.sync="improtDialog"> 104 <!--@close="closeImportDialog"-->
105 <el-dialog title="导入图形" :modal="false" :close-on-click-modal="false" custom-class="importDialog" :visible.sync="improtDialog" width="30%" @close="closeImportDialog">
105 <import-geo :property-info="zdData" :timeLine="new Date().getTime()" :geo-info="currentClickZdGeo" @closeImportDialog="closeImportDialog"></import-geo> 106 <import-geo :property-info="zdData" :timeLine="new Date().getTime()" :geo-info="currentClickZdGeo" @closeImportDialog="closeImportDialog"></import-geo>
106 </el-dialog> 107 </el-dialog>
107 <!-- 添加定着物弹框 --> 108 <!-- 添加定着物弹框 -->
...@@ -430,6 +431,7 @@ export default { ...@@ -430,6 +431,7 @@ export default {
430 }else { 431 }else {
431 BSM = this.zdData.bsm; 432 BSM = this.zdData.bsm;
432 } 433 }
434 //当确定导入图形是 跳转到图形界面
433 this.queryGeoByBsm(BSM,type,function (features){ 435 this.queryGeoByBsm(BSM,type,function (features){
434 if(features && features.length > 0){ 436 if(features && features.length > 0){
435 if(features[0].geometry){ 437 if(features[0].geometry){
...@@ -438,6 +440,7 @@ export default { ...@@ -438,6 +440,7 @@ export default {
438 cancelButtonText: '取消', 440 cancelButtonText: '取消',
439 type: 'warning' 441 type: 'warning'
440 }).then(() => { 442 }).then(() => {
443 self.postionToMap();
441 self.improtDialog = true; 444 self.improtDialog = true;
442 self.currentClickZdGeo = features[0]; 445 self.currentClickZdGeo = features[0];
443 }).catch(() => { 446 }).catch(() => {
...@@ -447,11 +450,13 @@ export default { ...@@ -447,11 +450,13 @@ export default {
447 }); 450 });
448 }); 451 });
449 }else { 452 }else {
453 self.postionToMap();
450 self.currentClickZdGeo = features[0]; 454 self.currentClickZdGeo = features[0];
451 self.improtDialog = true; 455 self.improtDialog = true;
452 } 456 }
453 457
454 }else{ 458 }else{
459 self.postionToMap();
455 self.currentClickZdGeo = null; 460 self.currentClickZdGeo = null;
456 self.improtDialog = true; 461 self.improtDialog = true;
457 } 462 }
...@@ -500,7 +505,6 @@ export default { ...@@ -500,7 +505,6 @@ export default {
500 }).then(res => { 505 }).then(res => {
501 debugger 506 debugger
502 });*/ 507 });*/
503
504 }else{ 508 }else{
505 self.$message.warning("暂无空间信息!!!!"); 509 self.$message.warning("暂无空间信息!!!!");
506 } 510 }
...@@ -574,6 +578,7 @@ export default { ...@@ -574,6 +578,7 @@ export default {
574 //关闭图形弹框 578 //关闭图形弹框
575 closeImportDialog(){ 579 closeImportDialog(){
576 this.improtDialog = false; 580 this.improtDialog = false;
581 this.clearOverLayer();
577 } 582 }
578 583
579 }, 584 },
...@@ -722,4 +727,8 @@ export default { ...@@ -722,4 +727,8 @@ export default {
722 center; 727 center;
723 background-size: contain; 728 background-size: contain;
724 } 729 }
730 /deep/ .importDialog{
731 margin-top: 120px!important;
732 margin-left: 291px;
733 }
725 </style> 734 </style>
......
1 <template> 1 <template>
2 <div > 2 <div >
3 <div v-if="!resultDialog && !txtResultDialog" class="importDiv"> 3 <div v-if="!resultDialog && !txtResultDialog && !dealDialog" class="importDiv">
4 <el-upload 4 <el-upload
5 class="upload-demo" 5 class="upload-demo"
6 action="#" 6 action="#"
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
108 { required: true, message: '请选择地块', trigger: 'change' }, 108 { required: true, message: '请选择地块', trigger: 'change' },
109 ]" 109 ]"
110 > 110 >
111 <el-select v-model="txtZd.name" filterable placeholder="请选择"> 111 <el-select v-model="txtZd.name" filterable placeholder="请选择" @change="txtChange">
112 <el-option 112 <el-option
113 v-for="(item,index) in txtResult" 113 v-for="(item,index) in txtResult"
114 :key="index" 114 :key="index"
...@@ -123,6 +123,30 @@ ...@@ -123,6 +123,30 @@
123 </el-form-item> 123 </el-form-item>
124 </el-form> 124 </el-form>
125 </div> 125 </div>
126 <div v-if="dealDialog">
127 <el-form :model="dealForm" ref="dealForm" label-width="100px" size="small" @submit.native.prevent class="demo-ruleForm">
128 <el-form-item
129 label="处理方法"
130 prop="method"
131 :rules="[
132 { required: true, message: '请选择', trigger: 'change' },
133 ]"
134 >
135 <el-select v-model="dealForm.method" filterable placeholder="请选择">
136 <el-option
137 v-for="(item,index) in dealMethods"
138 :key="index"
139 :label="item.label"
140 :value="item.value">
141 </el-option>
142 </el-select>
143 </el-form-item>
144 <el-form-item>
145 <el-button type="primary" @click="submitDealForm('dealForm')">确定</el-button>
146 <el-button @click="cancelDealForm('dealForm')">取消</el-button>
147 </el-form-item>
148 </el-form>
149 </div>
126 </div> 150 </div>
127 </template> 151 </template>
128 <script> 152 <script>
...@@ -157,6 +181,25 @@ export default { ...@@ -157,6 +181,25 @@ export default {
157 txtResultDialog:null, 181 txtResultDialog:null,
158 txtZd:{ 182 txtZd:{
159 name:"" 183 name:""
184 },
185 overResults:[],//与导入宗地重叠的地块
186 currntDealGraphic:null,
187 dealMethods:[{
188 label:"不做处理",
189 value:"1"
190 },{
191 label:"删除叠加部分",
192 value:"2"
193 },{
194 label:"删除已重叠部分",
195 value:"3"
196 },{
197 label:"删除原图形",
198 value:"4"
199 }],
200 dealDialog:false,
201 dealForm:{
202 method:""
160 } 203 }
161 } 204 }
162 }, 205 },
...@@ -167,6 +210,7 @@ export default { ...@@ -167,6 +210,7 @@ export default {
167 timeLine(newValue,oldValue){ 210 timeLine(newValue,oldValue){
168 this.resultDialog = false; 211 this.resultDialog = false;
169 this.txtResultDialog = false; 212 this.txtResultDialog = false;
213 this.dealDialog = false;
170 } 214 }
171 }, 215 },
172 methods:{ 216 methods:{
...@@ -268,11 +312,7 @@ export default { ...@@ -268,11 +312,7 @@ export default {
268 attributes:null, 312 attributes:null,
269 geometry:geometry 313 geometry:geometry
270 } 314 }
271 if(self.propertyInfo.type == "zd"){ 315 self.checkGeo(graphic);
272 self.saveZd(graphic);
273 }else{
274 self.saveZRZ(graphic);
275 }
276 }else{ 316 }else{
277 this.$message.warning(response.message); 317 this.$message.warning(response.message);
278 } 318 }
...@@ -291,25 +331,95 @@ export default { ...@@ -291,25 +331,95 @@ export default {
291 graphic.geometry.spatialReference = { 331 graphic.geometry.spatialReference = {
292 wkt:wkt 332 wkt:wkt
293 } 333 }
334 self.checkGeo(graphic);
335 }else{
336 console.log('error submit!!');
337 return false;
338 }
339 })
340 },
341 txtChange(value){
342 var wkt = "PROJCS[\"XADFZBX\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]";
343 var graphics = self.txtResult.filter(item => {
344 return item.attributes.name == value;
345 })
346 var graphic = graphics[0];
347 graphic.geometry.type = "polygon";
348 graphic.geometry.spatialReference = {
349 wkt:wkt
350 }
351 this.addOverLayer(graphic.geometry,[]);
352 },
353 //校验空间完整性
354 checkGeo(graphic){
355 var self = this;
294 //校验完整性 直接调用空间方法 提交空间表 356 //校验完整性 直接调用空间方法 提交空间表
295 self.geoJoint(geometry,function (isJoint,message) { 357 self.geoJoint(graphic.geometry,function (isJoint,message) {
296 if(isJoint){ 358 if(isJoint){
297 self.$message.warning(message) 359 self.$message.warning(message)
298 return; 360 return;
299 }else { 361 }else {
300 if(self.propertyInfo.type == "zd"){ 362 var type = self.propertyInfo.type;
363 if(type == 'zd'){
364 //重叠分析
365 self.zdOverAnalys(self.propertyInfo.zdbsm,graphic,function (flag,results) {
366 if(flag){
367 self.$message.warning("导入的宗地与其他宗地有重叠,请处理!!");
368 self.dealOverData(results,graphic);
369 }else {
301 self.saveZd(graphic); 370 self.saveZd(graphic);
302 }else{ 371 }
372 });
373 }else {
374 self.zrzOverAnalys(this.propertyInfo.bsm,graphic,function (flag,mes) {
375 if(flag){
376 self.$message.warning(mes);
377 return;
378 }else {
303 self.saveZRZ(graphic); 379 self.saveZRZ(graphic);
304 } 380 }
381 });
382 }
305 } 383 }
306 }); 384 });
307 }else{ 385 },
386 //选择处理方式
387 submitDealForm(formName){
388 var self = this;
389 this.$refs[formName].validate((valid) => {
390 if(valid){
391 //选择处理方式
392 var value = self.dealForm.method;
393 switch (value) {
394 case '1':self.currntDealGraphic.attributes.BGZT =1;self.saveZd(self.currntDealGraphic);break;
395 case "2":self.getDifference(self.currntDealGraphic,self.overResults,self.delOverGeo);break;
396 case "3":self.getResultsDif(self.overResults,self.currntDealGraphic,self.delOtherGeo,true);break;
397 case "4":self.getResultsDif(self.overResults,self.currntDealGraphic,self.delOtherGeo,false);break;
398 }
399 }else {
308 console.log('error submit!!'); 400 console.log('error submit!!');
309 return false; 401 return false;
310 } 402 }
311 }) 403 })
312 }, 404 },
405 //裁剪自己在保存
406 delOverGeo(geometry){
407 this.currntDealGraphic.attributes.BGZT =2;
408 if(geometry == null){
409 this.$message.warning("完全重叠,已删除图形信息!!!")
410 this.currntDealGraphic.geometry = geometry;
411 }
412 this.saveZd(this.currntDealGraphic);
413 },
414 //裁剪别的在保存
415 delOtherGeo(results){
416 //执行编辑操作
417 var layer = this.getLayerByName("ZDJBXX");
418 var featureUrl = layer.layerUrl.replace("MapServer","FeatureServer");
419 featureUrl += "/"+layer.id;
420 this.updateGraphic(featureUrl,results);
421 this.saveZd(this.currntDealGraphic);
422 },
313 //下载文档模板 423 //下载文档模板
314 downloadFile(url,fileName){ 424 downloadFile(url,fileName){
315 let link = document.createElement("a"); 425 let link = document.createElement("a");
...@@ -336,25 +446,20 @@ export default { ...@@ -336,25 +446,20 @@ export default {
336 attributes:self.currentClickZd, 446 attributes:self.currentClickZd,
337 geometry:geometry 447 geometry:geometry
338 } 448 }
339 self.geoJoint(geometry,function (isJoint,message) { 449 self.checkGeo(graphic);
340 if(isJoint){
341 self.$message.warning(message)
342 return;
343 }else {
344 if(self.propertyInfo.type == "zd"){
345 self.saveZd(graphic);
346 }else{
347 self.saveZRZ(graphic);
348 }
349 }
350 });
351
352 } else { 450 } else {
353 console.log('error submit!!'); 451 console.log('error submit!!');
354 return false; 452 return false;
355 } 453 }
356 }); 454 });
357 }, 455 },
456 dealOverData(results,graphic){
457 this.overResults = results;
458 this.currntDealGraphic = graphic;
459 this.resultDialog = false;
460 this.txtResultDialog = false;
461 this.dealDialog = true;
462 },
358 saveZd(graphic){ 463 saveZd(graphic){
359 var self = this; 464 var self = this;
360 var points = null,lines = null, 465 var points = null,lines = null,
...@@ -363,6 +468,9 @@ export default { ...@@ -363,6 +468,9 @@ export default {
363 featureUrl += "/"+layer.id; 468 featureUrl += "/"+layer.id;
364 if(self.geoInfo){ 469 if(self.geoInfo){
365 //替换 生成图像 高亮 470 //替换 生成图像 高亮
471 if(graphic.attributes && graphic.attributes.BGZT){
472 self.geoInfo.attributes.BGZT = graphic.attributes.BGZT;
473 }
366 self.geoInfo.attributes.BSM = this.propertyInfo.zdbsm; 474 self.geoInfo.attributes.BSM = this.propertyInfo.zdbsm;
367 self.geoInfo.attributes.ZDDM = this.propertyInfo.zddm; 475 self.geoInfo.attributes.ZDDM = this.propertyInfo.zddm;
368 self.geoInfo.attributes.XMMC = this.propertyInfo.mc; 476 self.geoInfo.attributes.XMMC = this.propertyInfo.mc;
...@@ -374,6 +482,7 @@ export default { ...@@ -374,6 +482,7 @@ export default {
374 var updResult = res.updateFeatureResults[0]; 482 var updResult = res.updateFeatureResults[0];
375 if(updResult.objectId){ 483 if(updResult.objectId){
376 var OBJECTID = updResult.objectId; 484 var OBJECTID = updResult.objectId;
485 if(graphic.geometry){
377 points = self.craetJZPoint(graphic); 486 points = self.craetJZPoint(graphic);
378 self.savejzd(points) 487 self.savejzd(points)
379 //生成边框线 488 //生成边框线
...@@ -381,27 +490,36 @@ export default { ...@@ -381,27 +490,36 @@ export default {
381 lines = res; 490 lines = res;
382 self.saveJzx(lines); 491 self.saveJzx(lines);
383 }); 492 });
493 }
494 self.$message.success("保存成功!!!");
384 self.goMap(); 495 self.goMap();
385 } 496 }
386 }); 497 });
387 }else{ 498 }else{
388 //生成图像 保存 499 //生成图像 保存
389 graphic.attributes = { 500 var attributes = {
390 BSM:this.propertyInfo.zdbsm, 501 BSM:this.propertyInfo.zdbsm,
391 ZDDM:this.propertyInfo.zddm, 502 ZDDM:this.propertyInfo.zddm,
392 XMMC:this.propertyInfo.mc 503 XMMC:this.propertyInfo.mc
504 };
505 if(graphic.attributes && graphic.attributes.BGZT){
506 attributes.BGZT = graphic.attributes.BGZT;
393 } 507 }
508 graphic.attributes = attributes;
394 self.addGraphic(featureUrl,graphic,function (res) { 509 self.addGraphic(featureUrl,graphic,function (res) {
395 var addRresult = res.addFeatureResults[0]; 510 var addRresult = res.addFeatureResults[0];
396 if(addRresult.objectId){ 511 if(addRresult.objectId){
397 var OBJECTID = addRresult.objectId; 512 var OBJECTID = addRresult.objectId;
513 if(graphic.geometry) {
398 points = self.craetJZPoint(graphic); 514 points = self.craetJZPoint(graphic);
399 self.savejzd(points) 515 self.savejzd(points)
400 //生成边框线 516 //生成边框线
401 self.createJZLine(graphic,function (res){ 517 self.createJZLine(graphic, function (res) {
402 lines = res; 518 lines = res;
403 self.saveJzx(lines); 519 self.saveJzx(lines);
404 }); 520 });
521 }
522 self.$message.success("保存成功!!!");
405 self.goMap(); 523 self.goMap();
406 } 524 }
407 }); 525 });
...@@ -459,12 +577,13 @@ export default { ...@@ -459,12 +577,13 @@ export default {
459 var featureUrl = layer.layerUrl.replace("MapServer","FeatureServer"); 577 var featureUrl = layer.layerUrl.replace("MapServer","FeatureServer");
460 featureUrl += "/"+layer.id; 578 featureUrl += "/"+layer.id;
461 if(self.geoInfo){ 579 if(self.geoInfo){
462 self.geoInfo.BSM = this.propertyInfo.bsm; 580 self.geoInfo.BSM = self.propertyInfo.bsm;
463 graphic.attributes = self.geoInfo; 581 graphic.attributes = self.geoInfo;
464 //替换 生成图像 高亮 582 //替换 生成图像 高亮
465 self.updateGraphic(featureUrl,graphic,function (res) { 583 self.updateGraphic(featureUrl,graphic,function (res) {
466 var addRresult = res.updateFeatureResults[0]; 584 var addRresult = res.updateFeatureResults[0];
467 if(addRresult.objectId) { 585 if(addRresult.objectId) {
586 self.$message.success("保存成功!!!");
468 self.goMap(); 587 self.goMap();
469 } 588 }
470 }); 589 });
...@@ -478,12 +597,13 @@ export default { ...@@ -478,12 +597,13 @@ export default {
478 self.addGraphic(featureUrl,graphic,function (res) { 597 self.addGraphic(featureUrl,graphic,function (res) {
479 var addRresult = res.addFeatureResults[0]; 598 var addRresult = res.addFeatureResults[0];
480 if(addRresult.objectId) { 599 if(addRresult.objectId) {
600 self.$message.success("保存成功!!!");
481 self.goMap(); 601 self.goMap();
482 } 602 }
483 }); 603 });
484 } 604 }
485 }, 605 },
486 //操作成功跳转 606 //操作成功不需要跳转地图 (直接定位新导入的图形)
487 goMap(){ 607 goMap(){
488 var bsm = "", type = this.propertyInfo.type; 608 var bsm = "", type = this.propertyInfo.type;
489 if(type == "zd"){ 609 if(type == "zd"){
...@@ -492,35 +612,46 @@ export default { ...@@ -492,35 +612,46 @@ export default {
492 bsm = this.propertyInfo.bsm; 612 bsm = this.propertyInfo.bsm;
493 } 613 }
494 this.resultDialog = false; 614 this.resultDialog = false;
615 this.txtResultDialog = false;
616 this.dealDialog = false;
495 this.$emit("closeImportDialog"); 617 this.$emit("closeImportDialog");
496 var curretRouterInfo = { 618 //TODO 定位当前新导入的图形
497 path: this.$route.path, 619 this.addGeoByBsm(bsm,type,"testMap");
498 query: this.$route.query
499 }
500 sessionStorage.setItem("curretRouterInfo", JSON.stringify(curretRouterInfo));
501 this.$router.push({
502 path: "/viewMap",
503 query: {
504 bsm: bsm,
505 type: this.propertyInfo.type
506 }
507 });
508 }, 620 },
509 //取消 621 //取消
510 cancel(){ 622 cancel(){
511 this.zdForm.zdBsm = ""; 623 this.zdForm.zdBsm = "";
512 this.currentClickZd = null; 624 this.currentClickZd = null;
513 this.resultDialog = false; 625 this.resultDialog = false;
626 // 清空当前图层上显示的图形
627 this.clearOverLayer();
514 }, 628 },
515 //取消文本选择的弹出框 629 //取消文本选择的弹出框
516 cancelTxtForm(){ 630 cancelTxtForm(){
517 this.txtZd.name = ""; 631 this.txtZd.name = "";
518 this.txtResultDialog = false; 632 this.txtResultDialog = false;
633 // 清空当前图层上显示的图形
634 this.clearOverLayer();
635 },
636 //取消导入处理的结果
637 cancelDealForm(){
638 this.dealForm.method = "";
639 this.dealDialog = false;
640 this.overResults = [];
641 // 清空当前图层上显示的图形
642 this.clearOverLayer();
519 }, 643 },
520 //宗地选择发生改变 644 //宗地选择发生改变
521 zdChange(value){ 645 zdChange(value){
522 this.zdForm.zdBsm = value.XMMC; 646 this.zdForm.zdBsm = value.XMMC;
523 this.currentClickZd = value; 647 this.currentClickZd = value;
648 var geometry = this.parseWktToArc(this.currentClickZd.wkt);
649 geometry.type = "polygon";
650 var wkt = "PROJCS[\"XADFZBX\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Transverse_Mercator\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]";
651 geometry.spatialReference = {
652 wkt:wkt
653 }
654 this.addOverLayer(geometry,[]);
524 } 655 }
525 } 656 }
526 } 657 }
......
...@@ -10,6 +10,7 @@ import featureUpdate from "@libs/map/featureUpdate"; ...@@ -10,6 +10,7 @@ import featureUpdate from "@libs/map/featureUpdate";
10 import arcgisParser from 'terraformer-arcgis-parser' 10 import arcgisParser from 'terraformer-arcgis-parser'
11 import wktParse from 'terraformer-wkt-parser' 11 import wktParse from 'terraformer-wkt-parser'
12 import {maps} from '@/libs/map/mapUtils' 12 import {maps} from '@/libs/map/mapUtils'
13 import graphicSymbol from '@/assets/json/graphicSymbol.json'
13 14
14 export default { 15 export default {
15 data(){ 16 data(){
...@@ -197,8 +198,9 @@ export default { ...@@ -197,8 +198,9 @@ export default {
197 } 198 }
198 for(var i = 0;i < results.length;i++){ 199 for(var i = 0;i < results.length;i++){
199 var feature = results[i].feature; 200 var feature = results[i].feature;
200 var flag = geometryEngine.disjoint(polygon,feature.geometry); 201 var flag = geometryEngine.intersects(polygon,feature.geometry);
201 if(flag){ 202 var withinFlag = geometryEngine.within(polygon,feature.geometry);
203 if(!withinFlag && flag){
202 isJoint = true; 204 isJoint = true;
203 layerName = results[i].layerName; 205 layerName = results[i].layerName;
204 switch (layerName) { 206 switch (layerName) {
...@@ -244,7 +246,260 @@ export default { ...@@ -244,7 +246,260 @@ export default {
244 featureUpdate.methods.addGraphic(featureUrl,graphic,callBackFunction) ; 246 featureUpdate.methods.addGraphic(featureUrl,graphic,callBackFunction) ;
245 } 247 }
246 }); 248 });
249 },
250 //叠加分析 同一个图层的叠加分析
251 zdOverAnalys(bsm,graphic,callBacFunction){
252 var self = this;
253 loadModules([
254 "esri/geometry/Polygon"
255 ]).then(([
256 Polygon
257 ]) => {
258 var zdLayer = null;
259 zdLayer = self.getLayerByName("ZDJBXX");
260 var layerIds = [];
261 layerIds.push(zdLayer.id);
262 var polygon = new Polygon(graphic.geometry);
263 identifyUtils.methods.identify(zdLayer.layerUrl,layerIds,polygon,function (res) {
264 var results = res.results;
265 //判断数据是否与其他数据有重叠
266 var flag = false;
267 if(results && results.length > 0){
268 flag = true;
269 //加载在图层上 原本的要导入的数据 和重叠数据
270 self.addOverLayer(polygon,results);
271 }
272 callBacFunction(flag,results);
273 },true)
274 }).catch(err => {
275 console.log(err);
276 throw (err);
277 })
278 },
279 //添加添加元素和覆盖的元素到地图上
280 addOverLayer(geometry,results){
281 var view = maps["testMap"];
282 loadModules([
283 "esri/Graphic",
284 "esri/layers/GraphicsLayer",
285 "esri/geometry/geometryEngineAsync",
286 "esri/geometry/Extent"
287 ]).then(([
288 Graphic,
289 GraphicsLayer,
290 geometryEngineAsync,
291 Extent
292 ])=>{
293 var graphic = new Graphic({
294 geometry:geometry
295 })
296 var layer = view.map.findLayerById("overLayer");
297 if(layer){
298 layer.removeAll();
299 }else {
300 layer = new GraphicsLayer({
301 id:"overLayer"
302 })
303 view.map.add(layer);
304 }
305 var impotSymbol = graphicSymbol.fillSymbol.importSymbol,
306 defaultSymbol = graphicSymbol.fillSymbol.defaultSymbol;
307 for(var i = 0;i < results.length;i++){
308 var feature = results[i].feature;
309 feature.symbol = defaultSymbol;
310 layer.add(feature);
311 var geo = geometryEngineAsync.intersect(feature.geometry,geometry);
312 geo.then(function (res) {
313 var interGra = new Graphic({
314 geometry:res,
315 symbol:graphicSymbol.fillSymbol.highlightSymbol
316 })
317 layer.add(interGra);
318 })
319 }
320 graphic.symbol = impotSymbol
321 layer.add(graphic);
322 var extent = new Extent(JSON.parse(JSON.stringify(graphic.geometry.extent)))
323 extent.spatialReference = view.spatialReference;
324 view.extent = extent;
325 }).catch(err => {
326 console.log(err);
327
328 })
329 },
330 clearOverLayer(){
331 var view = maps["testMap"];
332 var layer = view.map.findLayerById("overLayer");
333 if(layer){
334 layer.removeAll();
335 }
336 },
337 //自然幢叠加分析 不能跨宗地 图层本身的叠加分析
338 zrzOverAnalys(bsm,graphic,callBacFunction){
339 var self = this;
340 loadModules([
341 "esri/geometry/Polygon",
342 "esri/geometry/geometryEngine"
343 ]).then(([
344 Polygon,
345 geometryEngine
346 ]) => {
347 var polygon = new Polygon(graphic.geometry);
348 var zdLayer = null,
349 zrzLayer = null;
350 zdLayer = self.getLayerByName("ZDJBXX");
351 zdLayer = self.getLayerByName("ZRZ");
352 var layerIds = [];
353 layerIds.push(zdLayer.id);
354 layerIds.push(zrzLayer.id);
355 identifyUtils.methods.identify(zdLayer.layerUrl,layerIds,polygon,function (res) {
356 var results = res.results;
357 //判断数据是否与其他数据有重叠
358 var flag = false,
359 mesge = "";
360 if(results && results.length > 0){
361 for(var i = 1;i < results.length;i++){
362 var feature = results[i].feature,
363 layerName = results[i].layerName;
364 if(layerName == 'ZRZ'){
365 if(feature.attributes['标识码'] != bsm){
366 var interFlag = geometryEngine.intersects(polygon,feature.geometry);
367 if(interFlag){
368 flag = true;
369 mesge="导入的自然幢与其他自然幢重叠,不能导入!!!";
370 break;
371 }
372 }
373 }else {
374 var interFlag = geometryEngine.intersects(polygon,feature.geometry);
375 var withinFlag = geometryEngine.within(polygon,feature.geometry);
376 if(!withinFlag && interFlag){
377 flag = true;
378 mesge="导入的自然幢与其跨宗地,不能导入!!!";
379 break;
380 }
381 }
382 }
383 }
384 callBacFunction(flag,mesge);
385 },true)
386 }).catch( err => {
387 console.log(err);
388 })
389 },
390 //去除重叠部分
391 getDifference(inputGraphic,subGraphic,callBackFuncton){
392 loadModules([
393 "esri/geometry/Polygon",
394 "esri/geometry/geometryEngine",
395 "esri/Graphic"
396 ]).then(([
397 Polygon,
398 geometryEngine,
399 Graphic
400 ])=>{
401 var inputGeometry = new Polygon(inputGraphic.geometry);
402 var outGeometry = null;
403 for(var i = 0;i < subGraphic.length;i++){
404 var feature = subGraphic[i].feature;
405 outGeometry = geometryEngine.difference(inputGeometry,feature.geometry);
406 }
407 if(callBackFuncton && typeof callBackFuncton == 'function'){
408 callBackFuncton(outGeometry);
247 } 409 }
410 }).catch(err => {
411 console.log(err);
412 })
413 },
414 //业务处理 先用query方法 查询将所有属性查询 在做空间裁剪
415 getResultsDif(subGraphics,currntGraphic,callBackFunction,flag){
416 var self = this;
417 loadModules([
418 "esri/geometry/geometryEngine",
419 "esri/geometry/Polygon"
420 ]).then(([
421 geometryEngine,
422 Polygon
423 ]) => {
424 var objectIds = [];
425 subGraphics.filter(item => {
426 objectIds.push(item.feature.attributes.OBJECTID);
427 })
428 var inputGeometry = new Polygon(currntGraphic.geometry);
429 var zdLayer = self.getLayerByName("ZDJBXX");
430 queryUtils.methods.queryByWhere(zdLayer.layerUrl+"/"+zdLayer.id,{OBJECTID:objectIds},null,true,"",subGraphics[0].feature.geometry.spatialReference,function (result) {
431 var features = result.features;
432 if(flag){
433 for(var i = 0;i < features.length;i++){
434 features[i].geometry = geometryEngine.difference(features[i].geometry,inputGeometry);
435 features[i].attributes.BGZT = 3;
436 }
437 }else {
438 for(var i = 0;i < features.length;i++){
439 features[i].geometry = null;
440 features[i].attributes.BGZT = 4;
441 }
442 }
443 if(callBackFunction && typeof callBackFunction == 'function'){
444 callBackFunction(features);
445 }
446 })
447
448 }).catch(err=>{
449 console.log(err);
450 })
248 451
452 },
453 addGeoByBsm(bsm, type,viewId) {
454 var self = this;
455 var layer = null;
456 if (type == 'zd') {
457 layer = this.getLayerByName("ZDJBXX");
458 } else if (type == 'zrz') {
459 layer = this.getLayerByName("ZRZ");
460 } else {
461 console.log("未定义类型!!");
462 return;
463 }
464 if (!layer) {
465 console.log("没有找到图层,不能查询");
466 return;
467 }
468 queryUtils.methods.queryByWhere(layer.layerUrl+"/"+layer.id, {"BSM": bsm }, null, true, null, null, function (res) {
469 var features = res.features;
470 if(features && features.length > 0){
471 if( !features[0].geometry ){
472 self.$message.success("暂无图形信息!!");
473 return;
474 }
475 loadModules([
476 "esri/layers/GraphicsLayer"
477 ]).then( ([
478 GraphicsLayer
479 ]) => {
480 var view = maps[viewId];
481 var layer = view.map.findLayerById("highlightLayer");
482 if(layer){
483 layer.removeAll();
484 }else {
485 layer = new GraphicsLayer({
486 id:"highlightLayer"
487 })
488 view.map.add(layer,5);
489 }
490 var symbol = graphicSymbol.fillSymbol.highlightSymbol;
491 var graphic = features[0];
492 graphic.symbol = symbol;
493 layer.add(graphic);
494 view.extent = graphic.geometry.extent;
495 }).catch( err => {
496 thow(err);
497 })
498 }else {
499 self.$message.success("暂无图形信息!!");
500 return;
501 }
502 });
503 }
249 } 504 }
250 } 505 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -37,15 +37,13 @@ ...@@ -37,15 +37,13 @@
37 MapView, 37 MapView,
38 esriMap 38 esriMap
39 ]) => { 39 ]) => {
40 var map = new esriMap({ 40 //
41 basemap:"hybrid" 41 var map = new esriMap();
42 });
43 //108.95 34.27 42 //108.95 34.27
44 var view = new MapView({ 43 var view = new MapView({
45 container: self.viewId, 44 container: self.viewId,
46 map: map, 45 map: map,
47 zoom:10, 46 zoom:10,
48 zoom:10,
49 center: [-0.154133333770497,0.6138183594020817], 47 center: [-0.154133333770497,0.6138183594020817],
50 spatialReference: { 48 spatialReference: {
51 wkid: 102100 49 wkid: 102100
......
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
24 identifyParameters.tolerance = tolerance ? tolerance : 3; 24 identifyParameters.tolerance = tolerance ? tolerance : 3;
25 identifyParameters.mapExtent = mapExtent ? mapExtent : geometry.extent; 25 identifyParameters.mapExtent = mapExtent ? mapExtent : geometry.extent;
26 identifyParameters.returnGeometry = returnGeometry ? returnGeometry : false; 26 identifyParameters.returnGeometry = returnGeometry ? returnGeometry : false;
27 //identifyParameters.returnFieldName = false; 27 //identifyParameters.returnFieldName = true;
28 identifyParameters.spatialReference = geometry.spatialReference; 28 identifyParameters.spatialReference = geometry.spatialReference;
29 identifyTask.execute(identifyParameters).then(result => { 29 identifyTask.execute(identifyParameters).then(result => {
30 if(callBackFunction && typeof callBackFunction == 'function'){ 30 if(callBackFunction && typeof callBackFunction == 'function'){
......
...@@ -22,20 +22,29 @@ export default { ...@@ -22,20 +22,29 @@ export default {
22 var featureLayer = new FeatureLayer({ 22 var featureLayer = new FeatureLayer({
23 url:url 23 url:url
24 }) 24 })
25 var saveGraphics = [];
26 if(!Array.isArray(graphic)){
27 graphic = [graphic];
28 }
29 for(var i = 0;i < graphic.length;i++){
25 var geo = null; 30 var geo = null;
26 if(graphic.geometry.type == 'point'){ 31 if(!graphic[i].geometry){
27 geo = new Point(graphic.geometry); 32 geo = null;
28 }else if(graphic.geometry.type == 'polyline'){ 33 }else if(graphic[i].geometry.type == 'point'){
29 geo = new Polyline(graphic.geometry); 34 geo = new Point(graphic[i].geometry);
30 }else if(graphic.geometry.type == 'polygon'){ 35 }else if(graphic[i].geometry.type == 'polyline'){
31 geo = new Polygon(graphic.geometry); 36 geo = new Polyline(graphic[i].geometry);
37 }else if(graphic[i].geometry.type == 'polygon'){
38 geo = new Polygon(graphic[i].geometry);
32 } 39 }
33 var saveGraphic = new Graphic({ 40 var saveGraphic = new Graphic({
34 attributes:graphic.attributes, 41 attributes:graphic[i].attributes,
35 geometry:geo 42 geometry:geo
36 }); 43 });
44 saveGraphics.push(saveGraphic);
45 }
37 featureLayer.applyEdits({ 46 featureLayer.applyEdits({
38 addFeatures:[saveGraphic] 47 addFeatures:saveGraphics
39 }).then(function (res){ 48 }).then(function (res){
40 if(callBackFunction && typeof callBackFunction == 'function'){ 49 if(callBackFunction && typeof callBackFunction == 'function'){
41 callBackFunction(res); 50 callBackFunction(res);
...@@ -62,20 +71,30 @@ export default { ...@@ -62,20 +71,30 @@ export default {
62 var featureLayer = new FeatureLayer({ 71 var featureLayer = new FeatureLayer({
63 url:url 72 url:url
64 }) 73 })
74 var updGraphics = [];
75 if(!Array.isArray(graphic)){
76 graphic = [graphic];
77 }
78 for(var i = 0;i < graphic.length;i++){
65 var geo = null; 79 var geo = null;
66 if(graphic.geometry.type == 'point'){ 80 if(!graphic[i].geometry){
67 geo = new Point(graphic.geometry); 81 geo = new Polygon();
68 }else if(graphic.geometry.type == 'polyline'){ 82 }else if(graphic[i].geometry.type == 'point'){
69 geo = new Polyline(graphic.geometry); 83 geo = new Point(graphic[i].geometry);
70 }else if(graphic.geometry.type == 'polygon'){ 84 }else if(graphic[i].geometry.type == 'polyline'){
71 geo = new Polygon(graphic.geometry); 85 geo = new Polyline(graphic[i].geometry);
86 }else if(graphic[i].geometry.type == 'polygon'){
87 geo = new Polygon(graphic[i].geometry);
72 } 88 }
73 var updGraphic = new Graphic({ 89 var updGraphic = new Graphic({
74 attributes:graphic.attributes, 90 attributes:graphic[i].attributes,
75 geometry:geo 91 geometry:geo
76 }); 92 });
93 updGraphics.push(updGraphic);
94 }
95
77 featureLayer.applyEdits({ 96 featureLayer.applyEdits({
78 updateFeatures:[updGraphic] 97 updateFeatures:updGraphics
79 }).then(function (res){ 98 }).then(function (res){
80 if(callBackFunction && typeof callBackFunction == 'function'){ 99 if(callBackFunction && typeof callBackFunction == 'function'){
81 callBackFunction(res); 100 callBackFunction(res);
...@@ -102,21 +121,31 @@ export default { ...@@ -102,21 +121,31 @@ export default {
102 var featureLayer = new FeatureLayer({ 121 var featureLayer = new FeatureLayer({
103 url:url 122 url:url
104 }) 123 })
124 var delGraphics = [];
125 if(!Array.isArray(graphic)){
126 graphic = [graphic];
127 }
128 for(var i = 0;i < graphic.length;i++){
105 var geo = null; 129 var geo = null;
106 if(graphic.geometry.type == 'point'){ 130 if(!graphic[i].geometry){
107 geo = new Point(graphic.geometry); 131 geo = null;
108 }else if(graphic.geometry.type == 'polyline'){ 132 }else if(graphic[i].geometry.type == 'point'){
109 geo = new Polyline(graphic.geometry); 133 geo = new Point(graphic[i].geometry);
110 }else if(graphic.geometry.type == 'polygon'){ 134 }else if(graphic[i].geometry.type == 'polyline'){
111 geo = new Polygon(graphic.geometry); 135 geo = new Polyline(graphic[i].geometry);
136 }else if(graphic[i].geometry.type == 'polygon'){
137 geo = new Polygon(graphic[i].geometry);
112 } 138 }
113 var delGraphic = new Graphic({ 139 var delGraphic = new Graphic({
114 attributes:graphic.attributes, 140 attributes:graphic[i].attributes,
115 geometry:geo 141 geometry:geo
116 }); 142 });
143 delGraphics.push(delGraphic);
144 }
145
117 146
118 featureLayer.applyEdits({ 147 featureLayer.applyEdits({
119 deleteFeatures:[delGraphic] 148 deleteFeatures:delGraphics
120 }).then(function (res){ 149 }).then(function (res){
121 if(callBackFunction && typeof callBackFunction == 'function'){ 150 if(callBackFunction && typeof callBackFunction == 'function'){
122 callBackFunction(res); 151 callBackFunction(res);
......
...@@ -28,7 +28,7 @@ export default{ ...@@ -28,7 +28,7 @@ export default{
28 where += " and "; 28 where += " and ";
29 } 29 }
30 if(Array.isArray(parames[i].value)){ 30 if(Array.isArray(parames[i].value)){
31 where += parames[i].name + " in (" + parames[i].value.toString + ")"; 31 where += parames[i].name + " in (" + parames[i].value.toString() + ")";
32 }else if(typeof parames[i].value == 'number'){ 32 }else if(typeof parames[i].value == 'number'){
33 where += parames[i].name + " =" + parames[i].value ; 33 where += parames[i].name + " =" + parames[i].value ;
34 }else{ 34 }else{
......
...@@ -76,15 +76,20 @@ export default { ...@@ -76,15 +76,20 @@ export default {
76 }, 76 },
77 mixins:[mapLayerManager,findTask], 77 mixins:[mapLayerManager,findTask],
78 mounted(){ 78 mounted(){
79 var query = this.$route.query; 79
80 var query = this.$route.query
81 var self = this;
82 setTimeout(function () {
80 if(query && JSON.stringify(query) != "{}"){ 83 if(query && JSON.stringify(query) != "{}"){
81 //self.addGeoByBsm(query.bsm,query.type,self.viewId); 84 //self.addGeoByBsm(query.bsm,query.type,self.viewId);
82 if(query.type == 'zd'){ 85 if(query.type == 'zd'){
83 this.getRightTree(query.bsm) 86 self.getRightTree(query.bsm)
84 }else if(query.type == 'zrz'){ 87 }else if(query.type == 'zrz'){
85 this.getRightTreeByZrzbsm(query.bsm); 88 self.getRightTreeByZrzbsm(query.bsm);
86 } 89 }
87 } 90 }
91 },500);
92
88 93
89 }, 94 },
90 methods:{ 95 methods:{
...@@ -94,8 +99,10 @@ export default { ...@@ -94,8 +99,10 @@ export default {
94 view.ui.remove('zoom'); 99 view.ui.remove('zoom');
95 loadModules([ 100 loadModules([
96 "esri/layers/MapImageLayer", 101 "esri/layers/MapImageLayer",
102 "esri/geometry/Extent"
97 ]).then(([ 103 ]).then(([
98 MapImageLayer, 104 MapImageLayer,
105 Extent
99 ])=>{ 106 ])=>{
100 var mapImageLayer = new MapImageLayer({ 107 var mapImageLayer = new MapImageLayer({
101 url:self.layerUrl, 108 url:self.layerUrl,
...@@ -115,6 +122,13 @@ export default { ...@@ -115,6 +122,13 @@ export default {
115 }] 122 }]
116 }); 123 });
117 view.map.add(mapImageLayer,1); 124 view.map.add(mapImageLayer,1);
125 mapImageLayer.when(function () {
126 var extent = new Extent(JSON.parse(JSON.stringify(mapImageLayer.fullExtent)))
127 extent.spatialReference = view.spatialReference;
128 view.center = extent.center;
129 view.zoom = 15;
130 // view.extent = mapImageLayer.fullExtent;
131 });
118 var query = self.$route.query; 132 var query = self.$route.query;
119 if(query && JSON.stringify(query) != "{}"){ 133 if(query && JSON.stringify(query) != "{}"){
120 self.addGeoByBsm(query.bsm,query.type,self.viewId); 134 self.addGeoByBsm(query.bsm,query.type,self.viewId);
...@@ -137,9 +151,11 @@ export default { ...@@ -137,9 +151,11 @@ export default {
137 }, 151 },
138 //图层选择事件 152 //图层选择事件
139 selectLayerChange(){ 153 selectLayerChange(){
154 debugger
140 var self = this; 155 var self = this;
156 this.features = [];
141 var layerAndResult = this.results.filter(function (item) { 157 var layerAndResult = this.results.filter(function (item) {
142 return item.layerId = self.selectResLayerId; 158 return item.layerId == self.selectResLayerId;
143 }) 159 })
144 if(layerAndResult){ 160 if(layerAndResult){
145 this.features = layerAndResult[0].features; 161 this.features = layerAndResult[0].features;
......
...@@ -79,12 +79,12 @@ export default { ...@@ -79,12 +79,12 @@ export default {
79 return; 79 return;
80 } 80 }
81 for(var i = 0;i < searchResult.length;i++){ 81 for(var i = 0;i < searchResult.length;i++){
82 var layer = view.map.findLayerById("searchResult"+searchResult.layerName); 82 var layer = view.map.findLayerById("searchResult"+searchResult[i].layerId);
83 if(layer){ 83 if(layer){
84 layer.removeAll(); 84 layer.removeAll();
85 }else{ 85 }else{
86 layer = new GraphicsLayer({ 86 layer = new GraphicsLayer({
87 id:"searchResult"+searchResult.layerName 87 id:"searchResult"+searchResult[i].layerId
88 }) 88 })
89 view.map.add(layer); 89 view.map.add(layer);
90 } 90 }
......