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