@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,146 +0,0 @@
|
|
|
1
|
-
import { I3SAttributeLoader } from '@loaders.gl/i3s';
|
|
2
|
-
import { load } from '@loaders.gl/core';
|
|
3
|
-
export const filterTile = async (tile, filtersByAttribute) => {
|
|
4
|
-
var _tile$content$userDat;
|
|
5
|
-
const result = {
|
|
6
|
-
isFiltered: false,
|
|
7
|
-
id: tile.id
|
|
8
|
-
};
|
|
9
|
-
if (((_tile$content$userDat = tile.content.userData) === null || _tile$content$userDat === void 0 ? void 0 : _tile$content$userDat.customFilters) !== filtersByAttribute) {
|
|
10
|
-
var _tile$content$userDat4;
|
|
11
|
-
if (tile.content && filtersByAttribute) {
|
|
12
|
-
var _tile$content$userDat2, _tile$content$userDat3;
|
|
13
|
-
if (((_tile$content$userDat2 = tile.content.userData) === null || _tile$content$userDat2 === void 0 ? void 0 : _tile$content$userDat2.originalIndices) === undefined) {
|
|
14
|
-
tile.content.userData = {};
|
|
15
|
-
tile.content.userData.originalIndices = tile.content.indices;
|
|
16
|
-
}
|
|
17
|
-
tile.content.indices = (_tile$content$userDat3 = tile.content.userData) === null || _tile$content$userDat3 === void 0 ? void 0 : _tile$content$userDat3.originalIndices;
|
|
18
|
-
tile.content.userData.customFilters = filtersByAttribute;
|
|
19
|
-
const {
|
|
20
|
-
indices
|
|
21
|
-
} = await filterTileIndices(tile, filtersByAttribute, tile.tileset.loadOptions.i3s.token);
|
|
22
|
-
if (indices && tile.content.userData.customFilters === filtersByAttribute) {
|
|
23
|
-
tile.content.indices = indices;
|
|
24
|
-
result.isFiltered = true;
|
|
25
|
-
}
|
|
26
|
-
} else if (tile.content && ((_tile$content$userDat4 = tile.content.userData) === null || _tile$content$userDat4 === void 0 ? void 0 : _tile$content$userDat4.originalIndices) !== undefined) {
|
|
27
|
-
tile.content.indices = tile.content.userData.originalIndices;
|
|
28
|
-
tile.content.userData.customFilters = null;
|
|
29
|
-
result.isFiltered = true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
async function filterTileIndices(tile, filtersByAttribute, token) {
|
|
35
|
-
var _objectIdAttributeDat;
|
|
36
|
-
if (!filtersByAttribute.attributeName.length) {
|
|
37
|
-
return {
|
|
38
|
-
success: false
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
const filterAttributeField = tile.tileset.tileset.fields.find(_ref => {
|
|
42
|
-
let {
|
|
43
|
-
name
|
|
44
|
-
} = _ref;
|
|
45
|
-
return name === (filtersByAttribute === null || filtersByAttribute === void 0 ? void 0 : filtersByAttribute.attributeName);
|
|
46
|
-
});
|
|
47
|
-
if (!filterAttributeField || !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(filterAttributeField.type)) {
|
|
48
|
-
return {
|
|
49
|
-
success: false
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const tileFilterAttributeData = await loadFeatureAttributeData(filterAttributeField.name, tile.header.attributeUrls, tile.tileset.tileset.attributeStorageInfo, token);
|
|
53
|
-
if (!tileFilterAttributeData) {
|
|
54
|
-
return {
|
|
55
|
-
success: false
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const objectIdField = tile.tileset.tileset.fields.find(_ref2 => {
|
|
59
|
-
let {
|
|
60
|
-
type
|
|
61
|
-
} = _ref2;
|
|
62
|
-
return type === 'esriFieldTypeOID';
|
|
63
|
-
});
|
|
64
|
-
if (!objectIdField) {
|
|
65
|
-
return {
|
|
66
|
-
success: false
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
const objectIdAttributeData = await loadFeatureAttributeData(objectIdField.name, tile.header.attributeUrls, tile.tileset.tileset.attributeStorageInfo, token);
|
|
70
|
-
if (!objectIdAttributeData) {
|
|
71
|
-
return {
|
|
72
|
-
success: false
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
const attributeValuesMap = {};
|
|
76
|
-
(_objectIdAttributeDat = objectIdAttributeData[objectIdField.name]) === null || _objectIdAttributeDat === void 0 || _objectIdAttributeDat.forEach((elem, index) => {
|
|
77
|
-
attributeValuesMap[elem] = tileFilterAttributeData[filterAttributeField.name][index];
|
|
78
|
-
});
|
|
79
|
-
if (!tile.content.indices) {
|
|
80
|
-
const triangles = [];
|
|
81
|
-
for (let i = 0; i < tile.content.featureIds.length; i += 3) {
|
|
82
|
-
if (attributeValuesMap[tile.content.featureIds[i]] === filtersByAttribute.value) {
|
|
83
|
-
triangles.push(i);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const indices = new Uint32Array(3 * triangles.length);
|
|
87
|
-
triangles.forEach((vertex, index) => {
|
|
88
|
-
indices[index * 3] = vertex;
|
|
89
|
-
indices[index * 3 + 1] = vertex + 1;
|
|
90
|
-
indices[index * 3 + 2] = vertex + 2;
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
success: true,
|
|
94
|
-
indices
|
|
95
|
-
};
|
|
96
|
-
} else {
|
|
97
|
-
const triangles = [];
|
|
98
|
-
for (let i = 0; i < tile.content.indices.length; i += 3) {
|
|
99
|
-
if (attributeValuesMap[tile.content.featureIds[tile.content.indices[i]]] === filtersByAttribute.value) {
|
|
100
|
-
triangles.push(i);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const indices = new Uint32Array(3 * triangles.length);
|
|
104
|
-
triangles.forEach((vertex, index) => {
|
|
105
|
-
indices[index * 3] = tile.content.indices[vertex];
|
|
106
|
-
indices[index * 3 + 1] = tile.content.indices[vertex + 1];
|
|
107
|
-
indices[index * 3 + 2] = tile.content.indices[vertex + 2];
|
|
108
|
-
});
|
|
109
|
-
return {
|
|
110
|
-
success: true,
|
|
111
|
-
indices
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async function loadFeatureAttributeData(attributeName, attributeUrls, attributesStorageInfo, token) {
|
|
116
|
-
const attributeIndex = attributesStorageInfo.findIndex(_ref3 => {
|
|
117
|
-
let {
|
|
118
|
-
name
|
|
119
|
-
} = _ref3;
|
|
120
|
-
return attributeName === name;
|
|
121
|
-
});
|
|
122
|
-
if (attributeIndex === -1) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], token);
|
|
126
|
-
const attributeType = getAttributeValueType(attributesStorageInfo[attributeIndex]);
|
|
127
|
-
const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {
|
|
128
|
-
attributeName,
|
|
129
|
-
attributeType
|
|
130
|
-
});
|
|
131
|
-
return objectIdAttributeData;
|
|
132
|
-
}
|
|
133
|
-
function getUrlWithToken(url) {
|
|
134
|
-
let token = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
135
|
-
return token ? `${url}?token=${token}` : url;
|
|
136
|
-
}
|
|
137
|
-
function getAttributeValueType(attribute) {
|
|
138
|
-
if (attribute.hasOwnProperty('objectIds')) {
|
|
139
|
-
return 'Oid32';
|
|
140
|
-
} else if (attribute.hasOwnProperty('attributeValues')) {
|
|
141
|
-
var _attribute$attributeV;
|
|
142
|
-
return (_attribute$attributeV = attribute.attributeValues) === null || _attribute$attributeV === void 0 ? void 0 : _attribute$attributeV.valueType;
|
|
143
|
-
}
|
|
144
|
-
return '';
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=filter-tile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-tile.js","names":["I3SAttributeLoader","load","filterTile","tile","filtersByAttribute","_tile$content$userDat","result","isFiltered","id","content","userData","customFilters","_tile$content$userDat4","_tile$content$userDat2","_tile$content$userDat3","originalIndices","undefined","indices","filterTileIndices","tileset","loadOptions","i3s","token","_objectIdAttributeDat","attributeName","length","success","filterAttributeField","fields","find","_ref","name","includes","type","tileFilterAttributeData","loadFeatureAttributeData","header","attributeUrls","attributeStorageInfo","objectIdField","_ref2","objectIdAttributeData","attributeValuesMap","forEach","elem","index","triangles","i","featureIds","value","push","Uint32Array","vertex","attributesStorageInfo","attributeIndex","findIndex","_ref3","objectIdAttributeUrl","getUrlWithToken","attributeType","getAttributeValueType","url","arguments","attribute","hasOwnProperty","_attribute$attributeV","attributeValues","valueType"],"sources":["../../../src/data-driven-tile-3d-layer/utils/filter-tile.ts"],"sourcesContent":["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Tile3D} from '@loaders.gl/tiles';\nimport {FiltersByAttribute} from '../data-driven-tile-3d-layer';\nimport {AttributeStorageInfo, I3SAttributeLoader} from '@loaders.gl/i3s';\nimport {load} from '@loaders.gl/core';\nimport {TypedArray} from '@loaders.gl/schema';\n\ntype I3STileAttributes = Record<string, string[] | TypedArray | null>;\n\n/**\n * Filter tile indices by attribute value\n * @param tile - tile to be filtered\n * @param filtersByAttribute - custom filters patameters\n * @returns {Promise<{isFiltered: boolean; id: string}>} Result of the tile filtering - isFiltered: true/false and tile id\n */\nexport const filterTile = async (\n tile: Tile3D,\n filtersByAttribute: FiltersByAttribute | null\n): Promise<{isFiltered: boolean; id: string}> => {\n const result = {isFiltered: false, id: tile.id};\n\n if (tile.content.userData?.customFilters !== filtersByAttribute) {\n if (tile.content && filtersByAttribute) {\n if (tile.content.userData?.originalIndices === undefined) {\n tile.content.userData = {};\n //save original indices for filtring cancellation\n tile.content.userData.originalIndices = tile.content.indices;\n }\n tile.content.indices = tile.content.userData?.originalIndices;\n tile.content.userData.customFilters = filtersByAttribute;\n\n const {indices} = await filterTileIndices(\n tile,\n filtersByAttribute,\n (tile.tileset.loadOptions as any).i3s.token\n );\n // Make sure custom filters is not changed during async filtring execution\n if (indices && tile.content.userData.customFilters === filtersByAttribute) {\n tile.content.indices = indices;\n result.isFiltered = true;\n }\n } else if (tile.content && tile.content.userData?.originalIndices !== undefined) {\n tile.content.indices = tile.content.userData.originalIndices;\n tile.content.userData.customFilters = null;\n result.isFiltered = true;\n }\n }\n return result;\n};\n\nasync function filterTileIndices(\n tile: Tile3D,\n filtersByAttribute: FiltersByAttribute,\n token: string\n): Promise<{success: boolean; indices?: Uint32Array}> {\n if (!filtersByAttribute.attributeName.length) {\n return {success: false};\n }\n\n const filterAttributeField = tile.tileset.tileset.fields.find(\n ({name}) => name === filtersByAttribute?.attributeName\n );\n\n if (\n !filterAttributeField ||\n !['esriFieldTypeDouble', 'esriFieldTypeInteger', 'esriFieldTypeSmallInteger'].includes(\n filterAttributeField.type\n )\n ) {\n return {success: false};\n }\n\n const tileFilterAttributeData = await loadFeatureAttributeData(\n filterAttributeField.name,\n tile.header.attributeUrls,\n tile.tileset.tileset.attributeStorageInfo,\n token\n );\n if (!tileFilterAttributeData) {\n return {success: false};\n }\n\n const objectIdField = tile.tileset.tileset.fields.find(({type}) => type === 'esriFieldTypeOID');\n if (!objectIdField) {\n return {success: false};\n }\n\n const objectIdAttributeData = await loadFeatureAttributeData(\n objectIdField.name,\n tile.header.attributeUrls,\n tile.tileset.tileset.attributeStorageInfo,\n token\n );\n if (!objectIdAttributeData) {\n return {success: false};\n }\n\n const attributeValuesMap = {};\n objectIdAttributeData[objectIdField.name]?.forEach((elem, index) => {\n attributeValuesMap[elem] =\n //@ts-expect-error possible null\n tileFilterAttributeData[filterAttributeField.name][index];\n });\n\n if (!tile.content.indices) {\n const triangles: number[] = [];\n for (let i = 0; i < tile.content.featureIds.length; i += 3) {\n if (attributeValuesMap[tile.content.featureIds[i]] === filtersByAttribute.value) {\n triangles.push(i);\n }\n }\n\n const indices = new Uint32Array(3 * triangles.length);\n\n triangles.forEach((vertex, index) => {\n indices[index * 3] = vertex;\n indices[index * 3 + 1] = vertex + 1;\n indices[index * 3 + 2] = vertex + 2;\n });\n return {success: true, indices};\n } else {\n const triangles: number[] = [];\n for (let i = 0; i < tile.content.indices.length; i += 3) {\n if (\n attributeValuesMap[tile.content.featureIds[tile.content.indices[i]]] ===\n filtersByAttribute.value\n ) {\n triangles.push(i);\n }\n }\n\n const indices = new Uint32Array(3 * triangles.length);\n\n triangles.forEach((vertex, index) => {\n indices[index * 3] = tile.content.indices[vertex];\n indices[index * 3 + 1] = tile.content.indices[vertex + 1];\n indices[index * 3 + 2] = tile.content.indices[vertex + 2];\n });\n return {success: true, indices};\n }\n}\n\nasync function loadFeatureAttributeData(\n attributeName: string,\n attributeUrls: string[],\n attributesStorageInfo: AttributeStorageInfo[],\n token?: string\n): Promise<I3STileAttributes | null> {\n const attributeIndex = attributesStorageInfo.findIndex(({name}) => attributeName === name);\n if (attributeIndex === -1) {\n return null;\n }\n const objectIdAttributeUrl = getUrlWithToken(attributeUrls[attributeIndex], token);\n const attributeType = getAttributeValueType(attributesStorageInfo[attributeIndex]);\n const objectIdAttributeData = await load(objectIdAttributeUrl, I3SAttributeLoader, {\n attributeName,\n attributeType\n });\n\n return objectIdAttributeData;\n}\n\nfunction getUrlWithToken(url: string, token: string | null = null): string {\n return token ? `${url}?token=${token}` : url;\n}\n\nfunction getAttributeValueType(attribute: AttributeStorageInfo) {\n // eslint-disable-next-line no-prototype-builtins\n if (attribute.hasOwnProperty('objectIds')) {\n return 'Oid32';\n // eslint-disable-next-line no-prototype-builtins\n } else if (attribute.hasOwnProperty('attributeValues')) {\n return attribute.attributeValues?.valueType;\n }\n return '';\n}\n"],"mappings":"AAMA,SAA8BA,kBAAkB,QAAO,iBAAiB;AACxE,SAAQC,IAAI,QAAO,kBAAkB;AAWrC,OAAO,MAAMC,UAAU,GAAG,MAAAA,CACxBC,IAAY,EACZC,kBAA6C,KACE;EAAA,IAAAC,qBAAA;EAC/C,MAAMC,MAAM,GAAG;IAACC,UAAU,EAAE,KAAK;IAAEC,EAAE,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IACtD,QAAAA,qBAAA,GAAOF,SAAS,CAACG,eAAe,cAAAD,qBAAA,uBAAzBA,qBAAA,CAA2BE,SAAS;EAC7C;EACA,OAAO,EAAE;AACX"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TileSourceLayer","DataDrivenTile3DLayer","colorizeTile","filterTile"],"sources":["../src/index.ts"],"sourcesContent":["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nexport {TileSourceLayer} from './tile-source-layer';\nexport {DataDrivenTile3DLayer} from './data-driven-tile-3d-layer/data-driven-tile-3d-layer';\n\nexport {colorizeTile} from './data-driven-tile-3d-layer/utils/colorize-tile';\nexport {filterTile} from './data-driven-tile-3d-layer/utils/filter-tile';\n"],"mappings":"SAIQA,eAAe;AAAA,SACfC,qBAAqB;AAAA,SAErBC,YAAY;AAAA,SACZC,UAAU"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { CompositeLayer } from '@deck.gl/core';
|
|
2
|
-
import { TileLayer } from '@deck.gl/geo-layers';
|
|
3
|
-
import { BitmapLayer, GeoJsonLayer, PathLayer } from '@deck.gl/layers';
|
|
4
|
-
const devicePixelRatio = typeof window !== 'undefined' && window.devicePixelRatio || 1;
|
|
5
|
-
export class TileSourceLayer extends CompositeLayer {
|
|
6
|
-
constructor() {
|
|
7
|
-
super(...arguments);
|
|
8
|
-
this.state = void 0;
|
|
9
|
-
}
|
|
10
|
-
initializeState() {
|
|
11
|
-
this.setState({
|
|
12
|
-
tileSource: null
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
updateState(_ref) {
|
|
16
|
-
let {
|
|
17
|
-
props,
|
|
18
|
-
changeFlags
|
|
19
|
-
} = _ref;
|
|
20
|
-
this.setState({
|
|
21
|
-
tileSource: props.tileSource
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
renderLayers() {
|
|
25
|
-
const {
|
|
26
|
-
tileSource,
|
|
27
|
-
showTileBorders,
|
|
28
|
-
metadata,
|
|
29
|
-
onTilesLoad
|
|
30
|
-
} = this.props;
|
|
31
|
-
const minZoom = (metadata === null || metadata === void 0 ? void 0 : metadata.minZoom) || 0;
|
|
32
|
-
const maxZoom = (metadata === null || metadata === void 0 ? void 0 : metadata.maxZoom) || 30;
|
|
33
|
-
return [new TileLayer({
|
|
34
|
-
id: String(tileSource.url),
|
|
35
|
-
getTileData: tileSource.getTileData,
|
|
36
|
-
maxRequests: 20,
|
|
37
|
-
pickable: true,
|
|
38
|
-
onViewportLoad: onTilesLoad,
|
|
39
|
-
autoHighlight: showTileBorders,
|
|
40
|
-
highlightColor: [60, 60, 60, 40],
|
|
41
|
-
minZoom,
|
|
42
|
-
maxZoom,
|
|
43
|
-
tileSize: 256,
|
|
44
|
-
zoomOffset: devicePixelRatio === 1 ? -1 : 0,
|
|
45
|
-
renderSubLayers,
|
|
46
|
-
tileSource,
|
|
47
|
-
showTileBorders
|
|
48
|
-
})];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
TileSourceLayer.layerName = 'TileSourceLayer';
|
|
52
|
-
TileSourceLayer.defaultProps = {
|
|
53
|
-
...TileLayer.defaultProps,
|
|
54
|
-
showTileBorders: true
|
|
55
|
-
};
|
|
56
|
-
function renderSubLayers(props) {
|
|
57
|
-
const {
|
|
58
|
-
tileSource,
|
|
59
|
-
showTileBorders,
|
|
60
|
-
minZoom,
|
|
61
|
-
maxZoom,
|
|
62
|
-
tile: {
|
|
63
|
-
index: {
|
|
64
|
-
z: zoom
|
|
65
|
-
},
|
|
66
|
-
bbox: {
|
|
67
|
-
west,
|
|
68
|
-
south,
|
|
69
|
-
east,
|
|
70
|
-
north
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
} = props;
|
|
74
|
-
const layers = [];
|
|
75
|
-
const borderColor = zoom <= minZoom || zoom >= maxZoom ? [255, 0, 0, 255] : [0, 0, 255, 255];
|
|
76
|
-
switch (tileSource.mimeType) {
|
|
77
|
-
case 'application/vnd.mapbox-vector-tile':
|
|
78
|
-
layers.push(new GeoJsonLayer({
|
|
79
|
-
id: `${props.id}-geojson`,
|
|
80
|
-
data: props.data,
|
|
81
|
-
pickable: true,
|
|
82
|
-
getFillColor: [0, 190, 80, 255],
|
|
83
|
-
lineWidthScale: 500,
|
|
84
|
-
lineWidthMinPixels: 0.5
|
|
85
|
-
}));
|
|
86
|
-
break;
|
|
87
|
-
case 'image/png':
|
|
88
|
-
case 'image/jpeg':
|
|
89
|
-
case 'image/webp':
|
|
90
|
-
case 'image/avif':
|
|
91
|
-
layers.push(new BitmapLayer(props, {
|
|
92
|
-
data: null,
|
|
93
|
-
image: props.data,
|
|
94
|
-
bounds: [west, south, east, north],
|
|
95
|
-
pickable: true
|
|
96
|
-
}));
|
|
97
|
-
break;
|
|
98
|
-
default:
|
|
99
|
-
console.error('Unknown tile mimeType', tileSource === null || tileSource === void 0 ? void 0 : tileSource.mimeType);
|
|
100
|
-
}
|
|
101
|
-
if (showTileBorders) {
|
|
102
|
-
layers.push(new PathLayer({
|
|
103
|
-
id: `${props.id}-border`,
|
|
104
|
-
data: [[[west, north], [west, south], [east, south], [east, north], [west, north]]],
|
|
105
|
-
getPath: d => d,
|
|
106
|
-
getColor: borderColor,
|
|
107
|
-
widthMinPixels: 4
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
return layers;
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=tile-source-layer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile-source-layer.js","names":["CompositeLayer","TileLayer","BitmapLayer","GeoJsonLayer","PathLayer","devicePixelRatio","window","TileSourceLayer","constructor","arguments","state","initializeState","setState","tileSource","updateState","_ref","props","changeFlags","renderLayers","showTileBorders","metadata","onTilesLoad","minZoom","maxZoom","id","String","url","getTileData","maxRequests","pickable","onViewportLoad","autoHighlight","highlightColor","tileSize","zoomOffset","renderSubLayers","layerName","defaultProps","tile","index","z","zoom","bbox","west","south","east","north","layers","borderColor","mimeType","push","data","getFillColor","lineWidthScale","lineWidthMinPixels","image","bounds","console","error","getPath","d","getColor","widthMinPixels"],"sources":["../src/tile-source-layer.ts"],"sourcesContent":["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {CompositeLayer, Layer} from '@deck.gl/core';\nimport {TileLayer, TileLayerProps} from '@deck.gl/geo-layers';\nimport {BitmapLayer, GeoJsonLayer, PathLayer} from '@deck.gl/layers';\nimport type {TileSource} from '@loaders.gl/loader-utils';\n\n/* global window */\nconst devicePixelRatio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;\n\nexport type TileSourceLayerProps = TileLayerProps & {\n tileSource: TileSource;\n showTileBorders?: boolean;\n};\n\n/**\n * A Deck.gl layer that renders a tile source\n * Autodiscovers type of content (vector tile, bitmap, ...)\n * Can render debug borders around tiles\n * TODO - Change debug border color based on zoom level\n */\nexport class TileSourceLayer extends CompositeLayer<TileSourceLayerProps> {\n static layerName = 'TileSourceLayer';\n static defaultProps = {\n ...TileLayer.defaultProps,\n showTileBorders: true\n };\n\n state: {\n tileSource: TileSource | null;\n };\n\n initializeState() {\n this.setState({\n tileSource: null\n });\n }\n\n updateState({props, changeFlags}) {\n this.setState({\n tileSource: props.tileSource\n });\n }\n\n renderLayers() {\n const {tileSource, showTileBorders, metadata, onTilesLoad} = this.props;\n const minZoom = metadata?.minZoom || 0;\n const maxZoom = metadata?.maxZoom || 30;\n\n return [\n new TileLayer({\n // HACK: Trigger new layer via id prop to force clear tile cache\n id: String(tileSource.url),\n getTileData: tileSource.getTileData,\n // Assume the pmtiles file support HTTP/2, so we aren't limited by the browser to a certain number per domain.\n maxRequests: 20,\n \n pickable: true,\n onViewportLoad: onTilesLoad,\n autoHighlight: showTileBorders,\n highlightColor: [60, 60, 60, 40],\n minZoom,\n maxZoom,\n tileSize: 256,\n // TOOD - why is this needed?\n zoomOffset: devicePixelRatio === 1 ? -1 : 0,\n renderSubLayers,\n \n // Custom prop\n tileSource,\n showTileBorders\n })\n ];\n } \n}\n\nfunction renderSubLayers(props: TileSourceLayerProps & {tile: {index, bbox: {west, south, east, north}}}) {\n const {\n tileSource, \n showTileBorders, \n minZoom,\n maxZoom,\n tile: {index: {z: zoom}, \n bbox: {west, south, east, north}}\n } = props;\n\n const layers: Layer[] = [];\n\n const borderColor = zoom <= minZoom || zoom >= maxZoom ? [255, 0, 0, 255] : [0, 0, 255, 255];\n\n switch (tileSource.mimeType) {\n case 'application/vnd.mapbox-vector-tile':\n layers.push(\n new GeoJsonLayer({\n id: `${props.id}-geojson`,\n data: props.data,\n pickable: true,\n getFillColor: [0, 190, 80, 255],\n lineWidthScale: 500,\n lineWidthMinPixels: 0.5\n })\n );\n break;\n\n case 'image/png':\n case 'image/jpeg':\n case 'image/webp':\n case 'image/avif':\n layers.push(\n new BitmapLayer(props, {\n data: null,\n image: props.data,\n bounds: [west, south, east, north],\n pickable: true\n })\n );\n break;\n\n default:\n console.error('Unknown tile mimeType', tileSource?.mimeType);\n }\n\n // Debug tile borders\n if (showTileBorders) {\n layers.push(\n new PathLayer({\n id: `${props.id}-border`,\n data: [\n [\n [west, north],\n [west, south],\n [east, south],\n [east, north],\n [west, north]\n ]\n ],\n getPath: (d) => d,\n getColor: borderColor,\n widthMinPixels: 4\n })\n );\n }\n\n return layers;\n}\n"],"mappings":"AAIA,SAAQA,cAAc,QAAc,eAAe;AACnD,SAAQC,SAAS,QAAuB,qBAAqB;AAC7D,SAAQC,WAAW,EAAEC,YAAY,EAAEC,SAAS,QAAO,iBAAiB;AAIpE,MAAMC,gBAAgB,GAAI,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACD,gBAAgB,IAAK,CAAC;AAaxF,OAAO,MAAME,eAAe,SAASP,cAAc,CAAuB;EAAAQ,YAAA;IAAA,SAAAC,SAAA;IAAA,KAOxEC,KAAK;EAAA;EAILC,eAAeA,CAAA,EAAG;IAChB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,aAAVA,UAAU,uBAAVA,UAAU,CAAEoC,QAAQ,CAAC;EAChE;EAGA,IAAI9B,eAAe,EAAE;IACnB4B,MAAM,CAACG,IAAI,CACT,IAAI9C,SAAS,CAAC;MACZoB,EAAE,EAAG,GAAER,KAAK,CAACQ,EAAG,SAAQ;MACxB2B,IAAI,EAAE,CACJ,CACE,CAACR,IAAI,EAAEG,KAAK,CAAC,EACb,CAACH,IAAI,EAAEC,KAAK,CAAC,EACb,CAACC,IAAI,EAAED,KAAK,CAAC,EACb,CAACC,IAAI,EAAEC,KAAK,CAAC,EACb,CAACH,IAAI,EAAEG,KAAK,CAAC,CACd,CACF;MACDa,OAAO,EAAGC,CAAC,IAAKA,CAAC;MACjBC,QAAQ,EAAEb,WAAW;MACrBc,cAAc,EAAE;IAClB,CAAC,CACH,CAAC;EACH;EAEA,OAAOf,MAAM;AACf"}
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {Tile3DLayer, Tile3DLayerProps} from '@deck.gl/geo-layers';
|
|
6
|
-
import {UpdateParameters, Viewport, DefaultProps} from '@deck.gl/core';
|
|
7
|
-
import {TILE_TYPE, Tile3D, Tileset3D} from '@loaders.gl/tiles';
|
|
8
|
-
import {load} from '@loaders.gl/core';
|
|
9
|
-
|
|
10
|
-
const defaultProps: DefaultProps<DataDrivenTile3DLayerProps> = {
|
|
11
|
-
colorsByAttribute: null,
|
|
12
|
-
filtersByAttribute: null
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
type DataDrivenTile3DLayerProps<DataT = any> = _DataDrivenTile3DLayerProps &
|
|
16
|
-
Tile3DLayerProps<DataT>;
|
|
17
|
-
|
|
18
|
-
type _DataDrivenTile3DLayerProps = {
|
|
19
|
-
onTraversalComplete?: (selectedTiles: Tile3D[]) => Tile3D[];
|
|
20
|
-
colorsByAttribute?: ColorsByAttribute | null;
|
|
21
|
-
customizeColors?: (
|
|
22
|
-
tile: Tile3D,
|
|
23
|
-
colorsByAttribute: ColorsByAttribute | null
|
|
24
|
-
) => Promise<{isColored: boolean; id: string}>;
|
|
25
|
-
filtersByAttribute?: FiltersByAttribute | null;
|
|
26
|
-
filterTile?: (
|
|
27
|
-
tile: Tile3D,
|
|
28
|
-
filtersByAttribute: FiltersByAttribute | null
|
|
29
|
-
) => Promise<{isFiltered: boolean; id: string}>;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export type ColorsByAttribute = {
|
|
33
|
-
/** Feature attribute name */
|
|
34
|
-
attributeName: string;
|
|
35
|
-
/** Minimum attribute value */
|
|
36
|
-
minValue: number;
|
|
37
|
-
/** Maximum attribute value */
|
|
38
|
-
maxValue: number;
|
|
39
|
-
/** Minimum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */
|
|
40
|
-
minColor: [number, number, number, number];
|
|
41
|
-
/** Maximum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */
|
|
42
|
-
maxColor: [number, number, number, number];
|
|
43
|
-
/** Colorization mode. `replace` - replace vertex colors with a new colors, `multiply` - multiply vertex colors with new colors */
|
|
44
|
-
mode: string;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export type FiltersByAttribute = {
|
|
48
|
-
/** Feature attribute name */
|
|
49
|
-
attributeName: string;
|
|
50
|
-
/** Filter value */
|
|
51
|
-
value: number;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
//@ts-expect-error call of private method of the base class
|
|
55
|
-
export class DataDrivenTile3DLayer<DataT = any, ExtraProps extends {} = {}> extends Tile3DLayer<
|
|
56
|
-
DataT,
|
|
57
|
-
Required<_DataDrivenTile3DLayerProps> & ExtraProps
|
|
58
|
-
> {
|
|
59
|
-
static layerName = 'DataDrivenTile3DLayer';
|
|
60
|
-
static defaultProps = defaultProps as any;
|
|
61
|
-
|
|
62
|
-
state!: {
|
|
63
|
-
activeViewports: any;
|
|
64
|
-
frameNumber?: number;
|
|
65
|
-
lastUpdatedViewports: {[viewportId: string]: Viewport} | null;
|
|
66
|
-
layerMap: {[layerId: string]: any};
|
|
67
|
-
tileset3d: Tileset3D | null;
|
|
68
|
-
|
|
69
|
-
colorsByAttribute: ColorsByAttribute | null;
|
|
70
|
-
filtersByAttribute: FiltersByAttribute | null;
|
|
71
|
-
loadingCounter: number;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
initializeState() {
|
|
75
|
-
super.initializeState();
|
|
76
|
-
|
|
77
|
-
this.setState({
|
|
78
|
-
colorsByAttribute: this.props.colorsByAttribute,
|
|
79
|
-
filtersByAttribute: this.props.filtersByAttribute,
|
|
80
|
-
loadingCounter: 0
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
updateState(params: UpdateParameters<this>): void {
|
|
85
|
-
const {props, oldProps, changeFlags} = params;
|
|
86
|
-
|
|
87
|
-
if (props.data && props.data !== oldProps.data) {
|
|
88
|
-
this._loadTileset(props.data);
|
|
89
|
-
} else if (props.colorsByAttribute !== oldProps.colorsByAttribute) {
|
|
90
|
-
this.setState({
|
|
91
|
-
colorsByAttribute: props.colorsByAttribute
|
|
92
|
-
});
|
|
93
|
-
this._colorizeTileset();
|
|
94
|
-
} else if (props.filtersByAttribute !== oldProps.filtersByAttribute) {
|
|
95
|
-
this.setState({
|
|
96
|
-
filtersByAttribute: props.filtersByAttribute
|
|
97
|
-
});
|
|
98
|
-
this._filterTileset();
|
|
99
|
-
} else if (changeFlags.viewportChanged) {
|
|
100
|
-
const {activeViewports} = this.state;
|
|
101
|
-
const viewportsNumber = Object.keys(activeViewports).length;
|
|
102
|
-
if (viewportsNumber) {
|
|
103
|
-
if (!this.state.loadingCounter) {
|
|
104
|
-
//@ts-expect-error call of private method of the base class
|
|
105
|
-
super._updateTileset(activeViewports);
|
|
106
|
-
}
|
|
107
|
-
this.state.lastUpdatedViewports = activeViewports;
|
|
108
|
-
this.state.activeViewports = {};
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
super.updateState(params);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private override async _loadTileset(tilesetUrl) {
|
|
116
|
-
const {loadOptions = {}} = this.props;
|
|
117
|
-
|
|
118
|
-
// TODO: deprecate `loader` in v9.0
|
|
119
|
-
let loader = this.props.loader || this.props.loaders;
|
|
120
|
-
if (Array.isArray(loader)) {
|
|
121
|
-
loader = loader[0];
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const options = {loadOptions: {...loadOptions}};
|
|
125
|
-
if (loader.preload) {
|
|
126
|
-
const preloadOptions = await loader.preload(tilesetUrl, loadOptions);
|
|
127
|
-
|
|
128
|
-
if (preloadOptions.headers) {
|
|
129
|
-
options.loadOptions.fetch = {
|
|
130
|
-
...options.loadOptions.fetch,
|
|
131
|
-
headers: preloadOptions.headers
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
Object.assign(options, preloadOptions);
|
|
135
|
-
}
|
|
136
|
-
//@ts-expect-error loader
|
|
137
|
-
const tilesetJson = await load(tilesetUrl, loader, options.loadOptions);
|
|
138
|
-
|
|
139
|
-
const tileset3d = new Tileset3D(tilesetJson, {
|
|
140
|
-
onTileLoad: this._onTileLoad.bind(this),
|
|
141
|
-
//@ts-expect-error call of private method of the base class
|
|
142
|
-
onTileUnload: super._onTileUnload.bind(this),
|
|
143
|
-
onTileError: this.props.onTileError,
|
|
144
|
-
// New code ------------------
|
|
145
|
-
onTraversalComplete: this._onTraversalComplete.bind(this),
|
|
146
|
-
// ---------------------------
|
|
147
|
-
...options
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
this.setState({
|
|
151
|
-
tileset3d,
|
|
152
|
-
layerMap: {}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
//@ts-expect-error call of private method of the base class
|
|
156
|
-
super._updateTileset(this.state.activeViewports);
|
|
157
|
-
this.props.onTilesetLoad(tileset3d);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
private override _onTileLoad(tileHeader: Tile3D): void {
|
|
161
|
-
const {lastUpdatedViewports} = this.state;
|
|
162
|
-
// New code ------------------
|
|
163
|
-
this._colorizeTiles([tileHeader]);
|
|
164
|
-
this._filterTiles([tileHeader]);
|
|
165
|
-
// ---------------------------
|
|
166
|
-
this.props.onTileLoad(tileHeader);
|
|
167
|
-
// New code ------------------ condition is added
|
|
168
|
-
if (!this.state.colorsByAttribute && !this.state.filtersByAttribute) {
|
|
169
|
-
// ---------------------------
|
|
170
|
-
//@ts-expect-error call of private method of the base class
|
|
171
|
-
super._updateTileset(lastUpdatedViewports);
|
|
172
|
-
this.setNeedsUpdate();
|
|
173
|
-
// New code ------------------
|
|
174
|
-
}
|
|
175
|
-
// ------------------
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
private _onTraversalComplete(selectedTiles: Tile3D[]): Tile3D[] {
|
|
179
|
-
this._colorizeTiles(selectedTiles);
|
|
180
|
-
this._filterTiles(selectedTiles);
|
|
181
|
-
return this.props.onTraversalComplete
|
|
182
|
-
? this.props.onTraversalComplete(selectedTiles)
|
|
183
|
-
: selectedTiles;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
private _colorizeTiles(tiles: Tile3D[]): void {
|
|
187
|
-
if (this.props.customizeColors && tiles[0]?.type === TILE_TYPE.MESH) {
|
|
188
|
-
const {layerMap, colorsByAttribute} = this.state;
|
|
189
|
-
const promises: Promise<{isColored: boolean; id: string}>[] = [];
|
|
190
|
-
for (const tile of tiles) {
|
|
191
|
-
promises.push(this.props.customizeColors(tile, colorsByAttribute));
|
|
192
|
-
}
|
|
193
|
-
this.setState({
|
|
194
|
-
loadingCounter: this.state.loadingCounter + 1
|
|
195
|
-
});
|
|
196
|
-
Promise.allSettled(promises).then((result) => {
|
|
197
|
-
this.setState({
|
|
198
|
-
loadingCounter: this.state.loadingCounter - 1
|
|
199
|
-
});
|
|
200
|
-
let isTileChanged = false;
|
|
201
|
-
for (const item of result) {
|
|
202
|
-
if (item.status === 'fulfilled' && item.value.isColored) {
|
|
203
|
-
isTileChanged = true;
|
|
204
|
-
delete layerMap[item.value.id];
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
if (isTileChanged && !this.state.loadingCounter) {
|
|
208
|
-
//@ts-expect-error call of private method of the base class
|
|
209
|
-
super._updateTileset(this.state.activeViewports);
|
|
210
|
-
this.setNeedsUpdate();
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
private _colorizeTileset(): void {
|
|
217
|
-
const {tileset3d} = this.state;
|
|
218
|
-
|
|
219
|
-
if (tileset3d) {
|
|
220
|
-
this._colorizeTiles(tileset3d.selectedTiles);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
private _filterTiles(tiles: Tile3D[]): void {
|
|
225
|
-
if (this.props.filterTile && tiles[0]?.type === TILE_TYPE.MESH) {
|
|
226
|
-
const {layerMap, filtersByAttribute} = this.state;
|
|
227
|
-
const promises: Promise<{isFiltered: boolean; id: string}>[] = [];
|
|
228
|
-
for (const tile of tiles) {
|
|
229
|
-
promises.push(this.props.filterTile(tile, filtersByAttribute));
|
|
230
|
-
}
|
|
231
|
-
this.setState({
|
|
232
|
-
loadingCounter: this.state.loadingCounter + 1
|
|
233
|
-
});
|
|
234
|
-
Promise.allSettled(promises).then((result) => {
|
|
235
|
-
this.setState({
|
|
236
|
-
loadingCounter: this.state.loadingCounter - 1
|
|
237
|
-
});
|
|
238
|
-
let isTileChanged = false;
|
|
239
|
-
for (const item of result) {
|
|
240
|
-
if (item.status === 'fulfilled' && item.value.isFiltered) {
|
|
241
|
-
isTileChanged = true;
|
|
242
|
-
delete layerMap[item.value.id];
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
if (isTileChanged && !this.state.loadingCounter) {
|
|
246
|
-
//@ts-expect-error call of private method of the base class
|
|
247
|
-
super._updateTileset(this.state.activeViewports);
|
|
248
|
-
this.setNeedsUpdate();
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
private _filterTileset(): void {
|
|
255
|
-
const {tileset3d} = this.state;
|
|
256
|
-
|
|
257
|
-
if (tileset3d) {
|
|
258
|
-
this._filterTiles(tileset3d.selectedTiles);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// deck.gl-community
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import {customizeColors} from '@loaders.gl/i3s';
|
|
6
|
-
import {Tile3D} from '@loaders.gl/tiles';
|
|
7
|
-
import {ColorsByAttribute} from '../data-driven-tile-3d-layer';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Update tile colors with the custom colors assigned to the I3S Loader
|
|
11
|
-
* @returns {Promise<{isColored: boolean; id: string}>} Result of the tile colorization - isColored: true/false and tile id
|
|
12
|
-
*/
|
|
13
|
-
export const colorizeTile = async (
|
|
14
|
-
tile: Tile3D,
|
|
15
|
-
colorsByAttribute: ColorsByAttribute | null
|
|
16
|
-
): Promise<{isColored: boolean; id: string}> => {
|
|
17
|
-
const result = {isColored: false, id: tile.id};
|
|
18
|
-
|
|
19
|
-
if (tile.content.customColors !== colorsByAttribute) {
|
|
20
|
-
if (tile.content && colorsByAttribute) {
|
|
21
|
-
if (!tile.content.originalColorsAttributes) {
|
|
22
|
-
tile.content.originalColorsAttributes = {
|
|
23
|
-
...tile.content.attributes.colors,
|
|
24
|
-
value: new Uint8Array(tile.content.attributes.colors.value)
|
|
25
|
-
};
|
|
26
|
-
} else if (colorsByAttribute.mode === 'multiply') {
|
|
27
|
-
tile.content.attributes.colors.value.set(tile.content.originalColorsAttributes.value);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
tile.content.customColors = colorsByAttribute;
|
|
31
|
-
|
|
32
|
-
const newColors = await customizeColors(
|
|
33
|
-
tile.content.attributes.colors,
|
|
34
|
-
tile.content.featureIds,
|
|
35
|
-
tile.header.attributeUrls,
|
|
36
|
-
tile.tileset.tileset.fields,
|
|
37
|
-
tile.tileset.tileset.attributeStorageInfo,
|
|
38
|
-
colorsByAttribute,
|
|
39
|
-
(tile.tileset.loadOptions as any).i3s.token
|
|
40
|
-
);
|
|
41
|
-
// Make sure custom colors is not changed during async customizeColors execution
|
|
42
|
-
if (tile.content.customColors === colorsByAttribute) {
|
|
43
|
-
tile.content.attributes.colors = newColors;
|
|
44
|
-
result.isColored = true;
|
|
45
|
-
}
|
|
46
|
-
} else if (tile.content && tile.content.originalColorsAttributes) {
|
|
47
|
-
tile.content.attributes.colors.value = tile.content.originalColorsAttributes.value;
|
|
48
|
-
tile.content.customColors = null;
|
|
49
|
-
result.isColored = true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return result;
|
|
53
|
-
};
|