@mapgis/webclient-vue-cesium 10.5.5-1 → 10.5.5-6

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 (124) hide show
  1. package/README.md +46 -49
  2. package/dist-libs/webclient-vue-cesium.common.js +191087 -0
  3. package/dist-libs/webclient-vue-cesium.css +1 -1
  4. package/dist-libs/webclient-vue-cesium.umd.js +191097 -0
  5. package/dist-libs/webclient-vue-cesium.umd.min.js +204 -194
  6. package/docs/.vuepress/config.js +47 -46
  7. package/docs/README.md +5 -4
  8. package/docs/api/analysis/Aspect.md +236 -0
  9. package/docs/api/analysis/Contour.md +240 -0
  10. package/docs/api/analysis/CutFill.md +306 -0
  11. package/docs/api/analysis/DynamicSection.md +336 -0
  12. package/docs/api/analysis/Excavate.md +3 -11
  13. package/docs/api/analysis/Flood.md +177 -200
  14. package/docs/api/analysis/HeightLimited.md +7 -4
  15. package/docs/api/analysis/ParticleEffects.md +549 -0
  16. package/docs/api/analysis/Profile.md +464 -0
  17. package/docs/api/analysis/Shadow.md +76 -13
  18. package/docs/api/analysis/Sightline.md +66 -13
  19. package/docs/api/analysis/Skyline.md +144 -29
  20. package/docs/api/analysis/Slope.md +236 -0
  21. package/docs/api/analysis/Viewshed.md +100 -21
  22. package/docs/api/layer/IGServer/IgsDocLayer.md +10 -0
  23. package/docs/api/layer/IGServer/IgsFeatureLayer.md +253 -0
  24. package/docs/api/layer/IGServer/IgsTileLayer.md +11 -0
  25. package/docs/api/layer/OGC/CesiumOgcWmsLayer.md +20 -19
  26. package/docs/api/layer/OGC/Wms.png +0 -0
  27. package/docs/api/layer/marker/DynamicMarker.md +81 -0
  28. package/docs/api/layer/marker/dynamicmarker.png +0 -0
  29. package/docs/api/layer/marker/selects.png +0 -0
  30. package/docs/api/layer/vectortile/vectortile.md +10 -0
  31. package/docs/api/m3d/image/layer_control_1.png +0 -0
  32. package/docs/api/m3d/image/layer_control_2.png +0 -0
  33. package/docs/api/m3d/image/layer_control_3.png +0 -0
  34. package/docs/api/m3d/m3d.md +13 -2
  35. package/docs/api/service/comprehensiveQuery/comprehensiveQuery.md +946 -0
  36. package/docs/api/ui/draw.md +68 -40
  37. package/docs/api/ui/link.md +8 -1
  38. package/docs/api/ui/marker.md +19 -1
  39. package/docs/api/ui/measure.md +82 -10
  40. package/docs/api/ui/table.md +6 -6
  41. package/docs/guide/README.md +26 -23
  42. package/docs/guide/basemap.md +35 -33
  43. package/docs/guide/markers&popups.md +46 -53
  44. package/docs/plugin_components/create_storybook.md +241 -0
  45. package/docs/plugin_components/img.png +0 -0
  46. package/docs/plugin_components/img_1.png +0 -0
  47. package/docs/plugin_components/img_10.png +0 -0
  48. package/docs/plugin_components/img_2.png +0 -0
  49. package/docs/plugin_components/img_3.png +0 -0
  50. package/docs/plugin_components/img_4.png +0 -0
  51. package/docs/plugin_components/img_5.png +0 -0
  52. package/docs/plugin_components/img_6.png +0 -0
  53. package/docs/plugin_components/img_7.png +0 -0
  54. package/docs/plugin_components/img_8.png +0 -0
  55. package/docs/version/diff.md +4 -4
  56. package/docs/version/version.md +81 -0
  57. package/package.json +5 -5
  58. package/src/cdn/cdn_component.js +62 -0
  59. package/src/component.js +20 -2
  60. package/src/components/Analysis/Aspect.vue +318 -0
  61. package/src/components/Analysis/Contour.vue +257 -0
  62. package/src/components/Analysis/CutFill.vue +581 -0
  63. package/src/components/Analysis/DynamicCutting.vue +98 -59
  64. package/src/components/Analysis/DynamicSection.vue +494 -0
  65. package/src/components/Analysis/Excavate.vue +133 -87
  66. package/src/components/Analysis/Flood.vue +395 -487
  67. package/src/components/Analysis/Flood.vue-- +630 -0
  68. package/src/components/Analysis/HeightLimited.vue +66 -47
  69. package/src/components/Analysis/ModelFlatten.vue +2 -2
  70. package/src/components/Analysis/Profile.vue +503 -0
  71. package/src/components/Analysis/Shadow.vue +220 -309
  72. package/src/components/Analysis/Sightline.vue +393 -375
  73. package/src/components/Analysis/SkyLine.vue +283 -93
  74. package/src/components/Analysis/Slope.vue +317 -0
  75. package/src/components/Analysis/Viewshed.vue +806 -373
  76. package/src/components/Analysis/skyline2dChartOptions.js +66 -0
  77. package/src/components/DataSource/Geojson/GeoJsonDataSource.vue +201 -3
  78. package/src/components/Layer/GeoJSON/GeoJsonLayer.vue +345 -0
  79. package/src/components/Layer/IGServer/IgsFeatureLayer.vue +227 -0
  80. package/src/components/Layer/Marker/DynamicMarkerLayer.vue +487 -0
  81. package/src/components/Layer/Marker/Marker3dPro.vue +196 -0
  82. package/src/components/Layer/Marker/Marker3dSetPro.vue +67 -0
  83. package/src/components/Layer/VectorTile/VectorTileLayer.vue +117 -33
  84. package/src/components/Layer/VectorTile/VectorTileOptions.js +1 -1
  85. package/src/components/M3D/3DTilesetOptions.js +23 -1
  86. package/src/components/M3D/G3D.vue +150 -0
  87. package/src/components/M3D/M3d.vue +142 -32
  88. package/src/components/M3D/M3dSet.vue +118 -0
  89. package/src/components/M3D/M3dType.js +24 -0
  90. package/src/components/Overlay/Mapv3dLayer.vue +2 -0
  91. package/src/components/Overlay/ParticleEffects.vue +545 -0
  92. package/src/components/Overlay/mapv/MapvBaseLayer.js +351 -172
  93. package/src/components/Overlay/mapv/MapvLayer.js +372 -324
  94. package/src/components/Overlay/mapv/SuperCluster.js +611 -0
  95. package/src/components/Overlay/themeLayer/heater/CesiumHeater.vue +152 -0
  96. package/src/components/Overlay/themeLayer/heater/MapvHeater.vue +161 -0
  97. package/src/components/UI/Controls/Draw/Draw.vue +320 -92
  98. package/src/components/UI/Controls/Legend/Legend.vue +55 -51
  99. package/src/components/UI/Controls/Link/Link.vue +59 -37
  100. package/src/components/UI/Controls/Measure/Measure.vue +75 -33
  101. package/src/components/UI/Controls/Measure/components/MeasureResult.vue +71 -0
  102. package/src/components/UI/Controls/Measure/components/MeasureSetting.vue +63 -0
  103. package/src/components/UI/Controls/Measure/components/MeasureTool.vue +155 -0
  104. package/src/components/UI/Geojson/Popup.vue +101 -0
  105. package/src/components/UI/Marker/Marker.vue +185 -48
  106. package/src/components/UI/Popup/Popup.vue +21 -64
  107. package/src/components/Utils/common/color-util.js +159 -0
  108. package/src/components/Utils/util.js +311 -231
  109. package/src/components/WebGlobe/manager.js +81 -3
  110. package/src/components/WebGlobe/mixins/withPrivateMethods.js +4 -2
  111. package/src/components/WebGlobe/util.js +173 -0
  112. package/src/components/service/comprehensive-query/ComprehensiveQuery.vue +156 -0
  113. package/src/components/service/comprehensive-query/PlaceNameCesium.vue +102 -0
  114. package/src/components/service/comprehensive-query/util/catalog/document.js +626 -0
  115. package/src/components/service/comprehensive-query/util/feature/arcgis-feature-query.js +448 -0
  116. package/src/components/service/comprehensive-query/util/feature/feature-convert.js +408 -0
  117. package/src/components/service/comprehensive-query/util/feature/feature-edit.js +50 -0
  118. package/src/components/service/comprehensive-query/util/feature/feature-geojson.js +100 -0
  119. package/src/components/service/comprehensive-query/util/feature/feature-query.js +723 -0
  120. package/src/components/service/comprehensive-query/util/feature/feature.js +1 -0
  121. package/src/components/service/comprehensive-query/util/feature/index.js +9 -0
  122. package/src/components/service/comprehensive-query/util/objects/geometry.js +58 -0
  123. package/src/components/Overlay/Mapv.vue +0 -142
  124. package/src/components/Overlay/MapvHeater.vue +0 -98
