@deck.gl-community/layers 9.0.0-alpha.1 → 9.0.3
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 +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -5
- package/dist/path-marker-layer/arrow-2d-geometry.d.ts +5 -0
- package/dist/path-marker-layer/arrow-2d-geometry.d.ts.map +1 -0
- package/dist/path-marker-layer/arrow-2d-geometry.js +58 -0
- package/dist/path-marker-layer/create-path-markers.d.ts +19 -0
- package/dist/path-marker-layer/create-path-markers.d.ts.map +1 -0
- package/dist/path-marker-layer/create-path-markers.js +78 -0
- package/dist/path-marker-layer/path-marker-layer.d.ts +41 -0
- package/dist/path-marker-layer/path-marker-layer.d.ts.map +1 -0
- package/dist/path-marker-layer/path-marker-layer.js +124 -0
- package/dist/path-marker-layer/polyline.d.ts +19 -0
- package/dist/path-marker-layer/polyline.d.ts.map +1 -0
- package/dist/path-marker-layer/polyline.js +40 -0
- package/dist/path-outline-layer/outline.d.ts +9 -0
- package/dist/path-outline-layer/outline.d.ts.map +1 -0
- package/dist/path-outline-layer/outline.js +100 -0
- package/dist/path-outline-layer/path-outline-layer.d.ts +35 -0
- package/dist/path-outline-layer/path-outline-layer.d.ts.map +1 -0
- package/dist/path-outline-layer/path-outline-layer.js +116 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts +44 -0
- package/dist/tile-source-layer/tile-source-layer.d.ts.map +1 -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,193 +0,0 @@
|
|
|
1
|
-
import { Tile3DLayer } from '@deck.gl/geo-layers';
|
|
2
|
-
import { TILE_TYPE, Tileset3D } from '@loaders.gl/tiles';
|
|
3
|
-
import { load } from '@loaders.gl/core';
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
colorsByAttribute: null,
|
|
6
|
-
filtersByAttribute: null
|
|
7
|
-
};
|
|
8
|
-
export class DataDrivenTile3DLayer extends Tile3DLayer {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
this.state = void 0;
|
|
12
|
-
}
|
|
13
|
-
initializeState() {
|
|
14
|
-
super.initializeState();
|
|
15
|
-
this.setState({
|
|
16
|
-
colorsByAttribute: this.props.colorsByAttribute,
|
|
17
|
-
filtersByAttribute: this.props.filtersByAttribute,
|
|
18
|
-
loadingCounter: 0
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
updateState(params) {
|
|
22
|
-
const {
|
|
23
|
-
props,
|
|
24
|
-
oldProps,
|
|
25
|
-
changeFlags
|
|
26
|
-
} = params;
|
|
27
|
-
if (props.data && props.data !== oldProps.data) {
|
|
28
|
-
this._loadTileset(props.data);
|
|
29
|
-
} else if (props.colorsByAttribute !== oldProps.colorsByAttribute) {
|
|
30
|
-
this.setState({
|
|
31
|
-
colorsByAttribute: props.colorsByAttribute
|
|
32
|
-
});
|
|
33
|
-
this._colorizeTileset();
|
|
34
|
-
} else if (props.filtersByAttribute !== oldProps.filtersByAttribute) {
|
|
35
|
-
this.setState({
|
|
36
|
-
filtersByAttribute: props.filtersByAttribute
|
|
37
|
-
});
|
|
38
|
-
this._filterTileset();
|
|
39
|
-
} else if (changeFlags.viewportChanged) {
|
|
40
|
-
const {
|
|
41
|
-
activeViewports
|
|
42
|
-
} = this.state;
|
|
43
|
-
const viewportsNumber = Object.keys(activeViewports).length;
|
|
44
|
-
if (viewportsNumber) {
|
|
45
|
-
if (!this.state.loadingCounter) {
|
|
46
|
-
super._updateTileset(activeViewports);
|
|
47
|
-
}
|
|
48
|
-
this.state.lastUpdatedViewports = activeViewports;
|
|
49
|
-
this.state.activeViewports = {};
|
|
50
|
-
}
|
|
51
|
-
} else {
|
|
52
|
-
super.updateState(params);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async _loadTileset(tilesetUrl) {
|
|
56
|
-
const {
|
|
57
|
-
loadOptions = {}
|
|
58
|
-
} = this.props;
|
|
59
|
-
let loader = this.props.loader || this.props.loaders;
|
|
60
|
-
if (Array.isArray(loader)) {
|
|
61
|
-
loader = loader[0];
|
|
62
|
-
}
|
|
63
|
-
const options = {
|
|
64
|
-
loadOptions: {
|
|
65
|
-
...loadOptions
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
if (loader.preload) {
|
|
69
|
-
const preloadOptions = await loader.preload(tilesetUrl, loadOptions);
|
|
70
|
-
if (preloadOptions.headers) {
|
|
71
|
-
options.loadOptions.fetch = {
|
|
72
|
-
...options.loadOptions.fetch,
|
|
73
|
-
headers: preloadOptions.headers
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
Object.assign(options, preloadOptions);
|
|
77
|
-
}
|
|
78
|
-
const tilesetJson = await load(tilesetUrl, loader, options.loadOptions);
|
|
79
|
-
const tileset3d = new Tileset3D(tilesetJson, {
|
|
80
|
-
onTileLoad: this._onTileLoad.bind(this),
|
|
81
|
-
onTileUnload: super._onTileUnload.bind(this),
|
|
82
|
-
onTileError: this.props.onTileError,
|
|
83
|
-
onTraversalComplete: this._onTraversalComplete.bind(this),
|
|
84
|
-
...options
|
|
85
|
-
});
|
|
86
|
-
this.setState({
|
|
87
|
-
tileset3d,
|
|
88
|
-
layerMap: {}
|
|
89
|
-
});
|
|
90
|
-
super._updateTileset(this.state.activeViewports);
|
|
91
|
-
this.props.onTilesetLoad(tileset3d);
|
|
92
|
-
}
|
|
93
|
-
_onTileLoad(tileHeader) {
|
|
94
|
-
const {
|
|
95
|
-
lastUpdatedViewports
|
|
96
|
-
} = this.state;
|
|
97
|
-
this._colorizeTiles([tileHeader]);
|
|
98
|
-
this._filterTiles([tileHeader]);
|
|
99
|
-
this.props.onTileLoad(tileHeader);
|
|
100
|
-
if (!this.state.colorsByAttribute && !this.state.filtersByAttribute) {
|
|
101
|
-
super._updateTileset(lastUpdatedViewports);
|
|
102
|
-
this.setNeedsUpdate();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
_onTraversalComplete(selectedTiles) {
|
|
106
|
-
this._colorizeTiles(selectedTiles);
|
|
107
|
-
this._filterTiles(selectedTiles);
|
|
108
|
-
return this.props.onTraversalComplete ? this.props.onTraversalComplete(selectedTiles) : selectedTiles;
|
|
109
|
-
}
|
|
110
|
-
_colorizeTiles(tiles) {
|
|
111
|
-
var _tiles$;
|
|
112
|
-
if (this.props.customizeColors && ((_tiles$ = tiles[0]) === null || _tiles$ === void 0 ? void 0 : _tiles$.type) === TILE_TYPE.MESH) {
|
|
113
|
-
const {
|
|
114
|
-
layerMap,
|
|
115
|
-
colorsByAttribute
|
|
116
|
-
} = this.state;
|
|
117
|
-
const promises = [];
|
|
118
|
-
for (const tile of tiles) {
|
|
119
|
-
promises.push(this.props.customizeColors(tile, colorsByAttribute));
|
|
120
|
-
}
|
|
121
|
-
this.setState({
|
|
122
|
-
loadingCounter: this.state.loadingCounter + 1
|
|
123
|
-
});
|
|
124
|
-
Promise.allSettled(promises).then(result => {
|
|
125
|
-
this.setState({
|
|
126
|
-
loadingCounter: this.state.loadingCounter - 1
|
|
127
|
-
});
|
|
128
|
-
let isTileChanged = false;
|
|
129
|
-
for (const item of result) {
|
|
130
|
-
if (item.status === 'fulfilled' && item.value.isColored) {
|
|
131
|
-
isTileChanged = true;
|
|
132
|
-
delete layerMap[item.value.id];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (isTileChanged && !this.state.loadingCounter) {
|
|
136
|
-
super._updateTileset(this.state.activeViewports);
|
|
137
|
-
this.setNeedsUpdate();
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
_colorizeTileset() {
|
|
143
|
-
const {
|
|
144
|
-
tileset3d
|
|
145
|
-
} = this.state;
|
|
146
|
-
if (tileset3d) {
|
|
147
|
-
this._colorizeTiles(tileset3d.selectedTiles);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
_filterTiles(tiles) {
|
|
151
|
-
var _tiles$2;
|
|
152
|
-
if (this.props.filterTile && ((_tiles$2 = tiles[0]) === null || _tiles$2 === void 0 ? void 0 : _tiles$2.type) === TILE_TYPE.MESH) {
|
|
153
|
-
const {
|
|
154
|
-
layerMap,
|
|
155
|
-
filtersByAttribute
|
|
156
|
-
} = this.state;
|
|
157
|
-
const promises = [];
|
|
158
|
-
for (const tile of tiles) {
|
|
159
|
-
promises.push(this.props.filterTile(tile, filtersByAttribute));
|
|
160
|
-
}
|
|
161
|
-
this.setState({
|
|
162
|
-
loadingCounter: this.state.loadingCounter + 1
|
|
163
|
-
});
|
|
164
|
-
Promise.allSettled(promises).then(result => {
|
|
165
|
-
this.setState({
|
|
166
|
-
loadingCounter: this.state.loadingCounter - 1
|
|
167
|
-
});
|
|
168
|
-
let isTileChanged = false;
|
|
169
|
-
for (const item of result) {
|
|
170
|
-
if (item.status === 'fulfilled' && item.value.isFiltered) {
|
|
171
|
-
isTileChanged = true;
|
|
172
|
-
delete layerMap[item.value.id];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
if (isTileChanged && !this.state.loadingCounter) {
|
|
176
|
-
super._updateTileset(this.state.activeViewports);
|
|
177
|
-
this.setNeedsUpdate();
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
_filterTileset() {
|
|
183
|
-
const {
|
|
184
|
-
tileset3d
|
|
185
|
-
} = this.state;
|
|
186
|
-
if (tileset3d) {
|
|
187
|
-
this._filterTiles(tileset3d.selectedTiles);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
DataDrivenTile3DLayer.layerName = 'DataDrivenTile3DLayer';
|
|
192
|
-
DataDrivenTile3DLayer.defaultProps = defaultProps;
|
|
193
|
-
//# sourceMappingURL=data-driven-tile-3d-layer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"data-driven-tile-3d-layer.js","names":["Tile3DLayer","TILE_TYPE","Tileset3D","load","defaultProps","colorsByAttribute","filtersByAttribute","DataDrivenTile3DLayer","constructor","arguments","state","initializeState","setState","props","loadingCounter","updateState","params","oldProps","changeFlags","data","_loadTileset","_colorizeTileset","_filterTileset","viewportChanged","activeViewports","viewportsNumber","Object","keys","length","_updateTileset","lastUpdatedViewports","tilesetUrl","loadOptions","loader","loaders","Array","isArray","options","preload","preloadOptions","headers","fetch","assign","tilesetJson","tileset3d","onTileLoad","_onTileLoad","bind","onTileUnload","_onTileUnload","onTileError","onTraversalComplete","_onTraversalComplete","layerMap","onTilesetLoad","tileHeader","_colorizeTiles","_filterTiles","setNeedsUpdate","selectedTiles","tiles","_tiles$","customizeColors","type","MESH","promises","tile","push","Promise","allSettled","then","result","isTileChanged","item","status","value","isColored","id","_tiles$2","filterTile","isFiltered","layerName"],"sources":["../../src/data-driven-tile-3d-layer/data-driven-tile-3d-layer.ts"],"sourcesContent":["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {Tile3DLayer, Tile3DLayerProps} from '@deck.gl/geo-layers';\nimport {UpdateParameters, Viewport, DefaultProps} from '@deck.gl/core';\nimport {TILE_TYPE, Tile3D, Tileset3D} from '@loaders.gl/tiles';\nimport {load} from '@loaders.gl/core';\n\nconst defaultProps: DefaultProps<DataDrivenTile3DLayerProps> = {\n colorsByAttribute: null,\n filtersByAttribute: null\n};\n\ntype DataDrivenTile3DLayerProps<DataT = any> = _DataDrivenTile3DLayerProps &\n Tile3DLayerProps<DataT>;\n\ntype _DataDrivenTile3DLayerProps = {\n onTraversalComplete?: (selectedTiles: Tile3D[]) => Tile3D[];\n colorsByAttribute?: ColorsByAttribute | null;\n customizeColors?: (\n tile: Tile3D,\n colorsByAttribute: ColorsByAttribute | null\n ) => Promise<{isColored: boolean; id: string}>;\n filtersByAttribute?: FiltersByAttribute | null;\n filterTile?: (\n tile: Tile3D,\n filtersByAttribute: FiltersByAttribute | null\n ) => Promise<{isFiltered: boolean; id: string}>;\n};\n\nexport type ColorsByAttribute = {\n /** Feature attribute name */\n attributeName: string;\n /** Minimum attribute value */\n minValue: number;\n /** Maximum attribute value */\n maxValue: number;\n /** Minimum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */\n minColor: [number, number, number, number];\n /** Maximum color. 3DObject will be colorized with gradient from `minColor to `maxColor` */\n maxColor: [number, number, number, number];\n /** Colorization mode. `replace` - replace vertex colors with a new colors, `multiply` - multiply vertex colors with new colors */\n mode: string;\n};\n\nexport type FiltersByAttribute = {\n /** Feature attribute name */\n attributeName: string;\n /** Filter value */\n value: number;\n};\n\n//@ts-expect-error call of private method of the base class\nexport class DataDrivenTile3DLayer<DataT = any, ExtraProps extends {} = {}> extends Tile3DLayer<\n DataT,\n Required<_DataDrivenTile3DLayerProps> & ExtraProps\n> {\n static layerName = 'DataDrivenTile3DLayer';\n static defaultProps = defaultProps as any;\n\n state!: {\n activeViewports: any;\n frameNumber?: number;\n lastUpdatedViewports: {[viewportId: string]: Viewport} | null;\n layerMap: {[layerId: string]: any};\n tileset3d: Tileset3D | null;\n\n colorsByAttribute: ColorsByAttribute | null;\n filtersByAttribute: FiltersByAttribute | null;\n loadingCounter: number;\n };\n\n initializeState() {\n super.initializeState();\n\n this.setState({\n colorsByAttribute: this.props.colorsByAttribute,\n filtersByAttribute: this.props.filtersByAttribute,\n loadingCounter: 0\n });\n }\n\n updateState(params: UpdateParameters<this>): void {\n const {props, oldProps, changeFlags} = params;\n\n if (props.data && props.data !== oldProps.data) {\n this._loadTileset(props.data);\n } else if (props.colorsByAttribute !== oldProps.colorsByAttribute) {\n this.setState({\n colorsByAttribute: props.colorsByAttribute\n });\n this._colorizeTileset();\n } else if (props.filtersByAttribute !== oldProps.filtersByAttribute) {\n this.setState({\n filtersByAttribute: props.filtersByAttribute\n });\n this._filterTileset();\n } else if (changeFlags.viewportChanged) {\n const {activeViewports} = this.state;\n const viewportsNumber = Object.keys(activeViewports).length;\n if (viewportsNumber) {\n if (!this.state.loadingCounter) {\n //@ts-expect-error call of private method of the base class\n super._updateTileset(activeViewports);\n }\n this.state.lastUpdatedViewports = activeViewports;\n this.state.activeViewports = {};\n }\n } else {\n super.updateState(params);\n }\n }\n\n private override async _loadTileset(tilesetUrl) {\n const {loadOptions = {}} = this.props;\n\n // TODO: deprecate `loader` in v9.0\n let loader = this.props.loader || this.props.loaders;\n if (Array.isArray(loader)) {\n loader = loader[0];\n }\n\n const options = {loadOptions: {...loadOptions}};\n if (loader.preload) {\n const preloadOptions = await loader.preload(tilesetUrl, loadOptions);\n\n if (preloadOptions.headers) {\n options.loadOptions.fetch = {\n ...options.loadOptions.fetch,\n headers: preloadOptions.headers\n };\n }\n Object.assign(options, preloadOptions);\n }\n //@ts-expect-error loader\n const tilesetJson = await load(tilesetUrl, loader, options.loadOptions);\n\n const tileset3d = new Tileset3D(tilesetJson, {\n onTileLoad: this._onTileLoad.bind(this),\n //@ts-expect-error call of private method of the base class\n onTileUnload: super._onTileUnload.bind(this),\n onTileError: this.props.onTileError,\n // New code ------------------\n onTraversalComplete: this._onTraversalComplete.bind(this),\n // ---------------------------\n ...options\n });\n\n this.setState({\n tileset3d,\n layerMap: {}\n });\n\n //@ts-expect-error call of private method of the base class\n super._updateTileset(this.state.activeViewports);\n this.props.onTilesetLoad(tileset3d);\n }\n\n private override _onTileLoad(tileHeader: Tile3D): void {\n const {lastUpdatedViewports} = this.state;\n // New code ------------------\n this._colorizeTiles([tileHeader]);\n this._filterTiles([tileHeader]);\n // ---------------------------\n this.props.onTileLoad(tileHeader);\n // New code ------------------ condition is added\n if (!this.state.colorsByAttribute && !this.state.filtersByAttribute) {\n // ---------------------------\n //@ts-expect-error call of private method of the base class\n super._updateTileset(lastUpdatedViewports);\n this.setNeedsUpdate();\n // New code ------------------\n }\n // ------------------\n }\n\n private _onTraversalComplete(selectedTiles: Tile3D[]): Tile3D[] {\n this._colorizeTiles(selectedTiles);\n this._filterTiles(selectedTiles);\n return this.props.onTraversalComplete\n ? this.props.onTraversalComplete(selectedTiles)\n : selectedTiles;\n }\n\n private _colorizeTiles(tiles: Tile3D[]): void {\n if (this.props.customizeColors && tiles[0]?.type === TILE_TYPE.MESH) {\n const {layerMap, colorsByAttribute} = this.state;\n const promises: Promise<{isColored: boolean; id: string}>[] = [];\n for (const tile of tiles) {\n promises.push(this.props.customizeColors(tile, colorsByAttribute));\n }\n this.setState({\n loadingCounter: this.state.loadingCounter + 1\n });\n Promise.allSettled(promises).then((result) => {\n this.setState({\n loadingCounter: this.state.loadingCounter - 1\n });\n let isTileChanged = false;\n for (const item of result) {\n if (item.status === 'fulfilled' && item.value.isColored) {\n isTileChanged = true;\n delete layerMap[item.value.id];\n }\n }\n if (isTileChanged && !this.state.loadingCounter) {\n //@ts-expect-error call of private method of the base class\n super._updateTileset(this.state.activeViewports);\n this.setNeedsUpdate();\n }\n });\n }\n }\n\n private _colorizeTileset(): void {\n const {tileset3d} = this.state;\n\n if (tileset3d) {\n this._colorizeTiles(tileset3d.selectedTiles);\n }\n }\n\n private _filterTiles(tiles: Tile3D[]): void {\n if (this.props.filterTile && tiles[0]?.type === TILE_TYPE.MESH) {\n const {layerMap, filtersByAttribute} = this.state;\n const promises: Promise<{isFiltered: boolean; id: string}>[] = [];\n for (const tile of tiles) {\n promises.push(this.props.filterTile(tile, filtersByAttribute));\n }\n this.setState({\n loadingCounter: this.state.loadingCounter + 1\n });\n Promise.allSettled(promises).then((result) => {\n this.setState({\n loadingCounter: this.state.loadingCounter - 1\n });\n let isTileChanged = false;\n for (const item of result) {\n if (item.status === 'fulfilled' && item.value.isFiltered) {\n isTileChanged = true;\n delete layerMap[item.value.id];\n }\n }\n if (isTileChanged && !this.state.loadingCounter) {\n //@ts-expect-error call of private method of the base class\n super._updateTileset(this.state.activeViewports);\n this.setNeedsUpdate();\n }\n });\n }\n }\n\n private _filterTileset(): void {\n const {tileset3d} = this.state;\n\n if (tileset3d) {\n this._filterTiles(tileset3d.selectedTiles);\n }\n }\n}\n"],"mappings":"AAIA,SAAQA,WAAW,QAAyB,qBAAqB;AAEjE,SAAQC,SAAS,EAAUC,SAAS,QAAO,mBAAmB;AAC9D,SAAQC,IAAI,QAAO,kBAAkB;AAErC,MAAMC,YAAsD,GAAG;EAC7DC,iBAAiB,EAAE,IAAI;EACvBC,kBAAkB,EAAE;AACtB,CAAC;AA0CD,OAAO,MAAMC,qBAAqB,SAAkDP,WAAW,CAG7F;EAAAQ,YAAA;IAAA,SAAAC,SAAA;IAAA,KAIAC,KAAK;EAAA;EAYLC,eAAeA,CAAA,EAAG;IAChB,KAAK,CAACA,eAAe,CAAC,CAAC;IAEvB,IAAI,CAACC,QAAQ,CAAC;MACZP,iBAAiB,EAAE,IAAI,CA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AC,GAAG,IAAI,CAAClC,KAAK;IAE9B,IAAIkC,SAAS,EAAE;MACb,IAAI,CAACa,YAAY,CAACb,SAAS,CAACe,aAAa,CAAC;IAC5C;EACF;AACF;AA9MapD,qBAAqB,CAIzB0E,SAAS,GAAG,uBAAuB;AAJ/B1E,qBAAqB,CAKzBH,YAAY,GAAGA,YAAY"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { customizeColors } from '@loaders.gl/i3s';
|
|
2
|
-
export const colorizeTile = async (tile, colorsByAttribute) => {
|
|
3
|
-
const result = {
|
|
4
|
-
isColored: false,
|
|
5
|
-
id: tile.id
|
|
6
|
-
};
|
|
7
|
-
if (tile.content.customColors !== colorsByAttribute) {
|
|
8
|
-
if (tile.content && colorsByAttribute) {
|
|
9
|
-
if (!tile.content.originalColorsAttributes) {
|
|
10
|
-
tile.content.originalColorsAttributes = {
|
|
11
|
-
...tile.content.attributes.colors,
|
|
12
|
-
value: new Uint8Array(tile.content.attributes.colors.value)
|
|
13
|
-
};
|
|
14
|
-
} else if (colorsByAttribute.mode === 'multiply') {
|
|
15
|
-
tile.content.attributes.colors.value.set(tile.content.originalColorsAttributes.value);
|
|
16
|
-
}
|
|
17
|
-
tile.content.customColors = colorsByAttribute;
|
|
18
|
-
const newColors = await customizeColors(tile.content.attributes.colors, tile.content.featureIds, tile.header.attributeUrls, tile.tileset.tileset.fields, tile.tileset.tileset.attributeStorageInfo, colorsByAttribute, tile.tileset.loadOptions.i3s.token);
|
|
19
|
-
if (tile.content.customColors === colorsByAttribute) {
|
|
20
|
-
tile.content.attributes.colors = newColors;
|
|
21
|
-
result.isColored = true;
|
|
22
|
-
}
|
|
23
|
-
} else if (tile.content && tile.content.originalColorsAttributes) {
|
|
24
|
-
tile.content.attributes.colors.value = tile.content.originalColorsAttributes.value;
|
|
25
|
-
tile.content.customColors = null;
|
|
26
|
-
result.isColored = true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=colorize-tile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colorize-tile.js","names":["customizeColors","colorizeTile","tile","colorsByAttribute","result","isColored","id","content","customColors","originalColorsAttributes","attributes","colors","value","Uint8Array","mode","set","newColors","featureIds","header","attributeUrls","tileset","fields","attributeStorageInfo","loadOptions","i3s","token"],"sources":["../../../src/data-driven-tile-3d-layer/utils/colorize-tile.ts"],"sourcesContent":["// deck.gl-community\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {customizeColors} from '@loaders.gl/i3s';\nimport {Tile3D} from '@loaders.gl/tiles';\nimport {ColorsByAttribute} from '../data-driven-tile-3d-layer';\n\n/**\n * Update tile colors with the custom colors assigned to the I3S Loader\n * @returns {Promise<{isColored: boolean; id: string}>} Result of the tile colorization - isColored: true/false and tile id\n */\nexport const colorizeTile = async (\n tile: Tile3D,\n colorsByAttribute: ColorsByAttribute | null\n): Promise<{isColored: boolean; id: string}> => {\n const result = {isColored: false, id: tile.id};\n\n if (tile.content.customColors !== colorsByAttribute) {\n if (tile.content && colorsByAttribute) {\n if (!tile.content.originalColorsAttributes) {\n tile.content.originalColorsAttributes = {\n ...tile.content.attributes.colors,\n value: new Uint8Array(tile.content.attributes.colors.value)\n };\n } else if (colorsByAttribute.mode === 'multiply') {\n tile.content.attributes.colors.value.set(tile.content.originalColorsAttributes.value);\n }\n\n tile.content.customColors = colorsByAttribute;\n\n const newColors = await customizeColors(\n tile.content.attributes.colors,\n tile.content.featureIds,\n tile.header.attributeUrls,\n tile.tileset.tileset.fields,\n tile.tileset.tileset.attributeStorageInfo,\n colorsByAttribute,\n (tile.tileset.loadOptions as any).i3s.token\n );\n // Make sure custom colors is not changed during async customizeColors execution\n if (tile.content.customColors === colorsByAttribute) {\n tile.content.attributes.colors = newColors;\n result.isColored = true;\n }\n } else if (tile.content && tile.content.originalColorsAttributes) {\n tile.content.attributes.colors.value = tile.content.originalColorsAttributes.value;\n tile.content.customColors = null;\n result.isColored = true;\n }\n }\n return result;\n};\n"],"mappings":"AAIA,SAAQA,eAAe,QAAO,iBAAiB;AAQ/C,OAAO,MAAMC,YAAY,GAAG,MAAAA,CAC1BC,IAAY,EACZC,iBAA2C,KACG;EAC9C,MAAMC,MAAM,GAAG;IAACC,SAAS,EAAE,KAAK;IAAEC,EAAE,EAAEJ,IAAI,CAACI;EAAE,CAAC;EAE9C,IAAIJ,IAAI,CAACK,OAAO,CAACC,YAAY,KAAKL,iBAAiB,EAAE;IACnD,IAAID,IAAI,CAACK,OAAO,IAAIJ,iBAAiB,EAAE;MACrC,IAAI,CAACD,IAAI,CAACK,OAAO,CAACE,wBAAwB,EAAE;QAC1CP,IAAI,CAACK,OAAO,CAACE,wBAAwB,GAAG;UACtC,GAAGP,IAAI,CAACK,OAAO,CAACG,UAAU,CAACC,MAAM;UACjCC,KAAK,EAAE,IAAIC,UAAU,CAACX,IAAI,CAACK,OAAO,CAACG,UAAU,CAACC,MAAM,CAACC,KAAK;QAC5D,CAAC;MACH,CAAC,MAAM,IAAIT,iBAAiB,CAACW,IAAI,KAAK,UAAU,EAAE;QAChDZ,IAAI,CAACK,OAAO,CAACG,UAAU,CAACC,MAAM,CAACC,KAAK,CAACG,GAAG,CAACb,IAAI,CAACK,OAAO,CAACE,wBAAwB,CAACG,KAAK,CAAC;MACvF;MAEAV,IAAI,CAACK,OAAO,CAACC,YAAY,GAAGL,iBAAiB;MAE7C,MAAMa,SAAS,GAAG,MAAMhB,eAAe,CACrCE,IAAI,CAACK,OAAO,CAACG,UAAU,CAACC,MAAM,EAC9BT,IAAI,CAACK,OAAO,CAACU,UAAU,EACvBf,IAAI,CAACgB,MAAM,CAACC,aAAa,EACzBjB,IAAI,CAACkB,OAAO,CAACA,OAAO,CAACC,MAAM,EAC3BnB,IAAI,CAACkB,OAAO,CAACA,OAAO,CAACE,oBAAoB,EACzCnB,iBAAiB,EAChBD,IAAI,CAACkB,OAAO,CAACG,WAAW,CAASC,GAAG,CAACC,KACxC,CAAC;MAED,IAAIvB,IAAI,CAACK,OAAO,CAACC,YAAY,KAAKL,iBAAiB,EAAE;QACnDD,IAAI,CAACK,OAAO,CAACG,UAAU,CAACC,MAAM,GAAGK,SAAS;QAC1CZ,MAAM,CAACC,SAAS,GAAG,IAAI;MACzB;IACF,CAAC,MAAM,IAAIH,IAAI,CAACK,OAAO,IAAIL,IAAI,CAACK,OAAO,CAACE,wBAAwB,EAAE;MAChEP,IAAI,CAACK,OAAO,CAACG,UAAU,CAACC,MAAM,CAACC,KAAK,GAAGV,IAAI,CAACK,OAAO,CAACE,wBAAwB,CAACG,KAAK;MAClFV,IAAI,CAACK,OAAO,CAACC,YAAY,GAAG,IAAI;MAChCJ,MAAM,CAACC,SAAS,GAAG,IAAI;IACzB;EACF;EACA,OAAOD,MAAM;AACf,CAAC"}
|
|
@@ -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 (attrib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G,IAAI;EAC/D,OAAOxC,KAAK,GAAI,GAAEuC,GAAI,UAASvC,KAAM,EAAC,GAAGuC,GAAG;AAC9C;AAEA,SAASD,qBAAqBA,CAACG,SAA+B,EAAE;EAE9D,IAAIA,SAAS,CAACC,cAAc,CAAC,WAAW,CAAC,EAAE;IACzC,OAAO,OAAO;EAEhB,CAAC,MAAM,IAAID,SAAS,CAACC,cAAc,CAAC,iBAAiB,CAAC,EAAE;IAAA,IAAAC,qBAAA;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,q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