فهرست منبع

上海2000坐标转换

Bella 2 سال پیش
والد
کامیت
9c59b7f975
5فایلهای تغییر یافته به همراه544 افزوده شده و 76 حذف شده
  1. 39 0
      package-lock.json
  2. 1 0
      package.json
  3. 12 17
      src/components/map/MapHolder.vue
  4. 440 0
      src/utils/coordinate.js
  5. 52 59
      src/views/ComprehensiveAnalysis.vue

+ 39 - 0
package-lock.json

@@ -19,6 +19,7 @@
         "html2canvas": "^1.4.1",
         "jquery": "^3.6.1",
         "jszip": "^3.10.1",
+        "proj4": "^2.8.0",
         "svg-sprite-loader": "^6.0.11",
         "vue": "^2.6.14",
         "vue-pdf": "^4.3.0",
@@ -7032,6 +7033,11 @@
         "node": ">= 0.6"
       }
     },
+    "node_modules/mgrs": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/mgrs/-/mgrs-1.0.0.tgz",
+      "integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA=="
+    },
     "node_modules/micromatch": {
       "version": "4.0.5",
       "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.5.tgz",
@@ -8770,6 +8776,15 @@
         "webpack": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0"
       }
     },
+    "node_modules/proj4": {
+      "version": "2.8.0",
+      "resolved": "https://registry.npmmirror.com/proj4/-/proj4-2.8.0.tgz",
+      "integrity": "sha512-baC+YcD4xsSqJ+CpCZljj2gcQDhlKb+J+Zjv/2KSBwWNjk4M0pafgQsE+mWurd84tflMIsP+7j7mtIpFDHzQfQ==",
+      "dependencies": {
+        "mgrs": "1.0.0",
+        "wkt-parser": "^1.3.1"
+      }
+    },
     "node_modules/proxy-addr": {
       "version": "2.0.7",
       "resolved": "https://registry.npmmirror.com/proxy-addr/-/proxy-addr-2.0.7.tgz",
@@ -11491,6 +11506,11 @@
       "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==",
       "dev": true
     },
+    "node_modules/wkt-parser": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmmirror.com/wkt-parser/-/wkt-parser-1.3.2.tgz",
+      "integrity": "sha512-A26BOOo7sHAagyxG7iuRhnKMO7Q3mEOiOT4oGUmohtN/Li5wameeU4S6f8vWw6NADTVKljBs8bzA8JPQgSEMVQ=="
+    },
     "node_modules/worker-loader": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/worker-loader/-/worker-loader-2.0.0.tgz",
@@ -17169,6 +17189,11 @@
       "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
       "dev": true
     },
+    "mgrs": {
+      "version": "1.0.0",
+      "resolved": "https://registry.npmmirror.com/mgrs/-/mgrs-1.0.0.tgz",
+      "integrity": "sha512-awNbTOqCxK1DBGjalK3xqWIstBZgN6fxsMSiXLs9/spqWkF2pAhb2rrYCFSsr1/tT7PhcDGjZndG8SWYn0byYA=="
+    },
     "micromatch": {
       "version": "4.0.5",
       "resolved": "https://registry.npmmirror.com/micromatch/-/micromatch-4.0.5.tgz",
@@ -18479,6 +18504,15 @@
         "log-update": "^2.3.0"
       }
     },
+    "proj4": {
+      "version": "2.8.0",
+      "resolved": "https://registry.npmmirror.com/proj4/-/proj4-2.8.0.tgz",
+      "integrity": "sha512-baC+YcD4xsSqJ+CpCZljj2gcQDhlKb+J+Zjv/2KSBwWNjk4M0pafgQsE+mWurd84tflMIsP+7j7mtIpFDHzQfQ==",
+      "requires": {
+        "mgrs": "1.0.0",
+        "wkt-parser": "^1.3.1"
+      }
+    },
     "proxy-addr": {
       "version": "2.0.7",
       "resolved": "https://registry.npmmirror.com/proxy-addr/-/proxy-addr-2.0.7.tgz",
@@ -20679,6 +20713,11 @@
       "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==",
       "dev": true
     },
