@gisatcz/deckgl-geolib 1.11.0-dev.1 → 1.11.0-dev.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/cjs/index.js +283 -51
- 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 +56 -37
- package/dist/esm/index.js +283 -51
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +4 -4
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/types/cogbitmaplayer/CogBitmapLayer.d.ts +56 -37
- package/package.json +1 -1
- package/src/cogbitmaplayer/CogBitmapLayer.ts +435 -79
|
@@ -1,42 +1,61 @@
|
|
|
1
|
-
import { CompositeLayer } from '@deck.gl/core';
|
|
2
|
-
import {
|
|
1
|
+
import { CompositeLayer, CompositeLayerProps, DefaultProps, Layer, LayersList, TextureSource, UpdateParameters } from '@deck.gl/core';
|
|
2
|
+
import { TileLayerProps, GeoBoundingBox, _TileLoadProps as TileLoadProps, _Tile2DHeader as Tile2DHeader, NonGeoBoundingBox } from '@deck.gl/geo-layers';
|
|
3
3
|
import { BitmapLayer } from '@deck.gl/layers';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import type { MeshAttributes } from '@loaders.gl/schema';
|
|
5
|
+
export type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;
|
|
6
|
+
export type ZRange = [minZ: number, maxZ: number];
|
|
7
|
+
export type Bounds = [minX: number, minY: number, maxX: number, maxY: number];
|
|
8
|
+
export type URLTemplate = string | string[] | null;
|
|
9
|
+
export declare const urlType: {
|
|
10
|
+
type: "object";
|
|
11
|
+
value: URLTemplate;
|
|
12
|
+
validate: (value: any, propType: any) => boolean;
|
|
13
|
+
equal: (value1: any, value2: any) => boolean;
|
|
14
|
+
};
|
|
15
|
+
type MeshAndTexture = [MeshAttributes | null, TextureSource | null];
|
|
16
|
+
/** All properties supported by CogBitmapLayer */
|
|
17
|
+
export type CogBitmapLayerProps = _CogBitmapLayerProps & TileLayerProps<MeshAndTexture> & CompositeLayerProps;
|
|
18
|
+
/** Props added by the CogBitmapLayer */
|
|
19
|
+
type _CogBitmapLayerProps = {
|
|
20
|
+
/** Image url that encodes raster data. * */
|
|
21
|
+
rasterData: URLTemplate;
|
|
22
|
+
/** Bounding box of the bitmap image, [minX, minY, maxX, maxY] in world coordinates. * */
|
|
23
|
+
bounds: Bounds | null;
|
|
24
|
+
/** Whether the rendered texture should be blurred or not - effects minFilter and maxFilter * */
|
|
25
|
+
blurredTexture?: boolean;
|
|
26
|
+
/** Whether the rendered texture should be clamped to terrain * */
|
|
27
|
+
clampToTerrain?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* TODO
|
|
30
|
+
*/
|
|
31
|
+
cogBitmapOptions: Object;
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Use `loadOptions.terrain.workerUrl` instead
|
|
34
|
+
*/
|
|
35
|
+
workerUrl?: string;
|
|
36
|
+
};
|
|
37
|
+
/** Render bitmap texture from cog raster images. */
|
|
38
|
+
export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends CompositeLayer<ExtraPropsT & Required<_CogBitmapLayerProps & Required<TileLayerProps<MeshAndTexture>>>> {
|
|
39
|
+
static defaultProps: DefaultProps<CogBitmapLayerProps>;
|
|
8
40
|
static layerName: string;
|
|
9
|
-
|
|
10
|
-
url: string;
|
|
11
|
-
static displayName: string;
|
|
12
|
-
cogTiles: CogTiles;
|
|
13
|
-
tileSize: number;
|
|
41
|
+
rasterUrl: string;
|
|
14
42
|
minZoom: number;
|
|
15
43
|
maxZoom: number;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
bounds: [any, any, any, any];
|
|
33
|
-
opacity: number;
|
|
34
|
-
textureParameters: {
|
|
35
|
-
minFilter: "linear" | "nearest";
|
|
36
|
-
magFilter: "linear" | "nearest";
|
|
37
|
-
};
|
|
38
|
-
extensions: TerrainExtension[];
|
|
39
|
-
}>;
|
|
40
|
-
}>;
|
|
44
|
+
state: {
|
|
45
|
+
isTiled?: boolean;
|
|
46
|
+
terrain?: MeshAttributes;
|
|
47
|
+
zRange?: ZRange | null;
|
|
48
|
+
};
|
|
49
|
+
initializeState(context: any): Promise<void>;
|
|
50
|
+
init(rasterUrl: string): Promise<void>;
|
|
51
|
+
updateState({ props, oldProps }: UpdateParameters<this>): void;
|
|
52
|
+
getTiledBitmapData(tile: TileLoadProps): Promise<TextureSource>;
|
|
53
|
+
renderSubLayers(props: TileLayerProps<TextureSource> & {
|
|
54
|
+
id: string;
|
|
55
|
+
data: TextureSource;
|
|
56
|
+
tile: Tile2DHeader<TextureSource>;
|
|
57
|
+
}): BitmapLayer<{}>;
|
|
58
|
+
onViewportLoad(tiles?: Tile2DHeader<MeshAndTexture>[]): void;
|
|
59
|
+
renderLayers(): Layer | null | LayersList;
|
|
41
60
|
}
|
|
42
|
-
export
|
|
61
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,113 +1,469 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Color,
|
|
3
|
+
CompositeLayer,
|
|
4
|
+
CompositeLayerProps,
|
|
5
|
+
DefaultProps,
|
|
6
|
+
Layer,
|
|
7
|
+
LayersList,
|
|
8
|
+
log,
|
|
9
|
+
TextureSource,
|
|
10
|
+
UpdateParameters,
|
|
11
|
+
COORDINATE_SYSTEM,
|
|
12
|
+
} from '@deck.gl/core';
|
|
13
|
+
import {
|
|
14
|
+
TileLayer, TileLayerProps, GeoBoundingBox, _TileLoadProps as TileLoadProps,
|
|
15
|
+
_Tile2DHeader as Tile2DHeader, _getURLFromTemplate as getURLFromTemplate, NonGeoBoundingBox,
|
|
16
|
+
} from '@deck.gl/geo-layers';
|
|
3
17
|
import { BitmapLayer } from '@deck.gl/layers';
|
|
4
|
-
import { _TerrainExtension as TerrainExtension } from '@deck.gl/extensions';
|
|
5
|
-
import { GL } from '@luma.gl/constants';
|
|
18
|
+
// import { _TerrainExtension as TerrainExtension } from '@deck.gl/extensions';
|
|
19
|
+
// import { GL } from '@luma.gl/constants';
|
|
6
20
|
// import GL from '@luma.gl/constants';
|
|
7
21
|
// GL.GL.CLIP_DISTANCE0_WEBGL
|
|
22
|
+
import type { MeshAttributes } from '@loaders.gl/schema';
|
|
8
23
|
import CogTiles from '../cogtiles/cogtiles.ts';
|
|
9
24
|
|
|
10
25
|
import { GeoImageOptions } from '../geoimage/geoimage.ts';
|
|
26
|
+
// import { TileBoundingBox, ZRange } from '../cogterrainlayer/CogTerrainLayer.js';
|
|
27
|
+
export type TileBoundingBox = NonGeoBoundingBox | GeoBoundingBox;
|
|
28
|
+
|
|
29
|
+
export type ZRange = [minZ: number, maxZ: number];
|
|
11
30
|
|
|
12
31
|
// let needsRerender: boolean = false;
|
|
13
32
|
// let extent = [0, 0, 0, 0]
|
|
33
|
+
export type Bounds = [minX: number, minY: number, maxX: number, maxY: number];
|
|
14
34
|
|
|
15
|
-
|
|
16
|
-
static layerName = 'CogBitmapLayer';
|
|
35
|
+
export type URLTemplate = string | string[] | null;
|
|
17
36
|
|
|
18
|
-
|
|
37
|
+
export const urlType = {
|
|
38
|
+
type: 'object' as const,
|
|
39
|
+
value: null as URLTemplate,
|
|
40
|
+
validate: (value, propType) => (propType.optional && value === null)
|
|
41
|
+
|| typeof value === 'string'
|
|
42
|
+
|| (Array.isArray(value) && value.every((url) => typeof url === 'string')),
|
|
43
|
+
equal: (value1, value2) => {
|
|
44
|
+
if (value1 === value2) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (!Array.isArray(value1) || !Array.isArray(value2)) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
const len = value1.length;
|
|
51
|
+
if (len !== value2.length) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
for (let i = 0; i < len; i++) {
|
|
55
|
+
if (value1[i] !== value2[i]) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const DUMMY_DATA = [1];
|
|
64
|
+
|
|
65
|
+
const defaultProps: DefaultProps<CogBitmapLayerProps> = {
|
|
66
|
+
...TileLayer.defaultProps,
|
|
67
|
+
// Image url that encodes height data
|
|
68
|
+
// elevationData: urlType,
|
|
69
|
+
// Image url to use as texture
|
|
70
|
+
// texture: { ...urlType, optional: true },
|
|
71
|
+
// Martini error tolerance in meters, smaller number -> more detailed mesh
|
|
72
|
+
// meshMaxError: { type: 'number', value: 4.0 },
|
|
73
|
+
// Bounding box of the terrain image, [minX, minY, maxX, maxY] in world coordinates
|
|
74
|
+
bounds: {
|
|
75
|
+
type: 'array', value: null, optional: true, compare: true,
|
|
76
|
+
},
|
|
77
|
+
rasterData: urlType,
|
|
78
|
+
// Color to use if texture is unavailable
|
|
79
|
+
// color: { type: 'color', value: [255, 255, 255] },
|
|
80
|
+
blurredTexture: true,
|
|
81
|
+
clampToTerrain: true,
|
|
82
|
+
// Object to decode height data, from (r, g, b) to height in meters
|
|
83
|
+
// elevationDecoder: {
|
|
84
|
+
// type: 'object',
|
|
85
|
+
// value: {
|
|
86
|
+
// rScaler: 1,
|
|
87
|
+
// gScaler: 0,
|
|
88
|
+
// bScaler: 0,
|
|
89
|
+
// offset: 0,
|
|
90
|
+
// },
|
|
91
|
+
// },
|
|
92
|
+
// Supply url to local terrain worker bundle. Only required if running offline and cannot access CDN.
|
|
93
|
+
workerUrl: '',
|
|
94
|
+
// Same as SimpleMeshLayer wireframe
|
|
95
|
+
// wireframe: false,
|
|
96
|
+
// material: true,
|
|
97
|
+
|
|
98
|
+
// loaders: [TerrainLoader],
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// Turns array of templates into a single string to work around shallow change
|
|
102
|
+
function urlTemplateToUpdateTrigger(template: URLTemplate): string {
|
|
103
|
+
if (Array.isArray(template)) {
|
|
104
|
+
return template.join(';');
|
|
105
|
+
}
|
|
106
|
+
return template || '';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
type MeshAndTexture = [MeshAttributes | null, TextureSource | null];
|
|
110
|
+
|
|
111
|
+
/** All properties supported by CogBitmapLayer */
|
|
112
|
+
export type CogBitmapLayerProps = _CogBitmapLayerProps &
|
|
113
|
+
TileLayerProps<MeshAndTexture> &
|
|
114
|
+
CompositeLayerProps;
|
|
115
|
+
|
|
116
|
+
/** Props added by the CogBitmapLayer */
|
|
117
|
+
type _CogBitmapLayerProps = {
|
|
118
|
+
/** Image url that encodes raster data. * */
|
|
119
|
+
rasterData: URLTemplate;
|
|
120
|
+
|
|
121
|
+
// /** Image url to use as texture. * */
|
|
122
|
+
// texture?: URLTemplate;
|
|
123
|
+
|
|
124
|
+
// /** Martini error tolerance in meters, smaller number -> more detailed mesh. * */
|
|
125
|
+
// meshMaxError?: number;
|
|
19
126
|
|
|
20
|
-
|
|
127
|
+
/** Bounding box of the bitmap image, [minX, minY, maxX, maxY] in world coordinates. * */
|
|
128
|
+
bounds: Bounds | null;
|
|
21
129
|
|
|
22
|
-
|
|
130
|
+
// /** Color to use if texture is unavailable. * */
|
|
131
|
+
// color?: Color;
|
|
23
132
|
|
|
24
|
-
|
|
133
|
+
// /** Object to decode height data, from (r, g, b) to height in meters. * */
|
|
134
|
+
// elevationDecoder?: ElevationDecoder;
|
|
25
135
|
|
|
26
|
-
|
|
136
|
+
/** Whether the rendered texture should be blurred or not - effects minFilter and maxFilter * */
|
|
137
|
+
blurredTexture?: boolean;
|
|
27
138
|
|
|
28
|
-
|
|
139
|
+
/** Whether the rendered texture should be clamped to terrain * */
|
|
140
|
+
clampToTerrain?: boolean;
|
|
141
|
+
|
|
142
|
+
// /** Whether to render the mesh in wireframe mode. * */
|
|
143
|
+
// wireframe?: boolean;
|
|
144
|
+
|
|
145
|
+
// /** Material props for lighting effect. * */
|
|
146
|
+
// material?: Material;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* TODO
|
|
150
|
+
*/
|
|
151
|
+
cogBitmapOptions: Object;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @deprecated Use `loadOptions.terrain.workerUrl` instead
|
|
155
|
+
*/
|
|
156
|
+
workerUrl?: string;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/** Render bitmap texture from cog raster images. */
|
|
160
|
+
export default class CogBitmapLayer<ExtraPropsT extends {} = {}> extends CompositeLayer<
|
|
161
|
+
ExtraPropsT & Required<_CogBitmapLayerProps & Required<TileLayerProps<MeshAndTexture>>>
|
|
162
|
+
> {
|
|
163
|
+
static defaultProps = defaultProps;
|
|
164
|
+
|
|
165
|
+
static layerName = 'CogBitmapLayer';
|
|
166
|
+
|
|
167
|
+
rasterUrl: string;
|
|
29
168
|
|
|
30
169
|
minZoom: number;
|
|
31
170
|
|
|
32
171
|
maxZoom: number;
|
|
33
172
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// this.state = {
|
|
40
|
-
// initialized: false,
|
|
41
|
-
// };
|
|
42
|
-
// this._isLoaded = false;
|
|
43
|
-
this.cogTiles = new CogTiles(options);
|
|
44
|
-
this.blurredTexture = options.blurredTexture;
|
|
45
|
-
this.url = url;
|
|
46
|
-
// setTimeout(() => {
|
|
47
|
-
// this.init(url);
|
|
48
|
-
// }, 500);
|
|
49
|
-
}
|
|
173
|
+
state!: {
|
|
174
|
+
isTiled?: boolean;
|
|
175
|
+
terrain?: MeshAttributes;
|
|
176
|
+
zRange?: ZRange | null;
|
|
177
|
+
};
|
|
50
178
|
|
|
51
|
-
|
|
52
|
-
|
|
179
|
+
// private _isLoaded: boolean;
|
|
180
|
+
|
|
181
|
+
// id = '';
|
|
182
|
+
|
|
183
|
+
// url: string;
|
|
184
|
+
|
|
185
|
+
// static displayName: string;
|
|
186
|
+
|
|
187
|
+
// cogTiles: CogTiles;
|
|
188
|
+
//
|
|
189
|
+
// tileSize: number;
|
|
190
|
+
//
|
|
191
|
+
// blurredTexture: boolean;
|
|
192
|
+
|
|
193
|
+
async initializeState(context: any) {
|
|
194
|
+
super.initializeState(context);
|
|
195
|
+
|
|
196
|
+
this.setState({
|
|
197
|
+
bitmapCogTiles: new CogTiles(this.props.cogBitmapOptions),
|
|
53
198
|
initialized: false,
|
|
54
|
-
};
|
|
199
|
+
});
|
|
55
200
|
|
|
56
|
-
this.init(this.
|
|
201
|
+
await this.init(this.rasterUrl);
|
|
57
202
|
}
|
|
58
203
|
|
|
59
|
-
async init(
|
|
60
|
-
const cog = await this.
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
const zoomRange = this.
|
|
204
|
+
async init(rasterUrl: string) {
|
|
205
|
+
const cog = await this.state.bitmapCogTiles.initializeCog(this.props.rasterData);
|
|
206
|
+
// this.tileSize = this.terrainCogTiles.getTileSize(cog);
|
|
207
|
+
|
|
208
|
+
const zoomRange = this.state.bitmapCogTiles.getZoomRange(cog);
|
|
64
209
|
[this.minZoom, this.maxZoom] = zoomRange;
|
|
210
|
+
console.log(cog);
|
|
211
|
+
|
|
212
|
+
this.setState({ initialized: true });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
updateState({ props, oldProps }: UpdateParameters<this>): void {
|
|
216
|
+
const rasterDataChanged = props.rasterData !== oldProps.rasterData;
|
|
217
|
+
if (rasterDataChanged) {
|
|
218
|
+
const { rasterData } = props;
|
|
219
|
+
const isTiled = rasterData
|
|
220
|
+
&& (Array.isArray(rasterData)
|
|
221
|
+
|| (rasterData.includes('{x}') && rasterData.includes('{y}'))) || this.props.isTiled;
|
|
222
|
+
this.setState({ isTiled });
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Reloading for single terrain mesh
|
|
226
|
+
const shouldReload = rasterDataChanged
|
|
227
|
+
// || props.meshMaxError !== oldProps.meshMaxError
|
|
228
|
+
// || props.elevationDecoder !== oldProps.elevationDecoder
|
|
229
|
+
|| props.bounds !== oldProps.bounds;
|
|
230
|
+
|
|
231
|
+
if (!this.state.isTiled && shouldReload) {
|
|
232
|
+
// When state.isTiled, elevationData cannot be an array
|
|
233
|
+
// const terrain = this.loadTerrain(props as TerrainLoadProps);
|
|
234
|
+
// this.setState({ terrain });
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// TODO - remove in v9
|
|
238
|
+
// @ts-ignore
|
|
239
|
+
if (props.workerUrl) {
|
|
240
|
+
log.removed('workerUrl', 'loadOptions.terrain.workerUrl')();
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
async getTiledBitmapData(tile: TileLoadProps): Promise<TextureSource> {
|
|
245
|
+
console.log('getTiledBitmapData');
|
|
246
|
+
const {
|
|
247
|
+
rasterData, fetch,
|
|
248
|
+
} = this.props;
|
|
249
|
+
const { viewport } = this.context;
|
|
250
|
+
// const dataUrl = getURLFromTemplate(rasterData, tile);
|
|
251
|
+
// const textureUrl = texture && getURLFromTemplate(texture, tile);
|
|
252
|
+
|
|
253
|
+
const { signal } = tile;
|
|
254
|
+
let bottomLeft = [0, 0] as [number, number];
|
|
255
|
+
let topRight = [0, 0] as [number, number];
|
|
256
|
+
if (viewport.isGeospatial) {
|
|
257
|
+
const bbox = tile.bbox as GeoBoundingBox;
|
|
258
|
+
|
|
259
|
+
bottomLeft = viewport.projectFlat([bbox.west, bbox.south]);
|
|
260
|
+
topRight = viewport.projectFlat([bbox.east, bbox.north]);
|
|
261
|
+
} else {
|
|
262
|
+
const bbox = tile.bbox as Exclude<TileBoundingBox, GeoBoundingBox>;
|
|
263
|
+
bottomLeft = [bbox.left, bbox.bottom];
|
|
264
|
+
topRight = [bbox.right, bbox.top];
|
|
265
|
+
}
|
|
266
|
+
const bounds: Bounds = [bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]];
|
|
267
|
+
|
|
268
|
+
// TODO - pass signal to getTile
|
|
269
|
+
// abort request if signal is aborted
|
|
270
|
+
const cogBitmap = await this.state.bitmapCogTiles.getTile(
|
|
271
|
+
tile.index.x,
|
|
272
|
+
tile.index.y,
|
|
273
|
+
tile.index.z,
|
|
274
|
+
bounds,
|
|
275
|
+
// this.props.meshMaxError,
|
|
276
|
+
);
|
|
277
|
+
|
|
278
|
+
return Promise.all([cogBitmap]);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
renderSubLayers(
|
|
282
|
+
props: TileLayerProps<TextureSource> & {
|
|
283
|
+
id: string;
|
|
284
|
+
data: TextureSource;
|
|
285
|
+
tile: Tile2DHeader<TextureSource>;
|
|
286
|
+
},
|
|
287
|
+
) {
|
|
288
|
+
console.log('rendering sub layer and consoling props');
|
|
289
|
+
const SubLayerClass = this.getSubLayerClass('image', BitmapLayer);
|
|
290
|
+
|
|
291
|
+
// const { color } = this.props;
|
|
292
|
+
console.log(this.props);
|
|
293
|
+
const { bounds, blurredTexture, clampToTerrain } = this.props;
|
|
294
|
+
|
|
295
|
+
const { data } = props;
|
|
296
|
+
|
|
297
|
+
if (!data) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// const [raster, texture] = data;
|
|
302
|
+
const [image] = data;
|
|
303
|
+
|
|
304
|
+
const {
|
|
305
|
+
bbox: {
|
|
306
|
+
west, south, east, north,
|
|
307
|
+
},
|
|
308
|
+
} = props.tile;
|
|
309
|
+
|
|
310
|
+
return new SubLayerClass({ ...props, tileSize: 256 }, {
|
|
311
|
+
data: DUMMY_DATA,
|
|
312
|
+
// data: null,
|
|
313
|
+
image,
|
|
314
|
+
// texture,
|
|
315
|
+
_instanced: false,
|
|
316
|
+
// coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
|
|
317
|
+
// getPosition: (d) => [0, 0, 0],
|
|
318
|
+
bounds: [west, south, east, north],
|
|
319
|
+
// bounds,
|
|
320
|
+
opacity: 1,
|
|
321
|
+
textureParameters: {
|
|
322
|
+
minFilter: blurredTexture ? 'linear' : 'nearest',
|
|
323
|
+
magFilter: blurredTexture ? 'linear' : 'nearest',
|
|
324
|
+
},
|
|
325
|
+
// extensions: this.cogTiles?.options?.clampToTerrain ? [new TerrainExtension()] : [],
|
|
326
|
+
// ...(this.cogTiles?.options?.clampToTerrain?.terrainDrawMode
|
|
327
|
+
// ? { terrainDrawMode: this.cogTiles?.options?.clampToTerrain.terrainDrawMode }
|
|
328
|
+
// : {}),
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Update zRange of viewport
|
|
333
|
+
onViewportLoad(tiles?: Tile2DHeader<MeshAndTexture>[]): void {
|
|
334
|
+
if (!tiles) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const { zRange } = this.state;
|
|
339
|
+
const ranges = tiles
|
|
340
|
+
.map((tile) => tile.content)
|
|
341
|
+
.filter((x) => x && x[0])
|
|
342
|
+
.map((arr) => {
|
|
343
|
+
// @ts-ignore
|
|
344
|
+
const bounds = arr[0]?.header?.boundingBox;
|
|
345
|
+
return bounds?.map((bound) => bound[2]);
|
|
346
|
+
});
|
|
347
|
+
if (ranges.length === 0) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const minZ = Math.min(...ranges.map((x) => x[0]));
|
|
351
|
+
const maxZ = Math.max(...ranges.map((x) => x[1]));
|
|
352
|
+
|
|
353
|
+
if (!zRange || minZ < zRange[0] || maxZ > zRange[1]) {
|
|
354
|
+
this.setState({ zRange: [Number.isFinite(minZ) ? minZ : 0, Number.isFinite(maxZ) ? maxZ : 0] });
|
|
355
|
+
}
|
|
65
356
|
}
|
|
66
357
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
358
|
+
// constructor(id:string, url:string, options:GeoImageOptions) {
|
|
359
|
+
// super({});
|
|
360
|
+
// this.id = id;
|
|
361
|
+
// // this.state = {
|
|
362
|
+
// // initialized: false,
|
|
363
|
+
// // };
|
|
364
|
+
// // this._isLoaded = false;
|
|
365
|
+
// this.cogTiles = new CogTiles(options);
|
|
366
|
+
// this.blurredTexture = options.blurredTexture;
|
|
367
|
+
// this.url = url;
|
|
368
|
+
// // setTimeout(() => {
|
|
369
|
+
// // this.init(url);
|
|
370
|
+
// // }, 500);
|
|
371
|
+
// }
|
|
372
|
+
//
|
|
373
|
+
// initializeState() {
|
|
374
|
+
// this.state = {
|
|
375
|
+
// initialized: false,
|
|
376
|
+
// };
|
|
377
|
+
//
|
|
378
|
+
// this.init(this.url);
|
|
379
|
+
// }
|
|
380
|
+
//
|
|
381
|
+
// async init(url:string) {
|
|
382
|
+
// const cog = await this.cogTiles.initializeCog(url);
|
|
383
|
+
// this.setState({ initialized: true });
|
|
384
|
+
// this.tileSize = this.cogTiles.getTileSize(cog);
|
|
385
|
+
// const zoomRange = this.cogTiles.getZoomRange(cog);
|
|
386
|
+
// [this.minZoom, this.maxZoom] = zoomRange;
|
|
387
|
+
// }
|
|
388
|
+
//
|
|
389
|
+
renderLayers(): Layer | null | LayersList {
|
|
390
|
+
const {
|
|
391
|
+
rasterData,
|
|
392
|
+
blurredTexture,
|
|
393
|
+
clampToTerrain,
|
|
394
|
+
tileSize,
|
|
395
|
+
maxZoom,
|
|
396
|
+
minZoom,
|
|
397
|
+
extent,
|
|
398
|
+
maxRequests,
|
|
399
|
+
onTileLoad,
|
|
400
|
+
onTileUnload,
|
|
401
|
+
onTileError,
|
|
402
|
+
maxCacheSize,
|
|
403
|
+
maxCacheByteSize,
|
|
404
|
+
refinementStrategy,
|
|
405
|
+
} = this.props;
|
|
406
|
+
console.log('render bitmap layers');
|
|
407
|
+
// console.log(this.state);
|
|
408
|
+
if (this.state.isTiled && this.state.initialized) {
|
|
409
|
+
console.log('start rendering tile layer');
|
|
410
|
+
return new TileLayer<any>(this.getSubLayerProps({
|
|
411
|
+
id: 'tiles',
|
|
412
|
+
}), {
|
|
413
|
+
getTileData: this.getTiledBitmapData.bind(this),
|
|
414
|
+
// getTileData: (tileData: any) => this.state.bitmapCogTiles.getTile(
|
|
415
|
+
// tileData.index.x,
|
|
416
|
+
// tileData.index.y,
|
|
417
|
+
// tileData.index.z,
|
|
418
|
+
// ),
|
|
419
|
+
renderSubLayers: this.renderSubLayers.bind(this),
|
|
420
|
+
// renderSubLayers: (props: any) => {
|
|
421
|
+
// const {
|
|
422
|
+
// bbox: {
|
|
423
|
+
// west, south, east, north,
|
|
424
|
+
// },
|
|
425
|
+
// } = props.tile;
|
|
426
|
+
// // MK proc to tady funguje jen s 0?
|
|
427
|
+
// console.log(props.data[0]);
|
|
428
|
+
// return new BitmapLayer(props, {
|
|
429
|
+
// data: DUMMY_DATA,
|
|
430
|
+
// image: props.data[0],
|
|
431
|
+
// bounds: [west, south, east, north],
|
|
432
|
+
// opacity: 1, // 0.6
|
|
433
|
+
// textureParameters: {
|
|
434
|
+
// minFilter: blurredTexture ? 'linear' : 'nearest',
|
|
435
|
+
// magFilter: blurredTexture ? 'linear' : 'nearest',
|
|
436
|
+
// },
|
|
437
|
+
// // extensions: this.cogTiles?.options?.clampToTerrain ? [new TerrainExtension()] : [],
|
|
438
|
+
// // ...(this.cogTiles?.options?.clampToTerrain?.terrainDrawMode
|
|
439
|
+
// // ? { terrainDrawMode: this.cogTiles?.options?.clampToTerrain.terrainDrawMode }
|
|
440
|
+
// // : {}),
|
|
441
|
+
// });
|
|
442
|
+
// },
|
|
443
|
+
updateTriggers: {
|
|
444
|
+
getTileData: {
|
|
445
|
+
rasterData: urlTemplateToUpdateTrigger(rasterData),
|
|
446
|
+
blurredTexture,
|
|
447
|
+
clampToTerrain,
|
|
448
|
+
// texture: urlTemplateToUpdateTrigger(texture),
|
|
449
|
+
// meshMaxError,
|
|
450
|
+
// elevationDecoder,
|
|
451
|
+
},
|
|
103
452
|
},
|
|
453
|
+
onViewportLoad: this.onViewportLoad.bind(this),
|
|
454
|
+
zRange: this.state.zRange || null,
|
|
455
|
+
tileSize,
|
|
456
|
+
maxZoom,
|
|
457
|
+
minZoom,
|
|
458
|
+
extent,
|
|
459
|
+
maxRequests,
|
|
460
|
+
onTileLoad,
|
|
461
|
+
onTileUnload,
|
|
462
|
+
onTileError,
|
|
463
|
+
maxCacheSize,
|
|
464
|
+
maxCacheByteSize,
|
|
465
|
+
refinementStrategy,
|
|
104
466
|
});
|
|
105
|
-
return layer;
|
|
106
467
|
}
|
|
107
|
-
return null;
|
|
108
468
|
}
|
|
109
469
|
}
|
|
110
|
-
|
|
111
|
-
CogBitmapLayer.displayName = 'CogBitmapLayer';
|
|
112
|
-
|
|
113
|
-
export default CogBitmapLayer;
|