@deck.gl/geo-layers 8.9.18 → 8.10.0-alpha.1
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/dist/dist.dev.js +27 -24
- package/dist/es5/h3-layers/h3-cluster-layer.js +1 -1
- package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
- package/dist/es5/h3-layers/h3-hexagon-layer.js +23 -21
- package/dist/es5/h3-layers/h3-hexagon-layer.js.map +1 -1
- package/dist/esm/h3-layers/h3-cluster-layer.js +2 -2
- package/dist/esm/h3-layers/h3-cluster-layer.js.map +1 -1
- package/dist/esm/h3-layers/h3-hexagon-layer.js +15 -13
- package/dist/esm/h3-layers/h3-hexagon-layer.js.map +1 -1
- package/dist.min.js +8 -8
- package/package.json +3 -3
- package/src/h3-layers/h3-cluster-layer.ts +2 -2
- package/src/h3-layers/h3-hexagon-layer.ts +24 -21
- package/typed/h3-layers/h3-hexagon-layer.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@deck.gl/geo-layers",
|
|
3
3
|
"description": "deck.gl layers supporting geospatial use cases and GIS formats",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "8.
|
|
5
|
+
"version": "8.10.0-alpha.1",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@math.gl/culling": "^3.6.2",
|
|
45
45
|
"@math.gl/web-mercator": "^3.6.2",
|
|
46
46
|
"@types/geojson": "^7946.0.8",
|
|
47
|
-
"h3-js": "^
|
|
47
|
+
"h3-js": "^4.1.0",
|
|
48
48
|
"long": "^3.2.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"@loaders.gl/core": "^3.4.2",
|
|
56
56
|
"@luma.gl/core": "^8.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "8a3793449f88140ad1e16da7a190d192904629eb"
|
|
59
59
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {cellsToMultiPolygon, H3IndexInput} from 'h3-js';
|
|
2
2
|
|
|
3
3
|
import {AccessorFunction, createIterable, UpdateParameters, DefaultProps} from '@deck.gl/core';
|
|
4
4
|
import {default as H3HexagonLayer} from './h3-hexagon-layer';
|
|
@@ -45,7 +45,7 @@ export default class H3ClusterLayer<DataT = any, ExtraProps extends {} = {}> ext
|
|
|
45
45
|
for (const object of iterable) {
|
|
46
46
|
objectInfo.index++;
|
|
47
47
|
const hexagons = getHexagons(object, objectInfo);
|
|
48
|
-
const multiPolygon =
|
|
48
|
+
const multiPolygon = cellsToMultiPolygon(hexagons, true);
|
|
49
49
|
|
|
50
50
|
for (const polygon of multiPolygon) {
|
|
51
51
|
polygons.push(this.getSubLayerRow({polygon}, object, objectInfo.index));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
cellToBoundary,
|
|
3
|
+
getResolution,
|
|
4
|
+
cellToLatLng,
|
|
5
|
+
latLngToCell,
|
|
6
|
+
isPentagon,
|
|
7
|
+
gridDistance,
|
|
8
|
+
getHexagonEdgeLengthAvg,
|
|
9
9
|
H3Index
|
|
10
10
|
} from 'h3-js';
|
|
11
11
|
import {lerp} from '@math.gl/core';
|
|
@@ -41,13 +41,13 @@ export function normalizeLongitudes(vertices: number[][], refLng?: number): void
|
|
|
41
41
|
|
|
42
42
|
// scale polygon vertices w.r.t center (hexId)
|
|
43
43
|
export function scalePolygon(hexId: H3Index, vertices: number[][], factor: number): void {
|
|
44
|
-
const [lat, lng] =
|
|
44
|
+
const [lat, lng] = cellToLatLng(hexId);
|
|
45
45
|
const actualCount = vertices.length;
|
|
46
46
|
|
|
47
47
|
// normalize with respect to center
|
|
48
48
|
normalizeLongitudes(vertices, lng);
|
|
49
49
|
|
|
50
|
-
// `
|
|
50
|
+
// `cellToBoundary` returns same array object for first and last vertex (closed polygon),
|
|
51
51
|
// if so skip scaling the last vertex
|
|
52
52
|
const vertexCount = vertices[0] === vertices[actualCount - 1] ? actualCount - 1 : actualCount;
|
|
53
53
|
for (let i = 0; i < vertexCount; i++) {
|
|
@@ -58,12 +58,12 @@ export function scalePolygon(hexId: H3Index, vertices: number[][], factor: numbe
|
|
|
58
58
|
|
|
59
59
|
function getHexagonCentroid(getHexagon, object, objectInfo) {
|
|
60
60
|
const hexagonId = getHexagon(object, objectInfo);
|
|
61
|
-
const [lat, lng] =
|
|
61
|
+
const [lat, lng] = cellToLatLng(hexagonId);
|
|
62
62
|
return [lng, lat];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function h3ToPolygon(hexId: H3Index, coverage: number = 1): number[][] {
|
|
66
|
-
const vertices =
|
|
66
|
+
const vertices = cellToBoundary(hexId, true);
|
|
67
67
|
|
|
68
68
|
if (coverage !== 1) {
|
|
69
69
|
// scale and normalize vertices w.r.t to center
|
|
@@ -199,7 +199,7 @@ export default class H3HexagonLayer<
|
|
|
199
199
|
objectInfo.index++;
|
|
200
200
|
const hexId = this.props.getHexagon(object, objectInfo);
|
|
201
201
|
// Take the resolution of the first hex
|
|
202
|
-
const hexResolution =
|
|
202
|
+
const hexResolution = getResolution(hexId);
|
|
203
203
|
if (resolution < 0) {
|
|
204
204
|
resolution = hexResolution;
|
|
205
205
|
if (!this.props.highPrecision) break;
|
|
@@ -207,7 +207,7 @@ export default class H3HexagonLayer<
|
|
|
207
207
|
hasMultipleRes = true;
|
|
208
208
|
break;
|
|
209
209
|
}
|
|
210
|
-
if (
|
|
210
|
+
if (isPentagon(hexId)) {
|
|
211
211
|
hasPentagon = true;
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
@@ -215,7 +215,7 @@ export default class H3HexagonLayer<
|
|
|
215
215
|
|
|
216
216
|
return {
|
|
217
217
|
resolution,
|
|
218
|
-
edgeLengthKM: resolution >= 0 ?
|
|
218
|
+
edgeLengthKM: resolution >= 0 ? getHexagonEdgeLengthAvg(resolution, 'km') : 0,
|
|
219
219
|
hasMultipleRes,
|
|
220
220
|
hasPentagon
|
|
221
221
|
};
|
|
@@ -245,23 +245,26 @@ export default class H3HexagonLayer<
|
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
247
|
const hex =
|
|
248
|
-
this.props.centerHexagon ||
|
|
248
|
+
this.props.centerHexagon || latLngToCell(viewport.latitude, viewport.longitude, resolution);
|
|
249
249
|
if (centerHex === hex) {
|
|
250
250
|
return;
|
|
251
251
|
}
|
|
252
252
|
if (centerHex) {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
253
|
+
try {
|
|
254
|
+
const distance = gridDistance(centerHex, hex);
|
|
255
|
+
if (distance * edgeLengthKM < UPDATE_THRESHOLD_KM) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
} catch {
|
|
259
|
+
// gridDistance throws if the distance could not be computed
|
|
260
|
+
// due to the two indexes very far apart or on opposite sides of a pentagon.
|
|
258
261
|
}
|
|
259
262
|
}
|
|
260
263
|
|
|
261
264
|
const {unitsPerMeter} = viewport.distanceScales;
|
|
262
265
|
|
|
263
266
|
let vertices = h3ToPolygon(hex);
|
|
264
|
-
const [centerLat, centerLng] =
|
|
267
|
+
const [centerLat, centerLng] = cellToLatLng(hex);
|
|
265
268
|
|
|
266
269
|
const [centerX, centerY] = viewport.projectFlat([centerLng, centerLat]);
|
|
267
270
|
vertices = vertices.map(p => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"h3-hexagon-layer.d.ts","sourceRoot":"","sources":["../../src/h3-layers/h3-hexagon-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,OAAO,EACR,MAAM,OAAO,CAAC;A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