@supermapgis/iclient-ol 11.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +56 -0
  2. package/control/ChangeTileVersion.js +438 -0
  3. package/control/Logo.js +97 -0
  4. package/control/ScaleLine.js +164 -0
  5. package/control/index.js +6 -0
  6. package/core/MapExtend.js +49 -0
  7. package/core/StyleUtils.js +1253 -0
  8. package/core/Util.js +500 -0
  9. package/core/index.js +6 -0
  10. package/css/ChangeTileVersion.css +347 -0
  11. package/css/index.js +5 -0
  12. package/dist/iclient-openlayers-es6.js +124963 -0
  13. package/dist/iclient-openlayers-es6.min.js +8 -0
  14. package/dist/iclient-openlayers.css +668 -0
  15. package/dist/iclient-openlayers.js +142946 -0
  16. package/dist/iclient-openlayers.min.css +8 -0
  17. package/dist/iclient-openlayers.min.js +8 -0
  18. package/index.js +9 -0
  19. package/mapping/BaiduMap.js +121 -0
  20. package/mapping/ImageSuperMapRest.js +252 -0
  21. package/mapping/ImageTileSuperMapRest.js +99 -0
  22. package/mapping/InitMap.js +150 -0
  23. package/mapping/SuperMapCloud.js +56 -0
  24. package/mapping/Tianditu.js +152 -0
  25. package/mapping/TileSuperMapRest.js +374 -0
  26. package/mapping/WebMap.js +5485 -0
  27. package/mapping/index.js +11 -0
  28. package/mapping/webmap/Util.js +176 -0
  29. package/mapping/webmap/config/MunicipalCenter.json +1 -0
  30. package/mapping/webmap/config/ProvinceCenter.json +1 -0
  31. package/mapping/webmap/config/SampleDataInfo.json +55 -0
  32. package/namespace.js +150 -0
  33. package/overlay/DataFlow.js +114 -0
  34. package/overlay/FGB.js +100 -0
  35. package/overlay/Graph.js +439 -0
  36. package/overlay/GraphMap.js +140 -0
  37. package/overlay/Graphic.js +588 -0
  38. package/overlay/HeatMap.js +450 -0
  39. package/overlay/Label.js +966 -0
  40. package/overlay/Mapv.js +149 -0
  41. package/overlay/Range.js +129 -0
  42. package/overlay/RankSymbol.js +94 -0
  43. package/overlay/Turf.js +299 -0
  44. package/overlay/Unique.js +124 -0
  45. package/overlay/VectorTileSuperMapRest.js +501 -0
  46. package/overlay/graphic/CanvasRenderer.js +177 -0
  47. package/overlay/graphic/CloverShape.js +133 -0
  48. package/overlay/graphic/Graphic.js +174 -0
  49. package/overlay/graphic/HitCloverShape.js +64 -0
  50. package/overlay/graphic/WebGLRenderer.js +356 -0
  51. package/overlay/graphic/index.js +9 -0
  52. package/overlay/index.js +21 -0
  53. package/overlay/mapv/MapvCanvasLayer.js +104 -0
  54. package/overlay/mapv/MapvLayer.js +413 -0
  55. package/overlay/mapv/index.js +5 -0
  56. package/overlay/theme/GeoFeature.js +275 -0
  57. package/overlay/theme/Theme.js +587 -0
  58. package/overlay/theme/ThemeFeature.js +46 -0
  59. package/overlay/theme/index.js +6 -0
  60. package/overlay/vectortile/DeafultCanvasStyle.js +125 -0
  61. package/overlay/vectortile/MapboxStyles.js +377 -0
  62. package/overlay/vectortile/StyleMap.js +252 -0
  63. package/overlay/vectortile/VectorTileStyles.js +554 -0
  64. package/overlay/vectortile/index.js +7 -0
  65. package/overlay/vectortile/olExtends.js +382 -0
  66. package/package.json +30 -0
  67. package/services/AddressMatchService.js +60 -0
  68. package/services/ChartService.js +97 -0
  69. package/services/DataFlowService.js +119 -0
  70. package/services/DatasetService.js +104 -0
  71. package/services/DatasourceService.js +76 -0
  72. package/services/FeatureService.js +260 -0
  73. package/services/FieldService.js +53 -0
  74. package/services/GeoprocessingService.js +157 -0
  75. package/services/GridCellInfosService.js +53 -0
  76. package/services/ImageCollectionService.js +93 -0
  77. package/services/ImageService.js +70 -0
  78. package/services/KnowledgeGraphService.js +96 -0
  79. package/services/LayerInfoService.js +85 -0
  80. package/services/MapService.js +85 -0
  81. package/services/MeasureService.js +77 -0
  82. package/services/NetworkAnalyst3DService.js +93 -0
  83. package/services/NetworkAnalystService.js +268 -0
  84. package/services/ProcessingService.js +507 -0
  85. package/services/QueryService.js +116 -0
  86. package/services/ServiceBase.js +26 -0
  87. package/services/SpatialAnalystService.js +466 -0
  88. package/services/ThemeService.js +50 -0
  89. package/services/TrafficTransferAnalystService.js +93 -0
  90. package/services/WebPrintingJobService.js +112 -0
  91. package/services/index.js +27 -0
