@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,611 @@
1
+ function sortKD(ids, coords, nodeSize, left, right, depth) {
2
+ if (right - left <= nodeSize) { return; }
3
+
4
+ var m = (left + right) >> 1;
5
+
6
+ select(ids, coords, m, left, right, depth % 2);
7
+
8
+ sortKD(ids, coords, nodeSize, left, m - 1, depth + 1);
9
+ sortKD(ids, coords, nodeSize, m + 1, right, depth + 1);
10
+ }
11
+
12
+ function select(ids, coords, k, left, right, inc) {
13
+
14
+ while (right > left) {
15
+ if (right - left > 600) {
16
+ var n = right - left + 1;
17
+ var m = k - left + 1;
18
+ var z = Math.log(n);
19
+ var s = 0.5 * Math.exp(2 * z / 3);
20
+ var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
21
+ var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
22
+ var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
23
+ select(ids, coords, k, newLeft, newRight, inc);
24
+ }
25
+
26
+ var t = coords[2 * k + inc];
27
+ var i = left;
28
+ var j = right;
29
+
30
+ swapItem(ids, coords, left, k);
31
+ if (coords[2 * right + inc] > t) { swapItem(ids, coords, left, right); }
32
+
33
+ while (i < j) {
34
+ swapItem(ids, coords, i, j);
35
+ i++;
36
+ j--;
37
+ while (coords[2 * i + inc] < t) { i++; }
38
+ while (coords[2 * j + inc] > t) { j--; }
39
+ }
40
+
41
+ if (coords[2 * left + inc] === t) { swapItem(ids, coords, left, j); }
42
+ else {
43
+ j++;
44
+ swapItem(ids, coords, j, right);
45
+ }
46
+
47
+ if (j <= k) { left = j + 1; }
48
+ if (k <= j) { right = j - 1; }
49
+ }
50
+ }
51
+
52
+ function swapItem(ids, coords, i, j) {
53
+ swap(ids, i, j);
54
+ swap(coords, 2 * i, 2 * j);
55
+ swap(coords, 2 * i + 1, 2 * j + 1);
56
+ }
57
+
58
+ function swap(arr, i, j) {
59
+ var tmp = arr[i];
60
+ arr[i] = arr[j];
61
+ arr[j] = tmp;
62
+ }
63
+
64
+ function range(ids, coords, minX, minY, maxX, maxY, nodeSize) {
65
+ var stack = [0, ids.length - 1, 0];
66
+ var result = [];
67
+ var x, y;
68
+
69
+ while (stack.length) {
70
+ var axis = stack.pop();
71
+ var right = stack.pop();
72
+ var left = stack.pop();
73
+
74
+ if (right - left <= nodeSize) {
75
+ for (var i = left; i <= right; i++) {
76
+ x = coords[2 * i];
77
+ y = coords[2 * i + 1];
78
+ if (x >= minX && x <= maxX && y >= minY && y <= maxY) { result.push(ids[i]); }
79
+ }
80
+ continue;
81
+ }
82
+
83
+ var m = Math.floor((left + right) / 2);
84
+
85
+ x = coords[2 * m];
86
+ y = coords[2 * m + 1];
87
+
88
+ if (x >= minX && x <= maxX && y >= minY && y <= maxY) { result.push(ids[m]); }
89
+
90
+ var nextAxis = (axis + 1) % 2;
91
+
92
+ if (axis === 0 ? minX <= x : minY <= y) {
93
+ stack.push(left);
94
+ stack.push(m - 1);
95
+ stack.push(nextAxis);
96
+ }
97
+ if (axis === 0 ? maxX >= x : maxY >= y) {
98
+ stack.push(m + 1);
99
+ stack.push(right);
100
+ stack.push(nextAxis);
101
+ }
102
+ }
103
+
104
+ return result;
105
+ }
106
+
107
+ function within(ids, coords, qx, qy, r, nodeSize) {
108
+ var stack = [0, ids.length - 1, 0];
109
+ var result = [];
110
+ var r2 = r * r;
111
+
112
+ while (stack.length) {
113
+ var axis = stack.pop();
114
+ var right = stack.pop();
115
+ var left = stack.pop();
116
+
117
+ if (right - left <= nodeSize) {
118
+ for (var i = left; i <= right; i++) {
119
+ if (sqDist(coords[2 * i], coords[2 * i + 1], qx, qy) <= r2) { result.push(ids[i]); }
120
+ }
121
+ continue;
122
+ }
123
+
124
+ var m = Math.floor((left + right) / 2);
125
+
126
+ var x = coords[2 * m];
127
+ var y = coords[2 * m + 1];
128
+
129
+ if (sqDist(x, y, qx, qy) <= r2) { result.push(ids[m]); }
130
+
131
+ var nextAxis = (axis + 1) % 2;
132
+
133
+ if (axis === 0 ? qx - r <= x : qy - r <= y) {
134
+ stack.push(left);
135
+ stack.push(m - 1);
136
+ stack.push(nextAxis);
137
+ }
138
+ if (axis === 0 ? qx + r >= x : qy + r >= y) {
139
+ stack.push(m + 1);
140
+ stack.push(right);
141
+ stack.push(nextAxis);
142
+ }
143
+ }
144
+
145
+ return result;
146
+ }
147
+
148
+ function sqDist(ax, ay, bx, by) {
149
+ var dx = ax - bx;
150
+ var dy = ay - by;
151
+ return dx * dx + dy * dy;
152
+ }
153
+
154
+ var defaultGetX = function (p) { return p[0]; };
155
+ var defaultGetY = function (p) { return p[1]; };
156
+
157
+ var KDBush = function KDBush(points, getX, getY, nodeSize, ArrayType) {
158
+ if ( getX === void 0 ) getX = defaultGetX;
159
+ if ( getY === void 0 ) getY = defaultGetY;
160
+ if ( nodeSize === void 0 ) nodeSize = 64;
161
+ if ( ArrayType === void 0 ) ArrayType = Float64Array;
162
+
163
+ this.nodeSize = nodeSize;
164
+ this.points = points;
165
+
166
+ var IndexArrayType = points.length < 65536 ? Uint16Array : Uint32Array;
167
+
168
+ var ids = this.ids = new IndexArrayType(points.length);
169
+ var coords = this.coords = new ArrayType(points.length * 2);
170
+
171
+ for (var i = 0; i < points.length; i++) {
172
+ ids[i] = i;
173
+ coords[2 * i] = getX(points[i]);
174
+ coords[2 * i + 1] = getY(points[i]);
175
+ }
176
+
177
+ sortKD(ids, coords, nodeSize, 0, ids.length - 1, 0);
178
+ };
179
+
180
+ KDBush.prototype.range = function range$1 (minX, minY, maxX, maxY) {
181
+ return range(this.ids, this.coords, minX, minY, maxX, maxY, this.nodeSize);
182
+ };
183
+
184
+ KDBush.prototype.within = function within$1 (x, y, r) {
185
+ return within(this.ids, this.coords, x, y, r, this.nodeSize);
186
+ };
187
+
188
+ var defaultOptions = {
189
+ minZoom: 0, // min zoom to generate clusters on
190
+ maxZoom: 16, // max zoom level to cluster the points on
191
+ minPoints: 2, // minimum points to form a cluster
192
+ radius: 40, // cluster radius in pixels
193
+ extent: 512, // tile extent (radius is calculated relative to it)
194
+ nodeSize: 64, // size of the KD-tree leaf node, affects performance
195
+ log: false, // whether to log timing info
196
+
197
+ // whether to generate numeric ids for input features (in vector tiles)
198
+ generateId: false,
199
+
200
+ // a reduce function for calculating custom cluster properties
201
+ reduce: null, // (accumulated, props) => { accumulated.sum += props.sum; }
202
+
203
+ // properties to use for individual points when running the reducer
204
+ map: function (props) { return props; } // props => ({sum: props.my_value})
205
+ };
206
+
207
+ var Supercluster = function Supercluster(options) {
208
+ this.options = extend(Object.create(defaultOptions), options);
209
+ this.trees = new Array(this.options.maxZoom + 1);
210
+ };
211
+
212
+ Supercluster.prototype.load = function load (points) {
213
+ var ref = this.options;
214
+ var log = ref.log;
215
+ var minZoom = ref.minZoom;
216
+ var maxZoom = ref.maxZoom;
217
+ var nodeSize = ref.nodeSize;
218
+
219
+ if (log) { console.time('total time'); }
220
+
221
+ var timerId = "prepare " + (points.length) + " points";
222
+ if (log) { console.time(timerId); }
223
+
224
+ this.points = points;
225
+
226
+ // generate a cluster object for each point and index input points into a KD-tree
227
+ var clusters = [];
228
+ for (var i = 0; i < points.length; i++) {
229
+ if (!points[i].geometry) { continue; }
230
+ clusters.push(createPointCluster(points[i], i));
231
+ }
232
+ this.trees[maxZoom + 1] = new KDBush(clusters, getX, getY, nodeSize, Float32Array);
233
+
234
+ if (log) { console.timeEnd(timerId); }
235
+
236
+ // cluster points on max zoom, then cluster the results on previous zoom, etc.;
237
+ // results in a cluster hierarchy across zoom levels
238
+ for (var z = maxZoom; z >= minZoom; z--) {
239
+ var now = +Date.now();
240
+
241
+ // create a new set of clusters for the zoom and index them with a KD-tree
242
+ clusters = this._cluster(clusters, z);
243
+ this.trees[z] = new KDBush(clusters, getX, getY, nodeSize, Float32Array);
244
+
245
+ if (log) { console.log('z%d: %d clusters in %dms', z, clusters.length, +Date.now() - now); }
246
+ }
247
+
248
+ if (log) { console.timeEnd('total time'); }
249
+
250
+ return this;
251
+ };
252
+
253
+ Supercluster.prototype.getClusters = function getClusters (bbox, zoom) {
254
+ var minLng = ((bbox[0] + 180) % 360 + 360) % 360 - 180;
255
+ var minLat = Math.max(-90, Math.min(90, bbox[1]));
256
+ var maxLng = bbox[2] === 180 ? 180 : ((bbox[2] + 180) % 360 + 360) % 360 - 180;
257
+ var maxLat = Math.max(-90, Math.min(90, bbox[3]));
258
+
259
+ if (bbox[2] - bbox[0] >= 360) {
260
+ minLng = -180;
261
+ maxLng = 180;
262
+ } else if (minLng > maxLng) {
263
+ var easternHem = this.getClusters([minLng, minLat, 180, maxLat], zoom);
264
+ var westernHem = this.getClusters([-180, minLat, maxLng, maxLat], zoom);
265
+ return easternHem.concat(westernHem);
266
+ }
267
+
268
+ var tree = this.trees[this._limitZoom(zoom)];
269
+ var ids = tree.range(lngX(minLng), latY(maxLat), lngX(maxLng), latY(minLat));
270
+ var clusters = [];
271
+ for (var i = 0, list = ids; i < list.length; i += 1) {
272
+ var id = list[i];
273
+
274
+ var c = tree.points[id];
275
+ clusters.push(c.numPoints ? getClusterJSON(c) : this.points[c.index]);
276
+ }
277
+ return clusters;
278
+ };
279
+
280
+ Supercluster.prototype.getChildren = function getChildren (clusterId) {
281
+ var originId = this._getOriginId(clusterId);
282
+ var originZoom = this._getOriginZoom(clusterId);
283
+ var errorMsg = 'No cluster with the specified id.';
284
+
285
+ var index = this.trees[originZoom];
286
+ if (!index) { throw new Error(errorMsg); }
287
+
288
+ var origin = index.points[originId];
289
+ if (!origin) { throw new Error(errorMsg); }
290
+
291
+ var r = this.options.radius / (this.options.extent * Math.pow(2, originZoom - 1));
292
+ var ids = index.within(origin.x, origin.y, r);
293
+ var children = [];
294
+ for (var i = 0, list = ids; i < list.length; i += 1) {
295
+ var id = list[i];
296
+
297
+ var c = index.points[id];
298
+ if (c.parentId === clusterId) {
299
+ children.push(c.numPoints ? getClusterJSON(c) : this.points[c.index]);
300
+ }
301
+ }
302
+
303
+ if (children.length === 0) { throw new Error(errorMsg); }
304
+
305
+ return children;
306
+ };
307
+
308
+ Supercluster.prototype.getLeaves = function getLeaves (clusterId, limit, offset) {
309
+ limit = limit || 10;
310
+ offset = offset || 0;
311
+
312
+ var leaves = [];
313
+ this._appendLeaves(leaves, clusterId, limit, offset, 0);
314
+
315
+ return leaves;
316
+ };
317
+
318
+ Supercluster.prototype.getTile = function getTile (z, x, y) {
319
+ var tree = this.trees[this._limitZoom(z)];
320
+ var z2 = Math.pow(2, z);
321
+ var ref = this.options;
322
+ var extent = ref.extent;
323
+ var radius = ref.radius;
324
+ var p = radius / extent;
325
+ var top = (y - p) / z2;
326
+ var bottom = (y + 1 + p) / z2;
327
+
328
+ var tile = {
329
+ features: []
330
+ };
331
+
332
+ this._addTileFeatures(
333
+ tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom),
334
+ tree.points, x, y, z2, tile);
335
+
336
+ if (x === 0) {
337
+ this._addTileFeatures(
338
+ tree.range(1 - p / z2, top, 1, bottom),
339
+ tree.points, z2, y, z2, tile);
340
+ }
341
+ if (x === z2 - 1) {
342
+ this._addTileFeatures(
343
+ tree.range(0, top, p / z2, bottom),
344
+ tree.points, -1, y, z2, tile);
345
+ }
346
+
347
+ return tile.features.length ? tile : null;
348
+ };
349
+
350
+ Supercluster.prototype.getClusterExpansionZoom = function getClusterExpansionZoom (clusterId) {
351
+ var expansionZoom = this._getOriginZoom(clusterId) - 1;
352
+ while (expansionZoom <= this.options.maxZoom) {
353
+ var children = this.getChildren(clusterId);
354
+ expansionZoom++;
355
+ if (children.length !== 1) { break; }
356
+ clusterId = children[0].properties.cluster_id;
357
+ }
358
+ return expansionZoom;
359
+ };
360
+
361
+ Supercluster.prototype._appendLeaves = function _appendLeaves (result, clusterId, limit, offset, skipped) {
362
+ var children = this.getChildren(clusterId);
363
+
364
+ for (var i = 0, list = children; i < list.length; i += 1) {
365
+ var child = list[i];
366
+
367
+ var props = child.properties;
368
+
369
+ if (props && props.cluster) {
370
+ if (skipped + props.point_count <= offset) {
371
+ // skip the whole cluster
372
+ skipped += props.point_count;
373
+ } else {
374
+ // enter the cluster
375
+ skipped = this._appendLeaves(result, props.cluster_id, limit, offset, skipped);
376
+ // exit the cluster
377
+ }
378
+ } else if (skipped < offset) {
379
+ // skip a single point
380
+ skipped++;
381
+ } else {
382
+ // add a single point
383
+ result.push(child);
384
+ }
385
+ if (result.length === limit) { break; }
386
+ }
387
+
388
+ return skipped;
389
+ };
390
+
391
+ Supercluster.prototype._addTileFeatures = function _addTileFeatures (ids, points, x, y, z2, tile) {
392
+ for (var i$1 = 0, list = ids; i$1 < list.length; i$1 += 1) {
393
+ var i = list[i$1];
394
+
395
+ var c = points[i];
396
+ var isCluster = c.numPoints;
397
+ var f = {
398
+ type: 1,
399
+ geometry: [[
400
+ Math.round(this.options.extent * (c.x * z2 - x)),
401
+ Math.round(this.options.extent * (c.y * z2 - y))
402
+ ]],
403
+ tags: isCluster ? getClusterProperties(c) : this.points[c.index].properties
404
+ };
405
+
406
+ // assign id
407
+ var id = (void 0);
408
+ if (isCluster) {
409
+ id = c.id;
410
+ } else if (this.options.generateId) {
411
+ // optionally generate id
412
+ id = c.index;
413
+ } else if (this.points[c.index].id) {
414
+ // keep id if already assigned
415
+ id = this.points[c.index].id;
416
+ }
417
+
418
+ if (id !== undefined) { f.id = id; }
419
+
420
+ tile.features.push(f);
421
+ }
422
+ };
423
+
424
+ Supercluster.prototype._limitZoom = function _limitZoom (z) {
425
+ return Math.max(this.options.minZoom, Math.min(+z, this.options.maxZoom + 1));
426
+ };
427
+
428
+ Supercluster.prototype._cluster = function _cluster (points, zoom) {
429
+ var clusters = [];
430
+ var ref = this.options;
431
+ var radius = ref.radius;
432
+ var extent = ref.extent;
433
+ var reduce = ref.reduce;
434
+ var minPoints = ref.minPoints;
435
+ var r = radius / (extent * Math.pow(2, zoom));
436
+
437
+ // loop through each point
438
+ for (var i = 0; i < points.length; i++) {
439
+ var p = points[i];
440
+ // if we've already visited the point at this zoom level, skip it
441
+ if (p.zoom <= zoom) { continue; }
442
+ p.zoom = zoom;
443
+
444
+ // find all nearby points
445
+ var tree = this.trees[zoom + 1];
446
+ var neighborIds = tree.within(p.x, p.y, r);
447
+
448
+ var numPointsOrigin = p.numPoints || 1;
449
+ var numPoints = numPointsOrigin;
450
+
451
+ // count the number of points in a potential cluster
452
+ for (var i$1 = 0, list = neighborIds; i$1 < list.length; i$1 += 1) {
453
+ var neighborId = list[i$1];
454
+
455
+ var b = tree.points[neighborId];
456
+ // filter out neighbors that are already processed
457
+ if (b.zoom > zoom) { numPoints += b.numPoints || 1; }
458
+ }
459
+
460
+ if (numPoints >= minPoints) { // enough points to form a cluster
461
+ var wx = p.x * numPointsOrigin;
462
+ var wy = p.y * numPointsOrigin;
463
+
464
+ var clusterProperties = reduce && numPointsOrigin > 1 ? this._map(p, true) : null;
465
+
466
+ // encode both zoom and point index on which the cluster originated -- offset by total length of features
467
+ var id = (i << 5) + (zoom + 1) + this.points.length;
468
+
469
+ for (var i$2 = 0, list$1 = neighborIds; i$2 < list$1.length; i$2 += 1) {
470
+ var neighborId$1 = list$1[i$2];
471
+
472
+ var b$1 = tree.points[neighborId$1];
473
+
474
+ if (b$1.zoom <= zoom) { continue; }
475
+ b$1.zoom = zoom; // save the zoom (so it doesn't get processed twice)
476
+
477
+ var numPoints2 = b$1.numPoints || 1;
478
+ wx += b$1.x * numPoints2; // accumulate coordinates for calculating weighted center
479
+ wy += b$1.y * numPoints2;
480
+
481
+ b$1.parentId = id;
482
+
483
+ if (reduce) {
484
+ if (!clusterProperties) { clusterProperties = this._map(p, true); }
485
+ reduce(clusterProperties, this._map(b$1));
486
+ }
487
+ }
488
+
489
+ p.parentId = id;
490
+ clusters.push(createCluster(wx / numPoints, wy / numPoints, id, numPoints, clusterProperties));
491
+
492
+ } else { // left points as unclustered
493
+ clusters.push(p);
494
+
495
+ if (numPoints > 1) {
496
+ for (var i$3 = 0, list$2 = neighborIds; i$3 < list$2.length; i$3 += 1) {
497
+ var neighborId$2 = list$2[i$3];
498
+
499
+ var b$2 = tree.points[neighborId$2];
500
+ if (b$2.zoom <= zoom) { continue; }
501
+ b$2.zoom = zoom;
502
+ clusters.push(b$2);
503
+ }
504
+ }
505
+ }
506
+ }
507
+
508
+ return clusters;
509
+ };
510
+
511
+ // get index of the point from which the cluster originated
512
+ Supercluster.prototype._getOriginId = function _getOriginId (clusterId) {
513
+ return (clusterId - this.points.length) >> 5;
514
+ };
515
+
516
+ // get zoom of the point from which the cluster originated
517
+ Supercluster.prototype._getOriginZoom = function _getOriginZoom (clusterId) {
518
+ return (clusterId - this.points.length) % 32;
519
+ };
520
+
521
+ Supercluster.prototype._map = function _map (point, clone) {
522
+ if (point.numPoints) {
523
+ return clone ? extend({}, point.properties) : point.properties;
524
+ }
525
+ var original = this.points[point.index].properties;
526
+ var result = this.options.map(original);
527
+ return clone && result === original ? extend({}, result) : result;
528
+ };
529
+
530
+ function createCluster(x, y, id, numPoints, properties) {
531
+ return {
532
+ x: x, // weighted cluster center
533
+ y: y,
534
+ zoom: Infinity, // the last zoom the cluster was processed at
535
+ id: id, // encodes index of the first child of the cluster and its zoom level
536
+ parentId: -1, // parent cluster id
537
+ numPoints: numPoints,
538
+ properties: properties
539
+ };
540
+ }
541
+
542
+ function createPointCluster(p, id) {
543
+ var ref = p.geometry.coordinates;
544
+ var x = ref[0];
545
+ var y = ref[1];
546
+ return {
547
+ x: lngX(x), // projected point coordinates
548
+ y: latY(y),
549
+ zoom: Infinity, // the last zoom the point was processed at
550
+ index: id, // index of the source feature in the original input array,
551
+ parentId: -1 // parent cluster id
552
+ };
553
+ }
554
+
555
+ function getClusterJSON(cluster) {
556
+ return {
557
+ type: 'Feature',
558
+ id: cluster.id,
559
+ properties: getClusterProperties(cluster),
560
+ geometry: {
561
+ type: 'Point',
562
+ coordinates: [xLng(cluster.x), yLat(cluster.y)]
563
+ }
564
+ };
565
+ }
566
+
567
+ function getClusterProperties(cluster) {
568
+ var count = cluster.numPoints;
569
+ var abbrev =
570
+ count >= 10000 ? ((Math.round(count / 1000)) + "k") :
571
+ count >= 1000 ? ((Math.round(count / 100) / 10) + "k") : count;
572
+ return extend(extend({}, cluster.properties), {
573
+ cluster: true,
574
+ cluster_id: cluster.id,
575
+ point_count: count,
576
+ point_count_abbreviated: abbrev
577
+ });
578
+ }
579
+
580
+ // longitude/latitude to spherical mercator in [0..1] range
581
+ function lngX(lng) {
582
+ return lng / 360 + 0.5;
583
+ }
584
+ function latY(lat) {
585
+ var sin = Math.sin(lat * Math.PI / 180);
586
+ var y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);
587
+ return y < 0 ? 0 : y > 1 ? 1 : y;
588
+ }
589
+
590
+ // spherical mercator to longitude/latitude
591
+ function xLng(x) {
592
+ return (x - 0.5) * 360;
593
+ }
594
+ function yLat(y) {
595
+ var y2 = (180 - y * 360) * Math.PI / 180;
596
+ return 360 * Math.atan(Math.exp(y2)) / Math.PI - 90;
597
+ }
598
+
599
+ function extend(dest, src) {
600
+ for (var id in src) { dest[id] = src[id]; }
601
+ return dest;
602
+ }
603
+
604
+ function getX(p) {
605
+ return p.x;
606
+ }
607
+ function getY(p) {
608
+ return p.y;
609
+ }
610
+
611
+ export default Supercluster;