@deck.gl/geo-layers 8.8.0-alpha.5 → 8.8.0-beta.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.
- package/dist/dist.dev.js +32562 -62596
- package/dist/es5/geo-cell-layer/GeoCellLayer.js.map +1 -1
- package/dist/es5/great-circle-layer/great-circle-layer.js +12 -8
- package/dist/es5/great-circle-layer/great-circle-layer.js.map +1 -1
- package/dist/es5/h3-layers/h3-cluster-layer.js +5 -4
- package/dist/es5/h3-layers/h3-cluster-layer.js.map +1 -1
- package/dist/es5/h3-layers/h3-hexagon-layer.js +49 -34
- package/dist/es5/h3-layers/h3-hexagon-layer.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/mesh-layer/mesh-layer-fragment.glsl.js +1 -1
- package/dist/es5/mesh-layer/mesh-layer-vertex.glsl.js +1 -1
- package/dist/es5/mesh-layer/mesh-layer.js +22 -26
- package/dist/es5/mesh-layer/mesh-layer.js.map +1 -1
- package/dist/es5/mvt-layer/mvt-layer.js +6 -3
- package/dist/es5/mvt-layer/mvt-layer.js.map +1 -1
- package/dist/es5/quadkey-layer/quadkey-layer.js.map +1 -1
- package/dist/es5/s2-layer/s2-geometry.js.map +1 -1
- package/dist/es5/s2-layer/s2-layer.js +4 -2
- package/dist/es5/s2-layer/s2-layer.js.map +1 -1
- package/dist/es5/s2-layer/s2-utils.js.map +1 -1
- package/dist/es5/tile-3d-layer/tile-3d-layer.js +31 -16
- package/dist/es5/tile-3d-layer/tile-3d-layer.js.map +1 -1
- package/dist/es5/tile-layer/tile-layer.js +4 -1
- package/dist/es5/tile-layer/tile-layer.js.map +1 -1
- package/dist/es5/tile-layer/tileset-2d.js.map +1 -1
- package/dist/es5/trips-layer/trips-layer.js +9 -7
- package/dist/es5/trips-layer/trips-layer.js.map +1 -1
- package/dist/esm/geo-cell-layer/GeoCellLayer.js.map +1 -1
- package/dist/esm/great-circle-layer/great-circle-layer.js +7 -3
- package/dist/esm/great-circle-layer/great-circle-layer.js.map +1 -1
- package/dist/esm/h3-layers/h3-cluster-layer.js +6 -4
- package/dist/esm/h3-layers/h3-cluster-layer.js.map +1 -1
- package/dist/esm/h3-layers/h3-hexagon-layer.js +38 -24
- package/dist/esm/h3-layers/h3-hexagon-layer.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/mesh-layer/mesh-layer-fragment.glsl.js +1 -1
- package/dist/esm/mesh-layer/mesh-layer-fragment.glsl.js.map +1 -1
- package/dist/esm/mesh-layer/mesh-layer-vertex.glsl.js +1 -1
- package/dist/esm/mesh-layer/mesh-layer-vertex.glsl.js.map +1 -1
- package/dist/esm/mesh-layer/mesh-layer.js +15 -17
- package/dist/esm/mesh-layer/mesh-layer.js.map +1 -1
- package/dist/esm/mvt-layer/mvt-layer.js +6 -3
- package/dist/esm/mvt-layer/mvt-layer.js.map +1 -1
- package/dist/esm/quadkey-layer/quadkey-layer.js.map +1 -1
- package/dist/esm/s2-layer/s2-geometry.js.map +1 -1
- package/dist/esm/s2-layer/s2-layer.js +5 -2
- package/dist/esm/s2-layer/s2-layer.js.map +1 -1
- package/dist/esm/s2-layer/s2-utils.js.map +1 -1
- package/dist/esm/tile-3d-layer/tile-3d-layer.js +21 -10
- package/dist/esm/tile-3d-layer/tile-3d-layer.js.map +1 -1
- package/dist/esm/tile-layer/tile-layer.js +4 -1
- package/dist/esm/tile-layer/tile-layer.js.map +1 -1
- package/dist/esm/tile-layer/tileset-2d.js.map +1 -1
- package/dist/esm/trips-layer/trips-layer.js +8 -5
- package/dist/esm/trips-layer/trips-layer.js.map +1 -1
- package/dist.min.js +2 -2
- package/package.json +17 -15
- package/src/geo-cell-layer/GeoCellLayer.ts +4 -3
- package/src/great-circle-layer/great-circle-layer.ts +40 -0
- package/src/h3-layers/h3-cluster-layer.ts +60 -0
- package/src/h3-layers/{h3-hexagon-layer.js → h3-hexagon-layer.ts} +110 -42
- package/src/index.ts +5 -0
- package/src/mesh-layer/{mesh-layer-fragment.glsl.js → mesh-layer-fragment.glsl.ts} +0 -0
- package/src/mesh-layer/mesh-layer-vertex.glsl.ts +80 -0
- package/src/mesh-layer/{mesh-layer.js → mesh-layer.ts} +46 -13
- package/src/mvt-layer/mvt-layer.ts +5 -3
- package/src/quadkey-layer/quadkey-layer.ts +10 -9
- package/src/s2-layer/{s2-geometry.js → s2-geometry.ts} +17 -9
- package/src/s2-layer/s2-layer.ts +59 -0
- package/src/s2-layer/{s2-utils.js → s2-utils.ts} +14 -7
- package/src/tile-3d-layer/{tile-3d-layer.js → tile-3d-layer.ts} +107 -36
- package/src/tile-layer/tile-layer.ts +8 -7
- package/src/tile-layer/tileset-2d.ts +2 -2
- package/src/trips-layer/{trips-layer.js → trips-layer.ts} +41 -10
- package/typed/geo-cell-layer/GeoCellLayer.d.ts +12 -0
- package/typed/geo-cell-layer/GeoCellLayer.d.ts.map +1 -0
- package/typed/geo-cell-layer/GeoCellLayer.js +49 -0
- package/typed/great-circle-layer/great-circle-layer.d.ts +9 -0
- package/typed/great-circle-layer/great-circle-layer.d.ts.map +1 -0
- package/{src → typed}/great-circle-layer/great-circle-layer.js +5 -7
- package/typed/h3-layers/h3-cluster-layer.d.ts +22 -0
- package/typed/h3-layers/h3-cluster-layer.d.ts.map +1 -0
- package/typed/h3-layers/h3-cluster-layer.js +33 -0
- package/typed/h3-layers/h3-hexagon-layer.d.ts +70 -0
- package/typed/h3-layers/h3-hexagon-layer.d.ts.map +1 -0
- package/typed/h3-layers/h3-hexagon-layer.js +251 -0
- package/typed/index.d.ts +23 -0
- package/typed/index.d.ts.map +1 -0
- package/typed/index.js +33 -0
- package/typed/mesh-layer/mesh-layer-fragment.glsl.d.ts +3 -0
- package/typed/mesh-layer/mesh-layer-fragment.glsl.d.ts.map +1 -0
- package/typed/mesh-layer/mesh-layer-fragment.glsl.js +55 -0
- package/typed/mesh-layer/mesh-layer-vertex.glsl.d.ts +3 -0
- package/typed/mesh-layer/mesh-layer-vertex.glsl.d.ts.map +1 -0
- package/{src → typed}/mesh-layer/mesh-layer-vertex.glsl.js +0 -0
- package/typed/mesh-layer/mesh-layer.d.ts +37 -0
- package/typed/mesh-layer/mesh-layer.d.ts.map +1 -0
- package/typed/mesh-layer/mesh-layer.js +110 -0
- package/typed/mvt-layer/coordinate-transform.d.ts +4 -0
- package/typed/mvt-layer/coordinate-transform.d.ts.map +1 -0
- package/typed/mvt-layer/coordinate-transform.js +41 -0
- package/typed/mvt-layer/find-index-binary.d.ts +12 -0
- package/typed/mvt-layer/find-index-binary.d.ts.map +1 -0
- package/typed/mvt-layer/find-index-binary.js +96 -0
- package/typed/mvt-layer/mvt-layer.d.ts +70 -0
- package/typed/mvt-layer/mvt-layer.d.ts.map +1 -0
- package/typed/mvt-layer/mvt-layer.js +297 -0
- package/typed/package.json +6 -0
- package/typed/quadkey-layer/quadkey-layer.d.ts +20 -0
- package/typed/quadkey-layer/quadkey-layer.d.ts.map +1 -0
- package/typed/quadkey-layer/quadkey-layer.js +18 -0
- package/typed/quadkey-layer/quadkey-utils.d.ts +3 -0
- package/typed/quadkey-layer/quadkey-utils.d.ts.map +1 -0
- package/typed/quadkey-layer/quadkey-utils.js +26 -0
- package/typed/s2-layer/s2-geometry.d.ts +11 -0
- package/typed/s2-layer/s2-geometry.d.ts.map +1 -0
- package/typed/s2-layer/s2-geometry.js +123 -0
- package/typed/s2-layer/s2-layer.d.ts +20 -0
- package/typed/s2-layer/s2-layer.d.ts.map +1 -0
- package/{src → typed}/s2-layer/s2-layer.js +11 -16
- package/typed/s2-layer/s2-utils.d.ts +9 -0
- package/typed/s2-layer/s2-utils.d.ts.map +1 -0
- package/typed/s2-layer/s2-utils.js +88 -0
- package/typed/terrain-layer/terrain-layer.d.ts +28 -0
- package/typed/terrain-layer/terrain-layer.d.ts.map +1 -0
- package/typed/terrain-layer/terrain-layer.js +226 -0
- package/typed/tile-3d-layer/tile-3d-layer.d.ts +60 -0
- package/typed/tile-3d-layer/tile-3d-layer.d.ts.map +1 -0
- package/typed/tile-3d-layer/tile-3d-layer.js +294 -0
- package/typed/tile-layer/tile-2d-header.d.ts +40 -0
- package/typed/tile-layer/tile-2d-header.d.ts.map +1 -0
- package/typed/tile-layer/tile-2d-header.js +113 -0
- package/typed/tile-layer/tile-2d-traversal.d.ts +4 -0
- package/typed/tile-layer/tile-2d-traversal.d.ts.map +1 -0
- package/typed/tile-layer/tile-2d-traversal.js +181 -0
- package/typed/tile-layer/tile-layer.d.ts +118 -0
- package/typed/tile-layer/tile-layer.d.ts.map +1 -0
- package/typed/tile-layer/tile-layer.js +192 -0
- package/typed/tile-layer/tileset-2d.d.ts +88 -0
- package/typed/tile-layer/tileset-2d.d.ts.map +1 -0
- package/typed/tile-layer/tileset-2d.js +399 -0
- package/typed/tile-layer/types.d.ts +29 -0
- package/typed/tile-layer/types.d.ts.map +1 -0
- package/typed/tile-layer/types.js +1 -0
- package/typed/tile-layer/utils.d.ts +37 -0
- package/typed/tile-layer/utils.d.ts.map +1 -0
- package/typed/tile-layer/utils.js +197 -0
- package/typed/trips-layer/trips-layer.d.ts +36 -0
- package/typed/trips-layer/trips-layer.d.ts.map +1 -0
- package/typed/trips-layer/trips-layer.js +92 -0
- package/src/h3-layers/h3-cluster-layer.js +0 -43
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { log, COORDINATE_SYSTEM } from '@deck.gl/core';
|
|
2
|
+
import { GeoJsonLayer } from '@deck.gl/layers';
|
|
3
|
+
import { Matrix4 } from '@math.gl/core';
|
|
4
|
+
import { MVTWorkerLoader } from '@loaders.gl/mvt';
|
|
5
|
+
import { binaryToGeojson } from '@loaders.gl/gis';
|
|
6
|
+
import { ClipExtension } from '@deck.gl/extensions';
|
|
7
|
+
import TileLayer from '../tile-layer/tile-layer';
|
|
8
|
+
import { getURLFromTemplate, isGeoBoundingBox, isURLTemplate } from '../tile-layer/utils';
|
|
9
|
+
import { transform } from './coordinate-transform';
|
|
10
|
+
import findIndexBinary from './find-index-binary';
|
|
11
|
+
const WORLD_SIZE = 512;
|
|
12
|
+
const defaultProps = {
|
|
13
|
+
...GeoJsonLayer.defaultProps,
|
|
14
|
+
uniqueIdProperty: { type: 'string', value: '' },
|
|
15
|
+
highlightedFeatureId: null,
|
|
16
|
+
loaders: [MVTWorkerLoader],
|
|
17
|
+
binary: true
|
|
18
|
+
};
|
|
19
|
+
export default class MVTLayer extends TileLayer {
|
|
20
|
+
initializeState() {
|
|
21
|
+
super.initializeState();
|
|
22
|
+
// GlobeView doesn't work well with binary data
|
|
23
|
+
const binary = this.context.viewport.resolution !== undefined ? false : this.props.binary;
|
|
24
|
+
this.setState({
|
|
25
|
+
binary,
|
|
26
|
+
data: null,
|
|
27
|
+
tileJSON: null
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
get isLoaded() {
|
|
31
|
+
return this.state && this.state.data && this.state.tileset && super.isLoaded;
|
|
32
|
+
}
|
|
33
|
+
updateState({ props, oldProps, context, changeFlags }) {
|
|
34
|
+
if (changeFlags.dataChanged) {
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
36
|
+
this._updateTileData();
|
|
37
|
+
}
|
|
38
|
+
if (this.state?.data) {
|
|
39
|
+
super.updateState({ props, oldProps, context, changeFlags });
|
|
40
|
+
this._setWGS84PropertyForTiles();
|
|
41
|
+
}
|
|
42
|
+
const { highlightColor } = props;
|
|
43
|
+
if (highlightColor !== oldProps.highlightColor && Array.isArray(highlightColor)) {
|
|
44
|
+
this.setState({ highlightColor });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/* eslint-disable complexity */
|
|
48
|
+
async _updateTileData() {
|
|
49
|
+
let data = this.props.data;
|
|
50
|
+
let tileJSON = null;
|
|
51
|
+
if (typeof data === 'string' && !isURLTemplate(data)) {
|
|
52
|
+
const { onDataLoad, fetch } = this.props;
|
|
53
|
+
this.setState({ data: null, tileJSON: null });
|
|
54
|
+
try {
|
|
55
|
+
tileJSON = await fetch(data, { propName: 'data', layer: this, loaders: [] });
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
this.raiseError(error, 'loading TileJSON');
|
|
59
|
+
data = null;
|
|
60
|
+
}
|
|
61
|
+
if (onDataLoad) {
|
|
62
|
+
onDataLoad(tileJSON, { propName: 'data', layer: this });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (data.tilejson) {
|
|
66
|
+
tileJSON = data;
|
|
67
|
+
}
|
|
68
|
+
if (tileJSON) {
|
|
69
|
+
data = tileJSON.tiles;
|
|
70
|
+
}
|
|
71
|
+
this.setState({ data, tileJSON });
|
|
72
|
+
}
|
|
73
|
+
_getTilesetOptions() {
|
|
74
|
+
const opts = super._getTilesetOptions();
|
|
75
|
+
const tileJSON = this.state.tileJSON;
|
|
76
|
+
const { minZoom, maxZoom } = this.props;
|
|
77
|
+
if (tileJSON) {
|
|
78
|
+
if (Number.isFinite(tileJSON.minzoom) && tileJSON.minzoom > minZoom) {
|
|
79
|
+
opts.minZoom = tileJSON.minzoom;
|
|
80
|
+
}
|
|
81
|
+
if (Number.isFinite(tileJSON.maxzoom) &&
|
|
82
|
+
(!Number.isFinite(maxZoom) || tileJSON.maxzoom < maxZoom)) {
|
|
83
|
+
opts.maxZoom = tileJSON.maxzoom;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return opts;
|
|
87
|
+
}
|
|
88
|
+
/* eslint-disable complexity */
|
|
89
|
+
renderLayers() {
|
|
90
|
+
if (!this.state?.data)
|
|
91
|
+
return null;
|
|
92
|
+
return super.renderLayers();
|
|
93
|
+
}
|
|
94
|
+
getTileData(loadProps) {
|
|
95
|
+
const { data, binary } = this.state;
|
|
96
|
+
const { index, signal } = loadProps;
|
|
97
|
+
const url = getURLFromTemplate(data, loadProps);
|
|
98
|
+
if (!url) {
|
|
99
|
+
return Promise.reject('Invalid URL');
|
|
100
|
+
}
|
|
101
|
+
let loadOptions = this.getLoadOptions();
|
|
102
|
+
const { fetch } = this.props;
|
|
103
|
+
loadOptions = {
|
|
104
|
+
...loadOptions,
|
|
105
|
+
mimeType: 'application/x-protobuf',
|
|
106
|
+
mvt: {
|
|
107
|
+
...loadOptions?.mvt,
|
|
108
|
+
coordinates: this.context.viewport.resolution ? 'wgs84' : 'local',
|
|
109
|
+
tileIndex: index
|
|
110
|
+
// Local worker debug
|
|
111
|
+
// workerUrl: `modules/mvt/dist/mvt-loader.worker.js`
|
|
112
|
+
// Set worker to null to skip web workers
|
|
113
|
+
// workerUrl: null
|
|
114
|
+
},
|
|
115
|
+
gis: binary ? { format: 'binary' } : {}
|
|
116
|
+
};
|
|
117
|
+
return fetch(url, { propName: 'data', layer: this, loadOptions, signal });
|
|
118
|
+
}
|
|
119
|
+
renderSubLayers(props) {
|
|
120
|
+
const { x, y, z } = props.tile.index;
|
|
121
|
+
const worldScale = Math.pow(2, z);
|
|
122
|
+
const xScale = WORLD_SIZE / worldScale;
|
|
123
|
+
const yScale = -xScale;
|
|
124
|
+
const xOffset = (WORLD_SIZE * x) / worldScale;
|
|
125
|
+
const yOffset = WORLD_SIZE * (1 - y / worldScale);
|
|
126
|
+
const modelMatrix = new Matrix4().scale([xScale, yScale, 1]);
|
|
127
|
+
props.autoHighlight = false;
|
|
128
|
+
if (!this.context.viewport.resolution) {
|
|
129
|
+
props.modelMatrix = modelMatrix;
|
|
130
|
+
props.coordinateOrigin = [xOffset, yOffset, 0];
|
|
131
|
+
props.coordinateSystem = COORDINATE_SYSTEM.CARTESIAN;
|
|
132
|
+
props.extensions = [...(props.extensions || []), new ClipExtension()];
|
|
133
|
+
}
|
|
134
|
+
const subLayers = super.renderSubLayers(props);
|
|
135
|
+
if (this.state.binary && !(subLayers instanceof GeoJsonLayer)) {
|
|
136
|
+
log.warn('renderSubLayers() must return GeoJsonLayer when using binary:true')();
|
|
137
|
+
}
|
|
138
|
+
return subLayers;
|
|
139
|
+
}
|
|
140
|
+
_updateAutoHighlight(info) {
|
|
141
|
+
const { uniqueIdProperty } = this.props;
|
|
142
|
+
const { hoveredFeatureId, hoveredFeatureLayerName } = this.state;
|
|
143
|
+
const hoveredFeature = info.object;
|
|
144
|
+
let newHoveredFeatureId;
|
|
145
|
+
let newHoveredFeatureLayerName;
|
|
146
|
+
if (hoveredFeature) {
|
|
147
|
+
newHoveredFeatureId = getFeatureUniqueId(hoveredFeature, uniqueIdProperty);
|
|
148
|
+
newHoveredFeatureLayerName = getFeatureLayerName(hoveredFeature);
|
|
149
|
+
}
|
|
150
|
+
let { highlightColor } = this.props;
|
|
151
|
+
if (typeof highlightColor === 'function') {
|
|
152
|
+
highlightColor = highlightColor(info);
|
|
153
|
+
}
|
|
154
|
+
if (hoveredFeatureId !== newHoveredFeatureId ||
|
|
155
|
+
hoveredFeatureLayerName !== newHoveredFeatureLayerName) {
|
|
156
|
+
this.setState({
|
|
157
|
+
highlightColor,
|
|
158
|
+
hoveredFeatureId: newHoveredFeatureId,
|
|
159
|
+
hoveredFeatureLayerName: newHoveredFeatureLayerName
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
getPickingInfo(params) {
|
|
164
|
+
const info = super.getPickingInfo(params);
|
|
165
|
+
const isWGS84 = Boolean(this.context.viewport.resolution);
|
|
166
|
+
if (this.state.binary && info.index !== -1) {
|
|
167
|
+
const { data } = params.sourceLayer.props;
|
|
168
|
+
info.object = binaryToGeojson(data, { globalFeatureId: info.index });
|
|
169
|
+
}
|
|
170
|
+
if (info.object && !isWGS84) {
|
|
171
|
+
info.object = transformTileCoordsToWGS84(info.object, info.tile.bbox, this.context.viewport);
|
|
172
|
+
}
|
|
173
|
+
return info;
|
|
174
|
+
}
|
|
175
|
+
getSubLayerPropsByTile(tile) {
|
|
176
|
+
return {
|
|
177
|
+
highlightedObjectIndex: this.getHighlightedObjectIndex(tile),
|
|
178
|
+
highlightColor: this.state.highlightColor
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
getHighlightedObjectIndex(tile) {
|
|
182
|
+
const { hoveredFeatureId, hoveredFeatureLayerName, binary } = this.state;
|
|
183
|
+
const { uniqueIdProperty, highlightedFeatureId } = this.props;
|
|
184
|
+
const data = tile.content;
|
|
185
|
+
const isHighlighted = isFeatureIdDefined(highlightedFeatureId);
|
|
186
|
+
const isFeatureIdPresent = isFeatureIdDefined(hoveredFeatureId) || isHighlighted;
|
|
187
|
+
if (!isFeatureIdPresent) {
|
|
188
|
+
return -1;
|
|
189
|
+
}
|
|
190
|
+
const featureIdToHighlight = isHighlighted ? highlightedFeatureId : hoveredFeatureId;
|
|
191
|
+
// Iterable data
|
|
192
|
+
if (Array.isArray(data)) {
|
|
193
|
+
return data.findIndex(feature => {
|
|
194
|
+
const isMatchingId = getFeatureUniqueId(feature, uniqueIdProperty) === featureIdToHighlight;
|
|
195
|
+
const isMatchingLayer = isHighlighted || getFeatureLayerName(feature) === hoveredFeatureLayerName;
|
|
196
|
+
return isMatchingId && isMatchingLayer;
|
|
197
|
+
});
|
|
198
|
+
// Non-iterable data
|
|
199
|
+
}
|
|
200
|
+
else if (data && binary) {
|
|
201
|
+
// Get the feature index of the selected item to highlight
|
|
202
|
+
return findIndexBinary(data, uniqueIdProperty, featureIdToHighlight, isHighlighted ? '' : hoveredFeatureLayerName);
|
|
203
|
+
}
|
|
204
|
+
return -1;
|
|
205
|
+
}
|
|
206
|
+
_pickObjects(maxObjects) {
|
|
207
|
+
const { deck, viewport } = this.context;
|
|
208
|
+
const width = viewport.width;
|
|
209
|
+
const height = viewport.height;
|
|
210
|
+
const x = viewport.x;
|
|
211
|
+
const y = viewport.y;
|
|
212
|
+
const layerIds = [this.id];
|
|
213
|
+
return deck.pickObjects({ x, y, width, height, layerIds, maxObjects });
|
|
214
|
+
}
|
|
215
|
+
/** Get the rendered features in the current viewport. */
|
|
216
|
+
getRenderedFeatures(maxFeatures = null) {
|
|
217
|
+
const features = this._pickObjects(maxFeatures);
|
|
218
|
+
const featureCache = new Set();
|
|
219
|
+
const renderedFeatures = [];
|
|
220
|
+
for (const f of features) {
|
|
221
|
+
const featureId = getFeatureUniqueId(f.object, this.props.uniqueIdProperty);
|
|
222
|
+
if (featureId === undefined) {
|
|
223
|
+
// we have no id for the feature, we just add to the list
|
|
224
|
+
renderedFeatures.push(f.object);
|
|
225
|
+
}
|
|
226
|
+
else if (!featureCache.has(featureId)) {
|
|
227
|
+
// Add removing duplicates
|
|
228
|
+
featureCache.add(featureId);
|
|
229
|
+
renderedFeatures.push(f.object);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return renderedFeatures;
|
|
233
|
+
}
|
|
234
|
+
_setWGS84PropertyForTiles() {
|
|
235
|
+
const propName = 'dataInWGS84';
|
|
236
|
+
const tileset = this.state.tileset;
|
|
237
|
+
// @ts-expect-error selectedTiles are always initialized when tile is being processed
|
|
238
|
+
tileset.selectedTiles.forEach((tile) => {
|
|
239
|
+
if (!tile.hasOwnProperty(propName)) {
|
|
240
|
+
// eslint-disable-next-line accessor-pairs
|
|
241
|
+
Object.defineProperty(tile, propName, {
|
|
242
|
+
get: () => {
|
|
243
|
+
// Still loading or encountered an error
|
|
244
|
+
if (!tile.content) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
if (this.state.binary && Array.isArray(tile.content) && !tile.content.length) {
|
|
248
|
+
// TODO: @loaders.gl/mvt returns [] when no content. It should return a valid empty binary.
|
|
249
|
+
// https://github.com/visgl/loaders.gl/pull/1137
|
|
250
|
+
return [];
|
|
251
|
+
}
|
|
252
|
+
const { bbox } = tile;
|
|
253
|
+
if (tile._contentWGS84 === undefined && isGeoBoundingBox(bbox)) {
|
|
254
|
+
// Create a cache to transform only once
|
|
255
|
+
const content = this.state.binary ? binaryToGeojson(tile.content) : tile.content;
|
|
256
|
+
tile._contentWGS84 = content.map(feature => transformTileCoordsToWGS84(feature, bbox, this.context.viewport));
|
|
257
|
+
}
|
|
258
|
+
return tile._contentWGS84;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
MVTLayer.layerName = 'MVTLayer';
|
|
266
|
+
MVTLayer.defaultProps = defaultProps;
|
|
267
|
+
function getFeatureUniqueId(feature, uniqueIdProperty) {
|
|
268
|
+
if (feature.properties && uniqueIdProperty) {
|
|
269
|
+
return feature.properties[uniqueIdProperty];
|
|
270
|
+
}
|
|
271
|
+
if ('id' in feature) {
|
|
272
|
+
return feature.id;
|
|
273
|
+
}
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
function getFeatureLayerName(feature) {
|
|
277
|
+
return feature.properties?.layerName || null;
|
|
278
|
+
}
|
|
279
|
+
function isFeatureIdDefined(value) {
|
|
280
|
+
return value !== undefined && value !== null && value !== '';
|
|
281
|
+
}
|
|
282
|
+
function transformTileCoordsToWGS84(object, bbox, viewport) {
|
|
283
|
+
const feature = {
|
|
284
|
+
...object,
|
|
285
|
+
geometry: {
|
|
286
|
+
type: object.geometry.type
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
// eslint-disable-next-line accessor-pairs
|
|
290
|
+
Object.defineProperty(feature.geometry, 'coordinates', {
|
|
291
|
+
get: () => {
|
|
292
|
+
const wgs84Geom = transform(object.geometry, bbox, viewport);
|
|
293
|
+
return wgs84Geom.coordinates;
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
return feature;
|
|
297
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccessorFunction, DefaultProps } from '@deck.gl/core/typed';
|
|
2
|
+
import GeoCellLayer, { GeoCellLayerProps } from '../geo-cell-layer/GeoCellLayer';
|
|
3
|
+
/** All properties supported by QuadkeyLayer. */
|
|
4
|
+
export declare type QuadkeyLayerProps<DataT = any> = _QuadkeyLayerProps<DataT> & GeoCellLayerProps<DataT>;
|
|
5
|
+
/** Properties added by QuadkeyLayer. */
|
|
6
|
+
declare type _QuadkeyLayerProps<DataT> = {
|
|
7
|
+
/**
|
|
8
|
+
* Called for each data object to retrieve the quadkey string identifier.
|
|
9
|
+
*
|
|
10
|
+
* By default, it reads `quadkey` property of data object.
|
|
11
|
+
*/
|
|
12
|
+
getQuadkey?: AccessorFunction<DataT, string>;
|
|
13
|
+
};
|
|
14
|
+
export default class QuadkeyLayer<DataT = any, ExtraProps = {}> extends GeoCellLayer<DataT, Required<_QuadkeyLayerProps<DataT>> & ExtraProps> {
|
|
15
|
+
static layerName: string;
|
|
16
|
+
static defaultProps: DefaultProps<QuadkeyLayerProps<any>>;
|
|
17
|
+
indexToBounds(): Partial<GeoCellLayer['props']> | null;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=quadkey-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadkey-layer.d.ts","sourceRoot":"","sources":["../../src/quadkey-layer/quadkey-layer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,YAAY,EAAE,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAO/E,gDAAgD;AAChD,oBAAY,iBAAiB,CAAC,KAAK,GAAG,GAAG,IAAI,kBAAkB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAElG,wCAAwC;AACxC,aAAK,kBAAkB,CAAC,KAAK,IAAI;IAC/B;;;;OAIG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,YAAY,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,EAAE,CAAE,SAAQ,YAAY,CAClF,KAAK,EACL,QAAQ,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CACjD;IACC,MAAM,CAAC,SAAS,SAAkB;IAClC,MAAM,CAAC,YAAY,uCAAgB;IAEnC,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI;CAWvD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import GeoCellLayer from '../geo-cell-layer/GeoCellLayer';
|
|
2
|
+
import { getQuadkeyPolygon } from './quadkey-utils';
|
|
3
|
+
const defaultProps = {
|
|
4
|
+
getQuadkey: { type: 'accessor', value: d => d.quadkey }
|
|
5
|
+
};
|
|
6
|
+
export default class QuadkeyLayer extends GeoCellLayer {
|
|
7
|
+
indexToBounds() {
|
|
8
|
+
const { data, getQuadkey } = this.props;
|
|
9
|
+
return {
|
|
10
|
+
data,
|
|
11
|
+
_normalize: false,
|
|
12
|
+
positionFormat: 'XY',
|
|
13
|
+
getPolygon: (x, objectInfo) => getQuadkeyPolygon(getQuadkey(x, objectInfo))
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
QuadkeyLayer.layerName = 'QuadkeyLayer';
|
|
18
|
+
QuadkeyLayer.defaultProps = defaultProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadkey-utils.d.ts","sourceRoot":"","sources":["../../src/quadkey-layer/quadkey-utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAgB1E;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAK3D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { worldToLngLat } from '@math.gl/web-mercator';
|
|
2
|
+
const TILE_SIZE = 512;
|
|
3
|
+
export function quadkeyToWorldBounds(quadkey) {
|
|
4
|
+
let x = 0;
|
|
5
|
+
let y = 0;
|
|
6
|
+
let mask = 1 << quadkey.length;
|
|
7
|
+
const scale = mask / TILE_SIZE;
|
|
8
|
+
for (let i = 0; i < quadkey.length; i++) {
|
|
9
|
+
mask >>= 1;
|
|
10
|
+
const q = parseInt(quadkey[i]);
|
|
11
|
+
if (q % 2)
|
|
12
|
+
x |= mask;
|
|
13
|
+
if (q > 1)
|
|
14
|
+
y |= mask;
|
|
15
|
+
}
|
|
16
|
+
return [
|
|
17
|
+
[x / scale, TILE_SIZE - y / scale],
|
|
18
|
+
[(x + 0.99) / scale, TILE_SIZE - (y + 0.99) / scale]
|
|
19
|
+
];
|
|
20
|
+
}
|
|
21
|
+
export function getQuadkeyPolygon(quadkey) {
|
|
22
|
+
const [topLeft, bottomRight] = quadkeyToWorldBounds(quadkey);
|
|
23
|
+
const [w, n] = worldToLngLat(topLeft);
|
|
24
|
+
const [e, s] = worldToLngLat(bottomRight);
|
|
25
|
+
return [e, n, e, s, w, s, w, n, e, n];
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function IJToST(ij: [number, number], order: number, offsets: [number, number]): [number, number];
|
|
2
|
+
export declare function STToUV(st: [number, number]): [number, number];
|
|
3
|
+
export declare function FaceUVToXYZ(face: number, [u, v]: [number, number]): [number, number, number];
|
|
4
|
+
export declare function XYZToLngLat([x, y, z]: [number, number, number]): [number, number];
|
|
5
|
+
export declare function toHilbertQuadkey(idS: string): string;
|
|
6
|
+
export declare function FromHilbertQuadKey(hilbertQuadkey: string): {
|
|
7
|
+
face: number;
|
|
8
|
+
ij: [number, number];
|
|
9
|
+
level: number;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=s2-geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s2-geometry.d.ts","sourceRoot":"","sources":["../../src/s2-layer/s2-geometry.ts"],"names":[],"mappings":"AAuBA,wBAAgB,MAAM,CACpB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EACpB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GACxB,CAAC,MAAM,EAAE,MAAM,CAAC,CAIlB;AASD,wBAAgB,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAE7D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAiB5F;AAED,wBAAgB,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAKjF;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA0BpD;AAeD,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,MAAM,GAAG;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAoCA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Adapted from s2-geometry
|
|
3
|
+
|
|
4
|
+
ISC License (ISC)
|
|
5
|
+
|
|
6
|
+
Copyright (c) 2012-2016, Jon Atkins <github@jonatkins.com>
|
|
7
|
+
Copyright (c) 2016, AJ ONeal <aj@daplie.com>
|
|
8
|
+
|
|
9
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
12
|
+
*/
|
|
13
|
+
import Long from 'long';
|
|
14
|
+
//
|
|
15
|
+
// Functional Style
|
|
16
|
+
//
|
|
17
|
+
const FACE_BITS = 3;
|
|
18
|
+
const MAX_LEVEL = 30;
|
|
19
|
+
const POS_BITS = 2 * MAX_LEVEL + 1; // 61 (60 bits of data, 1 bit lsb marker)
|
|
20
|
+
const RADIAN_TO_DEGREE = 180 / Math.PI;
|
|
21
|
+
export function IJToST(ij, order, offsets) {
|
|
22
|
+
const maxSize = 1 << order;
|
|
23
|
+
return [(ij[0] + offsets[0]) / maxSize, (ij[1] + offsets[1]) / maxSize];
|
|
24
|
+
}
|
|
25
|
+
function singleSTtoUV(st) {
|
|
26
|
+
if (st >= 0.5) {
|
|
27
|
+
return (1 / 3.0) * (4 * st * st - 1);
|
|
28
|
+
}
|
|
29
|
+
return (1 / 3.0) * (1 - 4 * (1 - st) * (1 - st));
|
|
30
|
+
}
|
|
31
|
+
export function STToUV(st) {
|
|
32
|
+
return [singleSTtoUV(st[0]), singleSTtoUV(st[1])];
|
|
33
|
+
}
|
|
34
|
+
export function FaceUVToXYZ(face, [u, v]) {
|
|
35
|
+
switch (face) {
|
|
36
|
+
case 0:
|
|
37
|
+
return [1, u, v];
|
|
38
|
+
case 1:
|
|
39
|
+
return [-u, 1, v];
|
|
40
|
+
case 2:
|
|
41
|
+
return [-u, -v, 1];
|
|
42
|
+
case 3:
|
|
43
|
+
return [-1, -v, -u];
|
|
44
|
+
case 4:
|
|
45
|
+
return [v, -1, -u];
|
|
46
|
+
case 5:
|
|
47
|
+
return [v, u, -1];
|
|
48
|
+
default:
|
|
49
|
+
throw new Error('Invalid face');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function XYZToLngLat([x, y, z]) {
|
|
53
|
+
const lat = Math.atan2(z, Math.sqrt(x * x + y * y));
|
|
54
|
+
const lng = Math.atan2(y, x);
|
|
55
|
+
return [lng * RADIAN_TO_DEGREE, lat * RADIAN_TO_DEGREE];
|
|
56
|
+
}
|
|
57
|
+
export function toHilbertQuadkey(idS) {
|
|
58
|
+
let bin = Long.fromString(idS, true, 10).toString(2);
|
|
59
|
+
while (bin.length < FACE_BITS + POS_BITS) {
|
|
60
|
+
// eslint-disable-next-line prefer-template
|
|
61
|
+
bin = '0' + bin;
|
|
62
|
+
}
|
|
63
|
+
// MUST come AFTER binstr has been left-padded with '0's
|
|
64
|
+
const lsbIndex = bin.lastIndexOf('1');
|
|
65
|
+
// substr(start, len)
|
|
66
|
+
// substring(start, end) // includes start, does not include end
|
|
67
|
+
const faceB = bin.substring(0, 3);
|
|
68
|
+
// posB will always be a multiple of 2 (or it's invalid)
|
|
69
|
+
const posB = bin.substring(3, lsbIndex);
|
|
70
|
+
const levelN = posB.length / 2;
|
|
71
|
+
const faceS = Long.fromString(faceB, true, 2).toString(10);
|
|
72
|
+
let posS = Long.fromString(posB, true, 2).toString(4);
|
|
73
|
+
while (posS.length < levelN) {
|
|
74
|
+
// eslint-disable-next-line prefer-template
|
|
75
|
+
posS = '0' + posS;
|
|
76
|
+
}
|
|
77
|
+
return `${faceS}/${posS}`;
|
|
78
|
+
}
|
|
79
|
+
function rotateAndFlipQuadrant(n, point, rx, ry) {
|
|
80
|
+
if (ry === 0) {
|
|
81
|
+
if (rx === 1) {
|
|
82
|
+
point[0] = n - 1 - point[0];
|
|
83
|
+
point[1] = n - 1 - point[1];
|
|
84
|
+
}
|
|
85
|
+
const x = point[0];
|
|
86
|
+
point[0] = point[1];
|
|
87
|
+
point[1] = x;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function FromHilbertQuadKey(hilbertQuadkey) {
|
|
91
|
+
const parts = hilbertQuadkey.split('/');
|
|
92
|
+
const face = parseInt(parts[0], 10);
|
|
93
|
+
const position = parts[1];
|
|
94
|
+
const maxLevel = position.length;
|
|
95
|
+
const point = [0, 0];
|
|
96
|
+
let level;
|
|
97
|
+
for (let i = maxLevel - 1; i >= 0; i--) {
|
|
98
|
+
level = maxLevel - i;
|
|
99
|
+
const bit = position[i];
|
|
100
|
+
let rx = 0;
|
|
101
|
+
let ry = 0;
|
|
102
|
+
if (bit === '1') {
|
|
103
|
+
ry = 1;
|
|
104
|
+
}
|
|
105
|
+
else if (bit === '2') {
|
|
106
|
+
rx = 1;
|
|
107
|
+
ry = 1;
|
|
108
|
+
}
|
|
109
|
+
else if (bit === '3') {
|
|
110
|
+
rx = 1;
|
|
111
|
+
}
|
|
112
|
+
const val = Math.pow(2, level - 1);
|
|
113
|
+
rotateAndFlipQuadrant(val, point, rx, ry);
|
|
114
|
+
point[0] += val * rx;
|
|
115
|
+
point[1] += val * ry;
|
|
116
|
+
}
|
|
117
|
+
if (face % 2 === 1) {
|
|
118
|
+
const t = point[0];
|
|
119
|
+
point[0] = point[1];
|
|
120
|
+
point[1] = t;
|
|
121
|
+
}
|
|
122
|
+
return { face, ij: point, level };
|
|
123
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { AccessorFunction, DefaultProps } from '@deck.gl/core/typed';
|
|
2
|
+
import GeoCellLayer, { GeoCellLayerProps } from '../geo-cell-layer/GeoCellLayer';
|
|
3
|
+
/** All properties supported by S2Layer. */
|
|
4
|
+
export declare type S2LayerProps<DataT = any> = _S2LayerProps<DataT> & GeoCellLayerProps<DataT>;
|
|
5
|
+
/** Properties added by S2Layer. */
|
|
6
|
+
declare type _S2LayerProps<DataT> = {
|
|
7
|
+
/**
|
|
8
|
+
* Called for each data object to retrieve the quadkey string identifier.
|
|
9
|
+
*
|
|
10
|
+
* By default, it reads `token` property of data object.
|
|
11
|
+
*/
|
|
12
|
+
getS2Token?: AccessorFunction<DataT, string>;
|
|
13
|
+
};
|
|
14
|
+
export default class S2Layer<DataT = any, ExtraProps = {}> extends GeoCellLayer<DataT, Required<_S2LayerProps<DataT>> & ExtraProps> {
|
|
15
|
+
static layerName: string;
|
|
16
|
+
static defaultProps: DefaultProps<S2LayerProps<any>>;
|
|
17
|
+
indexToBounds(): Partial<GeoCellLayer['props']> | null;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=s2-layer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s2-layer.d.ts","sourceRoot":"","sources":["../../src/s2-layer/s2-layer.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,gBAAgB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAC7D,OAAO,YAAY,EAAE,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AAO/E,2CAA2C;AAC3C,oBAAY,YAAY,CAAC,KAAK,GAAG,GAAG,IAAI,aAAa,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAExF,mCAAmC;AACnC,aAAK,aAAa,CAAC,KAAK,IAAI;IAC1B;;;;OAIG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,OAAO,CAAC,KAAK,GAAG,GAAG,EAAE,UAAU,GAAG,EAAE,CAAE,SAAQ,YAAY,CAC7E,KAAK,EACL,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAC5C;IACC,MAAM,CAAC,SAAS,SAAa;IAC7B,MAAM,CAAC,YAAY,kCAAgB;IAEnC,aAAa,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI;CAUvD"}
|
|
@@ -17,26 +17,21 @@
|
|
|
17
17
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
18
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
19
|
// THE SOFTWARE.
|
|
20
|
-
|
|
21
20
|
import GeoCellLayer from '../geo-cell-layer/GeoCellLayer';
|
|
22
|
-
import {getS2Polygon} from './s2-utils';
|
|
23
|
-
|
|
21
|
+
import { getS2Polygon } from './s2-utils';
|
|
24
22
|
const defaultProps = {
|
|
25
|
-
|
|
23
|
+
getS2Token: { type: 'accessor', value: d => d.token }
|
|
26
24
|
};
|
|
27
|
-
|
|
28
25
|
export default class S2Layer extends GeoCellLayer {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}
|
|
26
|
+
indexToBounds() {
|
|
27
|
+
const { data, getS2Token } = this.props;
|
|
28
|
+
return {
|
|
29
|
+
data,
|
|
30
|
+
_normalize: false,
|
|
31
|
+
positionFormat: 'XY',
|
|
32
|
+
getPolygon: (x, objectInfo) => getS2Polygon(getS2Token(x, objectInfo))
|
|
33
|
+
};
|
|
34
|
+
}
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
S2Layer.layerName = 'S2Layer';
|
|
42
37
|
S2Layer.defaultProps = defaultProps;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function getS2QuadKey(token: string | number): string;
|
|
2
|
+
/**
|
|
3
|
+
* Get a polygon with corner coordinates for an s2 cell
|
|
4
|
+
* @param {*} cell - This can be an S2 key or token
|
|
5
|
+
* @return {Float64Array} - a simple polygon in flat array format: [lng0, lat0, lng1, lat1, ...]
|
|
6
|
+
* - the polygon is closed, i.e. last coordinate is a copy of the first coordinate
|
|
7
|
+
*/
|
|
8
|
+
export declare function getS2Polygon(token: string | number): Float64Array;
|
|
9
|
+
//# sourceMappingURL=s2-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"s2-utils.d.ts","sourceRoot":"","sources":["../../src/s2-layer/s2-utils.ts"],"names":[],"mappings":"AAwFA,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAW3D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,YAAY,CAKjE"}
|