+    "wkt-parser": {
+      "version": "1.3.2",
+      "resolved": "https://registry.npmmirror.com/wkt-parser/-/wkt-parser-1.3.2.tgz",
+      "integrity": "sha512-A26BOOo7sHAagyxG7iuRhnKMO7Q3mEOiOT4oGUmohtN/Li5wameeU4S6f8vWw6NADTVKljBs8bzA8JPQgSEMVQ=="
+    },
     "worker-loader": {
       "version": "2.0.0",
       "resolved": "https://registry.npmmirror.com/worker-loader/-/worker-loader-2.0.0.tgz",

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "html2canvas": "^1.4.1",
     "jquery": "^3.6.1",
     "jszip": "^3.10.1",
+    "proj4": "^2.8.0",
     "svg-sprite-loader": "^6.0.11",
     "vue": "^2.6.14",
     "vue-pdf": "^4.3.0",

+ 12 - 17
src/components/map/MapHolder.vue

@@ -7,6 +7,7 @@
 </template>
 <script>
 import publicFun from "@/utils/publicFunction.js";
+import transformCoord from "@/utils/coordinate";
 import { get } from "@/utils/request";
 import { streetLocation, townData } from "@/config/common";
 import CaseAuditPopup from "@/components/popup/CaseAuditPopup.vue";
@@ -31,9 +32,7 @@ export default {
       currentLabelHtml: null,
     };
   },
-  created(){
-
-  },
+  created() {},
   mounted() {
     // 监听全局事件总线中的卷帘对比事件(JLControl)
     this.$bus.$off("JLControl");
@@ -547,22 +546,17 @@ export default {
         return "#00ffd5";
       }
     },
