@supermapgis/iclient-ol 11.1.2

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 +99 -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 +478 -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 +121806 -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 +132335 -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 +125 -0
  23. package/mapping/SuperMapCloud.js +56 -0
  24. package/mapping/Tianditu.js +152 -0
  25. package/mapping/TileSuperMapRest.js +358 -0
  26. package/mapping/WebMap.js +5185 -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 +97 -0
  35. package/overlay/Graph.js +436 -0
  36. package/overlay/GraphMap.js +91 -0
  37. package/overlay/Graphic.js +587 -0
  38. package/overlay/HeatMap.js +444 -0
  39. package/overlay/Label.js +964 -0
  40. package/overlay/Mapv.js +146 -0
  41. package/overlay/Range.js +127 -0
  42. package/overlay/RankSymbol.js +94 -0
  43. package/overlay/Turf.js +298 -0
  44. package/overlay/Unique.js +123 -0
  45. package/overlay/VectorTileSuperMapRest.js +466 -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 +63 -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 +410 -0
  55. package/overlay/mapv/index.js +5 -0
  56. package/overlay/theme/GeoFeature.js +275 -0
  57. package/overlay/theme/Theme.js +585 -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 +375 -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 +29 -0
  67. package/services/AddressMatchService.js +60 -0
  68. package/services/ChartService.js +74 -0
  69. package/services/DataFlowService.js +118 -0
  70. package/services/DatasetService.js +104 -0
  71. package/services/DatasourceService.js +76 -0
  72. package/services/FeatureService.js +196 -0
  73. package/services/FieldService.js +53 -0
  74. package/services/GeoprocessingService.js +156 -0
  75. package/services/GridCellInfosService.js +53 -0
  76. package/services/ImageCollectionService.js +92 -0
  77. package/services/ImageService.js +69 -0
  78. package/services/KnowledgeGraphService.js +82 -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 +88 -0
  83. package/services/NetworkAnalystService.js +252 -0
  84. package/services/ProcessingService.js +478 -0
  85. package/services/QueryService.js +116 -0
  86. package/services/ServiceBase.js +26 -0
  87. package/services/SpatialAnalystService.js +432 -0
  88. package/services/ThemeService.js +50 -0
  89. package/services/TrafficTransferAnalystService.js +88 -0
  90. package/services/WebPrintingJobService.js +112 -0
  91. package/services/index.js +27 -0
