@deck.gl-community/layers 9.0.0-alpha.1 → 9.0.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/index.cjs +605 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -5
- package/dist/path-marker-layer/arrow-2d-geometry.d.ts +4 -0
- package/dist/path-marker-layer/arrow-2d-geometry.js +58 -0
- package/dist/path-marker-layer/create-path-markers.d.ts +18 -0
- package/dist/path-marker-layer/create-path-markers.js +78 -0
- package/dist/path-marker-layer/path-marker-layer.d.ts +40 -0
- package/dist/path-marker-layer/path-marker-layer.js +124 -0
- package/dist/path-marker-layer/polyline.d.ts +18 -0
- package/dist/path-marker-layer/polyline.js +40 -0
- package/dist/path-outline-layer/outline.d.ts +8 -0
- package/dist/path-outline-layer/outline.js +100 -0
- package/dist/path-outline-layer/path-outline-layer.d.ts +34 -0
- package/dist/path-outline-layer/path-outline-layer.js +116 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts +43 -0
- package/dist/tile-source-layer/tile-source-layer.js +109 -0
- package/package.json +27 -13
- package/src/index.ts +7 -4
- package/src/path-marker-layer/arrow-2d-geometry.ts +65 -0
- package/src/path-marker-layer/create-path-markers.ts +122 -0
- package/src/path-marker-layer/path-marker-layer.ts +183 -0
- package/src/path-marker-layer/polyline.ts +44 -0
- package/src/path-outline-layer/outline.ts +107 -0
- package/src/path-outline-layer/path-outline-layer.ts +159 -0
- package/src/{tile-source-layer.ts → tile-source-layer/tile-source-layer.ts} +30 -22
- package/dist/data-driven-tile-3d-layer/data-driven-tile-3d-layer.js +0 -193
- package/dist/data-driven-tile-3d-layer/data-driven-tile-3d-layer.js.map +0 -1
- package/dist/data-driven-tile-3d-layer/utils/colorize-tile.js +0 -31
- package/dist/data-driven-tile-3d-layer/utils/colorize-tile.js.map +0 -1
- package/dist/data-driven-tile-3d-layer/utils/filter-tile.js +0 -146
- package/dist/data-driven-tile-3d-layer/utils/filter-tile.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tile-source-layer.js +0 -112
- package/dist/tile-source-layer.js.map +0 -1
- package/src/data-driven-tile-3d-layer/data-driven-tile-3d-layer.ts +0 -261
- package/src/data-driven-tile-3d-layer/utils/colorize-tile.ts +0 -53
- package/src/data-driven-tile-3d-layer/utils/filter-tile.ts +0 -179
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {Tile3D} from '@loaders.gl/tiles';
|
|
6
|
-
import {FiltersByAttribute} from '../data-driven-tile-3d-layer';
|
|
7
|
-
import {AttributeStorageInfo, I3SAttributeLoader} from '@loaders.gl/i3s';
|
|
8
|
-
import {load} from '@loaders.gl/core';
|
|
9
|
-
import {TypedArray} from '@loaders.gl/schema';
|
|
10
|
-
|
|
11
|
-
type I3STileAttributes = Record<string, string[] | TypedArray | null>;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Filter tile indices by attribute value
|
|
15
|
-
* @param tile - tile to be filtered
|
|
16
|
-
* @param filtersByAttribute - custom filters patameters
|
|
17
|
-
* @returns {Promise<{isFiltered: boolean; id: string}>} Result of the tile filtering - isFiltered: true/false and tile id
|
|
18
|
-
*/
|
|
19
|
-
export const filterTile = async (
|
|
20
|
-
tile: Tile3D,
|
|
21
|
-
filtersByAttribute: FiltersByAttribute | null
|
|
22
|
-
): Promise<{isFiltered: boolean; id: string}> => {
|
|
23
|
-
const result = {isFiltered: false, id: tile.id};
|
|
24
|
-
|
|
25
|
-
if (tile.content.userData?.customFilters !== filtersByAttribute) {
|
|
26
|
-
if (tile.content && filtersByAttribute) {
|
|
27
|
-
if (tile.content.userData?.originalIndices === undefined) {
|
|
28
|
-
tile.content.userData = {};
|
|
29
|
-
//save original indices for filtring cancellation
|
|
30
|
-
tile.content.userData.originalIndices = tile.content.indices;
|
|
31
|
-
}
|
|
32
|
-
tile.content.indices = tile.content.userData?.originalIndices;
|
|
33
|
-
tile.content.userData.customFilters = filtersByAttribute;
|
|
34
|
-
|
|
35
|
-
const {indices} = await filterTileIndices(
|
|
36
|
-
tile,
|
|
37
|
-
filtersByAttribute,
|
|
38
|
-
(tile.tileset.loadOptions as any).i3s.token
|
|
39
|
-
);
|
|
40
|
-
// Make sure custom filters is not changed during async filtring execution
|
|
41
|
-
if (indices && tile.content.userData.customFilters === filtersByAttribute) {
|
|
42
|
-
tile.content.indices = indices;
|
|
43
|
-
result.isFiltered = true;
|
|
44
|
-
}
|
|
45
|
-
} else if (tile.content && tile.content.userData?.originalIndices !== undefined) {
|
|
46
|
-
tile.content.indices = tile.content.userData.originalIndices;
|
|
47
|
-
tile.content.userData.customFilters = null;
|
|
48
|
-
result.isFiltered = true;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
async function filterTileIndices(
|
|
55
|
-
tile: Tile3D,
|
|
56
|
-
filtersByAttribute: FiltersByAttribute,
|
|
57
|
-
token: string
|
|
58
|
-
): Promise<{success: boolean; indices?: Uint32Array}> {
|
|
59
|
-
if (!filtersByAttribute.attributeName.length) {
|
|
60
|
-
return {success: false};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const filterAttributeField = tile.tileset.tileset.fields.find(
|
|
64
|
-
({name}) => name === filtersByAttribute?.attributeName
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
!filterAttributeField ||
|
|
69
|
-
!['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(
|
|
70
|
-
filterAttributeField.type
|
|
71
|
-
)
|
|
72
|
-
) {
|
|
73
|
-
return {success: false};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const tileFilterAttributeData = await loadFeatureAttributeData(
|
|
77
|
-
filterAttributeField.name,
|
|
78
|
-
tile.header.attributeUrls,
|
|
79
|
-
tile.tileset.tileset.attributeStorageInfo,
|
|
80
|
-
token
|
|
81
|
-
);
|
|
82
|
-
if (!tileFilterAttributeData) {
|
|
83
|
-
return {success: false};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
const objectIdField = tile.tileset.tileset.fields.find(({type}) => type === 'esriFieldTypeOID');
|
|
87
|
-
if (!objectIdField) {
|
|
88
|
-
return {success: false};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const objectIdAttributeData = await loadFeatureAttributeData(
|
|
92
|
-
objectIdField.name,
|
|
93
|
-
tile.header.attributeUrls,
|
|
94
|
-
tile.tileset.tileset.attributeStorageInfo,
|
|
95
|
-
token
|
|
96
|
-
);
|
|
97
|
-
if (!objectIdAttributeData) {
|
|
98
|
-
return {success: false};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const attributeValuesMap = {};
|
|
102
|
-
objectIdAttributeData[objectIdField.name]?.forEach((elem, index) => {
|
|
103
|
-
attributeValuesMap[elem] =
|
|
104
|
-
//@ts-expect-error possible null
|
|
105
|
-
tileFilterAttributeData[filterAttributeField.name][index];
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
if (!tile.content.indices) {
|
|
109
|
-
const triangles: number[] = [];
|
|
110
|
-
for (let i = 0; i < tile.content.featureIds.length; i += 3) {
|
|
111
|
-
if (attributeValuesMap[tile.content.featureIds[i]] === filtersByAttribute.value) {
|
|
112
|
-
triangles.push(i);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const indices = new Uint32Array(3 * triangles.length);
|
|
117
|
-
|
|
118
|
-
triangles.forEach((vertex, index) => {
|
|
119
|
-
indices[index * 3] = vertex;
|
|
120
|
-
indices[index * 3 + 1] = vertex + 1;
|
|
121
|
-
indices[index * 3 + 2] = vertex + 2;
|
|
122
|
-
});
|
|
123
|
-
return {success: true, indices};
|
|
124
|
-
} else {
|
|
125
|
-
const triangles: number[] = [];
|
|
126
|
-
for (let i = 0; i < tile.content.indices.length; i += 3) {
|
|
127
|
-
if (
|
|
128
|
-
attributeValuesMap[tile.content.featureIds[tile.content.indices[i]]] ===
|
|
129
|
-
filtersByAttribute.value
|
|
130
|
-
) {
|
|
131
|
-
triangles.push(i);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const indices = new Uint32Array(3 * triangles.length);
|
|
136
|
-
|
|
137
|
-
triangles.forEach((vertex, index) => {
|
|
138
|
-
indices[index * 3] = tile.content.indices[vertex];
|
|
139
|
-
indices[index * 3 + 1] = tile.content.indices[vertex + 1];
|
|
140
|
-
indices[index * 3 + 2] = tile.content.indices[vertex + 2];
|
|
141
|
-
});
|
|
142
|
-
return {success: true, indices};
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
async function loadFeatureAttributeData(
|
|
147
|
-
attributeName: string,
|
|
148
|
-
attributeUrls: string[],
|
|
149
|
-
attributesStorageInfo: AttributeStorageInfo[],
|
|
150
|
-
token?: string
|
|
151
|
-
): Promise<I3STileAttributes | null> {
|
|
152
|
-
const attributeIndex = attributesStorageInfo.findIndex(({name}) => attributeName === name);
|
|
153
|
-
if (attributeIndex === -1) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], token);
|
|
157
|
-
const attributeType = getAttributeValueType(attributesStorageInfo[attributeIndex]);
|
|
158
|
-
const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {
|
|
159
|
-
attributeName,
|
|
160
|
-
attributeType
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
return objectIdAttributeData;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function getUrlWithToken(url: string, token: string | null = null): string {
|
|
167
|
-
return token ? `${url}?token=${token}` : url;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function getAttributeValueType(attribute: AttributeStorageInfo) {
|
|
171
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
172
|
-
if (attribute.hasOwnProperty('objectIds')) {
|
|
173
|
-
return 'Oid32';
|
|
174
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
175
|
-
} else if (attribute.hasOwnProperty('attributeValues')) {
|
|
176
|
-
return attribute.attributeValues?.valueType;
|
|
177
|
-
}
|
|
178
|
-
return '';
|
|
179
|
-
}
|