-    addSinglePolygon(geometry, cid, color) {
+    addSinglePolygon(geometry, cid, color,uniqueId) {
       // console.log(geometry[2], "打印出第一个");
-      let coordinates = null;
-      // console.log(geometry[0], "判断是否为json格式");
-      if (geometry[2] === "g") {
-        coordinates = JSON.parse(geometry).geometry.coordinates[0];
-      } else {
-        coordinates = JSON.parse(`{${geometry}}`).geometry.coordinates[0];
-      }
-
+      let coordinates = JSON.parse(geometry).geometry.coordinates[0];
+      // 纬经度
+      // [22474.568725585938, -16689.47381591797]
+      // x,y转换
       coordinates = coordinates.map((v) => {
-        return [v[1], v[0]];
+        let data = transformCoord.shcj_to_wgs84(v[1], [v[0]]);
+        data = [data[1], data[0]];
+        return data;
       });
-      // console.log(coordinates, "疑点坐标");
-      // console.log(cid, "cid");
-      // console.log(color, "color");
       let polygon = L.polygon(coordinates, {
         color: color,
         weight: 3,
@@ -570,7 +564,7 @@ export default {
         opacity: 1,
         fillOpacity: 0.4,
       }).addTo(map2DViewer.map);
-      map2DViewer.polygons[`${cid}_polygon`] = polygon;
+      map2DViewer.polygons[uniqueId].push(polygon);
       polygon.on("click", (e) => {
         this.auditPopupShow = true;
         this.popup = L.popup({ maxWidth: 700, maxHeight: 600 })
@@ -616,6 +610,7 @@ export default {
     },
     //综合分析 - 标记疑点 - 删除面
     deletePolygonLayer(layer) {
+      console.log(layer,"layer");
       map2DViewer.polygons[layer].forEach((polygon) => {
         map2DViewer.map.removeLayer(polygon);
       });

+ 440 - 0
src/utils/coordinate.js

@@ -0,0 +1,440 @@
+// const proj4 = require('proj4')
+import proj4 from 'proj4'
+/*****
+ * 地理帮助脚本
+ */
+const coordinate = {
+  x_PI: (Math.PI * 3000.0) / 180.0,
+  PI: Math.PI,
+  ee: 0.00669342162296594323,
+  a: 6378245.0,
+  projs: {
+    '01': 'wgs84', //84坐标
+    '02': 'gcj02', //火星坐标
+    '03': 'bd09', //百度坐标
+    '04': 'utm4', //utm坐标
+    '05': 'shcj', //城建坐标
+    '06': 'meter', //米制单位
+    '07': 'degree' // 度制单位
+  },
+  epsg: {
+    //WGS 84 - WGS84 - World Geodetic System 1984, used in GPS
+    '4326': '+proj=longlat +datum=WGS84 +no_defs',
+    //WGS 84 / Pseudo-Mercator - Spherical Mercator, Google Maps, OpenStreetMap, Bing, ArcGIS, ESRI
+    '3857':
+      '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs',
+    //CGCS2000 / 3-degree Gauss-Kruger zone 40
+    '4528':
+      '+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs'
+  },
+  bd09_to_gcj02: function (bd_lon, bd_lat) {
+    var x = bd_lon - 0.0065
+    var y = bd_lat - 0.006
+    var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * this.x_PI)
+    var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.x_PI)
+    var gg_lng = z * Math.cos(theta)
+    var gg_lat = z * Math.sin(theta)
+    return [gg_lng, gg_lat]
+  },
+
+  gcj02_to_bd09: function (lng, lat) {
+    var z =
+      Math.Sqrt(lng * lng + lat * lat) + 0.00002 * Math.Sin(lat * this.x_PI)
+    var theta = Math.Atan2(lat, lng) + 0.000003 * Math.Cos(lng * this.x_PI)
+    var bd_lng = z * Math.Cos(theta) + 0.0065
+    var bd_lat = z * Math.Sin(theta) + 0.006
+    return [bd_lng, bd_lat]
+  },
+
+  wgs84_to_gcj02: function (lng, lat) {
+    if (this.out_of_china(lng, lat)) {
+      [lng, lat]
+    } else {
+      var dlat = this.transformlat(lng - 105.0, lat - 35.0)
+      var dlng = this.transformlng(lng - 105.0, lat - 35.0)
+      var radlat = (lat / 180.0) * this.PI
+      var magic = Math.sin(radlat)
+      magic = 1 - this.ee * magic * magic
+      var sqrtmagic = Math.sqrt(magic)
+      dlat =
+        (dlat * 180.0) /
+        (((this.a * (1 - this.ee)) / (magic * sqrtmagic)) * this.PI)
+      dlng =
+        (dlng * 180.0) / ((this.a / sqrtmagic) * Math.cos(radlat) * this.PI)
+      var mglat = parseFloat(lat) + parseFloat(dlat)
+      var mglng = parseFloat(lng) + parseFloat(dlng)
+      return [mglng, mglat]
+    }
+  },
+
+  gcj02_to_wgs84: function (lng, lat) {
+    if (this.out_of_china(lng, lat)) {
+      return [lng, lat]
+    } else {
+      var dlat = this.transformlat(lng - 105.0, lat - 35.0)
+      var dlng = this.transformlng(lng - 105.0, lat - 35.0)
+      var radlat = (lat / 180.0) * this.PI
+      var magic = Math.sin(radlat)
+      magic = 1 - this.ee * magic * magic
+      var sqrtmagic = Math.sqrt(magic)
+      dlat =
+        (dlat * 180.0) /
+        (((this.a * (1 - this.ee)) / (magic * sqrtmagic)) * this.PI)
+      dlng =
+        (dlng * 180.0) / ((this.a / sqrtmagic) * Math.cos(radlat) * this.PI)
+      var mglat = lat + dlat
+      var mglng = lng + dlng
+      return [lng * 2 - mglng, lat * 2 - mglat]
+    }
+  },
+
+  out_of_china: function (lng, lat) {
+    // 纬度3.86~53.55,经度73.66~135.05
+    return !(lng > 73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55)
+  },
+
+  transformlat: function (lng, lat) {
+    var ret =
+      -100.0 +
+      2.0 * lng +
+      3.0 * lat +
+      0.2 * lat * lat +
+      0.1 * lng * lat +
+      0.2 * Math.sqrt(Math.abs(lng))
+    ret +=
+      ((20.0 * Math.sin(6.0 * lng * this.PI) +
+        20.0 * Math.sin(2.0 * lng * this.PI)) *
+        2.0) /
+      3.0
+    ret +=
+      ((20.0 * Math.sin(lat * this.PI) +
+        40.0 * Math.sin((lat / 3.0) * this.PI)) *
+        2.0) /
+      3.0
+    ret +=
+      ((160.0 * Math.sin((lat / 12.0) * this.PI) +
+        320 * Math.sin((lat * this.PI) / 30.0)) *
+        2.0) /
+      3.0
+    return ret
+  },
+
+  transformlng: function (lng, lat) {
+    var ret =
+      300.0 +
+      lng +
+      2.0 * lat +
+      0.1 * lng * lng +
+      0.1 * lng * lat +
+      0.1 * Math.sqrt(Math.abs(lng))
+    ret +=
+      ((20.0 * Math.sin(6.0 * lng * this.PI) +
+        20.0 * Math.sin(2.0 * lng * this.PI)) *
+        2.0) /
+      3.0
+    ret +=
+      ((20.0 * Math.sin(lng * this.PI) +
+        40.0 * Math.sin((lng / 3.0) * this.PI)) *
+        2.0) /
+      3.0
+    ret +=
+      ((150.0 * Math.sin((lng / 12.0) * this.PI) +
+        300.0 * Math.sin((lng / 30.0) * this.PI)) *
+        2.0) /
+      3.0
+    return ret
+  },
+
+  /// <summary>
+  /// web墨卡托经纬度转米
+  /// </summary>
+  /// <param name="lng"></param>
+  /// <param name="lat"></param>
+  /// <returns></returns>
+  degree_to_meter: function (lng, lat) {
+    var x = (lng * 20037508.34) / 180
+    var y = Math.log(Math.tan(((90 + lat) * this.PI) / 360)) / (this.PI / 180)
+    y = (y * 20037508.34) / 180
+    return [x, y]
+  },
+
+  //Web墨卡托转经纬度
+  meter_to_degree: function (x, y) {
+    var lon = (x / 20037508.34) * 180
+    var lat = (y / 20037508.34) * 180
+    lat =
+      (180 / this.PI) *
+      (2 * Math.atan(Math.exp((lat * this.PI) / 180)) - this.PI / 2)
+
+    return [lon, lat]
+  },
+  /**
+   * @description wgs84坐标转上海城建
+   * @time 2020-09-02
+   * @author zhb
+   * @param {*} x
+   * @param {*} y
+   */
+  wgs84_to_shcj: function (x, y) {
+    let xy = []
+    xy = this.shcj_get_UTM_from_WGS(x, y)
+    return this.utm_to_shcj4(xy[0], xy[1])
+  },
+
+  utm_to_shcj4 (x, y) {
+    let DX, DY, T, K
+    DX = -500199.29965
+    DY = -3457078.805985
+    T = 0.0000001755
+    K = 1.0004000106
+    return this.covert_by_four_parm(x, y, DX, DY, T, K)
+  },
+
+  shcj_get_UTM_from_WGS: function (lon, lat) {
+    let a = 6378137
+    let b = 6356752.3142451
+    let f = (a - b) / a
+
+    let eSquare = 2 * f - f * f
+    let k0 = 0.9996
+    let lonOrigin = 121.46714714
+    let FN = 0
+    // # 确保longtitude位于-180.00----179.9之间
+    let lonTemp = lon + 180 - Math.floor((lon + 180) / 360) * 360 - 180
+    let latRad = (lat * this.PI) / 180
+    let lonRad = (lonTemp * this.PI) / 180
+    let lonOriginRad = (lonOrigin * this.PI) / 180
+    let e2Square = eSquare / (1 - eSquare)
+
+    let V = a / Math.sqrt(1 - eSquare * Math.pow(Math.sin(latRad), 2))
+    let T = Math.pow(Math.tan(latRad), 2)
+    let C = e2Square * Math.pow(Math.cos(latRad), 2)
+    let A = Math.cos(latRad) * (lonRad - lonOriginRad)
+    let M =
+      a *
+      ((1 -
+        eSquare / 4 -
+        (3 * Math.pow(eSquare, 2)) / 64 -
+        (5 * Math.pow(eSquare, 3)) / 256) *
+        latRad -
+        ((3 * eSquare) / 8 +
+          (3 * Math.pow(eSquare, 2)) / 32 +
+          (45 * Math.pow(eSquare, 3)) / 1024) *
+          Math.sin(2 * latRad) +
+        ((15 * Math.pow(eSquare, 2)) / 256 +
+          (45 * Math.pow(eSquare, 3)) / 1024) *
+          Math.sin(4 * latRad) -
+        ((35 * Math.pow(eSquare, 3)) / 3072) * Math.sin(6 * latRad))
+
+    // # x
+    let UTMEasting =
+      k0 *
+        V *
+        (A +
+          ((1 - T + C) * Math.pow(A, 3)) / 6 +
+          ((5 - 18 * T + Math.pow(T, 2) + 72 * C - 58 * e2Square) *
+            Math.pow(A, 5)) /
+            120) +
+      500000.0
+    //  # y
+    let UTMNorthing =
+      k0 *
+      (M +
+        V *
+          Math.tan(latRad) *
+          (Math.pow(A, 2) / 2 +
+            ((5 - T + 9 * C + 4 * Math.pow(C, 2)) * Math.pow(A, 4)) / 24 +
+            ((61 - 58 * T + Math.pow(T, 2) + 600 * C - 330 * e2Square) *
+              Math.pow(A, 6)) /
+              720))
+    //# 南半球纬度起点为10000000.0m
+
+    UTMNorthing += FN
+    let xy = []
+    xy[0] = UTMEasting
+    xy[1] = UTMNorthing
+    return xy
+  },
+
+  /**
+   * @description 上海城建坐标转wgs84
+   * @time 2020-09-02
+   * @author zhb
+   * @param {*} x
+   * @param {*} y
+   */
+  shcj_to_wgs84: function (x, y) {
+    let xy = []
+    xy = this.shcj_to_utm4(x, y)
+    return this.shcj_get_WGS_from_UTM(xy[0], xy[1])
+  },
+
+  shcj_to_utm4: function (x, y) {
+    let DX, DY, T, K
+    DX = 499999.90104
+    DY = 3455696.403019
+    T = -0.0000001755
+    K = 0.999600149344
+    return this.covert_by_four_parm(x, y, DX, DY, T, K)
+  },
+
+  //四参数公式
+  covert_by_four_parm: function (x, y, dx, dy, a, k) {
+    let px = 0
+    let py = 0
+    px = x * k * Math.cos(a) - y * k * Math.sin(a) + dx
+    py = x * k * Math.sin(a) + y * k * Math.cos(a) + dy
+    let xy = []
+    xy[0] = px
+    xy[1] = py
+    return xy
+  },
+  shcj_get_WGS_from_UTM: function (x, y) {
+    //WGS84
+
+    let a = 6378137 //椭球体长半轴
+    let b = 6356752.3142451 //椭球体短半轴
+    //	        double a = 6378245 ;
+    //	        double b =6356863.018773047300000000;
+    x = 500000 - x
+    let k0 = 0.9996
+    let e = Math.sqrt(1 - Math.pow(b, 2) / Math.pow(a, 2))
+    // # calculate the meridional arc
+    let M = y / k0
+    //# calculate footprint latitude
+    let mu =
+      M /
+      (a *
+        (1 -
+          Math.pow(e, 2) / 4 -
+          (3 * Math.pow(e, 4)) / 64 -
+          (5 * Math.pow(e, 6)) / 256))
+    let e1 =
+      (1 - Math.pow(1 - Math.pow(e, 2), 1.0 / 2)) /
+      (1 + Math.pow(1 - Math.pow(e, 2), 1.0 / 2))
+
+    let J1 = (3 * e1) / 2 - (27 * Math.pow(e1, 3)) / 32
+    let J2 = (21 * Math.pow(e1, 2)) / 16 - (55 * Math.pow(e1, 4)) / 32
+    let J3 = (151 * Math.pow(e1, 3)) / 96
+    let J4 = (1097 * Math.pow(e1, 4)) / 512
+    let fp =
+      mu +
+      J1 * Math.sin(2 * mu) +
+      J2 * Math.sin(4 * mu) +
+      J3 * Math.sin(6 * mu) +
+      J4 * Math.sin(8 * mu)
+
+    // # Calculate Latitude and Longitude
+
+    let e2 = Math.pow(e, 2) / (1 - Math.pow(e, 2))
+    let C1 = e2 * Math.pow(Math.cos(fp), 2)
+    let T1 = Math.pow(Math.tan(fp), 2)
+    let R1 =
+      (a * (1 - Math.pow(e, 2))) /
+      Math.pow(1 - Math.pow(e * Math.sin(fp), 2), 3.0 / 2)
+    //# This is the same as rho in the forward conversion formulas above, but calculated for fp instead of lat.
+    let N1 = a / Math.pow(1 - Math.pow(e * Math.sin(fp), 2), 1.0 / 2)
+    //# This is the same as nu in the forward conversion formulas above, but calculated for fp instead of lat.
+    let D = x / (N1 * k0)
+
+    let Q1 = (N1 * Math.tan(fp)) / R1
+    let Q2 = Math.pow(D, 2) / 2
+    let Q3 =
+      ((5 + 3 * T1 + 10 * C1 - 4 * Math.pow(C1, 2) - 9 * e2) * Math.pow(D, 4)) /
+      24
+    let Q4 =
+      ((61 +
+        90 * T1 +
+        298 * C1 +
+        45 * Math.pow(T1, 2) -
+        3 * Math.pow(C1, 2) -
+        252 * e2) *
+        Math.pow(D, 6)) /
+      720
+    let lat = ((fp - Q1 * (Q2 - Q3 + Q4)) * 180) / this.PI
+    // System.out.println("lat===="+Math.toRadians(fp - Q1*(Q2 - Q3 + Q4)));
+    let Q5 = D
+    let Q6 = ((1 + 2 * T1 + C1) * Math.pow(D, 3)) / 6
+    let Q7 =
+      ((5 -
+        2 * C1 +
+        28 * T1 -
+        3 * Math.pow(C1, 2) +
+        8 * e2 +
+        24 * Math.pow(T1, 2)) *
+        Math.pow(D, 5)) /
+      120
+    let lonmid = 121.46714714
+    let lon = lonmid - (((Q5 - Q6 + Q7) / Math.cos(fp)) * 180) / this.PI
+    //System.out.println("lon===="+(mMid - Math.toRadians((Q5 - Q6 + Q7)/Math.cos(fp))));
+    // System.out.println(lat+","+lon);
+    let xy = []
+    xy[0] = lon
+    xy[1] = lat
+    return xy
+  },
+
+  wgs84_to_bd09: function (x, y) {
+    let ll = this.wgs84_to_gcj02(x, y)
+    ll = this.gcj02_to_bd09(ll[0], ll[1])
+    return ll
+  },
+  bd09_to_wgs84: function (x, y) {
+    let ll = this.bd09_to_gcj02(x, y)
+    ll = this.gcj02_to_wgs84(ll[0], ll[1])
+    return ll
+  },
+  gcj02_to_shcj: function (x, y) {
+    let ll = this.gcj02_to_wgs84(x, y)
+    ll = this.wgs84_to_shcj(ll[0], ll[1])
+    return ll
+  },
+  shcj_to_gcj02: function (x, y) {
+    let ll = this.shcj_to_wgs84(x, y)
+    ll = this.wgs84_to_gcj02(ll[0], ll[1])
+    return ll
+  },
+  /**
+   * @description 坐标转换转换 01:84,02:高德,03.百度,04,UTM,05,上海城建,06:米制单位
+   * @param {} from
+   * @param {*} to
+   * @param {*} xy
+   * @time 2020-09-02
+   * @author zhb
+   */
+  convert_proj_from_to: function (from, to, xy) {
+    if (from === to) {
+      return xy
+    } else {
+      let fromProj = this.projs[from]
+      let toProj = this.projs[to]
+      let targetMethod = `${fromProj}_to_${toProj}`
+      return this[targetMethod](xy[0], xy[1])
+    }
+  },
+  /**
+   * @description 坐标转换转换,from 和to 都是epsg ID,如4326,3857
+   * @param {} from 4528
+   * @param {*} to 4326
+   * @param {*} xy [x, y]
+   * @time 2021-01-19
+   * @author zhb
+   */
+  convert_proj_from_to2: function (from, to, xy) {
+    if (from === to) {
+      return xy
+    } else {
+      let fromProj = this.epsg[from]
+      let toProj = this.epsg[to]
+      if (fromProj && toProj) {
+        let coor = proj4(fromProj, toProj, xy)
+        return coor
+      } else {
+        return null
+      }
+    }
+  }
+}
+
+// module.exports = coordinate
+export default coordinate

+ 52 - 59
src/views/ComprehensiveAnalysis.vue

@@ -98,7 +98,6 @@
               node-key="id"
               ref="tree"
               :filter-node-method="filterNode"
-              @node-click="handleNodeClick"
             >
               <span class="custom-tree-node" slot-scope="{ node }">
                 <!-- <template
@@ -148,33 +147,6 @@
                     </span>
                   </el-checkbox>
                 </template>
-                <!-- <template v-else-if="node.parent.label === '我的模型'">
-                  <div
-                    :class="{
-                      'tree-arrow': !node.expanded,
-                      'tree-arrow-expanded': node.expanded,
-                    }"
-                  ></div>
-                  <el-checkbox style="position: relative">
-                  <span
-                    >{{ node.label }}
-                    <el-button
-                      v-if="node.parent.label === '我的模型'"
-                      size="small"
-                      type="text"
-                      icon="el-icon-edit"
-                      @click="handleUpdate(node)"
-                    ></el-button>
-                    <el-button
-                      v-if="node.parent.label === '我的模型'"
-                      size="small"
-                      type="text"
-                      icon="el-icon-delete"
-                      @click="handleDelete(node)"
-                    ></el-button>
-                  </span>
-                  </el-checkbox>
-                </template> -->
                 <template v-else>
                   <div
                     :class="{
@@ -458,7 +430,7 @@ export default {
       for (let layer in map2DViewer.polygons) {
         this.$store.state.mapMethodsCollection
           .get("RENDER")
-          .deleteSinglePolygon(map2DViewer.polygons[layer]);
+          .deletePolygonLayer(map2DViewer.polygons[layer]);
       }
     }
 
@@ -493,6 +465,7 @@ export default {
           res.content.forEach((v) => {
             this.classTextToIndex[keyName].set(v.name, v.index + "");
           });
+
           // console.log(this.classTextToIndex[keyName], keyName);
         }
       });
@@ -669,7 +642,7 @@ export default {
       //   },
       let params = new FormData();
       params = {
-        columnId: 89,
+        columnId: 49,
         states: "0,1,2,3",
         pageSize: 10,
         page: 0,
@@ -794,7 +767,8 @@ export default {
     locateEvent(node) {
       if (this.layerIdMap.has(node.data.id)) {
         let layer = this.layerIdMap.get(node.data.id);
-        map2DViewer.map.fitBounds(map2DViewer.polygons[layer].getBounds());
+        console.log(layer, "layer");
+        map2DViewer.map.fitBounds(map2DViewer.polygons[layer][0].getBounds());
       }
     },
     handleUpdate(node) {
@@ -832,12 +806,23 @@ export default {
             this.rightPanelTitle = data.label;
             this.originalData[`${data.label}_${data.town}`] =
               this.rightPanelDataMap.get(data.label);
-
             let searchParam = [];
+
             let targetTown = this.classTextToIndex["浦东新区行政区划"].get(
               data.town
             );
-            let targetType = this.classTextToIndex["任务类型"].get(data.type);
+
+            let targetType = "";
+            if (data.type !== "林资源" && data.type !== "林地资源") {
+              targetType = this.classTextToIndex["任务类型"].get(
+                data.type + "审计"
+              );
+            }
+            if (data.type === "林资源" || data.type === "林地资源") {
+              targetType =
+                this.classTextToIndex["任务类型"].get("林地资源审计");
+            }
+            console.log(targetTown, targetType, "target");
 
             let paramUser = {
               field: "c_user_id",
@@ -885,8 +870,8 @@ export default {
 
                 if (res.code === 200 && res.content.data.length > 0) {
                   layerAuthorityMap.set(data.id, "有权限");
-                  // console.log("有权限");
-                  // console.log(data, "有权限的图层");
+                  console.log("有权限");
+                  console.log(data, "有权限的图层");
                   this.$store.state.treeDataCollection.set(data.id, {
                     mainType: data.mainType,
                     town: data.town,
@@ -896,7 +881,7 @@ export default {
                   let layerParams = new FormData();
                   layerParams = {
                     columnId: data.columnId,
-                    states: 3,
+                    states: "0,1,2,3",
                     pageSize: 10,
                     page: 0,
                   };
@@ -904,8 +889,9 @@ export default {
                     this.urlsCollection.selectContentList,
                     layerParams
                   ).then((res) => {
+                    console.log(res, "最终res");
                     if (res.code === 200 && res.content.data.length > 0) {
-                      // console.log(res.content, "获取到的数据");
+                      console.log(res.content, "获取到的数据");
                       let uniqueId = `${data.label}_${data.town}`;
                       this.originalData[uniqueId] = res.content.data.map(
                         (ele) => {
@@ -950,7 +936,7 @@ export default {
             let params = new FormData();
             params = {
               columnId: data.id.split("_")[1],
-              states: "3",
+              states: "0,1,2,3",
               pageSize: 10,
               page: 0,
             };
@@ -958,33 +944,40 @@ export default {
             this.$Post(this.urlsCollection.selectContentList, params).then(
               (res) => {
                 if (res.code === 200 && res.content.data.length > 0) {
-                  // console.log(res.content.data, "点击预设模型后获取到的数据");
+                  console.log(res.content.data, "点击预设模型后获取到的数据");
                   this.$store.state.treeDataCollection.set(data.id, {
                     mainType: data.mainType,
                   });
                   // id: "水资源_88"
+                  console.log(data, "预设模型下的单独数据");
                   let uniqueId = data.id;
+                  map2DViewer.polygons[uniqueId] = [];
+                  this.layerIdMap.set(data.id, data.id);
                   this.originalData[uniqueId] = res.content.data.map((ele) => {
-                    let cid = uniqueId;
-                    let geometry = ele.c_geometry;
-                    map2DViewer.polygons[`${cid}_polygon`] = [];
-                    this.layerIdMap.set(data.id, `${cid}_polygon`);
+                    let cid = ele.id;
+                    let geometry = ele.c_content;
+
+                    let attrContent = JSON.parse(ele.c_content).properties;
+                    console.log(attrContent, "attrContent");
+
                     // 激活当前展开面板
                     this.activeNames = ["myLabel", data.id];
+
                     this.$store.state.mapMethodsCollection
                       .get("RENDER")
                       .addSinglePolygon(
                         geometry,
                         cid,
-                        this.randomColor.get(uniqueId)
+                        this.randomColor.get(uniqueId),
+                        uniqueId
                       );
 
                     return {
                       id: ele.id,
-                      name: ele.c_yichang,
-                      columnName: ele.column_name,
-                      area: ele.c_c_shui_area,
-                      nature: ele.c_xingzhi,
+                      name: ele.title || "--",
+                      columnName: ele.column_name || "--",
+                      area: ele.c_c_shui_area || "--",
+                      nature: ele.c_xingzhi || "--",
                     };
                   });
                 }
@@ -993,30 +986,30 @@ export default {
           }
         } else {
           // 设置右侧折叠面板item数量
-          delete this.originalData[`${data.label}_${data.town}`];
+          if (data.mainType === "所有图层") {
+            delete this.originalData[`${data.label}_${data.town}`];
+          }
+          if (data.mainType === "预设模型") {
+            delete this.originalData[data.id];
+          }
+
           this.layerIdMap.delete(data.id);
           //关联自定义模型
           this.$store.state.treeDataCollection.delete(data.id);
 
           // 只激活我的标记
           this.activeNames = ["myLabel"];
-
-          for (let key in map2DViewer.polygons) {
-            // console.log(key, "现在的面数据");
-            if (key.indexOf(data.label) > -1) {
-              this.$store.state.mapMethodsCollection
-                .get("RENDER")
-                .deleteSinglePolygon(map2DViewer.polygons[key]);
-            }
-          }
+          this.$store.state.mapMethodsCollection
+            .get("RENDER")
+            .deletePolygonLayer(data.id);
         }
+        debugger
 
         this.legendTitle = Object.keys(this.originalData).map((v) => {
           return { name: v, info: v };
         });
         this.legendIcon = this.legendTitle.map((c) => {
           let a = this.randomColor.get(c.name);
-
           return {
             background: "transparent",
             border: `1px solid ${this.randomColor.get(c.name)}`,