@deck.gl/geo-layers 8.9.4 → 8.9.5
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.min.js +1 -1
- package/package.json +2 -2
- package/typed/tile-layer/tileset-2d.d.ts.map +1 -1
- package/typed/tile-layer/utils.d.ts +1 -1
- package/typed/tile-layer/utils.d.ts.map +1 -1
- package/typed/geo-cell-layer/GeoCellLayer.js +0 -49
- package/typed/great-circle-layer/great-circle-layer.js +0 -29
- package/typed/h3-layers/h3-cluster-layer.js +0 -33
- package/typed/h3-layers/h3-hexagon-layer.js +0 -251
- package/typed/imagery-layer/imagery-layer.d.ts +0 -53
- package/typed/imagery-layer/imagery-layer.d.ts.map +0 -1
- package/typed/index.js +0 -33
- package/typed/mesh-layer/mesh-layer-fragment.glsl.js +0 -55
- package/typed/mesh-layer/mesh-layer-vertex.glsl.js +0 -80
- package/typed/mesh-layer/mesh-layer.js +0 -110
- package/typed/mvt-layer/coordinate-transform.js +0 -41
- package/typed/mvt-layer/find-index-binary.js +0 -96
- package/typed/mvt-layer/mvt-layer.js +0 -297
- package/typed/quadkey-layer/quadkey-layer.js +0 -18
- package/typed/quadkey-layer/quadkey-utils.js +0 -26
- package/typed/s2-layer/s2-geometry.js +0 -123
- package/typed/s2-layer/s2-layer.js +0 -37
- package/typed/s2-layer/s2-utils.js +0 -88
- package/typed/terrain-layer/terrain-layer.js +0 -226
- package/typed/tile-3d-layer/tile-3d-layer.js +0 -294
- package/typed/tile-layer/tile-2d-header.js +0 -113
- package/typed/tile-layer/tile-2d-traversal.js +0 -181
- package/typed/tile-layer/tile-layer.js +0 -192
- package/typed/tile-layer/tileset-2d.js +0 -399
- package/typed/tile-layer/types.js +0 -1
- package/typed/tile-layer/utils.js +0 -197
- package/typed/trips-layer/trips-layer.js +0 -92
package/typed/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2015 - 2017 Uber Technologies, Inc.
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
-
// THE SOFTWARE.
|
|
20
|
-
/* eslint-disable max-len */
|
|
21
|
-
export { default as GreatCircleLayer } from './great-circle-layer/great-circle-layer';
|
|
22
|
-
export { default as S2Layer } from './s2-layer/s2-layer';
|
|
23
|
-
export { default as QuadkeyLayer } from './quadkey-layer/quadkey-layer';
|
|
24
|
-
export { default as TileLayer } from './tile-layer/tile-layer';
|
|
25
|
-
export { default as TripsLayer } from './trips-layer/trips-layer';
|
|
26
|
-
export { default as H3ClusterLayer } from './h3-layers/h3-cluster-layer';
|
|
27
|
-
export { default as H3HexagonLayer } from './h3-layers/h3-hexagon-layer';
|
|
28
|
-
export { default as Tile3DLayer } from './tile-3d-layer/tile-3d-layer';
|
|
29
|
-
export { default as TerrainLayer } from './terrain-layer/terrain-layer';
|
|
30
|
-
export { default as MVTLayer } from './mvt-layer/mvt-layer';
|
|
31
|
-
export { getURLFromTemplate as _getURLFromTemplate } from './tile-layer/utils';
|
|
32
|
-
export { default as _Tileset2D } from './tile-layer/tileset-2d';
|
|
33
|
-
export { default as _Tile2DHeader } from './tile-layer/tile-2d-header';
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export default `#version 300 es
|
|
2
|
-
#define SHADER_NAME simple-mesh-layer-fs
|
|
3
|
-
|
|
4
|
-
precision highp float;
|
|
5
|
-
|
|
6
|
-
uniform bool hasTexture;
|
|
7
|
-
uniform sampler2D sampler;
|
|
8
|
-
uniform bool flatShading;
|
|
9
|
-
uniform float opacity;
|
|
10
|
-
|
|
11
|
-
in vec2 vTexCoord;
|
|
12
|
-
in vec3 cameraPosition;
|
|
13
|
-
in vec3 normals_commonspace;
|
|
14
|
-
in vec4 position_commonspace;
|
|
15
|
-
in vec4 vColor;
|
|
16
|
-
|
|
17
|
-
out vec4 fragColor;
|
|
18
|
-
|
|
19
|
-
void main(void) {
|
|
20
|
-
|
|
21
|
-
#ifdef MODULE_PBR
|
|
22
|
-
|
|
23
|
-
fragColor = vColor * pbr_filterColor(vec4(0));
|
|
24
|
-
geometry.uv = pbr_vUV;
|
|
25
|
-
fragColor.a *= opacity;
|
|
26
|
-
|
|
27
|
-
#else
|
|
28
|
-
|
|
29
|
-
geometry.uv = vTexCoord;
|
|
30
|
-
|
|
31
|
-
vec3 normal;
|
|
32
|
-
if (flatShading) {
|
|
33
|
-
|
|
34
|
-
// NOTE(Tarek): This is necessary because
|
|
35
|
-
// headless.gl reports the extension as
|
|
36
|
-
// available but does not support it in
|
|
37
|
-
// the shader.
|
|
38
|
-
#ifdef DERIVATIVES_AVAILABLE
|
|
39
|
-
normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
|
|
40
|
-
#else
|
|
41
|
-
normal = vec3(0.0, 0.0, 1.0);
|
|
42
|
-
#endif
|
|
43
|
-
} else {
|
|
44
|
-
normal = normals_commonspace;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;
|
|
48
|
-
vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
|
|
49
|
-
fragColor = vec4(lightColor, color.a * opacity);
|
|
50
|
-
|
|
51
|
-
#endif
|
|
52
|
-
|
|
53
|
-
DECKGL_FILTER_COLOR(fragColor, geometry);
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
export default `#version 300 es
|
|
2
|
-
#define SHADER_NAME simple-mesh-layer-vs
|
|
3
|
-
|
|
4
|
-
// Scale the model
|
|
5
|
-
uniform float sizeScale;
|
|
6
|
-
uniform bool composeModelMatrix;
|
|
7
|
-
uniform bool u_pickFeatureIds;
|
|
8
|
-
|
|
9
|
-
// Primitive attributes
|
|
10
|
-
in vec3 positions;
|
|
11
|
-
in vec3 normals;
|
|
12
|
-
in vec3 colors;
|
|
13
|
-
in vec2 texCoords;
|
|
14
|
-
in vec4 uvRegions;
|
|
15
|
-
in vec3 featureIdsPickingColors;
|
|
16
|
-
|
|
17
|
-
// Instance attributes
|
|
18
|
-
in vec4 instanceColors;
|
|
19
|
-
in vec3 instancePickingColors;
|
|
20
|
-
in mat3 instanceModelMatrix;
|
|
21
|
-
|
|
22
|
-
// Outputs to fragment shader
|
|
23
|
-
out vec2 vTexCoord;
|
|
24
|
-
out vec3 cameraPosition;
|
|
25
|
-
out vec3 normals_commonspace;
|
|
26
|
-
out vec4 position_commonspace;
|
|
27
|
-
out vec4 vColor;
|
|
28
|
-
|
|
29
|
-
vec2 applyUVRegion(vec2 uv) {
|
|
30
|
-
#ifdef HAS_UV_REGIONS
|
|
31
|
-
// https://github.com/Esri/i3s-spec/blob/master/docs/1.7/geometryUVRegion.cmn.md
|
|
32
|
-
return fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;
|
|
33
|
-
#else
|
|
34
|
-
return uv;
|
|
35
|
-
#endif
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
void main(void) {
|
|
39
|
-
vec2 uv = applyUVRegion(texCoords);
|
|
40
|
-
geometry.uv = uv;
|
|
41
|
-
|
|
42
|
-
if (u_pickFeatureIds) {
|
|
43
|
-
geometry.pickingColor = featureIdsPickingColors;
|
|
44
|
-
} else {
|
|
45
|
-
geometry.pickingColor = instancePickingColors;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
vTexCoord = uv;
|
|
49
|
-
cameraPosition = project_uCameraPosition;
|
|
50
|
-
vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
|
|
51
|
-
|
|
52
|
-
vec3 pos = (instanceModelMatrix * positions) * sizeScale;
|
|
53
|
-
vec3 projectedPosition = project_position(positions);
|
|
54
|
-
position_commonspace = vec4(projectedPosition, 1.0);
|
|
55
|
-
gl_Position = project_common_position_to_clipspace(position_commonspace);
|
|
56
|
-
|
|
57
|
-
geometry.position = position_commonspace;
|
|
58
|
-
normals_commonspace = project_normal(instanceModelMatrix * normals);
|
|
59
|
-
geometry.normal = normals_commonspace;
|
|
60
|
-
|
|
61
|
-
DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
|
|
62
|
-
|
|
63
|
-
#ifdef MODULE_PBR
|
|
64
|
-
// set PBR data
|
|
65
|
-
pbr_vPosition = geometry.position.xyz;
|
|
66
|
-
#ifdef HAS_NORMALS
|
|
67
|
-
pbr_vNormal = geometry.normal;
|
|
68
|
-
#endif
|
|
69
|
-
|
|
70
|
-
#ifdef HAS_UV
|
|
71
|
-
pbr_vUV = uv;
|
|
72
|
-
#else
|
|
73
|
-
pbr_vUV = vec2(0., 0.);
|
|
74
|
-
#endif
|
|
75
|
-
geometry.uv = pbr_vUV;
|
|
76
|
-
#endif
|
|
77
|
-
|
|
78
|
-
DECKGL_FILTER_COLOR(vColor, geometry);
|
|
79
|
-
}
|
|
80
|
-
`;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { GLTFMaterialParser } from '@luma.gl/experimental';
|
|
2
|
-
import { Model, pbr } from '@luma.gl/core';
|
|
3
|
-
import GL from '@luma.gl/constants';
|
|
4
|
-
import { SimpleMeshLayer } from '@deck.gl/mesh-layers';
|
|
5
|
-
import vs from './mesh-layer-vertex.glsl';
|
|
6
|
-
import fs from './mesh-layer-fragment.glsl';
|
|
7
|
-
function validateGeometryAttributes(attributes) {
|
|
8
|
-
const hasColorAttribute = attributes.COLOR_0 || attributes.colors;
|
|
9
|
-
if (!hasColorAttribute) {
|
|
10
|
-
attributes.colors = { constant: true, value: new Float32Array([1, 1, 1]) };
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const defaultProps = {
|
|
14
|
-
// PBR material object. _lighting must be pbr for this to work
|
|
15
|
-
pbrMaterial: { type: 'object', value: null },
|
|
16
|
-
featureIds: { type: 'array', value: null, optional: true }
|
|
17
|
-
};
|
|
18
|
-
export default class _MeshLayer extends SimpleMeshLayer {
|
|
19
|
-
getShaders() {
|
|
20
|
-
const shaders = super.getShaders();
|
|
21
|
-
const modules = shaders.modules;
|
|
22
|
-
modules.push(pbr);
|
|
23
|
-
return { ...shaders, vs, fs };
|
|
24
|
-
}
|
|
25
|
-
initializeState() {
|
|
26
|
-
const { featureIds } = this.props;
|
|
27
|
-
super.initializeState();
|
|
28
|
-
if (featureIds) {
|
|
29
|
-
this.state.attributeManager.add({
|
|
30
|
-
featureIdsPickingColors: {
|
|
31
|
-
type: GL.UNSIGNED_BYTE,
|
|
32
|
-
size: 3,
|
|
33
|
-
noAlloc: true,
|
|
34
|
-
update: this.calculateFeatureIdsPickingColors
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
updateState({ props, oldProps, changeFlags }) {
|
|
40
|
-
super.updateState({ props, oldProps, changeFlags });
|
|
41
|
-
if (props.pbrMaterial !== oldProps.pbrMaterial) {
|
|
42
|
-
this.updatePbrMaterialUniforms(props.pbrMaterial);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
draw(opts) {
|
|
46
|
-
const { featureIds } = this.props;
|
|
47
|
-
if (!this.state.model) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
this.state.model.setUniforms({
|
|
51
|
-
// Needed for PBR (TODO: find better way to get it)
|
|
52
|
-
u_Camera: this.state.model.getUniforms().project_uCameraPosition,
|
|
53
|
-
u_pickFeatureIds: Boolean(featureIds)
|
|
54
|
-
});
|
|
55
|
-
super.draw(opts);
|
|
56
|
-
}
|
|
57
|
-
getModel(mesh) {
|
|
58
|
-
const { id, pbrMaterial } = this.props;
|
|
59
|
-
const materialParser = this.parseMaterial(pbrMaterial, mesh);
|
|
60
|
-
const shaders = this.getShaders();
|
|
61
|
-
validateGeometryAttributes(mesh.attributes);
|
|
62
|
-
const model = new Model(this.context.gl, {
|
|
63
|
-
...this.getShaders(),
|
|
64
|
-
id,
|
|
65
|
-
geometry: mesh,
|
|
66
|
-
defines: {
|
|
67
|
-
...shaders.defines,
|
|
68
|
-
...materialParser?.defines,
|
|
69
|
-
HAS_UV_REGIONS: mesh.attributes.uvRegions
|
|
70
|
-
},
|
|
71
|
-
parameters: materialParser?.parameters,
|
|
72
|
-
isInstanced: true
|
|
73
|
-
});
|
|
74
|
-
return model;
|
|
75
|
-
}
|
|
76
|
-
updatePbrMaterialUniforms(pbrMaterial) {
|
|
77
|
-
const { model } = this.state;
|
|
78
|
-
if (model) {
|
|
79
|
-
const { mesh } = this.props;
|
|
80
|
-
const materialParser = this.parseMaterial(pbrMaterial, mesh);
|
|
81
|
-
model.setUniforms(materialParser.uniforms);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
parseMaterial(pbrMaterial, mesh) {
|
|
85
|
-
const unlit = Boolean(pbrMaterial.pbrMetallicRoughness && pbrMaterial.pbrMetallicRoughness.baseColorTexture);
|
|
86
|
-
const materialParser = new GLTFMaterialParser(this.context.gl, {
|
|
87
|
-
attributes: { NORMAL: mesh.attributes.normals, TEXCOORD_0: mesh.attributes.texCoords },
|
|
88
|
-
material: { unlit, ...pbrMaterial },
|
|
89
|
-
pbrDebug: false,
|
|
90
|
-
imageBasedLightingEnvironment: null,
|
|
91
|
-
lights: true,
|
|
92
|
-
useTangents: false
|
|
93
|
-
});
|
|
94
|
-
return materialParser;
|
|
95
|
-
}
|
|
96
|
-
calculateFeatureIdsPickingColors(attribute) {
|
|
97
|
-
const { featureIds } = this.props;
|
|
98
|
-
const value = new Uint8ClampedArray(featureIds.length * attribute.size);
|
|
99
|
-
const pickingColor = [];
|
|
100
|
-
for (let index = 0; index < featureIds.length; index++) {
|
|
101
|
-
this.encodePickingColor(featureIds[index], pickingColor);
|
|
102
|
-
value[index * 3] = pickingColor[0];
|
|
103
|
-
value[index * 3 + 1] = pickingColor[1];
|
|
104
|
-
value[index * 3 + 2] = pickingColor[2];
|
|
105
|
-
}
|
|
106
|
-
attribute.value = value;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
_MeshLayer.layerName = '_MeshLayer';
|
|
110
|
-
_MeshLayer.defaultProps = defaultProps;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { lerp } from '@math.gl/core';
|
|
2
|
-
const availableTransformations = {
|
|
3
|
-
Point,
|
|
4
|
-
MultiPoint,
|
|
5
|
-
LineString,
|
|
6
|
-
MultiLineString,
|
|
7
|
-
Polygon,
|
|
8
|
-
MultiPolygon
|
|
9
|
-
};
|
|
10
|
-
function Point([pointX, pointY], [nw, se], viewport) {
|
|
11
|
-
const x = lerp(nw[0], se[0], pointX);
|
|
12
|
-
const y = lerp(nw[1], se[1], pointY);
|
|
13
|
-
return viewport.unprojectFlat([x, y]);
|
|
14
|
-
}
|
|
15
|
-
function getPoints(geometry, bbox, viewport) {
|
|
16
|
-
return geometry.map(g => Point(g, bbox, viewport));
|
|
17
|
-
}
|
|
18
|
-
function MultiPoint(multiPoint, bbox, viewport) {
|
|
19
|
-
return getPoints(multiPoint, bbox, viewport);
|
|
20
|
-
}
|
|
21
|
-
function LineString(line, bbox, viewport) {
|
|
22
|
-
return getPoints(line, bbox, viewport);
|
|
23
|
-
}
|
|
24
|
-
function MultiLineString(multiLineString, bbox, viewport) {
|
|
25
|
-
return multiLineString.map(lineString => LineString(lineString, bbox, viewport));
|
|
26
|
-
}
|
|
27
|
-
function Polygon(polygon, bbox, viewport) {
|
|
28
|
-
return polygon.map(polygonRing => getPoints(polygonRing, bbox, viewport));
|
|
29
|
-
}
|
|
30
|
-
function MultiPolygon(multiPolygon, bbox, viewport) {
|
|
31
|
-
return multiPolygon.map(polygon => Polygon(polygon, bbox, viewport));
|
|
32
|
-
}
|
|
33
|
-
export function transform(geometry, bbox, viewport) {
|
|
34
|
-
const nw = viewport.projectFlat([bbox.west, bbox.north]);
|
|
35
|
-
const se = viewport.projectFlat([bbox.east, bbox.south]);
|
|
36
|
-
const projectedBbox = [nw, se];
|
|
37
|
-
return {
|
|
38
|
-
...geometry,
|
|
39
|
-
coordinates: availableTransformations[geometry.type](geometry.coordinates, projectedBbox, viewport)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
const GEOM_TYPES = ['points', 'lines', 'polygons'];
|
|
2
|
-
/**
|
|
3
|
-
* Return the index of feature (numericProps or featureIds) for given feature id
|
|
4
|
-
* Example: findIndexBinary(data, 'id', 33) will return the index in the array of numericProps
|
|
5
|
-
* of the feature 33.
|
|
6
|
-
* @param {Object} data - The data in binary format
|
|
7
|
-
* @param {String} uniqueIdProperty - Name of the unique id property
|
|
8
|
-
* @param {Number|String} featureId - feature id to find
|
|
9
|
-
* @param {String} layerName - the layer to search in
|
|
10
|
-
*/
|
|
11
|
-
export default function findIndexBinary(data, uniqueIdProperty, featureId, layerName) {
|
|
12
|
-
for (const gt of GEOM_TYPES) {
|
|
13
|
-
const index = data[gt] && findIndexByType(data[gt], uniqueIdProperty, featureId, layerName);
|
|
14
|
-
if (index >= 0) {
|
|
15
|
-
return index;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return -1;
|
|
19
|
-
}
|
|
20
|
-
function findIndexByType(geomData, uniqueIdProperty, featureId, layerName) {
|
|
21
|
-
const featureIds = geomData.featureIds.value;
|
|
22
|
-
if (!featureIds.length) {
|
|
23
|
-
return -1;
|
|
24
|
-
}
|
|
25
|
-
let startFeatureIndex = 0;
|
|
26
|
-
let endFeatureIndex = featureIds[featureIds.length - 1] + 1;
|
|
27
|
-
if (layerName) {
|
|
28
|
-
const layerRange = getLayerRange(geomData, layerName);
|
|
29
|
-
if (layerRange) {
|
|
30
|
-
startFeatureIndex = layerRange[0];
|
|
31
|
-
endFeatureIndex = layerRange[1] + 1;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return -1;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Look for the uniqueIdProperty
|
|
38
|
-
let featureIndex = -1;
|
|
39
|
-
if (uniqueIdProperty in geomData.numericProps) {
|
|
40
|
-
const vertexIndex = geomData.numericProps[uniqueIdProperty].value.findIndex((x, i) => x === featureId && featureIds[i] >= startFeatureIndex && featureIds[i] < endFeatureIndex);
|
|
41
|
-
return vertexIndex >= 0 ? geomData.globalFeatureIds.value[vertexIndex] : -1;
|
|
42
|
-
}
|
|
43
|
-
else if (uniqueIdProperty) {
|
|
44
|
-
featureIndex = findIndex(geomData.properties, elem => elem[uniqueIdProperty] === featureId, startFeatureIndex, endFeatureIndex);
|
|
45
|
-
}
|
|
46
|
-
else if (geomData.fields) {
|
|
47
|
-
featureIndex = findIndex(geomData.fields, (elem) => elem.id === featureId, startFeatureIndex, endFeatureIndex);
|
|
48
|
-
}
|
|
49
|
-
return featureIndex >= 0 ? getGlobalFeatureId(geomData, featureIndex) : -1;
|
|
50
|
-
}
|
|
51
|
-
// Returns [firstFeatureIndex, lastFeatureIndex]
|
|
52
|
-
// MVTLoader parses tiles layer-by-layer, so each layer is a continuous range
|
|
53
|
-
function getLayerRange(geomData, layerName) {
|
|
54
|
-
if (!geomData.__layers) {
|
|
55
|
-
// Cache a map from properties.layerName to index ranges
|
|
56
|
-
const layerNames = {};
|
|
57
|
-
const { properties } = geomData;
|
|
58
|
-
for (let i = 0; i < properties.length; i++) {
|
|
59
|
-
const { layerName: key } = properties[i];
|
|
60
|
-
if (!key) {
|
|
61
|
-
// ignore
|
|
62
|
-
}
|
|
63
|
-
else if (layerNames[key]) {
|
|
64
|
-
layerNames[key][1] = i;
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
layerNames[key] = [i, i];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
geomData.__layers = layerNames;
|
|
71
|
-
}
|
|
72
|
-
return geomData.__layers[layerName];
|
|
73
|
-
}
|
|
74
|
-
// Returns global feature id
|
|
75
|
-
function getGlobalFeatureId(geomData, featureIndex) {
|
|
76
|
-
if (!geomData.__ids) {
|
|
77
|
-
// Cache a map from featureId to globalFeatureId
|
|
78
|
-
const result = [];
|
|
79
|
-
const featureIds = geomData.featureIds.value;
|
|
80
|
-
const globalFeatureIds = geomData.globalFeatureIds.value;
|
|
81
|
-
for (let i = 0; i < featureIds.length; i++) {
|
|
82
|
-
result[featureIds[i]] = globalFeatureIds[i];
|
|
83
|
-
}
|
|
84
|
-
geomData.__ids = result;
|
|
85
|
-
}
|
|
86
|
-
return geomData.__ids[featureIndex];
|
|
87
|
-
}
|
|
88
|
-
// Like array.findIndex, but only search within a range
|
|
89
|
-
function findIndex(array, predicate, startIndex, endIndex) {
|
|
90
|
-
for (let i = startIndex; i < endIndex; i++) {
|
|
91
|
-
if (predicate(array[i], i)) {
|
|
92
|
-
return i;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return -1;
|
|
96
|
-
}
|