suerprisePlus
2024-12-17 5dfcbd19cd041e1f8a5fb7ed9ab694bf4de00352
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
"use strict";
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var wfsConfig = {
  url: "",
  layer: "",
  color: "",
  property: "",
  keyVal: "",
  polygonLayer: null,
  wfsLayer: null,
  //   参数初始化
  Init: function Init() {
    this.url = "https://cim.smartearth.cn/SEserver/wfsserver/SubicBayAreaVector_wfs";
    this.layer = "GeoEntity";
    this.color = "#f40824";
    this.keyVal = "市政";
    this.setPolyGonStart();
  },
  //wfsLayer初始化
  setPolyGonStart: function setPolyGonStart() {
    this.polygonLayer = earthCtrl.factory.createWfsLayer("polygon", {
      urls: this.url,
      layer: this.layer,
      color: this.color,
      extrudedHeight: 100,
      // 拉伸高度,无拉伸高度则为贴地面
      extrudedkey: "ELEVATION"
    });
    this.setWfsLayerStart();
  },
  //wfsLayer初始化
  setWfsLayerStart: function setWfsLayerStart() {
    this.wfsLayer = new OpenLayers.Protocol.WFS({
      version: "1.1.0",
      url: this.url,
      layer: this.layer
    });
    this.setLayerQuery();
  },
  setLayerQuery: function setLayerQuery() {
    var filter = new OpenLayers.Filter.Comparison({
      type: OpenLayers.Filter.Comparison.EQUAL_TO,
      property: "SJFL",
      value: this.keyVals
    });
    var that = this;
    console.log(this.wfsLayer);
    that.wfsLayer.read({
      filter: filter,
      callback: function callback(result) {
        console.log(1231, result);
 
        if (result.success() && result.features.length > 0) {
          var feature = result.features[0]; // var lon = Number(feature.attributes.lon);
          // var lat = Number(feature.attributes.lat);
 
          that.setLayerQuery2(feature);
        }
      }
    });
  },
  setLayerQuery2: function setLayerQuery2() {
    var that = this;
    var wfs2 = new OpenLayers.Protocol.WFS({
      version: "1.1.0",
      url: this.url,
      featureType: this.layer,
      geometryName: "TargetType"
    });
    wfs2.read({
      filter: new OpenLayers.Filter.Spatial({
        type: OpenLayers.Filter.Spatial.DWITHIN,
        value: feature.geometry,
        distance: 0.1,
        distanceUnits: "km"
      }),
      callback: function callback(result) {
        console.log('w1223', result);
 
        if (result.success()) {
          if (result.features && result.features.length) {
            that.addFeaturesToMap(result.features);
          }
        }
      }
    });
  },
  addFeaturesToMap: function addFeaturesToMap(features) {
    var highlightColor = Cesium.Color.YELLOW.withAlpha(0.5);
    var highlightIds = [];
    features.forEach(function (feature) {
      var id = feature.attributes.OBJECTID;
      highlightIds.push(id);
    });
    this.polygonLayer.setHighlightColor(highlightIds, highlightColor);
  }
};
var _default = wfsConfig;
exports["default"] = _default;