@@ -0,0 +1,408 @@
1
+ import * as Zondy from "@mapgis/webclient-es6-service";
2
+ import { GeometryExp } from "../objects/geometry";
3
+ class GGeometryPoint {
4
+ constructor(coors, crs) {
5
+ this.coors = [NaN, NaN];
6
+ this.coors = coors;
7
+ this.geoCRS = crs;
8
+ }
9
+ get type() {
10
+ return "Point";
11
+ }
12
+ get coordinates() {
13
+ return this.coors;
14
+ }
15
+ get crs() {
16
+ return this.geoCRS;
17
+ }
18
+ toFeatureGeometry() {
19
+ const [x, y] = this.coordinates;
20
+ const point = new Zondy.Common.GPoint(x, y);
21
+ return new Zondy.Common.FeatureGeometry({ PntGeom: [point] });
22
+ }
23
+ toTangram() {
24
+ const [x, y] = this.coordinates;
25
+ return new Zondy.Common.Point2D(x, y);
26
+ }
27
+ }
28
+ class GGeometryLine {
29
+ constructor(coors, crs) {
30
+ this.coors = [];
31
+ this.coors = coors;
32
+ this.geoCRS = crs;
33
+ }
34
+ get type() {
35
+ return "LineString";
36
+ }
37
+ get coordinates() {
38
+ return this.coors;
39
+ }
40
+ get crs() {
41
+ return this.geoCRS;
42
+ }
43
+ toFeatureGeometry() {
44
+ const coords = this.coordinates.map(([x, y]) => {
45
+ return new Zondy.Common.Point2D(x, y);
46
+ });
47
+ const arc = new Zondy.Common.Arc(coords);
48
+ const anyLine = new Zondy.Common.AnyLine([arc]);
49
+ const gline = new Zondy.Common.GLine(anyLine);
50
+ return new Zondy.Common.FeatureGeometry({ LinGeom: [gline] });
51
+ }
52
+ toTangram() {
53
+ const coords = this.coordinates.map(([x, y]) => {
54
+ return new Zondy.Common.Point2D(x, y);
55
+ });
56
+ return new Zondy.Common.PolyLine(coords);
57
+ }
58
+ }
59
+ class GGeometryPolygon {
60
+ constructor(coors, crs) {
61
+ this.coors = [];
62
+ this.coors = coors;
63
+ this.geoCRS = crs;
64
+ }
65
+ get type() {
66
+ return "Polygon";
67
+ }
68
+ get coordinates() {
69
+ return this.coors;
70
+ }
71
+ get crs() {
72
+ return this.geoCRS;
73
+ }
74
+ toFeatureGeometry() {
75
+ const arcs = this.coordinates.map(line => {
76
+ const coords = line.map(([x, y]) => {
77
+ return new Zondy.Common.Point2D(x, y);
78
+ });
79
+ return new Zondy.Common.Arc(coords);
80
+ });
81
+ const anyLine = new Zondy.Common.AnyLine(arcs);
82
+ const gRegion = new Zondy.Common.GRegion([anyLine]);
83
+ return new Zondy.Common.FeatureGeometry({ RegGeom: [gRegion] });
84
+ }
85
+ toTangram() {
86
+ const coords = this.coordinates[0].map(([x, y]) => {
87
+ return new Zondy.Common.Point2D(x, y);
88
+ });
89
+ return new Zondy.Common.Polygon(coords);
90
+ }
91
+ }
92
+ class GGeometryMultiPolygon {
93
+ constructor(coors, crs) {
94
+ this.coors = [];
95
+ this.coors = coors;
96
+ this.geoCRS = crs;
97
+ }
98
+ get type() {
99
+ return "MultiPolygon";
100
+ }
101
+ get coordinates() {
102
+ return this.coors;
103
+ }
104
+ get crs() {
105
+ return this.geoCRS;
106
+ }
107
+ toFeatureGeometry() {
108
+ const arcs = this.coordinates[0].map(line => {
109
+ const coords = line.map(([x, y]) => {
110
+ return new Zondy.Common.Point2D(x, y);
111
+ });
112
+ return new Zondy.Common.Arc(coords);
113
+ });
114
+ const anyLine = new Zondy.Common.AnyLine(arcs);
115
+ const gRegion = new Zondy.Common.GRegion([anyLine]);
116
+ return new Zondy.Common.FeatureGeometry({ RegGeom: [gRegion] });
117
+ }
118
+ toTangram() {
119
+ const coords = this.coordinates[0][0].map(([x, y]) => {
120
+ return new Zondy.Common.Point2D(x, y);
121
+ });
122
+ return new Zondy.Common.Polygon(coords);
123
+ }
124
+ }
125
+ export default class FeatureConvert {
126
+ /**
127
+ * IGServer数据结构转为GeoJSON数据结构
128
+ * @param igsFeatures
129
+ * @param useAlias 转换后的属性key值是否使用FldAlias,默认使用FldName
130
+ */
131
+ static featureIGSToFeatureGeoJSON(igsFeatures, useAlias) {
132
+ const dataCount =
133
+ igsFeatures.TotalCount > -1
134
+ ? igsFeatures.TotalCount
135
+ : igsFeatures.SFEleArray.length;
136
+ const geojsonFeatures = {
137
+ type: "FeatureCollection",
138
+ features: [],
139
+ dataCount
140
+ };
141
+ if (!igsFeatures.SFEleArray) {
142
+ return geojsonFeatures;
143
+ }
144
+ const tags = igsFeatures.AttStruct.FldName;
145
+ const alias = igsFeatures.AttStruct.FldAlias;
146
+ const fldType = igsFeatures.AttStruct.FldType;
147
+ for (let i = 0; i < igsFeatures.SFEleArray.length; i += 1) {
148
+ const sfele = igsFeatures.SFEleArray[i];
149
+ const { ftype, FID, bound, AttValue, fGeom } = sfele;
150
+ const properties = { fid: FID };
151
+ if (AttValue && tags) {
152
+ for (let a = 0; a < AttValue.length; a += 1) {
153
+ const val = AttValue[a];
154
+ let tag = tags[a];
155
+ if (useAlias) {
156
+ // 如果要求使用别名,那有别名的地方使用别名,没有的使用字段名
157
+ tag = alias && alias[a] && alias[a] !== "" ? alias[a] : tags[a];
158
+ }
159
+ if (
160
+ val !== null &&
161
+ fldType &&
162
+ ["int", "double", "float", "long", "number"].includes(fldType[a])
163
+ ) {
164
+ properties[tag] = Number(val);
165
+ } else {
166
+ properties[tag] = val;
167
+ }
168
+ }
169
+ }
170
+ let coordinates = [];
171
+ let type = "";
172
+ if (ftype === 1) {
173
+ // 点
174
+ if (fGeom.PntGeom) {
175
+ const { Dot } = fGeom.PntGeom[0];
176
+ if (Dot) {
177
+ coordinates = [Dot.x, Dot.y];
178
+ }
179
+ }
180
+ type = "Point";
181
+ } else if (ftype === 2) {
182
+ // 线
183
+ if (fGeom.LinGeom) {
184
+ const { Line } = fGeom.LinGeom[0];
185
+ if (Line) {
186
+ const { Arcs } = Line;
187
+ if (Arcs) {
188
+ const LineDots = Arcs[0].Dots;
189
+ if (LineDots) {
190
+ for (let l = 0; l < LineDots.length; i += 1) {
191
+ const coord = [LineDots[l].x, LineDots[l].y];
192
+ coordinates.push(coord);
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
+ type = "LineString";
199
+ } else if (ftype === 3) {
200
+ // 面
201
+ if (fGeom.RegGeom) {
202
+ const { Rings } = fGeom.RegGeom[0];
203
+ if (Rings) {
204
+ const { Arcs } = Rings[0];
205
+ if (Arcs) {
206
+ for (let p = 0; p < Arcs.length; p += 1) {
207
+ const arc = [];
208
+ const PolygonDots = Arcs[p].Dots;
209
+ if (PolygonDots) {
210
+ for (let d = 0; d < PolygonDots.length; d += 1) {
211
+ const coord = [PolygonDots[d].x, PolygonDots[d].y];
212
+ arc.push(coord);
213
+ }
214
+ coordinates.push(arc);
215
+ }
216
+ }
217
+ }
218
+ }
219
+ }
220
+ type = "Polygon";
221
+ }
222
+ const geometry = {
223
+ type,
224
+ coordinates
225
+ };
226
+ const feature = {
227
+ type: "Feature",
228
+ properties,
229
+ geometry,
230
+ bound: Object.assign({}, bound)
231
+ };
232
+ geojsonFeatures.features.push(feature);
233
+ }
234
+ return geojsonFeatures;
235
+ }
236
+ /**
237
+ * GeoJSON数据结构转IGServer数据结构
238
+ * @param geojsonFeatures
239
+ */
240
+ static featureGeoJSONTofeatureIGS(geojsonFeatures) {
241
+ const FldAlias = [];
242
+ const FldName = [];
243
+ const FldType = [];
244
+ let FldNumber = 0;
245
+ const SFEleArray = [];
246
+ if (geojsonFeatures.features.length > 0) {
247
+ const pro = geojsonFeatures.features[0].properties;
248
+ Object.keys(pro).forEach(key => {
249
+ if (key !== "geoCenter") {
250
+ FldAlias.push(null);
251
+ FldName.push(key);
252
+ FldNumber += 1;
253
+ if (typeof pro[key] === "string") {
254
+ FldType.push("string");
255
+ } else if (typeof pro[key] === "number") {
256
+ FldType.push("double");
257
+ }
258
+ }
259
+ });
260
+ }
261
+ const AttStruct = {
262
+ FldAlias,
263
+ FldName,
264
+ FldNumber,
265
+ FldType
266
+ };
267
+ for (let i = 0; i < geojsonFeatures.features.length; i += 1) {
268
+ const PntGeom = [];
269
+ const LinGeom = [];
270
+ const RegGeom = [];
271
+ let ftype = 0;
272
+ let bound = {};
273
+ const { geometry } = geojsonFeatures.features[i];
274
+ if (geometry.type === "Point") {
275
+ ftype = 1;
276
+ bound = GeometryExp.calculateBound([geometry.coordinates]);
277
+ const Dot = {
278
+ x: geometry.coordinates[0],
279
+ y: geometry.coordinates[1]
280
+ };
281
+ PntGeom.push({
282
+ Dot,
283
+ GID: 0
284
+ });
285
+ } else if (geometry.type === "LineString") {
286
+ ftype = 2;
287
+ bound = GeometryExp.calculateBound(geometry.coordinates);
288
+ const dots = [];
289
+ for (let j = 0; j < geometry.coordinates.length; j += 1) {
290
+ dots.push({
291
+ x: geometry.coordinates[j][0],
292
+ y: geometry.coordinates[j][1]
293
+ });
294
+ }
295
+ LinGeom.push({
296
+ GID: 0,
297
+ Line: {
298
+ Arcs: [
299
+ {
300
+ ArcID: 0,
301
+ Dots: dots
302
+ }
303
+ ]
304
+ }
305
+ });
306
+ } else if (geometry.type === "Polygon") {
307
+ ftype = 3;
308
+ bound = GeometryExp.calculateBound(geometry.coordinates[0]);
309
+ const dots = [];
310
+ for (let j = 0; j < geometry.coordinates[0].length; j += 1) {
311
+ dots.push({
312
+ x: geometry.coordinates[0][j][0],
313
+ y: geometry.coordinates[0][j][1]
314
+ });
315
+ }
316
+ RegGeom.push({
317
+ GID: 0,
318
+ Rings: [
319
+ {
320
+ Arcs: [
321
+ {
322
+ ArcID: 0,
323
+ Dots: dots
324
+ }
325
+ ]
326
+ }
327
+ ]
328
+ });
329
+ }
330
+ const AttValue = [];
331
+ const property = geojsonFeatures.features[i].properties;
332
+ Object.keys(property).forEach(key => {
333
+ if (key !== "geoCenter") {
334
+ AttValue.push(property[key]);
335
+ }
336
+ });
337
+ const data = {
338
+ AttValue,
339
+ FID: i,
340
+ GraphicInfo: {
341
+ AnnInfo: null,
342
+ InfoType: null,
343
+ LinInfo: null,
344
+ PntInfo: null,
345
+ RegInfo: null
346
+ },
347
+ bound,
348
+ fGeom: {
349
+ EntityGeom: [],
350
+ LinGeom,
351
+ PntGeom,
352
+ RegGeom,
353
+ StreamGeom: null,
354
+ SurfaceGeom: []
355
+ },
356
+ ftype
357
+ };
358
+ SFEleArray.push(data);
359
+ }
360
+ const result = {
361
+ AttStruct,
362
+ SFEleArray,
363
+ TotalCount: geojsonFeatures.dataCount || geojsonFeatures.features.length
364
+ };
365
+ const featureSet = new Zondy.Common.FeatureSet(result);
366
+ return featureSet;
367
+ }
368
+ static featureGeoJSONToTangram(obj) {
369
+ const { type } = obj;
370
+ switch (type) {
371
+ case "FeatureCollection":
372
+ return this.toTangram(obj);
373
+ case "Feature":
374
+ return this.featureToTangram(obj);
375
+ default:
376
+ return undefined;
377
+ }
378
+ }
379
+ static toTangram(featureGeoJSON) {
380
+ const { features } = featureGeoJSON;
381
+ return features.map(feature => this.featureToTangram(feature));
382
+ }
383
+ static featureToTangram(gFeature) {
384
+ const { geometry } = gFeature;
385
+ return this.geometryToTangram(geometry);
386
+ }
387
+ static geometryToTangram(gGeometry) {
388
+ const { type, coordinates } = gGeometry;
389
+ let geometry;
390
+ switch (type) {
391
+ case "Point":
392
+ geometry = new GGeometryPoint(coordinates);
393
+ break;
394
+ case "LineString":
395
+ geometry = new GGeometryLine(coordinates);
396
+ break;
397
+ case "Polygon":
398
+ geometry = new GGeometryPolygon(coordinates);
399
+ break;
400
+ case "MultiPolygon":
401
+ geometry = new GGeometryMultiPolygon(coordinates);
402
+ break;
403
+ default:
404
+ throw new Error(`未实现类型:${type}`);
405
+ }
406
+ return geometry.toTangram();
407
+ }
408
+ }
@@ -0,0 +1,50 @@
1
+ import * as Zondy from "@mapgis/webclient-es6-service";
2
+ export default class FeatureEdit {
3
+ /**
4
+ * 要素修改
5
+ * @param {object} params
6
+ * @param {string} params.gdbp gdbp地址
7
+ * @param {string} params.featureSet featureSet对象
8
+ * @param {string|null} params.ip
9
+ * @param {string|null} params.port
10
+ * @param {boolean|null} params.updateAttribute
11
+ * @param {boolean|null} params.updateGeometry
12
+ * @param {boolean|null} params.updateGeomInfo
13
+ */
14
+ update(params) {
15
+ if (!params || !params.gdbp || !params.featureSet) {
16
+ return;
17
+ }
18
+ const tempParams = {};
19
+ tempParams.gdbp = params.gdbp;
20
+ tempParams.featureSet = params.featureSet;
21
+ tempParams.ip = params.ip;
22
+ tempParams.port = params.port;
23
+ tempParams.guid = params.guid || "__readonly_user__";
24
+ tempParams.updateAttribute =
25
+ params.updateAttribute != undefined ? params.updateAttribute : true;
26
+ tempParams.updateGeometry =
27
+ params.updateGeometry != undefined ? params.updateGeometry : true;
28
+ tempParams.updateGeomInfo =
29
+ params.updateGeomInfo != undefined ? params.updateGeomInfo : true;
30
+ const editService = new Zondy.MRFS.EditLayerFeature(tempParams.gdbp, {
31
+ ip: tempParams.ip,
32
+ port: tempParams.port,
33
+ guid: tempParams.guid,
34
+ updateAttribute: tempParams.updateAttribute,
35
+ updateGeometry: tempParams.updateGeometry
36
+ });
37
+ const promise = new Promise((resolve, reject) => {
38
+ editService.update(tempParams.featureSet, data => {
39
+ if (data) {
40
+ resolve(data);
41
+ } else {
42
+ resolve(undefined);
43
+ }
44
+ });
45
+ });
46
+ return promise.then(data => {
47
+ return data;
48
+ });
49
+ }
50
+ }
@@ -0,0 +1,100 @@
1
+ import { GeometryExp } from "../objects/geometry";
2
+ /**
3
+ *
4
+ * @param feature 获取GeoJSON要素的中心点坐标
5
+ */
6
+ export function getGeoJSONFeatureCenter(feature) {
7
+ const { geometry } = feature;
8
+ let center = [];
9
+ switch (geometry.type) {
10
+ case "Point":
11
+ center = geometry.coordinates;
12
+ break;
13
+ case "LineString":
14
+ const a = Math.floor(geometry.coordinates.length / 2);
15
+ center = geometry.coordinates[a];
16
+ break;
17
+ case "Polygon":
18
+ center = GeometryExp.getCenterOfGravityPoint(geometry.coordinates[0]);
19
+ break;
20
+ case "MultiPolygon":
21
+ const coordinates = geometry.coordinates;
22
+ const centers = [];
23
+ for (let i = 0; i < coordinates.length; i += 1) {
24
+ const tempCenter = GeometryExp.getCenterOfGravityPoint(
25
+ coordinates[i][0]
26
+ );
27
+ if (tempCenter) {
28
+ centers.push(tempCenter);
29
+ }
30
+ }
31
+ centers.push(centers[0]);
32
+ center = centers[0];
33
+ if (centers.length === 3) {
34
+ center = [
35
+ (centers[0][0] + centers[1][0]) / 2,
36
+ (centers[0][1] + centers[1][1]) / 2
37
+ ];
38
+ } else if (centers.length > 3) {
39
+ center = GeometryExp.getCenterOfGravityPoint(centers);
40
+ }
41
+ break;
42
+ default:
43
+ break;
44
+ }
45
+ return center;
46
+ }
47
+ /**
48
+ * 获取一组要素的中心
49
+ * @param features
50
+ */
51
+ export function getGeoJSONFeaturesCenter(features) {
52
+ const centers = [];
53
+ for (let i = 0; i < features.length; i += 1) {
54
+ const feature = features[i];
55
+ const featureCenter = getGeoJSONFeatureCenter(feature);
56
+ if (featureCenter.length > 0) {
57
+ centers.push(featureCenter);
58
+ }
59
+ }
60
+ centers.push(centers[0]);
61
+ let center = centers[0];
62
+ if (centers.length === 3) {
63
+ center = [
64
+ (centers[0][0] + centers[1][0]) / 2,
65
+ (centers[0][1] + centers[1][1]) / 2
66
+ ];
67
+ } else if (centers.length > 3) {
68
+ center = GeometryExp.getCenterOfGravityPoint(centers);
69
+ }
70
+ return center;
71
+ }
72
+ /**
73
+ * 获取GeoJSON的外包矩形
74
+ * @param feature GeoJSON的Feature
75
+ */
76
+ export function getGeoJSONFeatureBound(feature) {
77
+ // 获取所有坐标值(0:x,1:y)
78
+ const getNumbers = (coordinates, index) => {
79
+ const obj = coordinates[index];
80
+ if (typeof obj === "number") {
81
+ return [obj];
82
+ }
83
+ if (Array.isArray(coordinates[0])) {
84
+ const arr = coordinates.map(item => getNumbers(item, index));
85
+ return arr.reduce((a, b) => [...a, ...b]);
86
+ }
87
+ return [];
88
+ };
89
+ const {
90
+ geometry: { coordinates }
91
+ } = feature;
92
+ const x = getNumbers(coordinates, 0);
93
+ const y = getNumbers(coordinates, 1);
94
+ return {
95
+ xmin: Math.min(...x),
96
+ ymin: Math.min(...y),
97
+ xmax: Math.max(...x),
98
+ ymax: Math.max(...y)
99
+ };
100
+ }