月球大数据地理空间分析展示平台-【前端】-月球2期前端
Surpriseplus
2023-08-11 5c63e3106bc4b82e06d280bf7fd44785f07ac56a
src/assets/js/Map/menuTool.js
@@ -8,7 +8,7 @@
  toolMenu: null,
  toolFlag: null,
  oldLeftMenuId: null,
  bufferSize: 100,
  squareOjb: [],
  localPoint: null,
  colorAll: {
@@ -71,7 +71,13 @@
      case "e1": //快照
        this.snapshot();
        break;
      case "f1": //空间查询
      case "f2": //点查询
        this.spatialPointQuery();
        break;
      case "f3": //线查询
        this.spatialLineQuery();
        break;
      case "f4": //面查询
        this.spatialQuery();
        break;
      case "g1": //坐标定位
@@ -160,6 +166,45 @@
    contourUniforms.color = contourColor;
    globe.material = window.material;
  },
  //线查询
  spatialLineQuery() {
    var that = this;
    sgworld.Creator.createSimpleGraphic('polyline', {}, (entity) => {
      var res = entity.polyline.positions.getValue()
      var std = []
      for (var i in res) {
        var line_data = this.setCartesianToEightFour(res[i])
        std.push([line_data.lng, line_data.lat])
      }
      var line = turf.lineString(std, { name: "polyline" })
      var restVal = turf.buffer(line, this.bufferSize, { units: "meters" })
      that.setSpatialQuery(restVal)
    });
  },
  spatialPointQuery() {
    var that = this;
    sgworld.Creator.createSimpleGraphic('point', {}, (entity) => {
      var res = entity.position.getValue();
      var val = that.setCartesianToEightFour(res)
      sgworld.Creator.SimpleGraphic.clear();
      var options = {
        steps: 10,
        units: "meters",
        properties: { foo: "bar" },
      }
      var circle = turf.circle([val.lng, val.lat], this.bufferSize, options)
      that.setSpatialQuery(circle)
    });
  },
  setCartesianToEightFour(res) {
    var std = {}
    let ellipsoid = Viewer.scene.globe.ellipsoid
    let cartographic = ellipsoid.cartesianToCartographic(res)
    std.lat = Cesium.Math.toDegrees(cartographic.latitude)
    std.lng = Cesium.Math.toDegrees(cartographic.longitude)
    std.alt = cartographic.height
    return std
  },
  //空间查询
  spatialQuery() {
    sgworld.Creator.createSimpleGraphic(
@@ -189,14 +234,17 @@
            [east, north],
          ],
        ]);
        var wkt = WKT.convert(polygon.geometry);
        window.functionForJs({
          type: "spatialQuery",
          value: this.encr(wkt),
        });
        this.setSpatialQuery(polygon)
      }
    );
  },
  setSpatialQuery(res) {
    var wkt = WKT.convert(res.geometry);
    window.functionForJs({
      type: "spatialQuery",
      value: this.encr(wkt),
    });
  },
  //加密
  encr(word) {
@@ -404,11 +452,11 @@
  },
  //垂直高度
  verticalHeight() {
    sgworld.Analysis.verticalHeight(this.colorAll, () => {});
    sgworld.Analysis.verticalHeight(this.colorAll, () => { });
  },
  //高程测量
  heightMeasure() {
    earthCtrl.Analysis.altitude(this.colorAll, () => {});
    earthCtrl.Analysis.altitude(this.colorAll, () => { });
  },
  //表面面积
  planeDistance() {
@@ -427,7 +475,7 @@
  },
  //表面距离
  surfaceDistance() {
    sgworld.Analysis.horizontalDistance(this.colorAll, () => {});
    sgworld.Analysis.horizontalDistance(this.colorAll, () => { });
  },
  //点漫游
  pointRoam() {
@@ -502,6 +550,6 @@
    // }
    earthCtrl.analysis.deleteObject();
  },
  clearLeftTools(res) {},
  clearLeftTools(res) { },
};
export default menuTool;