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