@juun-roh/cesium-utils 0.0.2 → 0.0.4
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/README.md +3 -3
- package/dist/chunk-4XCQZPKH.js +1 -0
- package/dist/chunk-C52KJ2WP.js +1 -0
- package/dist/chunk-H3FSQZZE.js +1 -0
- package/dist/chunk-STARYORM.js +1 -0
- package/dist/chunk-YZ7AUGIO.js +1 -0
- package/dist/collection/index.cjs +1 -0
- package/dist/collection/index.d.cts +363 -0
- package/dist/collection/index.d.ts +363 -0
- package/dist/collection/index.js +1 -0
- package/dist/hybrid-terrain-provider-C6aXdtyo.d.cts +345 -0
- package/dist/hybrid-terrain-provider-C6aXdtyo.d.ts +345 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -834
- package/dist/index.d.ts +6 -834
- package/dist/index.js +1 -1
- package/dist/terrain/index.cjs +1 -0
- package/dist/terrain/index.d.cts +22 -0
- package/dist/terrain/index.d.ts +22 -0
- package/dist/terrain/index.js +1 -0
- package/dist/utils/index.cjs +1 -0
- package/dist/utils/index.d.cts +133 -0
- package/dist/utils/index.d.ts +133 -0
- package/dist/utils/index.js +1 -0
- package/dist/viewer/index.cjs +1 -0
- package/dist/viewer/index.d.cts +12 -0
- package/dist/viewer/index.d.ts +12 -0
- package/dist/viewer/index.js +1 -0
- package/package.json +32 -16
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { TilingScheme, TerrainProvider, Rectangle, Request, TerrainData, Credit, TileAvailability } from 'cesium';
|
|
2
|
+
|
|
3
|
+
/** A range of tiles from `start` to `end` */
|
|
4
|
+
type TileRange = {
|
|
5
|
+
/** Top Left tile coordinates */
|
|
6
|
+
start: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
/** Bottom Right tile coordinates */
|
|
11
|
+
end: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/** A `TileRange` map with specific levels as their keys. */
|
|
17
|
+
type TileRanges = Map<number, TileRange>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @class
|
|
21
|
+
* Defines the geographic boundaries for a terrain area and handles tile availability checks.
|
|
22
|
+
*/
|
|
23
|
+
declare class TerrainBounds {
|
|
24
|
+
private _rectangle;
|
|
25
|
+
private _tilingScheme;
|
|
26
|
+
private _tileRanges;
|
|
27
|
+
private _levels;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of TerrainBounds.
|
|
30
|
+
* @param options {@link TerrainBounds.ConstructorOptions}
|
|
31
|
+
* @param tilingScheme (optional) The tiling scheme to use for coordinate calculations.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options: TerrainBounds.ConstructorOptions, tilingScheme?: TilingScheme);
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
+
* @param x The tile X coordinate.
|
|
37
|
+
* @param y The tile Y coordinate.
|
|
38
|
+
* @param level The tile level.
|
|
39
|
+
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
40
|
+
*/
|
|
41
|
+
contains(x: number, y: number, level: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* Configures a terrain provider's availability based on these bounds.
|
|
45
|
+
* @see WARNING This method is accessing private property of {@link https://cesium.com/learn/csiumjs/ref-doc/TileAvailability.html `TileAvailability`}.
|
|
46
|
+
* @param provider The terrain provider to configure.
|
|
47
|
+
*/
|
|
48
|
+
configureAvailability(provider: TerrainProvider): void;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the rectangle representing these bounds.
|
|
51
|
+
*/
|
|
52
|
+
get rectangle(): Rectangle;
|
|
53
|
+
/** Gets the tiling scheme used by these bounds. */
|
|
54
|
+
get tilingScheme(): TilingScheme;
|
|
55
|
+
/** Gets the tile ranges defined for these bounds. */
|
|
56
|
+
get tileRanges(): TileRanges;
|
|
57
|
+
/** Gets the levels for which tile ranges are defined. */
|
|
58
|
+
get levels(): Set<number>;
|
|
59
|
+
/**
|
|
60
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private _calculateRectangleFromTileRanges;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @namespace
|
|
67
|
+
* Contains types and factory methods for creating `TerrainBounds` instances.
|
|
68
|
+
*/
|
|
69
|
+
declare namespace TerrainBounds {
|
|
70
|
+
/** Initialization options for Terrain Bounds constructor */
|
|
71
|
+
interface ConstructorOptions {
|
|
72
|
+
/** Type of bounds definition. */
|
|
73
|
+
type: 'tileRange' | 'rectangle';
|
|
74
|
+
/**
|
|
75
|
+
* Tile ranges by level when using tileRange type.
|
|
76
|
+
* Keys are zoom levels, values define the range of tiles at that level.
|
|
77
|
+
* Can be provided either as a Map or as a plain object with numeric keys.
|
|
78
|
+
*/
|
|
79
|
+
tileRanges?: Map<number, TileRange> | Record<string | number, TileRange>;
|
|
80
|
+
/** Rectangle bounds when using rectangle type. */
|
|
81
|
+
rectangle?: Rectangle;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates `TerrainBounds` from tile coordinates at a specific level.
|
|
85
|
+
* @param x The tile X coordinate.
|
|
86
|
+
* @param y The tile Y coordinate.
|
|
87
|
+
* @param level The tile level.
|
|
88
|
+
* @param tilingScheme The tiling scheme to use.
|
|
89
|
+
* @returns A new `TerrainBounds` instance for the specified tile.
|
|
90
|
+
*/
|
|
91
|
+
function fromTile(x: number, y: number, level: number, tilingScheme?: TilingScheme): TerrainBounds;
|
|
92
|
+
/**
|
|
93
|
+
* Creates `TerrainBounds` from a rectangle.
|
|
94
|
+
* @param rectangle The rectangle defining the bounds.
|
|
95
|
+
* @param tilingScheme The tiling scheme to use.
|
|
96
|
+
* @returns A new `TerrainBounds` instance for the specified rectangle.
|
|
97
|
+
*/
|
|
98
|
+
function fromRectangle(rectangle: Rectangle, tilingScheme?: TilingScheme): TerrainBounds;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @class
|
|
103
|
+
* Represents a geographic area with a specific terrain provider.
|
|
104
|
+
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
105
|
+
*/
|
|
106
|
+
declare class TerrainArea {
|
|
107
|
+
private _provider;
|
|
108
|
+
private _bounds;
|
|
109
|
+
private _levels;
|
|
110
|
+
private _ready;
|
|
111
|
+
private _credit;
|
|
112
|
+
private _isCustom;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new instance of `TerrainArea`.
|
|
115
|
+
* @param options Object describing initialization options
|
|
116
|
+
* @private Use {@link TerrainArea.create} instead.
|
|
117
|
+
*/
|
|
118
|
+
private constructor();
|
|
119
|
+
/**
|
|
120
|
+
* Asynchronously creates a new instance of `TerrainArea`.
|
|
121
|
+
* @param options {@link TerrainArea.ConstructorOptions}
|
|
122
|
+
* @returns A promise that resolves to a new `TerrainArea` instance.
|
|
123
|
+
*/
|
|
124
|
+
static create(options: TerrainArea.ConstructorOptions): Promise<TerrainArea>;
|
|
125
|
+
/**
|
|
126
|
+
* @see {@link TerrainBounds.contains}
|
|
127
|
+
*/
|
|
128
|
+
contains(x: number, y: number, level: number): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Requests the geometry for a given tile. The result must include terrain data and
|
|
131
|
+
* may optionally include a water mask and an indication of which child tiles are available.
|
|
132
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
133
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
134
|
+
* @param level - The level of the tile for which to request geometry.
|
|
135
|
+
* @param [request] - The request object. Intended for internal use only.
|
|
136
|
+
* @returns A promise for the requested geometry. If this method
|
|
137
|
+
* returns undefined instead of a promise, it is an indication that too many requests are already
|
|
138
|
+
* pending and the request will be retried later.
|
|
139
|
+
*/
|
|
140
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Determines whether data for a tile is available to be loaded.
|
|
143
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
144
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
145
|
+
* @param level - The level of the tile for which to request geometry.
|
|
146
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
147
|
+
* @see {@link TerrainProvider.getTileDataAvailable} */
|
|
148
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean;
|
|
149
|
+
/** Checks if this terrain provider is marked as a custom provider. */
|
|
150
|
+
get isCustom(): boolean;
|
|
151
|
+
/** Gets the credit associated with this terrain area. */
|
|
152
|
+
get credit(): string | Credit;
|
|
153
|
+
/** Gets the terrain provider for this terrain area. */
|
|
154
|
+
get provider(): TerrainProvider | undefined;
|
|
155
|
+
/** Gets the terrain bounds for this terrain area. */
|
|
156
|
+
get bounds(): TerrainBounds;
|
|
157
|
+
/** Gets available zoom levels set with this terrain area. */
|
|
158
|
+
get levels(): Set<number>;
|
|
159
|
+
/** Gets if this terrain area is ready. */
|
|
160
|
+
get ready(): boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @namespace
|
|
164
|
+
* Contains types and factory methods for creating `TerrainArea` instances.
|
|
165
|
+
*/
|
|
166
|
+
declare namespace TerrainArea {
|
|
167
|
+
/** Initialization options for `TerrainArea` constructor. */
|
|
168
|
+
interface ConstructorOptions {
|
|
169
|
+
/** The terrain provider for this area or a URL to create one from. */
|
|
170
|
+
provider: TerrainProvider | string;
|
|
171
|
+
/** The geographic bounds of this terrain area. */
|
|
172
|
+
bounds: TerrainBounds | TerrainBounds.ConstructorOptions;
|
|
173
|
+
/**
|
|
174
|
+
* The zoom levels this terrain area applies to.
|
|
175
|
+
* If empty, the area applies to all levels.
|
|
176
|
+
*/
|
|
177
|
+
levels?: number[];
|
|
178
|
+
/**
|
|
179
|
+
* Credit to associate with this terrain provider.
|
|
180
|
+
* Used to identify custom terrain providers.
|
|
181
|
+
* @default custom
|
|
182
|
+
*/
|
|
183
|
+
credit?: string | Credit;
|
|
184
|
+
/**
|
|
185
|
+
* Whether this is a custom terrain provider.
|
|
186
|
+
* @default true
|
|
187
|
+
*/
|
|
188
|
+
isCustom?: boolean;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
192
|
+
* @param url The URL to create the terrain provider from.
|
|
193
|
+
* @param tileRanges Tile ranges by level.
|
|
194
|
+
* @param levels The zoom levels this area applies to.
|
|
195
|
+
* @param credit Credit to associate with this terrain provider.
|
|
196
|
+
* @returns A promise resolving to a new `TerrainArea`
|
|
197
|
+
*/
|
|
198
|
+
function fromUrl(url: string, tileRanges: TileRanges, levels?: number[], credit?: string | Credit): Promise<Awaited<TerrainArea>>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @class
|
|
203
|
+
* Provides terrain by delegating requests to different terrain providers
|
|
204
|
+
* based on geographic regions and zoom levels. This allows combining
|
|
205
|
+
* multiple terrain sources into a single seamless terrain.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ``` typescript
|
|
209
|
+
* const hybridTerrain = await HybridTerrainProvider.create({
|
|
210
|
+
* terrainAreas: [
|
|
211
|
+
* provider: 'custom-terrain-url',
|
|
212
|
+
* bounds: {
|
|
213
|
+
* type: 'tileRange',
|
|
214
|
+
* tileRanges: {
|
|
215
|
+
* 15: {
|
|
216
|
+
* start: { x: 55852, y: 9556 },
|
|
217
|
+
* end: { x: 55871, y: 9575 },
|
|
218
|
+
* },
|
|
219
|
+
* },
|
|
220
|
+
* levels: [15],
|
|
221
|
+
* }
|
|
222
|
+
* ],
|
|
223
|
+
* terrainProvider: 'default-terrain-url',
|
|
224
|
+
* fallbackProvider: new EllipsoidTerrainProvider(),
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* viewer.terrainProvider = hybridTerrain;
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare class HybridTerrainProvider implements TerrainProvider {
|
|
231
|
+
private _terrainAreas;
|
|
232
|
+
private _terrainProvider;
|
|
233
|
+
private _fallbackProvider;
|
|
234
|
+
private _tilingScheme;
|
|
235
|
+
private _ready;
|
|
236
|
+
private _availability?;
|
|
237
|
+
/**
|
|
238
|
+
* Creates a new `HybridTerrainProvider`. Use the {@link HybridTerrainProvider.create}
|
|
239
|
+
* instead of the constructor for async initialization.
|
|
240
|
+
* @param terrainProvider The initialized default terrain provider
|
|
241
|
+
* @param fallbackProvider The initialized fallback terrain provider
|
|
242
|
+
* @param terrainAreas The array of initialized terrain areas
|
|
243
|
+
* @private - Use {@link HybridTerrainProvider.create} instead.
|
|
244
|
+
*/
|
|
245
|
+
private constructor();
|
|
246
|
+
/**
|
|
247
|
+
* Asynchronously creates a new `HybridTerrainProvider`.
|
|
248
|
+
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
249
|
+
* @returns A promise that resolves to a new `HybridTerrainProvider` instance.
|
|
250
|
+
*/
|
|
251
|
+
static create(options: HybridTerrainProvider.ConstructorOptions): Promise<HybridTerrainProvider>;
|
|
252
|
+
/**
|
|
253
|
+
* Gets a value indicating whether or not the provider is ready for use,
|
|
254
|
+
* or a promise that resolves when the provider becomes ready.
|
|
255
|
+
*/
|
|
256
|
+
get ready(): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Gets the tiling scheme used by this provider.
|
|
259
|
+
*/
|
|
260
|
+
get tilingScheme(): TilingScheme;
|
|
261
|
+
/**
|
|
262
|
+
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
263
|
+
*/
|
|
264
|
+
get availability(): TileAvailability | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* Gets the list of terrain areas managed by this provider.
|
|
267
|
+
*/
|
|
268
|
+
get terrainAreas(): readonly TerrainArea[];
|
|
269
|
+
/**
|
|
270
|
+
* Gets the default terrain provider.
|
|
271
|
+
*/
|
|
272
|
+
get defaultProvider(): TerrainProvider;
|
|
273
|
+
/**
|
|
274
|
+
* Gets the fallback terrain provider.
|
|
275
|
+
*/
|
|
276
|
+
get fallbackProvider(): TerrainProvider;
|
|
277
|
+
/**
|
|
278
|
+
* @see {@link TerrainProvider.credit}
|
|
279
|
+
*/
|
|
280
|
+
get credit(): any;
|
|
281
|
+
/**
|
|
282
|
+
* @see {@link TerrainProvider.errorEvent}
|
|
283
|
+
*/
|
|
284
|
+
get errorEvent(): any;
|
|
285
|
+
/**
|
|
286
|
+
* @see {@link TerrainProvider.hasWaterMask}
|
|
287
|
+
*/
|
|
288
|
+
get hasWaterMask(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* @see {@link TerrainProvider.hasVertexNormals}
|
|
291
|
+
*/
|
|
292
|
+
get hasVertexNormals(): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* @see {@link TerrainProvider.loadTileDataAvailability}
|
|
295
|
+
*/
|
|
296
|
+
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* @see {@link TerrainProvider.getLevelMaximumGeometricError}
|
|
299
|
+
*/
|
|
300
|
+
getLevelMaximumGeometricError(level: number): number;
|
|
301
|
+
/**
|
|
302
|
+
* Requests the terrain for a given tile coordinate.
|
|
303
|
+
* @param x The X coordinate of the tile.
|
|
304
|
+
* @param y The Y coordinate of the tile.
|
|
305
|
+
* @param level The zoom level of the tile.
|
|
306
|
+
* @param request The request.
|
|
307
|
+
* @returns A promise for the requested terrain.
|
|
308
|
+
*/
|
|
309
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
310
|
+
/**
|
|
311
|
+
* @see {@link TerrainProvider.getTileDataAvailable}
|
|
312
|
+
* @param x
|
|
313
|
+
* @param y
|
|
314
|
+
* @param level
|
|
315
|
+
*/
|
|
316
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @namespace
|
|
320
|
+
* Contains types and factory methods for creating `HybridTerrainProvider` instance.
|
|
321
|
+
*/
|
|
322
|
+
declare namespace HybridTerrainProvider {
|
|
323
|
+
/**
|
|
324
|
+
* Initialization options for `HybridTerrainProvider` constructor.
|
|
325
|
+
*/
|
|
326
|
+
interface ConstructorOptions {
|
|
327
|
+
/** An array of terrain areas to include in the hybrid terrain. */
|
|
328
|
+
terrainAreas: TerrainArea.ConstructorOptions[];
|
|
329
|
+
/** Default provider to use outside of specified terrain areas. */
|
|
330
|
+
terrainProvider: TerrainProvider | string;
|
|
331
|
+
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
332
|
+
fallbackProvider?: TerrainProvider | string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Creates a `HybridTerrainProvider` with a custom terrain area overlaid on a base terrain.
|
|
336
|
+
* @param customTerrainUrl URL to the custom terrain.
|
|
337
|
+
* @param baseTerrainUrl URL to the base terrain.
|
|
338
|
+
* @param tileRanges Tile ranges defining the custom terrain area.
|
|
339
|
+
* @param levels Levels to apply the custom terrain.
|
|
340
|
+
* @returns A promise resolving to a new `HybridTerrainProvider`.
|
|
341
|
+
*/
|
|
342
|
+
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges: TileRanges, levels?: number[]): Promise<Awaited<HybridTerrainProvider>>;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export { HybridTerrainProvider as H, TerrainArea as T, TerrainBounds as a, type TileRange as b, type TileRanges as c };
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import { TilingScheme, TerrainProvider, Rectangle, Request, TerrainData, Credit, TileAvailability } from 'cesium';
|
|
2
|
+
|
|
3
|
+
/** A range of tiles from `start` to `end` */
|
|
4
|
+
type TileRange = {
|
|
5
|
+
/** Top Left tile coordinates */
|
|
6
|
+
start: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
/** Bottom Right tile coordinates */
|
|
11
|
+
end: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/** A `TileRange` map with specific levels as their keys. */
|
|
17
|
+
type TileRanges = Map<number, TileRange>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @class
|
|
21
|
+
* Defines the geographic boundaries for a terrain area and handles tile availability checks.
|
|
22
|
+
*/
|
|
23
|
+
declare class TerrainBounds {
|
|
24
|
+
private _rectangle;
|
|
25
|
+
private _tilingScheme;
|
|
26
|
+
private _tileRanges;
|
|
27
|
+
private _levels;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new instance of TerrainBounds.
|
|
30
|
+
* @param options {@link TerrainBounds.ConstructorOptions}
|
|
31
|
+
* @param tilingScheme (optional) The tiling scheme to use for coordinate calculations.
|
|
32
|
+
*/
|
|
33
|
+
constructor(options: TerrainBounds.ConstructorOptions, tilingScheme?: TilingScheme);
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the specified tile coordinates are within the bounds.
|
|
36
|
+
* @param x The tile X coordinate.
|
|
37
|
+
* @param y The tile Y coordinate.
|
|
38
|
+
* @param level The tile level.
|
|
39
|
+
* @returns `true` if the tile is within bounds, `false` otherwise.
|
|
40
|
+
*/
|
|
41
|
+
contains(x: number, y: number, level: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* Configures a terrain provider's availability based on these bounds.
|
|
45
|
+
* @see WARNING This method is accessing private property of {@link https://cesium.com/learn/csiumjs/ref-doc/TileAvailability.html `TileAvailability`}.
|
|
46
|
+
* @param provider The terrain provider to configure.
|
|
47
|
+
*/
|
|
48
|
+
configureAvailability(provider: TerrainProvider): void;
|
|
49
|
+
/**
|
|
50
|
+
* Gets the rectangle representing these bounds.
|
|
51
|
+
*/
|
|
52
|
+
get rectangle(): Rectangle;
|
|
53
|
+
/** Gets the tiling scheme used by these bounds. */
|
|
54
|
+
get tilingScheme(): TilingScheme;
|
|
55
|
+
/** Gets the tile ranges defined for these bounds. */
|
|
56
|
+
get tileRanges(): TileRanges;
|
|
57
|
+
/** Gets the levels for which tile ranges are defined. */
|
|
58
|
+
get levels(): Set<number>;
|
|
59
|
+
/**
|
|
60
|
+
* Calculates a bounding rectangle that encompasses all the specified tile ranges.
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private _calculateRectangleFromTileRanges;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* @namespace
|
|
67
|
+
* Contains types and factory methods for creating `TerrainBounds` instances.
|
|
68
|
+
*/
|
|
69
|
+
declare namespace TerrainBounds {
|
|
70
|
+
/** Initialization options for Terrain Bounds constructor */
|
|
71
|
+
interface ConstructorOptions {
|
|
72
|
+
/** Type of bounds definition. */
|
|
73
|
+
type: 'tileRange' | 'rectangle';
|
|
74
|
+
/**
|
|
75
|
+
* Tile ranges by level when using tileRange type.
|
|
76
|
+
* Keys are zoom levels, values define the range of tiles at that level.
|
|
77
|
+
* Can be provided either as a Map or as a plain object with numeric keys.
|
|
78
|
+
*/
|
|
79
|
+
tileRanges?: Map<number, TileRange> | Record<string | number, TileRange>;
|
|
80
|
+
/** Rectangle bounds when using rectangle type. */
|
|
81
|
+
rectangle?: Rectangle;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates `TerrainBounds` from tile coordinates at a specific level.
|
|
85
|
+
* @param x The tile X coordinate.
|
|
86
|
+
* @param y The tile Y coordinate.
|
|
87
|
+
* @param level The tile level.
|
|
88
|
+
* @param tilingScheme The tiling scheme to use.
|
|
89
|
+
* @returns A new `TerrainBounds` instance for the specified tile.
|
|
90
|
+
*/
|
|
91
|
+
function fromTile(x: number, y: number, level: number, tilingScheme?: TilingScheme): TerrainBounds;
|
|
92
|
+
/**
|
|
93
|
+
* Creates `TerrainBounds` from a rectangle.
|
|
94
|
+
* @param rectangle The rectangle defining the bounds.
|
|
95
|
+
* @param tilingScheme The tiling scheme to use.
|
|
96
|
+
* @returns A new `TerrainBounds` instance for the specified rectangle.
|
|
97
|
+
*/
|
|
98
|
+
function fromRectangle(rectangle: Rectangle, tilingScheme?: TilingScheme): TerrainBounds;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @class
|
|
103
|
+
* Represents a geographic area with a specific terrain provider.
|
|
104
|
+
* `TerrainArea` pairs a provider with geographic bounds and level constraints.
|
|
105
|
+
*/
|
|
106
|
+
declare class TerrainArea {
|
|
107
|
+
private _provider;
|
|
108
|
+
private _bounds;
|
|
109
|
+
private _levels;
|
|
110
|
+
private _ready;
|
|
111
|
+
private _credit;
|
|
112
|
+
private _isCustom;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new instance of `TerrainArea`.
|
|
115
|
+
* @param options Object describing initialization options
|
|
116
|
+
* @private Use {@link TerrainArea.create} instead.
|
|
117
|
+
*/
|
|
118
|
+
private constructor();
|
|
119
|
+
/**
|
|
120
|
+
* Asynchronously creates a new instance of `TerrainArea`.
|
|
121
|
+
* @param options {@link TerrainArea.ConstructorOptions}
|
|
122
|
+
* @returns A promise that resolves to a new `TerrainArea` instance.
|
|
123
|
+
*/
|
|
124
|
+
static create(options: TerrainArea.ConstructorOptions): Promise<TerrainArea>;
|
|
125
|
+
/**
|
|
126
|
+
* @see {@link TerrainBounds.contains}
|
|
127
|
+
*/
|
|
128
|
+
contains(x: number, y: number, level: number): boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Requests the geometry for a given tile. The result must include terrain data and
|
|
131
|
+
* may optionally include a water mask and an indication of which child tiles are available.
|
|
132
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
133
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
134
|
+
* @param level - The level of the tile for which to request geometry.
|
|
135
|
+
* @param [request] - The request object. Intended for internal use only.
|
|
136
|
+
* @returns A promise for the requested geometry. If this method
|
|
137
|
+
* returns undefined instead of a promise, it is an indication that too many requests are already
|
|
138
|
+
* pending and the request will be retried later.
|
|
139
|
+
*/
|
|
140
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Determines whether data for a tile is available to be loaded.
|
|
143
|
+
* @param x - The X coordinate of the tile for which to request geometry.
|
|
144
|
+
* @param y - The Y coordinate of the tile for which to request geometry.
|
|
145
|
+
* @param level - The level of the tile for which to request geometry.
|
|
146
|
+
* @returns Undefined if not supported by the terrain provider, otherwise true or false.
|
|
147
|
+
* @see {@link TerrainProvider.getTileDataAvailable} */
|
|
148
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean;
|
|
149
|
+
/** Checks if this terrain provider is marked as a custom provider. */
|
|
150
|
+
get isCustom(): boolean;
|
|
151
|
+
/** Gets the credit associated with this terrain area. */
|
|
152
|
+
get credit(): string | Credit;
|
|
153
|
+
/** Gets the terrain provider for this terrain area. */
|
|
154
|
+
get provider(): TerrainProvider | undefined;
|
|
155
|
+
/** Gets the terrain bounds for this terrain area. */
|
|
156
|
+
get bounds(): TerrainBounds;
|
|
157
|
+
/** Gets available zoom levels set with this terrain area. */
|
|
158
|
+
get levels(): Set<number>;
|
|
159
|
+
/** Gets if this terrain area is ready. */
|
|
160
|
+
get ready(): boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* @namespace
|
|
164
|
+
* Contains types and factory methods for creating `TerrainArea` instances.
|
|
165
|
+
*/
|
|
166
|
+
declare namespace TerrainArea {
|
|
167
|
+
/** Initialization options for `TerrainArea` constructor. */
|
|
168
|
+
interface ConstructorOptions {
|
|
169
|
+
/** The terrain provider for this area or a URL to create one from. */
|
|
170
|
+
provider: TerrainProvider | string;
|
|
171
|
+
/** The geographic bounds of this terrain area. */
|
|
172
|
+
bounds: TerrainBounds | TerrainBounds.ConstructorOptions;
|
|
173
|
+
/**
|
|
174
|
+
* The zoom levels this terrain area applies to.
|
|
175
|
+
* If empty, the area applies to all levels.
|
|
176
|
+
*/
|
|
177
|
+
levels?: number[];
|
|
178
|
+
/**
|
|
179
|
+
* Credit to associate with this terrain provider.
|
|
180
|
+
* Used to identify custom terrain providers.
|
|
181
|
+
* @default custom
|
|
182
|
+
*/
|
|
183
|
+
credit?: string | Credit;
|
|
184
|
+
/**
|
|
185
|
+
* Whether this is a custom terrain provider.
|
|
186
|
+
* @default true
|
|
187
|
+
*/
|
|
188
|
+
isCustom?: boolean;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Creates a `TerrainArea` from a URL and tile ranges.
|
|
192
|
+
* @param url The URL to create the terrain provider from.
|
|
193
|
+
* @param tileRanges Tile ranges by level.
|
|
194
|
+
* @param levels The zoom levels this area applies to.
|
|
195
|
+
* @param credit Credit to associate with this terrain provider.
|
|
196
|
+
* @returns A promise resolving to a new `TerrainArea`
|
|
197
|
+
*/
|
|
198
|
+
function fromUrl(url: string, tileRanges: TileRanges, levels?: number[], credit?: string | Credit): Promise<Awaited<TerrainArea>>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @class
|
|
203
|
+
* Provides terrain by delegating requests to different terrain providers
|
|
204
|
+
* based on geographic regions and zoom levels. This allows combining
|
|
205
|
+
* multiple terrain sources into a single seamless terrain.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ``` typescript
|
|
209
|
+
* const hybridTerrain = await HybridTerrainProvider.create({
|
|
210
|
+
* terrainAreas: [
|
|
211
|
+
* provider: 'custom-terrain-url',
|
|
212
|
+
* bounds: {
|
|
213
|
+
* type: 'tileRange',
|
|
214
|
+
* tileRanges: {
|
|
215
|
+
* 15: {
|
|
216
|
+
* start: { x: 55852, y: 9556 },
|
|
217
|
+
* end: { x: 55871, y: 9575 },
|
|
218
|
+
* },
|
|
219
|
+
* },
|
|
220
|
+
* levels: [15],
|
|
221
|
+
* }
|
|
222
|
+
* ],
|
|
223
|
+
* terrainProvider: 'default-terrain-url',
|
|
224
|
+
* fallbackProvider: new EllipsoidTerrainProvider(),
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* viewer.terrainProvider = hybridTerrain;
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare class HybridTerrainProvider implements TerrainProvider {
|
|
231
|
+
private _terrainAreas;
|
|
232
|
+
private _terrainProvider;
|
|
233
|
+
private _fallbackProvider;
|
|
234
|
+
private _tilingScheme;
|
|
235
|
+
private _ready;
|
|
236
|
+
private _availability?;
|
|
237
|
+
/**
|
|
238
|
+
* Creates a new `HybridTerrainProvider`. Use the {@link HybridTerrainProvider.create}
|
|
239
|
+
* instead of the constructor for async initialization.
|
|
240
|
+
* @param terrainProvider The initialized default terrain provider
|
|
241
|
+
* @param fallbackProvider The initialized fallback terrain provider
|
|
242
|
+
* @param terrainAreas The array of initialized terrain areas
|
|
243
|
+
* @private - Use {@link HybridTerrainProvider.create} instead.
|
|
244
|
+
*/
|
|
245
|
+
private constructor();
|
|
246
|
+
/**
|
|
247
|
+
* Asynchronously creates a new `HybridTerrainProvider`.
|
|
248
|
+
* @param options {@link HybridTerrainProvider.ConstructorOptions}
|
|
249
|
+
* @returns A promise that resolves to a new `HybridTerrainProvider` instance.
|
|
250
|
+
*/
|
|
251
|
+
static create(options: HybridTerrainProvider.ConstructorOptions): Promise<HybridTerrainProvider>;
|
|
252
|
+
/**
|
|
253
|
+
* Gets a value indicating whether or not the provider is ready for use,
|
|
254
|
+
* or a promise that resolves when the provider becomes ready.
|
|
255
|
+
*/
|
|
256
|
+
get ready(): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Gets the tiling scheme used by this provider.
|
|
259
|
+
*/
|
|
260
|
+
get tilingScheme(): TilingScheme;
|
|
261
|
+
/**
|
|
262
|
+
* Gets an object that can be used to determine availability of terrain from this provider.
|
|
263
|
+
*/
|
|
264
|
+
get availability(): TileAvailability | undefined;
|
|
265
|
+
/**
|
|
266
|
+
* Gets the list of terrain areas managed by this provider.
|
|
267
|
+
*/
|
|
268
|
+
get terrainAreas(): readonly TerrainArea[];
|
|
269
|
+
/**
|
|
270
|
+
* Gets the default terrain provider.
|
|
271
|
+
*/
|
|
272
|
+
get defaultProvider(): TerrainProvider;
|
|
273
|
+
/**
|
|
274
|
+
* Gets the fallback terrain provider.
|
|
275
|
+
*/
|
|
276
|
+
get fallbackProvider(): TerrainProvider;
|
|
277
|
+
/**
|
|
278
|
+
* @see {@link TerrainProvider.credit}
|
|
279
|
+
*/
|
|
280
|
+
get credit(): any;
|
|
281
|
+
/**
|
|
282
|
+
* @see {@link TerrainProvider.errorEvent}
|
|
283
|
+
*/
|
|
284
|
+
get errorEvent(): any;
|
|
285
|
+
/**
|
|
286
|
+
* @see {@link TerrainProvider.hasWaterMask}
|
|
287
|
+
*/
|
|
288
|
+
get hasWaterMask(): boolean;
|
|
289
|
+
/**
|
|
290
|
+
* @see {@link TerrainProvider.hasVertexNormals}
|
|
291
|
+
*/
|
|
292
|
+
get hasVertexNormals(): boolean;
|
|
293
|
+
/**
|
|
294
|
+
* @see {@link TerrainProvider.loadTileDataAvailability}
|
|
295
|
+
*/
|
|
296
|
+
loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* @see {@link TerrainProvider.getLevelMaximumGeometricError}
|
|
299
|
+
*/
|
|
300
|
+
getLevelMaximumGeometricError(level: number): number;
|
|
301
|
+
/**
|
|
302
|
+
* Requests the terrain for a given tile coordinate.
|
|
303
|
+
* @param x The X coordinate of the tile.
|
|
304
|
+
* @param y The Y coordinate of the tile.
|
|
305
|
+
* @param level The zoom level of the tile.
|
|
306
|
+
* @param request The request.
|
|
307
|
+
* @returns A promise for the requested terrain.
|
|
308
|
+
*/
|
|
309
|
+
requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<Awaited<TerrainData>> | undefined;
|
|
310
|
+
/**
|
|
311
|
+
* @see {@link TerrainProvider.getTileDataAvailable}
|
|
312
|
+
* @param x
|
|
313
|
+
* @param y
|
|
314
|
+
* @param level
|
|
315
|
+
*/
|
|
316
|
+
getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* @namespace
|
|
320
|
+
* Contains types and factory methods for creating `HybridTerrainProvider` instance.
|
|
321
|
+
*/
|
|
322
|
+
declare namespace HybridTerrainProvider {
|
|
323
|
+
/**
|
|
324
|
+
* Initialization options for `HybridTerrainProvider` constructor.
|
|
325
|
+
*/
|
|
326
|
+
interface ConstructorOptions {
|
|
327
|
+
/** An array of terrain areas to include in the hybrid terrain. */
|
|
328
|
+
terrainAreas: TerrainArea.ConstructorOptions[];
|
|
329
|
+
/** Default provider to use outside of specified terrain areas. */
|
|
330
|
+
terrainProvider: TerrainProvider | string;
|
|
331
|
+
/** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
|
|
332
|
+
fallbackProvider?: TerrainProvider | string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Creates a `HybridTerrainProvider` with a custom terrain area overlaid on a base terrain.
|
|
336
|
+
* @param customTerrainUrl URL to the custom terrain.
|
|
337
|
+
* @param baseTerrainUrl URL to the base terrain.
|
|
338
|
+
* @param tileRanges Tile ranges defining the custom terrain area.
|
|
339
|
+
* @param levels Levels to apply the custom terrain.
|
|
340
|
+
* @returns A promise resolving to a new `HybridTerrainProvider`.
|
|
341
|
+
*/
|
|
342
|
+
function createOverlay(customTerrainUrl: string, baseTerrainUrl: string, tileRanges: TileRanges, levels?: number[]): Promise<Awaited<HybridTerrainProvider>>;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
export { HybridTerrainProvider as H, TerrainArea as T, TerrainBounds as a, type TileRange as b, type TileRanges as c };
|