Pārlūkot izejas kodu

智能选址,详情分析定位

liutao 2 mēneši atpakaļ
vecāks
revīzija
c22e1798b3

+ 22 - 0
web_ui/src/views/industrial-land/AiIndustriaLandDetail.vue

@@ -317,6 +317,7 @@
           @cluster="addClusterLayer"
           @gowkt="goWkt"
           @locationByGeojson="locationByGeojson"
+          @analysisLayer="addAnalysisGeoLayer"
           @clear="clearMark"
           :item="detailData"
         ></znxz-detail>
@@ -408,6 +409,7 @@ export default {
         }
       ],
       geoLayer: null,
+      analysisGeoLayer:null,
       nearMarkerList: [],
       radarScanStyle: {
         width: "100%",
@@ -616,6 +618,22 @@ export default {
       });
       this.geoLayer.addTo(this.map);
     },
+    addAnalysisGeoLayer(geojsonList) {
+      if (this.analysisGeoLayer) {
+        this.map.removeLayer(this.analysisGeoLayer);
+        this.analysisGeoLayer = null;
+      }
+      this.analysisGeoLayer = L.geoJSON(geojsonList, {
+        style: function (feature) {
+          return { color: "yellow",fillOpacity:0.6 ,weight:2};
+        },
+      });
+      if(!geojsonList || !geojsonList.length){
+        return;
+      }
+      this.analysisGeoLayer.addTo(this.map);
+      // this.map.fitBounds(this.analysisGeoLayer.getBounds())
+    },
     toggleLayerControl() {
       this.showLayerControl = !this.showLayerControl;
       if (!this.showLegend) {
@@ -715,6 +733,10 @@ export default {
         this.map.removeLayer(this.geojsonLayer);
         this.geojsonLayer = null;
       }
+      if (this.analysisGeoLayer) {
+        this.map.removeLayer(this.analysisGeoLayer);
+        this.analysisGeoLayer = null;
+      }
       this.toggleInfoTab();
       this.toggleTab(0);
     },

+ 286 - 5
web_ui/src/views/industrial-land/ZnxzDetail.vue

@@ -196,7 +196,8 @@
                     class="t-item"
                     v-for="(item, index) in xzfxList"
                     :key="index"
-                    :class="{ border: index == xzfxList.length - 1 }"
+                    @click="xzfxClick(item, index)"
+                    :class="{ activate: index == xzfxIndex }"
                   >
                     <div class="td c6">{{ item.name }}</div>
                     <div class="td c1 t2">{{ item.value }}</div>
@@ -215,7 +216,8 @@
                     class="t-item"
                     v-for="(item, index) in ghfxList"
                     :key="index"
-                    :class="{ border: index == ghfxList.length - 1 }"
+                    @click="ghfxClick(item,index)"
+                    :class="{ activate: index == ghfxIndex }"
                   >
                     <div class="td c6">{{ item.name }}</div>
                     <div class="td c1 t2">{{ item.value }}</div>
@@ -234,7 +236,8 @@
                     class="t-item"
                     v-for="(item, index) in sqsxList"
                     :key="index"
-                    :class="{ border: index == sqsxList.length - 1 }"
+                    @click="sqsxClick(item, index)"
+                    :class="{ activate: index == sqsxIndex }"
                   >
                     <div class="td c6">{{ item.name }}</div>
                     <div class="td c1 t2">{{ item.value }}</div>
@@ -405,7 +408,10 @@
 import landMethods from "@/api/land";
 import { getMilliSeconds } from "@/util/date";
 import axios from "axios";
-import { distance } from "@turf/turf";
+import * as turf from "@turf/turf";
+import proj4 from "proj4";
+import wkt from "wellknown";
+import { arcgisToGeoJSON, geojsonToArcGIS } from "@terraformer/arcgis";
 export default {
   components: {},
   props: {
@@ -413,6 +419,21 @@ export default {
   },
   data() {
     return {
+      sqsxAnalysisReuslt: { yjjbnt: null, czkfbj: null, stbhhx: null },
+      ghfxAnalysisReuslt: {},
+      xzfxAnalysisReuslt: {
+        湿地: null,
+        耕地: null,
+        园地: null,
+        草地: null,
+        林地: null,
+        设施农用地: null,
+        城镇村及工矿用地: null,
+        水域及水利设施用地: null,
+      },
+      xzfxIndex: -1,
+      sqsxIndex: -1,
+      ghfxIndex: -1,
       xzfxResult: {
         code: 0,
         data: {
@@ -1107,6 +1128,12 @@ export default {
     },
   },
   mounted() {
+    proj4.defs("EPSG:4490", "+proj=longlat +ellps=GRS80 +no_defs +type=crs");
+    proj4.defs(
+      "EPSG:4528",
+      "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs"
+    );
+
     this.init();
   },
   watch: {
@@ -1194,6 +1221,9 @@ export default {
       this.jbxxIndex = 0;
       this.ggssIndex = 0;
       this.qytsIndex = 0;
+      this.ghfxIndex=-1;
+      this.xzfxIndex=-1;
+      this.sqsxIndex=-1;
       this.$emit("toggle");
       if (index == 2) {
         this.toggltGgssIndex(0, { name: "医院" });
@@ -1478,7 +1508,6 @@ export default {
       });
     },
 
-
     getDataFromTianditu(name, targetList) {
       let query = { title: name };
       let text = [query.title];
@@ -1645,6 +1674,210 @@ export default {
           }
         });
     },
+    async ghfxAnalysis(wktStr) {
+      const url =
+        "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/877a7710f9d7477f88120d5b30ab488a/arcgis/rest/services/GCS330000K2007_KZXXXGH_GHDK/GCS330000_2007_KZXXXGH_GHDK_GKY_2022/MapServer/0/query";
+      // const url =
+      //   "arcserver-host/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query";
+      const res = await this.ghfx_analysis_intersect(url, wktStr);
+      this.ghfxAnalysisReuslt = res;
+      console.log("ghfxAnalysis:");
+      console.log(this.ghfxAnalysisReuslt);
+    },
+    async sqsxAnalysis(wktStr) {
+      const urlMap = {
+        yjjbnt:
+          "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy226/a119e0e024944866a260798599aa19f4/arcgis/rest/services/GCS330000_2001_YJJBNT_GX/GCS330000_2001_YJJBNT_GX_XSB/MapServer/0/query",
+        czkfbj:
+          "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy226/789b497aff224fb3b612187decca0586/arcgis/rest/services/GCS330000_2001_CZKFBJ/GCS330000_2001_CZKFBJ_YHCG/MapServer/0/query",
+        stbhhx:
+          "https://ai.zrzyt.zj.gov.cn:10086/mapserver/zjgt38/9a971693e3e1461b99a66c3a81dc6823/arcgis/rest/services/GCS330000_2001_SQSX_2022/GCS330000_2001_STBHHX_2022/MapServer/0/query",
+      };
+      // const urlMap = {
+      //   yjjbnt:
+      //     "arcserver-host/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query",
+      //   czkfbj:
+      //     "arcserver-host/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query",
+      //   stbhhx:
+      //     "arcserver-host/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query",
+      // };
+      for (let ele in urlMap) {
+        const res = await this.analysis_intersect(urlMap[ele], wktStr);
+        this.sqsxAnalysisReuslt[ele] = res;
+      }
+      console.log("sqsxAnalysis:");
+      console.log(this.sqsxAnalysisReuslt);
+    },
+    async xzfxAnalysis(wktStr) {
+      const urlMap = {
+        湿地: "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/3a92d7f92e8f45ea92e1e83be0e52291/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_SD_2024/MapServer/0/query",
+        耕地: "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/ff1cca31b3a244b78f6e3cf64e7bd71d/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_GD_2024/MapServer/0/query",
+        园地: "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/30731be1e964442b85adad8e7edc74cf/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_ZZYYD_2024/MapServer/0/query",
+        草地: "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/c52a1605393540f0b3a13a75e054a8d6/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_CD_2024/MapServer/0/query",
+        林地: "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/c01be7d0f2ef48b289d91d0b694cc303/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_LD_2024/MapServer/0/query",
+        设施农用地:
+          "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/09d60c0e015c42d1a267b3481a69c7cf/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_SSNYD_2024/MapServer/0/query",
+        城镇村及工矿用地:
+          "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/9d894ce773064ac1a342747cb050156f/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_CZCJGKYD_2024/MapServer/0/query",
+        水域及水利设施用地:
+          "https://ai.zrzyt.zj.gov.cn:10086/mapserver/GDPProxy231/e72be3d0da9042ac8f6fe1ac97d70377/arcgis/rest/services/GCS330000_1002_GTBGDC_ZWB_2024/GCS330000_1002_GTBGDC_SYJSLSSYD_2024/MapServer/0/query",
+      };
+      for (let ele in urlMap) {
+        const res = await this.analysis_intersect(urlMap[ele], wktStr);
+        this.xzfxAnalysisReuslt[ele] = res;
+      }
+      console.log("xzfxAnalysis:");
+      console.log(this.xzfxAnalysisReuslt);
+    },
+    async analysis_intersect(url, wktStr) {
+      // 将wkt转换为esrijson
+      //发送post请求
+      // const url =
+      //   "arcserver-host/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query";
+      const geometry = wkt.parse(wktStr);
+      const esrijson = geojsonToArcGIS(geometry);
+      esrijson["spatialReference"] = undefined;
+      console.log(esrijson);
+      const esrijson_str = JSON.stringify(esrijson);
+      console.log(esrijson_str);
+      //计算重叠面积和重叠图形
+      const formdata = new FormData();
+      formdata.append("where", "1=1");
+      formdata.append("geometryType", "esriGeometryPolygon");
+      formdata.append("geometry", esrijson_str);
+      formdata.append("inSR", "4490");
+      formdata.append("spatialRel", "esriSpatialRelIntersects");
+      formdata.append("outFields", "*");
+      formdata.append("returnGeometry", "true");
+      formdata.append("outSR", "4490");
+      formdata.append("f", "pjson");
+      return new Promise((resolve) => {
+        axios
+          .post(url, formdata, {
+            headers: {
+              "Content-Type": "multipart/form-data",
+            },
+          })
+          .then((data) => {
+            if (data && data.data && data.data.features) {
+              const d = data.data.features;
+              console.log(d);
+              const res = this.intersectsAnalysis(d, geometry);
+              resolve(res);
+            }
+          });
+      });
+    },
+    intersectsAnalysis(features, geometry) {
+      const result = {
+        total_intersect_area: 0,
+        geojson_list: [],
+      };
+
+      // Define coordinate systems (you might need to add proper definitions)
+      // proj4.defs('EPSG:4490', '+proj=longlat +ellps=GRS80 +no_defs');
+      // proj4.defs('EPSG:4528', '+proj=longlat +ellps=GRS80 +no_defs'); // Replace with actual EPSG:4528 definition
+
+      // Parse WKT geometry
+
+      for (const feature of features) {
+        // Convert ESRI JSON to GeoJSON (you might need a specific library for this)
+        // This is a simplified approach - you may need proper conversion
+        const geom = arcgisToGeoJSON(feature.geometry);
+
+        // Get intersection
+        const intersection = turf.intersect(geometry, geom);
+        if (!intersection) {
+          continue;
+        }
+
+        // Transform coordinates
+        // const transformedCoords = turf
+        //   .coordAll(intersection)
+        //   .map((coord) => proj4("EPSG:4490", "EPSG:4528", coord));
+
+        // Create new polygon with transformed coordinates
+        // const transformGeom = turf.polygon([transformedCoords]);
+
+        // const area = turf.area(transformGeom);
+
+        // if (area < 10) {
+        //   continue;
+        // }
+
+        // result.total_intersect_area += area;
+        result.geojson_list.push(intersection);
+      }
+
+      return result;
+    },
+    async ghfx_analysis_intersect(url, wktStr) {
+      // 将wkt转换为esrijson
+      //发送post请求
+      // const url =
+      //   "arcserver-host/arcgis/rest/services/sd_dxyd/dxyd_xz/MapServer/0/query";
+      const geometry = wkt.parse(wktStr);
+      const esrijson = geojsonToArcGIS(geometry);
+      esrijson["spatialReference"] = undefined;
+      console.log(esrijson);
+      const esrijson_str = JSON.stringify(esrijson);
+      console.log(esrijson_str);
+      //计算重叠面积和重叠图形
+      const formdata = new FormData();
+      formdata.append("where", "1=1");
+      formdata.append("geometryType", "esriGeometryPolygon");
+      formdata.append("geometry", esrijson_str);
+      formdata.append("inSR", "4490");
+      formdata.append("spatialRel", "esriSpatialRelIntersects");
+      formdata.append("outFields", "*");
+      formdata.append("returnGeometry", "true");
+      formdata.append("outSR", "4490");
+      formdata.append("f", "pjson");
+      return new Promise((resolve) => {
+        axios
+          .post(url, formdata, {
+            headers: {
+              "Content-Type": "multipart/form-data",
+            },
+          })
+          .then((data) => {
+            if (data && data.data && data.data.features) {
+              const d = data.data.features;
+              console.log(d);
+              const res = this.ghfxIntersectsAnalysis(d, geometry);
+              resolve(res);
+            }
+          });
+      });
+    },
+    ghfxIntersectsAnalysis(features, geometry) {
+      const ydxz_dict_res = {};
+      for (const feature of features) {
+        // Convert ESRI JSON to GeoJSON (you might need a specific library for this)
+        // This is a simplified approach - you may need proper conversion
+        const geom = arcgisToGeoJSON(feature.geometry);
+        const ydxz = feature["attributes"]["ydxz"];
+        if (!ydxz) {
+          continue;
+        }
+        ydxz = ydxz.replace(/[\n\r]+/g, '');
+        // Get intersection
+        const intersection = turf.intersect(geometry, geom);
+        if (!intersection) {
+          continue;
+        }
+        if (!ydxz_dict_res.hasOwnProperty(ydxz)) {
+          ydxz_dict_res[ydxz] = {
+            total_intersect_area: 0,
+            geojson_list: [],
+          };
+        }
+        ydxz_dict_res[ydxz].geojson_list.push(intersection);
+      }
+
+      return ydxz_dict_res;
+    },
+
     initQyyq(wktStr) {
       let kfqintersectUrl = window.ApplicationConfig.kfqintersectUrl;
       axios.get(kfqintersectUrl, { params: { wkt: wktStr } }).then((data) => {
@@ -1661,12 +1894,57 @@ export default {
         }
       });
     },
+    sqsxClick(item, index) {
+      console.log(item);
+      let geometryList = null;
+      if (item.name == "城镇开发边界") {
+        geometryList = this.sqsxAnalysisReuslt["czkfbj"];
+      } else if (item.name == "生态保护红线") {
+        geometryList = this.sqsxAnalysisReuslt["stbhhx"];
+      } else if (item.name == "永久基本农田") {
+        geometryList = this.sqsxAnalysisReuslt["yjjbnt"];
+      }
+      this.sqsxIndex = index;
+      console.log(geometryList);
+      if (!geometryList) return;
+      const geojson = geometryList["geojson_list"];
+      this.$emit("analysisLayer", geojson);
+    },
+    xzfxClick(item, index) {
+      console.log(item);
+      let geometryList = this.xzfxAnalysisReuslt[item.name];
+      console.log(geometryList);
+      this.xzfxIndex = index;
+      if (!geometryList) return;
+      const geojson = geometryList["geojson_list"];
+      this.$emit("analysisLayer", geojson);
+    },
+    ghfxClick(item, index) {
+      item.name = item.name.replace(/[\n\r]+/g, '');
+      console.log(item);
+      let geometryList = this.ghfxAnalysisReuslt[item.name];
+      console.log(geometryList);
+      this.ghfxIndex = index;
+      if (!geometryList) return;
+      const geojson = geometryList["geojson_list"];
+      this.$emit("analysisLayer", geojson);
+    },
     analysis() {
       this.initXzfx(this.item.geom);
       this.initGhfx(this.item.geom);
       this.initSqsx(this.item.geom);
       this.initQyyq(this.item.geom);
       this.initZbcy(this.item.geom);
+
+      this.sqsxAnalysis(this.item.geom);
+      // this.sqsxAnalysis(
+      //   "POLYGON ((117.11419709081183 36.182983468640515, 117.11420047198547 36.18294635016128, 117.11421755948791 36.182947168376224, 117.11429144933 36.182950712593104, 117.11428765128782 36.18298780623907, 117.11421406714791 36.182984281554766, 117.11419709081183 36.182983468640515))"
+      // );
+      this.ghfxAnalysis(
+        this.item.geom
+      );
+      this.xzfxAnalysis(this.item.geom);
+
       let pointWkt = this.item.center_wkt;
       var c = this.item.center_wkt;
       this.center = c.substring(6, c.length - 1).replace(" ", ",");
@@ -2229,6 +2507,9 @@ export default {
           border: 1px solid #d9dde1;
           .table-con {
             width: 100%;
+            .activate {
+              background: #1684fc;
+            }
             .t-item {
               width: 100%;
               display: flex;