@gisatcz/deckgl-geolib 1.11.0-dev.6 → 1.11.0-dev.7
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/cjs/index.js +16 -29
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +4 -4
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/cjs/types/cogbitmaplayer/CogBitmapLayer.d.ts +9 -5
- package/dist/esm/index.js +16 -29
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/types/cogbitmaplayer/CogBitmapLayer.d.ts +9 -5
- package/package.json +1 -1
- package/src/cogbitmaplayer/CogBitmapLayer.ts +27 -41
|
@@ -17,8 +17,6 @@ export type ClampToTerrainOptions = {
|
|
|
17
17
|
terrainDrawMode?: string;
|
|
18
18
|
};
|
|
19
19
|
type MeshAndTexture = [MeshAttributes | null, TextureSource | null];
|
|
20
|
-
/** All properties supported by CogBitmapLayer */
|
|
21
|
-
export type CogBitmapLayerProps = _CogBitmapLayerProps & TileLayerProps<MeshAndTexture> & CompositeLayerProps;
|
|
22
20
|
/** Props added by the CogBitmapLayer */
|
|
23
21
|
type _CogBitmapLayerProps = {
|
|
24
22
|
/** Image url that encodes raster data. * */
|
|
@@ -33,26 +31,31 @@ type _CogBitmapLayerProps = {
|
|
|
33
31
|
* TODO
|
|
34
32
|
*/
|
|
35
33
|
cogBitmapOptions: GeoImageOptions;
|
|
34
|
+
isTiled: boolean;
|
|
36
35
|
/**
|
|
37
36
|
* @deprecated Use `loadOptions.terrain.workerUrl` instead
|
|
38
37
|
*/
|
|
39
38
|
workerUrl?: string;
|
|
40
39
|
};
|
|
40
|
+
/** All properties supported by CogBitmapLayer */
|
|
41
|
+
export type CogBitmapLayerProps = _CogBitmapLayerProps & TileLayerProps<MeshAndTexture> & CompositeLayerProps;
|
|
41
42
|
/** Render bitmap texture from cog raster images. */
|
|
42
43
|
export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends CompositeLayer<ExtraPropsT & Required<_CogBitmapLayerProps & Required<TileLayerProps<MeshAndTexture>>>> {
|
|
43
44
|
static defaultProps: DefaultProps<CogBitmapLayerProps>;
|
|
44
45
|
static layerName: string;
|
|
45
|
-
rasterUrl: string;
|
|
46
46
|
minZoom: number;
|
|
47
47
|
maxZoom: number;
|
|
48
48
|
state: {
|
|
49
|
+
initialized: boolean;
|
|
49
50
|
isTiled?: boolean;
|
|
50
51
|
terrain?: MeshAttributes;
|
|
51
52
|
zRange?: ZRange | null;
|
|
52
53
|
bitmapCogTiles: any;
|
|
54
|
+
minZoom: number;
|
|
55
|
+
maxZoom: number;
|
|
53
56
|
};
|
|
54
57
|
initializeState(context: any): Promise<void>;
|
|
55
|
-
init(
|
|
58
|
+
init(): Promise<void>;
|
|
56
59
|
updateState({ props, oldProps }: UpdateParameters<this>): void;
|
|
57
60
|
getTiledBitmapData(tile: TileLoadProps): Promise<TextureSource>;
|
|
58
61
|
renderSubLayers(props: TileLayerProps<TextureSource> & {
|
|
@@ -66,11 +69,12 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
66
69
|
updateTriggers: {
|
|
67
70
|
getTileData: {
|
|
68
71
|
rasterData: string;
|
|
72
|
+
cogBitmapOptions: GeoImageOptions;
|
|
69
73
|
clampToTerrain: boolean | ClampToTerrainOptions;
|
|
70
74
|
};
|
|
71
75
|
};
|
|
72
76
|
extent: any;
|
|
73
|
-
tileSize:
|
|
77
|
+
tileSize: any;
|
|
74
78
|
minZoom: number;
|
|
75
79
|
maxZoom: number;
|
|
76
80
|
maxRequests: number;
|
package/package.json
CHANGED
|
@@ -106,11 +106,6 @@ function urlTemplateToUpdateTrigger(template: URLTemplate): string {
|
|
|
106
106
|
|
|
107
107
|
type MeshAndTexture = [MeshAttributes | null, TextureSource | null];
|
|
108
108
|
|
|
109
|
-
/** All properties supported by CogBitmapLayer */
|
|
110
|
-
export type CogBitmapLayerProps = _CogBitmapLayerProps &
|
|
111
|
-
TileLayerProps<MeshAndTexture> &
|
|
112
|
-
CompositeLayerProps;
|
|
113
|
-
|
|
114
109
|
/** Props added by the CogBitmapLayer */
|
|
115
110
|
type _CogBitmapLayerProps = {
|
|
116
111
|
/** Image url that encodes raster data. * */
|
|
@@ -130,12 +125,19 @@ type _CogBitmapLayerProps = {
|
|
|
130
125
|
*/
|
|
131
126
|
cogBitmapOptions: GeoImageOptions;
|
|
132
127
|
|
|
128
|
+
isTiled: boolean;
|
|
129
|
+
|
|
133
130
|
/**
|
|
134
131
|
* @deprecated Use `loadOptions.terrain.workerUrl` instead
|
|
135
132
|
*/
|
|
136
133
|
workerUrl?: string;
|
|
137
134
|
};
|
|
138
135
|
|
|
136
|
+
/** All properties supported by CogBitmapLayer */
|
|
137
|
+
export type CogBitmapLayerProps = _CogBitmapLayerProps &
|
|
138
|
+
TileLayerProps<MeshAndTexture> &
|
|
139
|
+
CompositeLayerProps;
|
|
140
|
+
|
|
139
141
|
/** Render bitmap texture from cog raster images. */
|
|
140
142
|
export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends CompositeLayer<
|
|
141
143
|
ExtraPropsT & Required<_CogBitmapLayerProps & Required<TileLayerProps<MeshAndTexture>>>
|
|
@@ -144,17 +146,18 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
144
146
|
|
|
145
147
|
static layerName = 'CogBitmapLayer';
|
|
146
148
|
|
|
147
|
-
rasterUrl: string;
|
|
148
|
-
|
|
149
149
|
minZoom: number;
|
|
150
150
|
|
|
151
151
|
maxZoom: number;
|
|
152
152
|
|
|
153
153
|
state!: {
|
|
154
|
+
initialized: boolean;
|
|
154
155
|
isTiled?: boolean;
|
|
155
156
|
terrain?: MeshAttributes;
|
|
156
157
|
zRange?: ZRange | null;
|
|
157
158
|
bitmapCogTiles: any;
|
|
159
|
+
minZoom: number;
|
|
160
|
+
maxZoom: number;
|
|
158
161
|
};
|
|
159
162
|
|
|
160
163
|
// private _isLoaded: boolean;
|
|
@@ -178,17 +181,17 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
178
181
|
initialized: false,
|
|
179
182
|
});
|
|
180
183
|
|
|
181
|
-
await this.init(
|
|
184
|
+
await this.init();
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
async init(
|
|
187
|
+
async init() {
|
|
185
188
|
const cog = await this.state.bitmapCogTiles.initializeCog(this.props.rasterData);
|
|
186
|
-
// this.tileSize = this.terrainCogTiles.getTileSize(cog);
|
|
187
189
|
|
|
188
190
|
const zoomRange = this.state.bitmapCogTiles.getZoomRange(cog);
|
|
189
|
-
[this.minZoom, this.maxZoom] = zoomRange;
|
|
190
191
|
|
|
191
|
-
|
|
192
|
+
const [minZoom, maxZoom] = zoomRange;
|
|
193
|
+
|
|
194
|
+
this.setState({ initialized: true, minZoom, maxZoom });
|
|
192
195
|
}
|
|
193
196
|
|
|
194
197
|
updateState({ props, oldProps }: UpdateParameters<this>): void {
|
|
@@ -196,8 +199,8 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
196
199
|
if (rasterDataChanged) {
|
|
197
200
|
const { rasterData } = props;
|
|
198
201
|
const isTiled = rasterData
|
|
199
|
-
&& (Array.isArray(rasterData)
|
|
200
|
-
|| (rasterData.includes('{x}') && rasterData.includes('{y}'))) || this.props.isTiled;
|
|
202
|
+
&& ((Array.isArray(rasterData)
|
|
203
|
+
|| (rasterData.includes('{x}') && rasterData.includes('{y}'))) || this.props.isTiled);
|
|
201
204
|
this.setState({ isTiled });
|
|
202
205
|
}
|
|
203
206
|
|
|
@@ -221,37 +224,16 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
221
224
|
}
|
|
222
225
|
|
|
223
226
|
async getTiledBitmapData(tile: TileLoadProps): Promise<TextureSource> {
|
|
224
|
-
// const {
|
|
225
|
-
// rasterData, fetch,
|
|
226
|
-
// } = this.props;
|
|
227
|
-
const { viewport } = this.context;
|
|
228
|
-
// const dataUrl = getURLFromTemplate(rasterData, tile);
|
|
229
|
-
// const textureUrl = texture && getURLFromTemplate(texture, tile);
|
|
230
|
-
|
|
231
|
-
const { signal } = tile;
|
|
232
|
-
let bottomLeft = [0, 0] as [number, number];
|
|
233
|
-
let topRight = [0, 0] as [number, number];
|
|
234
|
-
if (viewport.isGeospatial) {
|
|
235
|
-
const bbox = tile.bbox as GeoBoundingBox;
|
|
236
|
-
|
|
237
|
-
bottomLeft = viewport.projectFlat([bbox.west, bbox.south]);
|
|
238
|
-
topRight = viewport.projectFlat([bbox.east, bbox.north]);
|
|
239
|
-
} else {
|
|
240
|
-
const bbox = tile.bbox as Exclude<TileBoundingBox, GeoBoundingBox>;
|
|
241
|
-
bottomLeft = [bbox.left, bbox.bottom];
|
|
242
|
-
topRight = [bbox.right, bbox.top];
|
|
243
|
-
}
|
|
244
|
-
const bounds: Bounds = [bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]];
|
|
245
|
-
|
|
246
227
|
// TODO - pass signal to getTile
|
|
247
228
|
// abort request if signal is aborted
|
|
248
|
-
|
|
229
|
+
const tileData = await this.state.bitmapCogTiles.getTile(
|
|
249
230
|
tile.index.x,
|
|
250
231
|
tile.index.y,
|
|
251
232
|
tile.index.z,
|
|
252
233
|
// bounds,
|
|
253
234
|
// this.props.meshMaxError,
|
|
254
235
|
);
|
|
236
|
+
return tileData;
|
|
255
237
|
}
|
|
256
238
|
|
|
257
239
|
renderSubLayers(
|
|
@@ -278,7 +260,7 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
278
260
|
},
|
|
279
261
|
} = props.tile;
|
|
280
262
|
|
|
281
|
-
return new SubLayerClass({ ...props, tileSize:
|
|
263
|
+
return new SubLayerClass({ ...props, tileSize: this.state.bitmapCogTiles.tileSize }, {
|
|
282
264
|
data: null,
|
|
283
265
|
image: data,
|
|
284
266
|
_instanced: false,
|
|
@@ -302,7 +284,7 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
302
284
|
blurredTexture,
|
|
303
285
|
opacity,
|
|
304
286
|
clampToTerrain,
|
|
305
|
-
tileSize,
|
|
287
|
+
// tileSize,
|
|
306
288
|
maxRequests,
|
|
307
289
|
onTileLoad,
|
|
308
290
|
onTileUnload,
|
|
@@ -310,8 +292,11 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
310
292
|
maxCacheSize,
|
|
311
293
|
maxCacheByteSize,
|
|
312
294
|
refinementStrategy,
|
|
295
|
+
cogBitmapOptions,
|
|
313
296
|
} = this.props;
|
|
314
297
|
if (this.state.isTiled && this.state.initialized) {
|
|
298
|
+
const { tileSize } = this.state.bitmapCogTiles;
|
|
299
|
+
|
|
315
300
|
return new TileLayer(this.getSubLayerProps({
|
|
316
301
|
id: 'tiles',
|
|
317
302
|
}), {
|
|
@@ -322,14 +307,15 @@ export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends Composi
|
|
|
322
307
|
rasterData: urlTemplateToUpdateTrigger(rasterData),
|
|
323
308
|
// blurredTexture,
|
|
324
309
|
// opacity,
|
|
310
|
+
cogBitmapOptions,
|
|
325
311
|
clampToTerrain,
|
|
326
312
|
},
|
|
327
313
|
},
|
|
328
314
|
extent: this.state.bitmapCogTiles.cog
|
|
329
315
|
? this.state.bitmapCogTiles.getBoundsAsLatLon(this.state.bitmapCogTiles.cog) : null,
|
|
330
316
|
tileSize,
|
|
331
|
-
minZoom: this.minZoom,
|
|
332
|
-
maxZoom: this.maxZoom,
|
|
317
|
+
minZoom: this.state.minZoom,
|
|
318
|
+
maxZoom: this.state.maxZoom,
|
|
333
319
|
maxRequests,
|
|
334
320
|
onTileLoad,
|
|
335
321
|
onTileUnload,
|