@@ -0,0 +1,450 @@
1
+ /* Copyright© 2000 - 2024 SuperMap Software Co.Ltd. All rights reserved.
2
+ * This program are made available under the terms of the Apache License, Version 2.0
3
+ * which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
4
+ import {Util} from '../core/Util';
5
+ import { Util as CommonUtil } from '@supermapgis/iclient-common/commontypes/Util';
6
+ import { LonLat } from '@supermapgis/iclient-common/commontypes/LonLat';
7
+ import { GeoJSON as GeoJSONFormat } from '@supermapgis/iclient-common/format/GeoJSON';
8
+ import { ServerFeature } from '@supermapgis/iclient-common/iServer/ServerFeature';
9
+ import { Vector as FeatureVector } from '@supermapgis/iclient-common/commontypes/Vector';
10
+ import { Point as GeometryPoint } from '@supermapgis/iclient-common/commontypes/geometry/Point';
11
+ import { GeoText } from '@supermapgis/iclient-common/commontypes/geometry/GeoText';
12
+ import ImageCanvasSource from 'ol/source/ImageCanvas';
13
+ import Feature from 'ol/Feature';
14
+ import Point from 'ol/geom/Point';
15
+
16
+ /**
17
+ * @class HeatMap
18
+ * @browsernamespace ol.source
19
+ * @classdesc 热力图层类。热力图是通过颜色分布,描述诸如人群分布、密度和变化趋势等的一种地图表现手法。
20
+ * 热点图的衰减是像素级别的,视觉效果极佳,但不能与具体数据进行一一对应,只能表示权重之间的差别,
21
+ * 因此可以用于一些对精度要求不高而需要重点突出权重渐变的行业,如制作气象温度对比动态效果图、地震区域的震点强弱图等。<br>
22
+ * 在客户端直接渲染栅格图的三要素:<br>
23
+ * 1.热点数据,热点数据需要点数据,每一个热点数据需要有地理位置以及权重值 (能够明显地表现某位置某事件发生频率或事物分布密度等,如可以为温度的高低、人口密集度等等);<br>
24
+ * 2.热点衰减渐变填充色集合, 用于渲染每一个热点从中心向外衰减时的渐变色;<br>
25
+ * 3.热点半径,也就是衰减半径。每一个热点需要从中心点外四周根据半径计算衰减度,对在热点衰减区内的每一个像素计算需要渲染的颜色值。
26
+ * @modulecategory Overlay
27
+ * @category Visualization HeatMap
28
+ * @param {string} name - 图层名称。
29
+ * @param {Object} options - 参数。
30
+ * @param {ol.Map} options.map - OpenLayers 的地图对象。
31
+ * @param {string} [options.id] - 专题图层 ID,默认使用 CommonUtil.createUniqueID("HeatMapSource_") 创建专题图层 ID。
32
+ * @param {string} [options.featureWeight] - 对应 feature 属性中的热点权重字段名称,权重值类型为 number。
33
+ * @param {number} [options.radius=50] - 热点渲染的最大半径(热点像素半径),单位为 px,当 useGeoUnit 参数 为 true 时,单位使用当前图层地理坐标单位。热点显示的时候以精确点为中心点开始往四周辐射衰减,其衰减半径和权重值成比列。
34
+ * @param {number} [options.opacity=1] - 图层不透明度。
35
+ * @param {Array.<string>} [options.colors=['blue','cyan','lime','yellow','red']] - 颜色线性渐变数组,颜色值必须为 canvas 所支持的。
36
+ * @param {boolean} [options.useGeoUnit=false] - 使用地理单位,false 表示默认热点半径默认使用像素单位。当设置为 true 时,热点半径和图层地理坐标保持一致。
37
+ * @extends {ol.source.ImageCanvas}
38
+ * @usage
39
+ */
40
+ export class HeatMap extends ImageCanvasSource {
41
+
42
+ constructor(name, opt_options) {
43
+ var options = opt_options ? opt_options : {};
44
+ super({
45
+ attributions: options.attributions || "Map Data <span>© SuperMap iServer</span> with <span>© SuperMap iClient</span>",
46
+ canvasFunction: canvasFunctionInternal_,
47
+ logo: Util.getOlVersion() === '4' ? options.logo : null,
48
+ projection: options.projection,
49
+ ratio: options.ratio,
50
+ resolutions: options.resolutions,
51
+ state: options.state
52
+ });
53
+
54
+ function canvasFunctionInternal_(extent, resolution, pixelRatio, size, projection) { // eslint-disable-line no-unused-vars
55
+ var mapWidth = size[0] * pixelRatio;
56
+ var mapHeight = size[1] * pixelRatio;
57
+
58
+ this.rootCanvas.width = this.maxWidth = mapWidth;
59
+ this.rootCanvas.height = this.maxHeight = mapHeight;
60
+ if (!this.features) {
61
+ return this.rootCanvas;
62
+ }
63
+ this.pixelRatio = pixelRatio;
64
+
65
+ //记录偏移量
66
+ var width = this.map.getSize()[0] * pixelRatio;
67
+ var height = this.map.getSize()[1] * pixelRatio;
68
+ this.offset = [(mapWidth - width) / 2 / pixelRatio, (mapHeight - height) / 2 / pixelRatio];
69
+
70
+ this.updateHeatPoints(resolution);
71
+
72
+ return this.rootCanvas;
73
+ }
74
+
75
+ //初始化成员变量
76
+ this.canvasFunctionInternal_ = canvasFunctionInternal_;
77
+ this.features = [];
78
+ this.name = name;
79
+ if (!options.map) {
80
+ throw new Error('options.map is not found.');
81
+ }
82
+ this.map = options.map;
83
+ // this.TFEvents = options.TFEvents || [];
84
+ this.id = options.id ? options.id : CommonUtil.createUniqueID("HeatMapSource_");
85
+ this.opacity = options.opacity ? options.opacity : 1;
86
+ this.colors = options.colors ? options.colors : ['blue', 'cyan', 'lime', 'yellow', 'red'];
87
+ this.useGeoUnit = options.useGeoUnit ? options.useGeoUnit : false;
88
+ this.radius = options.radius ? options.radius : 50;
89
+ this.featureWeight = options.featureWeight ? options.featureWeight : null;
90
+ this.maxWeight = null;
91
+ this.minWeight = null;
92
+ this.maxWidth = null;
93
+ this.maxHeight = null;
94
+
95
+ //创建热力图绘制面板
96
+ this.rootCanvas = document.createElement("canvas");
97
+ var mapSize = this.map.getSize();
98
+ this.rootCanvas.width = this.maxWidth = parseInt(mapSize[0]);
99
+ this.rootCanvas.height = this.maxHeight = parseInt(mapSize[1]);
100
+ CommonUtil.modifyDOMElement(this.rootCanvas, null, null, null,
101
+ null, null, null, this.opacity);
102
+ this.canvasContext = this.rootCanvas.getContext('2d');
103
+ }
104
+
105
+ /**
106
+ * @function HeatMap.prototype.addFeatures
107
+ * @description 添加热点信息。
108
+ * @param {(GeoJSONObject|Array.<ol.Feature>)} features - 待添加的要素数组。
109
+ * @example
110
+ * var geojson = {
111
+ * "type": "FeatureCollection",
112
+ * "features": [
113
+ * {
114
+ * "type": "feature",
115
+ * "geometry": {
116
+ * "type": "Point", //只支持point类型
117
+ * "coordinates": [0, 0]
118
+ * },
119
+ * "properties": {
120
+ * "height": Math.random()*9,
121
+ * }
122
+ * }
123
+ * ]
124
+ * };
125
+ * var heatMapSource = new HeatMap("heatMap",{"map": map});
126
+ * heatMapSource.addFeatures(geojson);
127
+ * map.addLayer(new ol.layer.Image({
128
+ * source: heatMapSource
129
+ * }));
130
+ */
131
+ addFeatures(features) {
132
+ this.features = this.toiClientFeature(features);
133
+ //支持更新features,刷新底图
134
+ this.changed();
135
+ }
136
+
137
+ /**
138
+ * @function HeatMap.prototype.setOpacity
139
+ * @description 设置图层的不透明度,取值范围:[0-1]。
140
+ * @param {number} opacity - 不透明度。
141
+ */
142
+ setOpacity(opacity) {
143
+ if (opacity !== this.opacity) {
144
+ this.opacity = opacity;
145
+ var element = this.rootCanvas;
146
+ CommonUtil.modifyDOMElement(element, null, null, null,
147
+ null, null, null, opacity);
148
+
149
+ if (this.map !== null) {
150
+ // this.dispatchEvent({type: 'changelayer', value: {layer: this, property: "opacity"}});
151
+ this.changed();
152
+ }
153
+ }
154
+ }
155
+
156
+ /**
157
+ * @function HeatMap.prototype.updateHeatPoints
158
+ * @description 刷新热点图显示。
159
+ * @param {ol.LngLatBounds} resolution - 当前显示范围。
160
+ * @private
161
+ */
162
+ updateHeatPoints(resolution) {
163
+ if (this.features && this.features.length > 0) {
164
+ this.convertFastToPixelPoints(resolution);
165
+ } else {
166
+ this.canvasContext.clearRect(0, 0, this.maxWidth, this.maxWidth);
167
+ }
168
+ }
169
+
170
+ /**
171
+ * @function HeatMap.prototype.convertFastToPixelPoints
172
+ * @description 过滤位于当前显示范围内的热点,并转换其为当前分辨率下的像素坐标。
173
+ * @param {number} resolution - 当前分辨率。
174
+ * @private
175
+ */
176
+ convertFastToPixelPoints(resolution) {
177
+ var data = [], x, y, k, maxTemp, minTemp, maxWeightTemp;
178
+
179
+ //热点半径
180
+ this.useRadius = this.useGeoUnit ? parseInt(this.radius / resolution) : this.radius;
181
+
182
+ for (var i = 0; i < this.features.length; i++) {
183
+ var feature = this.features[i];
184
+ var point = feature.geometry;
185
+ //过滤,只显示当前范围
186
+ // if (mapBounds.contains(point.x, point.y)) {
187
+ var pixelPoint = this.getLocalXY(new LonLat(point.x, point.y));
188
+ if (this.featureWeight) {
189
+ pixelPoint.weight = feature.attributes[this.featureWeight];//point.value;
190
+ if (!this.maxWeight) {
191
+ //找出最大最小权重值
192
+ maxTemp = maxTemp ? maxTemp : pixelPoint.weight;
193
+ minTemp = minTemp ? minTemp : pixelPoint.weight;
194
+ maxTemp = Math.max(maxTemp, pixelPoint.weight);
195
+ minTemp = Math.min(minTemp, pixelPoint.weight);
196
+ }
197
+ } else {
198
+ pixelPoint.weight = 1;
199
+ }
200
+
201
+ x = Math.floor(pixelPoint[0]);
202
+ y = Math.floor(pixelPoint[1]);
203
+ k = pixelPoint.weight;
204
+
205
+ data.push([x, y, k]);
206
+ // }
207
+ }
208
+
209
+ //无最大权重设置
210
+ if (!this.maxWeight) {
211
+ if (maxTemp && minTemp) {
212
+ maxWeightTemp = (maxTemp + minTemp) / 2;
213
+ } else {
214
+ maxWeightTemp = 1;
215
+ }
216
+ this.draw(data, maxWeightTemp);
217
+ } else {
218
+ this.draw(data, this.maxWeight);
219
+ }
220
+
221
+ }
222
+
223
+ /**
224
+ * @function HeatMap.prototype.draw
225
+ * @description 绘制热点图。
226
+ * @param {Array} data - convertToPixelPoints 方法计算出的点。
227
+ * @param {number} maxWeight -最大权重。
228
+ * @private
229
+ */
230
+ draw(data, maxWeight) {
231
+ if (this.maxHeight > 0 && this.maxWidth > 0) {
232
+ //清空
233
+ var ctx = this.canvasContext;
234
+ this.canvasContext.clearRect(0, 0, this.maxWidth, this.maxHeight);
235
+ this.drawCircle(this.useRadius);
236
+ this.createGradient();
237
+
238
+ for (var i = 0; i < data.length; i++) {
239
+ var p = data[i];
240
+ this.canvasContext.globalAlpha = Math.max(p[2] / maxWeight, 0.05);
241
+ this.canvasContext.drawImage(this.circle, p[0] - this.useRadius, p[1] - this.useRadius);
242
+ }
243
+
244
+ var colored = ctx.getImageData(0, 0, this.maxWidth, this.maxHeight);
245
+ this.colorize(colored.data, this.grad);
246
+ ctx.putImageData(colored, 0, 0);
247
+ } else {
248
+ return false;
249
+ }
250
+
251
+ }
252
+
253
+ /**
254
+ * @function HeatMap.prototype.colorize
255
+ * @description 根据渐变色重置热点图 rgb 值。
256
+ * @param {Object} pixels - 像素 rgba 值。
257
+ * @param {Array} gradient - 渐变 canvas.getImageData.data。
258
+ * @private
259
+ */
260
+ colorize(pixels, gradient) {
261
+ for (var i = 0, j; i < pixels.length; i += 4) {
262
+ j = pixels[i + 3] * 4;
263
+ if (j) {
264
+ pixels[i] = gradient[j];
265
+ pixels[i + 1] = gradient[j + 1];
266
+ pixels[i + 2] = gradient[j + 2];
267
+ }
268
+ }
269
+ }
270
+
271
+ /**
272
+ * @function HeatMap.drawCircle
273
+ * @description 绘制热点半径圆。
274
+ * @param {number} r - 热点半径。
275
+ * @private
276
+ */
277
+ drawCircle(r) {
278
+ var blur = r / 2;
279
+
280
+ var circle = this.circle = document.createElement('canvas'),
281
+ ctx = circle.getContext("2d");
282
+
283
+ circle.height = 2 * r;
284
+ circle.width = 2 * r;
285
+ ctx.shadowOffsetX = ctx.shadowOffsetY = 2 * r;
286
+ ctx.shadowBlur = blur;
287
+ ctx.shadowColor = "#000000";
288
+
289
+ ctx.beginPath();
290
+ ctx.arc(-r, -r, r / 2, 0, Math.PI * 2, true);
291
+ ctx.closePath();
292
+ ctx.fill();
293
+ }
294
+
295
+ /**
296
+ * @function HeatMap.createGradient
297
+ * @description 根据 this.canvasColors 设置渐变并 getImageData。
298
+ * @private
299
+ */
300
+ createGradient() {
301
+ var colors = this.colors;
302
+ var canvas = document.createElement('canvas'),
303
+ ctx = canvas.getContext("2d"),
304
+ gradient = ctx.createLinearGradient(0, 0, 0, 256);
305
+ canvas.height = 256;
306
+ canvas.width = 1;
307
+
308
+ var index = 1;
309
+ for (var i = 0, len = colors.length; i < len; i++) {
310
+ gradient.addColorStop(index / len, colors[i]);
311
+ index++;
312
+ }
313
+
314
+ ctx.fillStyle = gradient;
315
+ ctx.fillRect(0, 0, 1, 256);
316
+
317
+ this.grad = ctx.getImageData(0, 0, 1, 256).data;
318
+ }
319
+
320
+ /**
321
+ * @function HeatMap.prototype.getLocalXY
322
+ * @description 地理坐标转为像素坐标。
323
+ * @param {Object} coordinate - 坐标位置。
324
+ */
325
+ getLocalXY(coordinate) {
326
+ var pixelP, map = this.map;
327
+ if (coordinate instanceof GeometryPoint || coordinate instanceof GeoText) {
328
+ pixelP = map.getPixelFromCoordinate([coordinate.x, coordinate.y]);
329
+ }
330
+ if (coordinate instanceof LonLat) {
331
+ pixelP = map.getPixelFromCoordinate([coordinate.lon, coordinate.lat]);
332
+ }
333
+ var rotation = -map.getView().getRotation();
334
+ var center = map.getPixelFromCoordinate(map.getView().getCenter());
335
+ var rotatedP = pixelP;
336
+ if (this.pixelRatio) {
337
+ rotatedP = this.scale(pixelP, center, this.pixelRatio);
338
+ }
339
+ if (pixelP && center) {
340
+ rotatedP = this.rotate(rotatedP, rotation, center);
341
+ }
342
+ if (this.offset && rotatedP) {
343
+ return [rotatedP[0] + this.offset[0], rotatedP[1] + this.offset[1]];
344
+ }
345
+ return rotatedP;
346
+ }
347
+
348
+ /**
349
+ * @function HeatMap.prototype.rotate
350
+ * @description 获取某像素坐标点 pixelP 绕中心 center 逆时针旋转 rotation 弧度后的像素点坐标。
351
+ * @param {number} pixelP - 像素坐标点位置。
352
+ * @param {number} rotation - 旋转角度。
353
+ * @param {number} center - 中心位置。
354
+ */
355
+ rotate(pixelP, rotation, center) {
356
+ var x = Math.cos(rotation) * (pixelP[0] - center[0]) - Math.sin(rotation) * (pixelP[1] - center[1]) + center[0];
357
+ var y = Math.sin(rotation) * (pixelP[0] - center[0]) + Math.cos(rotation) * (pixelP[1] - center[1]) + center[1];
358
+ return [x, y];
359
+ }
360
+
361
+ /**
362
+ * @function HeatMap.prototype.scale
363
+ * @description 获取某像素坐标点 pixelP 相对于中心 center 进行缩放 scaleRatio 倍后的像素点坐标。
364
+ * @param {Object} pixelP - 像素点。
365
+ * @param {Object} center - 中心点。
366
+ * @param {number} scaleRatio - 缩放倍数。
367
+ * @returns {Array.<number>} 返回数组型比例。
368
+ */
369
+ scale(pixelP, center, scaleRatio) {
370
+ var x = (pixelP[0] - center[0]) * scaleRatio + center[0];
371
+ var y = (pixelP[1] - center[1]) * scaleRatio + center[1];
372
+ return [x, y];
373
+ }
374
+
375
+ /**
376
+ * @function HeatMap.prototype.removeFeatures
377
+ * @description 移除指定的热点信息。
378
+ * @param {Array.<FeatureVector>|FeatureVector} features - 热点信息数组。
379
+ */
380
+ removeFeatures(features) {
381
+ if (!features || features.length === 0 || !this.features || this.features.length === 0) {
382
+ return;
383
+ }
384
+ if (features === this.features) {
385
+ return this.removeAllFeatures();
386
+ }
387
+ if (!(CommonUtil.isArray(features))) {
388
+ features = [features];
389
+ }
390
+ var heatPoint, index, heatPointsFailedRemoved = [];
391
+ for (var i = 0, len = features.length; i < len; i++) {
392
+ heatPoint = features[i];
393
+ index = CommonUtil.indexOf(this.features, heatPoint);
394
+ //找不到视为删除失败
395
+ if (index === -1) {
396
+ heatPointsFailedRemoved.push(heatPoint);
397
+ continue;
398
+ }
399
+ //删除热点
400
+ this.features.splice(index, 1);
401
+ }
402
+ var succeed = heatPointsFailedRemoved.length == 0 ? true : false;
403
+ //派发删除features成功的事件
404
+ this.dispatchEvent({type: 'featuresremoved', value: {features: heatPointsFailedRemoved, succeed: succeed}});
405
+ this.changed();
406
+ }
407
+
408
+ /**
409
+ * @function HeatMap.prototype.removeAllFeatures
410
+ * @description 移除全部的热点信息。
411
+ */
412
+ removeAllFeatures() {
413
+ this.features = [];
414
+ this.changed();
415
+ }
416
+
417
+ /**
418
+ * @function HeatMap.prototype.toiClientFeature
419
+ * @description 转为 iClient 要素。
420
+ * @param {GeoJSONObject|Array.<ol.Feature>} features - 待添加的要素数组。
421
+ * @returns {FeatureVector} 转换后的 iClient 要素。
422
+ */
423
+ toiClientFeature(features) {
424
+ if (!Util.isArray(features)) {
425
+ features = [features];
426
+ }
427
+ let featuresTemp = [], geometry, attributes;
428
+ for (let i = 0, len = features.length; i < len; i++) {
429
+ if (features[i] instanceof Feature) {
430
+ //热点图支支持传入点对象要素
431
+ if (features[i].getGeometry() instanceof Point) {
432
+ geometry = new GeometryPoint(features[i].getGeometry().getCoordinates()[0], features[i].getGeometry().getCoordinates()[1]);
433
+ //固定属性字段为 "Properties"
434
+ attributes = features[i].getProperties()["Properties"] ? features[i].getProperties()["Properties"] : {};
435
+ featuresTemp.push(new FeatureVector(geometry, attributes));
436
+ }
437
+ } else if (["FeatureCollection", "Feature", "Geometry"].indexOf(features[i].type) != -1) {
438
+ let format = new GeoJSONFormat();
439
+ featuresTemp = featuresTemp.concat(format.read(features[i]));
440
+ } else if (features[i].geometry && features[i].geometry.parts) {
441
+ //iServer服务器返回数据格式
442
+ featuresTemp.push(ServerFeature.fromJson(features[i]).toFeature());
443
+ } else {
444
+ throw new Error(`Features[${i}]'s type does not match, please check.`);
445
+ }
446
+ }
447
+ return featuresTemp;
448
+ }
449
+
450
+ }