@@ -0,0 +1,298 @@
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 * as turf from '@turf/turf';
5
+ import VectorSource from 'ol/source/Vector';
6
+ import GeoJSON from 'ol/format/GeoJSON';
7
+ import { Util } from '../core/Util';
8
+
9
+ /**
10
+ * @class Turf
11
+ * @browsernamespace ol.source
12
+ * @category Visualization Turf
13
+ * @classdesc Turf.js 图层源。
14
+ * @modulecategory Overlay
15
+ * @param {Object} opt_options - 参数。
16
+ * @extends {ol.source.Vector}
17
+ * @usage
18
+ */
19
+ export class Turf extends VectorSource {
20
+
21
+ constructor(opt_options) {
22
+ var options = opt_options ? opt_options : {};
23
+
24
+ super({
25
+ attributions: options.attributions || "<span>© turfjs</span> with <span>© SuperMap iClient</span>",
26
+ features: options.features,
27
+ format: options.format,
28
+ extent: options.extent,
29
+ logo: Util.getOlVersion() === '4' ? options.logo : null,
30
+ projection: options.projection,
31
+ wrapX: options.wrapX
32
+ });
33
+ this.turfMap = {
34
+ "Measurement.along": ["line", "distance", "units"],
35
+ "Measurement.area": ["geojson"],
36
+ "Measurement.bbox": ["geojson"],
37
+ "Measurement.bboxPolygon": ["bbox"],
38
+ "Measurement.bearing": ["start", "end", "final"],
39
+ "Measurement.center": ["geojson", "properties"],
40
+ "Measurement.centerOfMass": ["geojson", "properties"],
41
+ "Measurement.centroid": ["geojson", "properties"],
42
+ "Measurement.destination": ["origin", "distance", "bearing", "units"],
43
+ "Measurement.distance": ["from", "to", "units"],
44
+ "Measurement.envelope": ["geojson"],
45
+ "Measurement.length": ["geojson", "units"],
46
+ "Measurement.midpoint": ["point1", "point2"],
47
+ "Measurement.pointOnFeature": ["geojson"],
48
+ "Measurement.polygonTangents": ["point", "polygon"],
49
+ "Measurement.rhumbBearing": ["start", "end", "final"],
50
+ "Measurement.rhumbDestination": ["origin", "distance", "bearing", "units"],
51
+ "Measurement.rhumbDistance": ["from", "to", "units"],
52
+ "Measurement.square": ["bbox"],
53
+ "Measurement.greatCircle": ["start", "end", "properties", "npoints", "offset"],
54
+ "CoordinateMutation.cleanCoords":["geojson","mutate"],
55
+ "CoordinateMutation.flip": ["geojson", "mutate"],
56
+ "CoordinateMutation.rewind": ["geojson", "reverse", "mutate"],
57
+ "CoordinateMutation.round": ["num", "precision"],
58
+ "CoordinateMutation.truncate": ["geojson", "precision", "coordinates", "mutate"],
59
+ "Transformation.bboxClip": ["feature", "bbox"],
60
+ "Transformation.bezierSpline": ["line", "resolution", "sharpness"],
61
+ "Transformation.buffer": ["geojson", "radius", "units", "steps"],
62
+ "Transformation.circle": ["center", "radius", "steps", "units", "properties"],
63
+ "Transformation.clone": ["geojson"],
64
+ "Transformation.concave": ["points", "maxEdge", "units"],
65
+ "Transformation.convex": ["geojson","concavity"],
66
+ "Transformation.difference": ["polygon1", "polygon2"],
67
+ "Transformation.dissolve": ["featureCollection", "propertyName"],
68
+ "Transformation.intersect": ["poly1", "poly2"],
69
+ "Transformation.lineOffset": ["geojson", "distance", "units"],
70
+ "Transformation.simplify": ["feature", "tolerance", "highQuality"],
71
+ "Transformation.tesselate": ["poly"],
72
+ "Transformation.transformRotate": ["geojson", "angle", "pivot", "mutate"],
73
+ "Transformation.transformTranslate": ["geojson", "distance", "direction", "units", "zTranslation", "mutate"],
74
+ "Transformation.transformScale": ["geojson", "factor", "origin", "mutate"],
75
+ "Transformation.union": ["A"],
76
+ "Transformation.voronoi": ["points","bbox"],
77
+ "featureConversion.combine": ["fc"],
78
+ "featureConversion.explode": ["geojson"],
79
+ "featureConversion.flatten": ["geojson"],
80
+ "featureConversion.lineStringToPolygon": ["lines", "properties", "autoComplete", "orderCoords"],
81
+ "featureConversion.polygonize": ["geojson"],
82
+ "featureConversion.polygonToLineString": ["polygon", "properties"],
83
+ "Misc.kinks": ["featureIn"],
84
+ "Misc.lineArc": ["center", "radius", "bearing1", "bearing2", "steps", "units"],
85
+ "Misc.lineChunk": ["geojson", "segmentLength", "units", "reverse"],
86
+ "Misc.lineIntersect": ["line1", "line2"],
87
+ "Misc.lineOverlap": ["line1", "line2"],
88
+ "Misc.lineSegment": ["geojson"],
89
+ "Misc.lineSlice": ["startPt", "stopPt", "line"],
90
+ "Misc.lineSliceAlong": ["line", "startDist", "stopDist", "units"],
91
+ "Misc.lineSplit": ["line", "splitter"],
92
+ "Misc.mask": ["polygon", "mask"],
93
+ "Misc.pointOnLine": ["lines", "pt", "units"],
94
+ "Misc.sector": ["center", "radius", "bearing1", "bearing2", "steps", "units"],
95
+ "Misc.shortestPath": ["start", "end", "obstacles", "units","resolution"],
96
+ "Misc.unkinkPolygon": ["geojson"],
97
+ "Helper.featureCollection": ["features","bbox","id"],
98
+ "Helper.feature": ["geometry", "properties","bbox","id"],
99
+ "Helper.geometryCollection": ["geometries", "properties","bbox","id"],
100
+ "Helper.lineString": ["coordinates", "properties","bbox","id"],
101
+ "Helper.multiLineString": ["coordinates", "properties","bbox","id"],
102
+ "Helper.multiPoint": ["coordinates", "properties","bbox","id"],
103
+ "Helper.multiPolygon": ["coordinates", "properties","bbox","id"],
104
+ "Helper.point": ["coordinates", "properties","bbox","id"],
105
+ "Helper.polygon": ["coordinates", "properties","bbox","id"],
106
+ "Data.sample": ["featurecollection", "num"],
107
+ "Interpolation.interpolate": ["points", "cellSize", "gridType", "property", "units", "weight"],
108
+ "Interpolation.isobands": ["pointGrid", "breaks", "zProperty", "commonProperties","breaksProperties"],
109
+ "Interpolation.isolines": ["pointGrid", "breaks", "zProperty", "commonProperties", "breaksProperties"],
110
+ "Interpolation.planepoint": ["point", "triangle"],
111
+ "Interpolation.tin": ["points", "z"],
112
+ "Joins.pointsWithinPolygon": ["points", "polygons"],
113
+ "Joins.tag": ["points", "polygons", "field", "outField","mask","properties"],
114
+ "Grids.hexGrid": ["bbox", "cellSide", "units", "triangles"],
115
+ "Grids.pointGrid": ["bbox", "cellSide", "units", "mask","properties"],
116
+ "Grids.squareGrid": ["bbox", "cellSide", "units", "mask","properties"],
117
+ "Grids.triangleGrid": ["bbox", "cellSide", "units", "mask","properties"],
118
+ "Classification.nearestPoint": ["targetPoint", "points"],
119
+ "Aggregation.collect": ["polygons", "points", "inProperty", "outProperty"],
120
+ "Aggregation.clustersDbscan": ["points", "maxDistance", "units", "minPoints","mutate"],
121
+ "Aggregation.clustersKmeans": ["points", "numberOfClusters", "mutate"],
122
+ "Meta.coordAll": ["geojson"],
123
+ "Meta.coordEach": ["geojson", "callback", "excludeWrapCoord"],
124
+ "Meta.coordReduce": ["geojson", "callback", "initialValue", "excludeWrapCoord"],
125
+ "Meta.featureEach": ["geojson", "callback"],
126
+ "Meta.featureReduce": ["geojson", "callback", "initialValue"],
127
+ "Meta.flattenEach": ["geojson", "callback"],
128
+ "Meta.flattenReduce": ["geojson", "callback", "initialValue"],
129
+ "Meta.getCoord": ["coord"],
130
+ "Meta.getCoords": ["coords"],
131
+ "Meta.getGeom": ["geojson"],
132
+ "Meta.getGeomType": ["geojson","name"],
133
+ "Meta.geomEach": ["geojson", "callback"],
134
+ "Meta.geomReduce": ["geojson", "callback", "initialValue"],
135
+ "Meta.propEach": ["geojson", "callback"],
136
+ "Meta.propReduce": ["geojson", "callback", "initialValue"],
137
+ "Meta.segmentEach": ["geojson", "callback"],
138
+ "Meta.segmentReduce": ["geojson", "callback", "initialValue"],
139
+ "Meta.getCluster": ["geojson", "filter"],
140
+ "Meta.clusterEach": ["geojson", "property", "callback"],
141
+ "Meta.clusterReduce": ["geojson", "property", "callback", "initialValue"],
142
+ "Assertions.collectionOf": ["featureCollection", "type", "name"],
143
+ "Assertions.containsNumber": ["coordinates"],
144
+ "Assertions.geojsonType": ["value", "type", "name"],
145
+ "Assertions.featureOf": ["feature", "type", "name"],
146
+ "Booleans.booleanClockwise": ["line"],
147
+ "Booleans.booleanContains": ["feature1", "feature2"],
148
+ "Booleans.booleanCrosses": ["feature1", "feature2"],
149
+ "Booleans.booleanDisjoint": ["feature1", "feature2"],
150
+ "Booleans.booleanEqual": ["feature1", "feature2"],
151
+ "Booleans.booleanOverlap": ["feature1", "feature2"],
152
+ "Booleans.booleanParallel": ["feature1", "feature2"],
153
+ "Booleans.booleanPointInPolygon": ["point", "polygon", "ignoreBoundary"],
154
+ "Booleans.booleanPointOnLine": ["point", "linestring", "ignoreEndVertices"],
155
+ "UnitConversion.bearingToAngle": ["bearing"],
156
+ "UnitConversion.convertArea": ["area", "originalUnit", "finalUnit"],
157
+ "UnitConversion.convertLength": ["length", "originalUnit", "finalUnit"],
158
+ "UnitConversion.degreesToradians": ["degrees"],
159
+ "UnitConversion.lengthToRadians": ["distance", "units"],
160
+ "UnitConversion.lengthToDegrees": ["distance", "units"],
161
+ "UnitConversion.radiansToLength": ["radians", "units"],
162
+ "UnitConversion.radiansToDegrees": ["radians"],
163
+ "UnitConversion.toMercator": ["geojson","mutate"],
164
+ "UnitConversion.toWgs84": ["geojson","mutate"]
165
+ };
166
+
167
+ // 5.0.0 及以上版本参数配置
168
+ this.turfOptionMap={
169
+ "Measurement.along": ["line", "distance", {units:""}],
170
+ "Measurement.bboxPolygon": ["bbox",{properties:"",id:""}],
171
+ "Measurement.bearing": ["start", "end", {final:""}],
172
+ "Measurement.center": ["geojson", {properties:""}],
173
+ "Measurement.destination": ["origin", "distance", "bearing", {units:"",properties:""}],
174
+ "Measurement.distance": ["from", "to", {units:""}],
175
+ "Measurement.length": ["geojson", {units:""}],
176
+ "Measurement.rhumbBearing": ["start", "end", {final:""}],
177
+ "Measurement.rhumbDestination": ["origin", "distance", "bearing", {units:"",properties:""}],
178
+ "Measurement.rhumbDistance": ["from", "to", {units:""}],
179
+ "Measurement.greatCircle": ["start", "end", {properties:"", npoints:"", offset:""}],
180
+ "CoordinateMutation.cleanCoords":["geojson",{mutate:""}],
181
+ "CoordinateMutation.flip": ["geojson", {mutate:""}],
182
+ "CoordinateMutation.rewind": ["geojson",{mutate:"",reverse:""}],
183
+ "CoordinateMutation.truncate": ["geojson", {precision:"", coordinates:"", mutate:""}],
184
+ "Transformation.bezierSpline": ["line", {resolution:"", sharpness:""}],
185
+ "Transformation.buffer": ["geojson", "radius", {units:"", steps:""}],
186
+ "Transformation.circle": ["center", "radius", {units:"", steps:"",properties:""}],
187
+ "Transformation.concave": ["points", {maxEdge:"", units:""}],
188
+ "Transformation.convex": ["geojson",{concavity:""}],
189
+ "Transformation.dissolve": ["featureCollection", {propertyName:""}],
190
+ "Transformation.lineOffset": ["geojson", "distance", {units:""}],
191
+ "Transformation.simplify": ["geojson", {tolerance:"", highQuality:""}],
192
+ "Transformation.transformRotate": ["geojson", "angle", {pivot:"", mutate:""}],
193
+ "Transformation.transformTranslate": ["geojson", "distance", "direction", {units:"", zTranslation:"", mutate:""}],
194
+ "Transformation.transformScale": ["geojson", "factor", {origin:"", mutate:""}],
195
+ "Transformation.voronoi": ["points",{bbox:""}],
196
+ "featureConversion.lineStringToPolygon": ["lines",{properties:"", autoComplete:"", orderCoords:""}],
197
+ "featureConversion.polygonToLineString": ["polygon", {properties:""}],
198
+ "Misc.lineArc": ["center", "radius", "bearing1", "bearing2", {steps:"", units:""}],
199
+ "Misc.lineChunk": ["geojson", "segmentLength", {units:"", reverse:""}],
200
+ "Misc.lineOverlap": ["line1", "line2",{tolerance:""}],
201
+ "Misc.lineSliceAlong": ["line", "startDist", "stopDist", {units:""}],
202
+ "Misc.pointOnLine": ["lines", "pt", {units:""}],
203
+ "Misc.sector": ["center", "radius", "bearing1", "bearing2", {units:"",steps:"",properties:""}],
204
+ "Misc.shortestPath": ["start", "end", {obstacles:"", units:"",resolution:""}],
205
+ "Helper.feature": ["geometry", "properties",{bbox:"",id:""}],
206
+ "Helper.geometryCollection": ["geometries", "properties",{bbox:"",id:""}],
207
+ "Helper.lineString": ["coordinates", "properties",{bbox:"",id:""}],
208
+ "Helper.multiLineString": ["coordinates", "properties",{bbox:"",id:""}],
209
+ "Helper.multiPoint": ["coordinates", "properties",{bbox:"",id:""}],
210
+ "Helper.multiPolygon": ["coordinates", "properties",{bbox:"",id:""}],
211
+ "Helper.point": ["coordinates", "properties",{bbox:"",id:""}],
212
+ "Helper.polygon": ["coordinates", "properties",{bbox:"",id:""}],
213
+ "Interpolation.interpolate": ["points", "cellSize", {gridType:"", property:"", units:"", weight:""}],
214
+ "Interpolation.isobands": ["pointGrid", "breaks", {zProperty:"", commonProperties:"",breaksProperties:""}],
215
+ "Interpolation.isolines": ["pointGrid", "breaks", {zProperty:"", commonProperties:"", breaksProperties:""}],
216
+ "Grids.hexGrid": ["bbox", "cellSide", {units:"", triangles:"",properties:"",mask:""}],
217
+ "Grids.pointGrid": ["bbox", "cellSide", {units:"", mask:"",properties:""}],
218
+ "Grids.squareGrid": ["bbox", "cellSide", {units:"", mask:"",properties:""}],
219
+ "Grids.triangleGrid": ["bbox", "cellSide", {units:"", mask:"",properties:""}],
220
+ "Aggregation.clustersDbscan": ["points", "maxDistance", {units:"", minPoints:"",mutate:""}],
221
+ "Aggregation.clustersKmeans": ["points", {numberOfClusters:"", mutate:""}],
222
+ "Booleans.booleanPointInPolygon": ["point", "polygon", {ignoreBoundary:""}],
223
+ "Booleans.booleanPointOnLine": ["point", "linestring", {ignoreEndVertices:""}],
224
+ "UnitConversion.toMercator": ["geojson",{mutate:""}],
225
+ "UnitConversion.toWgs84": ["geojson",{mutate:""}]
226
+ }
227
+
228
+ }
229
+
230
+ /**
231
+ * @function Turf.prototype.process
232
+ * @description 执行 Turf.js 提供的相关空间分析方法。
233
+ * @param {string} type - Turf.js 提供的空间分析方法名。
234
+ * @param {Object} args - Turf.js 提供的空间分析方法对应的参数对象。
235
+ * @param {function} callback - 空间分析完成执行的回调函数,返回执行的结果。
236
+ * @param {boolean} addFeaturesToMap - 是否添加到 Map。
237
+ */
238
+ process(type, args, callback, addFeaturesToMap) {
239
+ var result;
240
+ // 兼容版本4到5
241
+ try{
242
+ result = turf[type.split('.')[1]].apply(this, this.parse(type, args));
243
+ }catch(e){
244
+ result = turf[type.split('.')[1]].apply(this, this.parseOption(type, args));
245
+ }
246
+
247
+ var features = null;
248
+ try {
249
+ features = (new GeoJSON()).readFeatures(result);
250
+ } catch (e) {
251
+ if (callback) {
252
+ callback(result);
253
+ }
254
+ return;
255
+ }
256
+ addFeaturesToMap = addFeaturesToMap == null ? true : addFeaturesToMap;
257
+ if (addFeaturesToMap) {
258
+ this.addFeatures(features);
259
+ }
260
+ if (callback) {
261
+ callback(result);
262
+ }
263
+ }
264
+
265
+ parse(type, args) {
266
+ if (type === 'Transformation.union') {
267
+ return args['A'];
268
+ }
269
+ var result = [];
270
+ var tempArgs = this.turfMap[type];
271
+ if (tempArgs) {
272
+ tempArgs.map(function (key) {
273
+ result.push(args[key]);
274
+ return args[key];
275
+ });
276
+ }
277
+ return result;
278
+ }
279
+
280
+ parseOption(type,args){
281
+ var result = [];
282
+ var tempArgs = this.turfOptionMap[type];
283
+ tempArgs.map(function(key){
284
+ if(key instanceof Object){
285
+ var options = key;
286
+ Object.keys(options).forEach(function(k){
287
+ options[k]=args[k]
288
+ })
289
+ result.push(options);
290
+ }else{
291
+ result.push(args[key])
292
+ }
293
+ return args;
294
+ })
295
+ return result;
296
+ }
297
+
298
+ }
@@ -0,0 +1,123 @@
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 as CommonUtil} from '@supermapgis/iclient-common/commontypes/Util';
5
+ import { ShapeFactory } from '@supermapgis/iclient-common/overlay/feature/ShapeFactory';
6
+ import { ThemeVector } from '@supermapgis/iclient-common/overlay/ThemeVector';
7
+ import {GeoFeature} from './theme/GeoFeature';
8
+
9
+ /**
10
+ * @class Unique
11
+ * @browsernamespace ol.source
12
+ * @category Visualization Theme
13
+ * @classdesc 单值专题图图层源。
14
+ * @modulecategory Overlay
15
+ * @param {string} name - 图层名称。
16
+ * @param {Object} opt_options - 参数。
17
+ * @param {ol.Map} opt_options.map - 当前 Map 对象。
18
+ * @param {string} [opt_options.id] - 专题图层 ID。默认使用 CommonUtil.createUniqueID("themeLayer_") 创建专题图层ID。
19
+ * @param {number} [opt_options.opacity=1] - 图层透明度。
20
+ * @param {string} [opt_options.logo] - Logo(openLayers 5.0.0 及更高版本不再支持此参数)。
21
+ * @param {ol.proj.Projection} [opt_options.projection] - 投影信息。
22
+ * @param {number} [opt_options.ratio=1.5] - 视图比,1 表示画布是地图视口的大小,2 表示地图视口的宽度和高度的两倍,依此类推。必须是1 或更高。
23
+ * @param {Array} [opt_options.resolutions] - 分辨率数组。
24
+ * @param {ol.source.State} [opt_options.state] - 资源状态。
25
+ * @param {string} [opt_options.themeField] - 指定创建专题图字段。
26
+ * @param {Object} [opt_options.style] - 专题图样式。
27
+ * @param {Object} [opt_options.styleGroups] - 各专题类型样式组。
28
+ * @param {boolean} [opt_options.isHoverAble=false] - 是否开启 hover 事件。
29
+ * @param {Object} [opt_options.highlightStyle] - 开启 hover 事件后,触发的样式风格。
30
+ * @param {(string|Object)} [opt_options.attributions='Map Data <span>© <a href='http://support.supermap.com.cn/product/iServer.aspx' target='_blank'>SuperMap iServer</a></span> with <span>© <a href='https://iclient.supermap.io' target='_blank'>SuperMap iClient</a></span>'] - 版权信息。
31
+ * @extends {GeoFeature}
32
+ * @usage
33
+ */
34
+ export class Unique extends GeoFeature {
35
+
36
+ constructor(name, opt_options) {
37
+ super(name, opt_options);
38
+ this.themeField = opt_options.themeField;
39
+ this.style = opt_options.style;
40
+ this.styleGroups = opt_options.styleGroups;
41
+ this.isHoverAble = opt_options.isHoverAble;
42
+ this.highlightStyle = opt_options.highlightStyle;
43
+ }
44
+
45
+ /**
46
+ * @function Unique.prototype.destroy
47
+ * @description 释放资源,将引用资源的属性置空。
48
+ */
49
+ destroy() {
50
+ this.style = null;
51
+ this.themeField = null;
52
+ this.styleGroups = null;
53
+ GeoFeature.prototype.destroy.apply(this, arguments);
54
+ }
55
+
56
+ /**
57
+ * @private
58
+ * @function Unique.prototype.createThematicFeature
59
+ * @description 创建专题要素。
60
+ * @param {Object} feature - 要素。
61
+ */
62
+ createThematicFeature(feature) {
63
+ var style = this.getStyleByData(feature);
64
+ //创建专题要素时的可选参数
65
+ var options = {};
66
+ options.nodesClipPixel = this.nodesClipPixel;
67
+ options.isHoverAble = this.isHoverAble;
68
+ options.isMultiHover = this.isMultiHover;
69
+ options.isClickAble = this.isClickAble;
70
+ options.highlightStyle = ShapeFactory.transformStyle(this.highlightStyle);
71
+ //将数据转为专题要素(ThemeVector)
72
+ var thematicFeature = new ThemeVector(feature, this, ShapeFactory.transformStyle(style), options);
73
+ //直接添加图形到渲染器
74
+ for (var m = 0; m < thematicFeature.shapes.length; m++) {
75
+ this.renderer.addShape(thematicFeature.shapes[m]);
76
+ }
77
+ return thematicFeature;
78
+ }
79
+
80
+ /**
81
+ * @private
82
+ * @function Unique.prototype.getStyleByData
83
+ * @description 根据用户数据(feature)设置专题要素的 Style。
84
+ * @param {Object} fea - 用户要素数据。
85
+ */
86
+ getStyleByData(fea) {
87
+ var style = {};
88
+ var feature = fea;
89
+ style = CommonUtil.copyAttributesWithClip(style, this.style);
90
+ if (this.themeField && this.styleGroups && this.styleGroups.length > 0 && feature.attributes) {
91
+ var tf = this.themeField;
92
+ var Attrs = feature.attributes;
93
+ var Gro = this.styleGroups;
94
+ var isSfInAttrs = false; //指定的 themeField 是否是 feature 的属性字段之一
95
+ var attr = null; //属性值
96
+ for (var property in Attrs) {
97
+ if (tf === property) {
98
+ isSfInAttrs = true;
99
+ attr = Attrs[property];
100
+ break;
101
+ }
102
+ }
103
+ //判断属性值是否属于styleGroups的某一个范围,以便对获取分组 style
104
+ if (isSfInAttrs) {
105
+ for (var i = 0, len = Gro.length; i < len; i++) {
106
+ if ((attr).toString() === ( Gro[i].value).toString()) {
107
+ //feature.style = CommonUtil.copyAttributes(feature.style, this.defaultStyle);
108
+ var sty1 = Gro[i].style;
109
+ style = CommonUtil.copyAttributesWithClip(style, sty1);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ if (feature.style && this.isAllowFeatureStyle === true) {
115
+ style = CommonUtil.copyAttributesWithClip(feature.style);
116
+ }
117
+ return style;
118
+ }
119
+
120
+ canvasFunctionInternal_(extent, resolution, pixelRatio, size, projection) { // eslint-disable-line no-unused-vars
121
+ return GeoFeature.prototype.canvasFunctionInternal_.apply(this, arguments);
122
+ }
123
+ }