isard 0.6.1 → 0.8.0
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/CHANGELOG.md +100 -0
- package/dist/basemap.worker.d.ts +7 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +8 -7
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +6 -5
- package/dist/engine-loader.d.ts +1 -1
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +4 -3
- package/dist/geoplateforme.js +43 -19
- package/dist/geoplateforme.js.map +1 -1
- package/dist/glyphs.js +2 -1
- package/dist/glyphs.js.map +1 -1
- package/dist/icons.js +5 -1
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +2 -0
- package/dist/interaction.js +29 -2
- package/dist/interaction.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/layers.d.ts +2 -0
- package/dist/layers.js +22 -4
- package/dist/layers.js.map +1 -1
- package/dist/loader.d.ts +2 -0
- package/dist/loader.js +10 -0
- package/dist/loader.js.map +1 -1
- package/dist/map.d.ts +52 -3
- package/dist/map.js +171 -6
- package/dist/map.js.map +1 -1
- package/dist/overlay.d.ts +55 -0
- package/dist/overlay.js +185 -7
- package/dist/overlay.js.map +1 -1
- package/dist/panoramas.d.ts +94 -0
- package/dist/panoramas.js +245 -0
- package/dist/panoramas.js.map +1 -0
- package/dist/pmtiles.js +3 -2
- package/dist/pmtiles.js.map +1 -1
- package/dist/pointclouds.js +1 -1
- package/dist/pointclouds.js.map +1 -1
- package/dist/protocol.d.ts +7 -1
- package/dist/protocol.js.map +1 -1
- package/dist/requests.d.ts +14 -0
- package/dist/requests.js +48 -0
- package/dist/requests.js.map +1 -0
- package/dist/resample.js +2 -1
- package/dist/resample.js.map +1 -1
- package/dist/style.js +3 -0
- package/dist/style.js.map +1 -1
- package/dist/terrain.d.ts +0 -5
- package/dist/terrain.js +2 -1
- package/dist/terrain.js.map +1 -1
- package/dist/types.d.ts +36 -4
- package/dist/types.js.map +1 -1
- package/dist/vectortiles.d.ts +6 -2
- package/dist/vectortiles.js +92 -33
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +105 -11
- package/dist/wasm/isard.js +211 -13
- package/dist/wasm/isard_core.d.ts +64 -6
- package/dist/wasm/isard_core.js +149 -6
- package/dist/wmts.js +2 -1
- package/dist/wmts.js.map +1 -1
- package/package.json +1 -1
|
@@ -130,6 +130,16 @@ export class Engine {
|
|
|
130
130
|
* callback of a custom layer. Static: the engine is borrowed while it draws
|
|
131
131
|
*/
|
|
132
132
|
static customMatrix(lon: number, lat: number, altitude: number): Float32Array | undefined;
|
|
133
|
+
/**
|
|
134
|
+
* Altitude of the relief at a position (metres, exaggeration included), from the copy of its tiles kept on the
|
|
135
|
+
* CPU (as coarse as the tiles loaded there); undefined without relief or where none is loaded
|
|
136
|
+
*/
|
|
137
|
+
elevationAt(lon: number, lat: number): number | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Height of the RAF20 geoid above the ellipsoid at a position (metres; 0 away from mainland France): what raises
|
|
140
|
+
* the altitudes (NGF-IGN69) of a source onto the IGN relief
|
|
141
|
+
*/
|
|
142
|
+
static geoidHeight(lon: number, lat: number): number;
|
|
133
143
|
/**
|
|
134
144
|
* Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself
|
|
135
145
|
*/
|
|
@@ -140,6 +150,12 @@ export class Engine {
|
|
|
140
150
|
* through the layer's ramp, up to `max` (above: its own color)
|
|
141
151
|
*/
|
|
142
152
|
linkExtrusionNetwork(id: number, network: number | null | undefined, max: number): void;
|
|
153
|
+
/**
|
|
154
|
+
* Model-view-projection matrix (16 numbers, column-major) of the local frame at a longitude, latitude (degrees)
|
|
155
|
+
* and altitude (metres), x east, y north, z up, in metres, for the last frame drawn (else the camera): the 3D
|
|
156
|
+
* overlays of the page (`Panel`) placed with it after each frame
|
|
157
|
+
*/
|
|
158
|
+
localMatrix(lon: number, lat: number, altitude: number): Float32Array;
|
|
143
159
|
/**
|
|
144
160
|
* Moves a layer to a drawing position (0 = bottom)
|
|
145
161
|
*/
|
|
@@ -175,9 +191,9 @@ export class Engine {
|
|
|
175
191
|
*/
|
|
176
192
|
preload(lon: number, lat: number, zoom: number, pitch: number, bearing: number): void;
|
|
177
193
|
/**
|
|
178
|
-
* Screen point (CSS pixels) of a ground position, undefined behind the camera
|
|
194
|
+
* Screen point (CSS pixels) of a ground position, or `height` metres above it, undefined behind the camera
|
|
179
195
|
*/
|
|
180
|
-
project(lon: number, lat: number): [x: number, y: number] | undefined;
|
|
196
|
+
project(lon: number, lat: number, height?: number | null): [x: number, y: number] | undefined;
|
|
181
197
|
removeExtrusionBatch(id: number, key: number): void;
|
|
182
198
|
removeLayer(id: number): void;
|
|
183
199
|
render(): boolean;
|
|
@@ -255,6 +271,12 @@ export class Engine {
|
|
|
255
271
|
* New polygons for a fill layer (same arguments as `addFills`, the same features)
|
|
256
272
|
*/
|
|
257
273
|
setFills(id: number, points: Float64Array, ring_start: Uint32Array, polygon_start: Uint32Array, feature: Uint32Array): void;
|
|
274
|
+
/**
|
|
275
|
+
* A street-level view: the eye `height` metres above the ground at `lon`, `lat` (degrees), looking `bearing`
|
|
276
|
+
* (degrees clockwise from north) and `pitch` (0 straight down, 90 level, 180 straight up), with a vertical field
|
|
277
|
+
* of view of `fov` degrees. A camera set with `setCamera` turns around a point again
|
|
278
|
+
*/
|
|
279
|
+
setFirstPerson(lon: number, lat: number, height: number, bearing: number, pitch: number, fov: number): void;
|
|
258
280
|
/**
|
|
259
281
|
* Color of the globe under the tiles (polar caps)
|
|
260
282
|
*/
|
|
@@ -331,10 +353,20 @@ export class Engine {
|
|
|
331
353
|
*/
|
|
332
354
|
setNetworkValues(id: number, values: Float32Array): void;
|
|
333
355
|
setRasterStyle(id: number, opacity: number, saturation: number): void;
|
|
356
|
+
/**
|
|
357
|
+
* The headers added to the engine's requests by URL prefix (`setRequestHeaders`, the same for every map of the
|
|
358
|
+
* page): `prefixes[i]` with `counts[i]` name and value pairs, in order, flattened into `pairs`
|
|
359
|
+
*/
|
|
360
|
+
setRequestHeaders(prefixes: string[], counts: Uint32Array, pairs: string[]): void;
|
|
334
361
|
/**
|
|
335
362
|
* Space behind the globe (stars, atmosphere halo), in the globe projection
|
|
336
363
|
*/
|
|
337
364
|
setSky(enabled: boolean): void;
|
|
365
|
+
/**
|
|
366
|
+
* Shows `layers` on one side of a vertical line only, the others beneath on the other side (comparing two states
|
|
367
|
+
* of a place): left of `x` (CSS pixels from the left of the canvas), or right of it; a non-finite `x` stops
|
|
368
|
+
*/
|
|
369
|
+
setSwipe(x: number, right: boolean, layers: Uint32Array): void;
|
|
338
370
|
/**
|
|
339
371
|
* Layer-wide style of a symbol layer: size scale and opacity as zoom stops (four zooms then four values each),
|
|
340
372
|
* zoom range, visibility
|
|
@@ -362,14 +394,26 @@ export class Engine {
|
|
|
362
394
|
* (16 at most): longitude, latitude (degrees), metres above the ground, range (metres), then to look one way
|
|
363
395
|
* only heading, tilt, angles of view across and up (degrees), the heading NaN to look all around. What some
|
|
364
396
|
* observer sees is tinted with `visible`, what is hidden from all those that reach it with `hidden` (RGB 0-1),
|
|
365
|
-
* at `opacity`
|
|
397
|
+
* at `opacity`; `outline` (RGB 0-1, or empty) the color of the cones' edges drawn in 3D
|
|
366
398
|
*/
|
|
367
|
-
setViewshed(observers: Float64Array, visible: Float32Array, hidden: Float32Array, opacity: number): void;
|
|
399
|
+
setViewshed(observers: Float64Array, visible: Float32Array, hidden: Float32Array, opacity: number, outline: Float32Array): void;
|
|
368
400
|
setZoomRange(min: number, max: number): void;
|
|
369
401
|
/**
|
|
370
402
|
* Tile counters of the raster layers, for diagnostics
|
|
371
403
|
*/
|
|
372
404
|
stats(): RasterLayerStats[];
|
|
405
|
+
/**
|
|
406
|
+
* The height above the relief (metres) of the top of what stands at a position (degrees): a roof, a mesh, 0 on
|
|
407
|
+
* the bare ground; undefined where nothing of the last frame is there. The scene is drawn from above into a single
|
|
408
|
+
* pixel and read back (a stall, cheap: one pixel to fill)
|
|
409
|
+
*/
|
|
410
|
+
surfaceAt(lon: number, lat: number): any;
|
|
411
|
+
/**
|
|
412
|
+
* What is drawn under a screen point (CSS pixels): longitude, latitude and its height above the relief (metres),
|
|
413
|
+
* on a roof, a wall or a mesh as on the ground; undefined where nothing was drawn. The scene is drawn again and
|
|
414
|
+
* read back (a stall): for clicks and drags
|
|
415
|
+
*/
|
|
416
|
+
surface(x: number, y: number): [lon: number, lat: number, height: number] | undefined;
|
|
373
417
|
/**
|
|
374
418
|
* A region of the first page of the glyph atlas: `width` × `height` bytes at (`x`, `y`)
|
|
375
419
|
*/
|
|
@@ -386,6 +430,11 @@ export class Engine {
|
|
|
386
430
|
* A region of the icon atlas: `width` × `height` RGBA texels (premultiplied) at (`x`, `y`)
|
|
387
431
|
*/
|
|
388
432
|
updateIconAtlas(x: number, y: number, width: number, height: number, data: Uint8Array): void;
|
|
433
|
+
/**
|
|
434
|
+
* Tiles a raster layer wants for the view of the last frame, three numbers per tile (z, x, y), the nearest to
|
|
435
|
+
* the eye first: the level each area of the ground is drawn at, for the labels of a vector style to follow it
|
|
436
|
+
*/
|
|
437
|
+
wantedTiles(id: number): Uint32Array;
|
|
389
438
|
zoomAt(delta: number, x: number, y: number): void;
|
|
390
439
|
}
|
|
391
440
|
|
|
@@ -408,8 +457,11 @@ export interface InitOutput {
|
|
|
408
457
|
readonly engine_clearPreload: (a: number) => void;
|
|
409
458
|
readonly engine_clearViewshed: (a: number) => void;
|
|
410
459
|
readonly engine_customMatrix: (a: number, b: number, c: number) => [number, number];
|
|
460
|
+
readonly engine_elevationAt: (a: number, b: number, c: number) => [number, number];
|
|
461
|
+
readonly engine_geoidHeight: (a: number, b: number) => number;
|
|
411
462
|
readonly engine_ground: (a: number, b: number, c: number) => any;
|
|
412
463
|
readonly engine_linkExtrusionNetwork: (a: number, b: number, c: number, d: number) => void;
|
|
464
|
+
readonly engine_localMatrix: (a: number, b: number, c: number, d: number) => [number, number];
|
|
413
465
|
readonly engine_moveLayer: (a: number, b: number, c: number) => void;
|
|
414
466
|
readonly engine_networkStats: (a: number, b: number) => any;
|
|
415
467
|
readonly engine_new: (a: any, b: any) => [number, number, number];
|
|
@@ -417,7 +469,7 @@ export interface InitOutput {
|
|
|
417
469
|
readonly engine_pick: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
|
|
418
470
|
readonly engine_pollPick: (a: number) => any;
|
|
419
471
|
readonly engine_preload: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
420
|
-
readonly engine_project: (a: number, b: number, c: number) => any;
|
|
472
|
+
readonly engine_project: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
421
473
|
readonly engine_removeExtrusionBatch: (a: number, b: number, c: number) => void;
|
|
422
474
|
readonly engine_removeLayer: (a: number, b: number) => void;
|
|
423
475
|
readonly engine_render: (a: number) => number;
|
|
@@ -438,6 +490,7 @@ export interface InitOutput {
|
|
|
438
490
|
readonly engine_setFeatureStyle: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
439
491
|
readonly engine_setFeatureValues: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
440
492
|
readonly engine_setFills: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
493
|
+
readonly engine_setFirstPerson: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
441
494
|
readonly engine_setGlobe: (a: number, b: number) => void;
|
|
442
495
|
readonly engine_setGlobeColor: (a: number, b: number, c: number, d: number) => void;
|
|
443
496
|
readonly engine_setGlyphAtlas: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
@@ -457,17 +510,22 @@ export interface InitOutput {
|
|
|
457
510
|
readonly engine_setNetworkStyle: (a: number, b: number, c: number, d: number) => void;
|
|
458
511
|
readonly engine_setNetworkValues: (a: number, b: number, c: number, d: number) => void;
|
|
459
512
|
readonly engine_setRasterStyle: (a: number, b: number, c: number, d: number) => void;
|
|
513
|
+
readonly engine_setRequestHeaders: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
460
514
|
readonly engine_setSky: (a: number, b: number) => void;
|
|
515
|
+
readonly engine_setSwipe: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
461
516
|
readonly engine_setSymbolLayer: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
462
517
|
readonly engine_setSymbols: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
463
518
|
readonly engine_setTerrain: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
464
|
-
readonly engine_setViewshed: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
519
|
+
readonly engine_setViewshed: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
465
520
|
readonly engine_setZoomRange: (a: number, b: number, c: number) => void;
|
|
466
521
|
readonly engine_stats: (a: number) => any;
|
|
522
|
+
readonly engine_surface: (a: number, b: number, c: number) => any;
|
|
523
|
+
readonly engine_surfaceAt: (a: number, b: number, c: number) => any;
|
|
467
524
|
readonly engine_updateGlyphAtlas: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
468
525
|
readonly engine_updateGlyphPage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
469
526
|
readonly engine_updateGroundTexture: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => [number, number];
|
|
470
527
|
readonly engine_updateIconAtlas: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
528
|
+
readonly engine_wantedTiles: (a: number, b: number) => [number, number];
|
|
471
529
|
readonly engine_zoomAt: (a: number, b: number, c: number, d: number) => void;
|
|
472
530
|
readonly wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___js_sys_b1e1c29ba6b0e6b3___Function_fn_wasm_bindgen_2e566c63402fe7fa___JsValue_____wasm_bindgen_2e566c63402fe7fa___sys__Undefined___js_sys_b1e1c29ba6b0e6b3___Function_fn_wasm_bindgen_2e566c63402fe7fa___JsValue_____wasm_bindgen_2e566c63402fe7fa___sys__Undefined_______true_: (a: number, b: number, c: any, d: any) => void;
|
|
473
531
|
readonly wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_: (a: number, b: number, c: any) => [number, number];
|
package/dist/wasm/isard_core.js
CHANGED
|
@@ -233,6 +233,28 @@ export class Engine {
|
|
|
233
233
|
}
|
|
234
234
|
return v1;
|
|
235
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Altitude of the relief at a position (metres, exaggeration included), from the copy of its tiles kept on the
|
|
238
|
+
* CPU (as coarse as the tiles loaded there); undefined without relief or where none is loaded
|
|
239
|
+
* @param {number} lon
|
|
240
|
+
* @param {number} lat
|
|
241
|
+
* @returns {number | undefined}
|
|
242
|
+
*/
|
|
243
|
+
elevationAt(lon, lat) {
|
|
244
|
+
const ret = wasm.engine_elevationAt(this.__wbg_ptr, lon, lat);
|
|
245
|
+
return ret[0] === 0 ? undefined : ret[1];
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Height of the RAF20 geoid above the ellipsoid at a position (metres; 0 away from mainland France): what raises
|
|
249
|
+
* the altitudes (NGF-IGN69) of a source onto the IGN relief
|
|
250
|
+
* @param {number} lon
|
|
251
|
+
* @param {number} lat
|
|
252
|
+
* @returns {number}
|
|
253
|
+
*/
|
|
254
|
+
static geoidHeight(lon, lat) {
|
|
255
|
+
const ret = wasm.engine_geoidHeight(lon, lat);
|
|
256
|
+
return ret;
|
|
257
|
+
}
|
|
236
258
|
/**
|
|
237
259
|
* Position under a screen point (CSS pixels), undefined above the horizon; on the relief itself
|
|
238
260
|
* @param {number} x
|
|
@@ -254,6 +276,21 @@ export class Engine {
|
|
|
254
276
|
linkExtrusionNetwork(id, network, max) {
|
|
255
277
|
wasm.engine_linkExtrusionNetwork(this.__wbg_ptr, id, isLikeNone(network) ? Number.MAX_SAFE_INTEGER : (network) >>> 0, max);
|
|
256
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* Model-view-projection matrix (16 numbers, column-major) of the local frame at a longitude, latitude (degrees)
|
|
281
|
+
* and altitude (metres), x east, y north, z up, in metres, for the last frame drawn (else the camera): the 3D
|
|
282
|
+
* overlays of the page (`Panel`) placed with it after each frame
|
|
283
|
+
* @param {number} lon
|
|
284
|
+
* @param {number} lat
|
|
285
|
+
* @param {number} altitude
|
|
286
|
+
* @returns {Float32Array}
|
|
287
|
+
*/
|
|
288
|
+
localMatrix(lon, lat, altitude) {
|
|
289
|
+
const ret = wasm.engine_localMatrix(this.__wbg_ptr, lon, lat, altitude);
|
|
290
|
+
var v1 = getArrayF32FromWasm0(ret[0], ret[1]).slice();
|
|
291
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
292
|
+
return v1;
|
|
293
|
+
}
|
|
257
294
|
/**
|
|
258
295
|
* Moves a layer to a drawing position (0 = bottom)
|
|
259
296
|
* @param {number} id
|
|
@@ -335,13 +372,14 @@ export class Engine {
|
|
|
335
372
|
wasm.engine_preload(this.__wbg_ptr, lon, lat, zoom, pitch, bearing);
|
|
336
373
|
}
|
|
337
374
|
/**
|
|
338
|
-
* Screen point (CSS pixels) of a ground position, undefined behind the camera
|
|
375
|
+
* Screen point (CSS pixels) of a ground position, or `height` metres above it, undefined behind the camera
|
|
339
376
|
* @param {number} lon
|
|
340
377
|
* @param {number} lat
|
|
378
|
+
* @param {number | null} [height]
|
|
341
379
|
* @returns {[x: number, y: number] | undefined}
|
|
342
380
|
*/
|
|
343
|
-
project(lon, lat) {
|
|
344
|
-
const ret = wasm.engine_project(this.__wbg_ptr, lon, lat);
|
|
381
|
+
project(lon, lat, height) {
|
|
382
|
+
const ret = wasm.engine_project(this.__wbg_ptr, lon, lat, !isLikeNone(height), isLikeNone(height) ? 0 : height);
|
|
345
383
|
return ret;
|
|
346
384
|
}
|
|
347
385
|
/**
|
|
@@ -583,6 +621,20 @@ export class Engine {
|
|
|
583
621
|
const len3 = WASM_VECTOR_LEN;
|
|
584
622
|
wasm.engine_setFills(this.__wbg_ptr, id, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
|
|
585
623
|
}
|
|
624
|
+
/**
|
|
625
|
+
* A street-level view: the eye `height` metres above the ground at `lon`, `lat` (degrees), looking `bearing`
|
|
626
|
+
* (degrees clockwise from north) and `pitch` (0 straight down, 90 level, 180 straight up), with a vertical field
|
|
627
|
+
* of view of `fov` degrees. A camera set with `setCamera` turns around a point again
|
|
628
|
+
* @param {number} lon
|
|
629
|
+
* @param {number} lat
|
|
630
|
+
* @param {number} height
|
|
631
|
+
* @param {number} bearing
|
|
632
|
+
* @param {number} pitch
|
|
633
|
+
* @param {number} fov
|
|
634
|
+
*/
|
|
635
|
+
setFirstPerson(lon, lat, height, bearing, pitch, fov) {
|
|
636
|
+
wasm.engine_setFirstPerson(this.__wbg_ptr, lon, lat, height, bearing, pitch, fov);
|
|
637
|
+
}
|
|
586
638
|
/**
|
|
587
639
|
* Color of the globe under the tiles (polar caps)
|
|
588
640
|
* @param {number} r
|
|
@@ -801,6 +853,22 @@ export class Engine {
|
|
|
801
853
|
setRasterStyle(id, opacity, saturation) {
|
|
802
854
|
wasm.engine_setRasterStyle(this.__wbg_ptr, id, opacity, saturation);
|
|
803
855
|
}
|
|
856
|
+
/**
|
|
857
|
+
* The headers added to the engine's requests by URL prefix (`setRequestHeaders`, the same for every map of the
|
|
858
|
+
* page): `prefixes[i]` with `counts[i]` name and value pairs, in order, flattened into `pairs`
|
|
859
|
+
* @param {string[]} prefixes
|
|
860
|
+
* @param {Uint32Array} counts
|
|
861
|
+
* @param {string[]} pairs
|
|
862
|
+
*/
|
|
863
|
+
setRequestHeaders(prefixes, counts, pairs) {
|
|
864
|
+
const ptr0 = passArrayJsValueToWasm0(prefixes, wasm.__wbindgen_malloc);
|
|
865
|
+
const len0 = WASM_VECTOR_LEN;
|
|
866
|
+
const ptr1 = passArray32ToWasm0(counts, wasm.__wbindgen_malloc);
|
|
867
|
+
const len1 = WASM_VECTOR_LEN;
|
|
868
|
+
const ptr2 = passArrayJsValueToWasm0(pairs, wasm.__wbindgen_malloc);
|
|
869
|
+
const len2 = WASM_VECTOR_LEN;
|
|
870
|
+
wasm.engine_setRequestHeaders(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
871
|
+
}
|
|
804
872
|
/**
|
|
805
873
|
* Space behind the globe (stars, atmosphere halo), in the globe projection
|
|
806
874
|
* @param {boolean} enabled
|
|
@@ -808,6 +876,18 @@ export class Engine {
|
|
|
808
876
|
setSky(enabled) {
|
|
809
877
|
wasm.engine_setSky(this.__wbg_ptr, enabled);
|
|
810
878
|
}
|
|
879
|
+
/**
|
|
880
|
+
* Shows `layers` on one side of a vertical line only, the others beneath on the other side (comparing two states
|
|
881
|
+
* of a place): left of `x` (CSS pixels from the left of the canvas), or right of it; a non-finite `x` stops
|
|
882
|
+
* @param {number} x
|
|
883
|
+
* @param {boolean} right
|
|
884
|
+
* @param {Uint32Array} layers
|
|
885
|
+
*/
|
|
886
|
+
setSwipe(x, right, layers) {
|
|
887
|
+
const ptr0 = passArray32ToWasm0(layers, wasm.__wbindgen_malloc);
|
|
888
|
+
const len0 = WASM_VECTOR_LEN;
|
|
889
|
+
wasm.engine_setSwipe(this.__wbg_ptr, x, right, ptr0, len0);
|
|
890
|
+
}
|
|
811
891
|
/**
|
|
812
892
|
* Layer-wide style of a symbol layer: size scale and opacity as zoom stops (four zooms then four values each),
|
|
813
893
|
* zoom range, visibility
|
|
@@ -877,20 +957,23 @@ export class Engine {
|
|
|
877
957
|
* (16 at most): longitude, latitude (degrees), metres above the ground, range (metres), then to look one way
|
|
878
958
|
* only heading, tilt, angles of view across and up (degrees), the heading NaN to look all around. What some
|
|
879
959
|
* observer sees is tinted with `visible`, what is hidden from all those that reach it with `hidden` (RGB 0-1),
|
|
880
|
-
* at `opacity`
|
|
960
|
+
* at `opacity`; `outline` (RGB 0-1, or empty) the color of the cones' edges drawn in 3D
|
|
881
961
|
* @param {Float64Array} observers
|
|
882
962
|
* @param {Float32Array} visible
|
|
883
963
|
* @param {Float32Array} hidden
|
|
884
964
|
* @param {number} opacity
|
|
965
|
+
* @param {Float32Array} outline
|
|
885
966
|
*/
|
|
886
|
-
setViewshed(observers, visible, hidden, opacity) {
|
|
967
|
+
setViewshed(observers, visible, hidden, opacity, outline) {
|
|
887
968
|
const ptr0 = passArrayF64ToWasm0(observers, wasm.__wbindgen_malloc);
|
|
888
969
|
const len0 = WASM_VECTOR_LEN;
|
|
889
970
|
const ptr1 = passArrayF32ToWasm0(visible, wasm.__wbindgen_malloc);
|
|
890
971
|
const len1 = WASM_VECTOR_LEN;
|
|
891
972
|
const ptr2 = passArrayF32ToWasm0(hidden, wasm.__wbindgen_malloc);
|
|
892
973
|
const len2 = WASM_VECTOR_LEN;
|
|
893
|
-
const
|
|
974
|
+
const ptr3 = passArrayF32ToWasm0(outline, wasm.__wbindgen_malloc);
|
|
975
|
+
const len3 = WASM_VECTOR_LEN;
|
|
976
|
+
const ret = wasm.engine_setViewshed(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, opacity, ptr3, len3);
|
|
894
977
|
if (ret[1]) {
|
|
895
978
|
throw takeFromExternrefTable0(ret[0]);
|
|
896
979
|
}
|
|
@@ -910,6 +993,30 @@ export class Engine {
|
|
|
910
993
|
const ret = wasm.engine_stats(this.__wbg_ptr);
|
|
911
994
|
return ret;
|
|
912
995
|
}
|
|
996
|
+
/**
|
|
997
|
+
* The height above the relief (metres) of the top of what stands at a position (degrees): a roof, a mesh, 0 on
|
|
998
|
+
* the bare ground; undefined where nothing of the last frame is there. The scene is drawn from above into a single
|
|
999
|
+
* pixel and read back (a stall, cheap: one pixel to fill)
|
|
1000
|
+
* @param {number} lon
|
|
1001
|
+
* @param {number} lat
|
|
1002
|
+
* @returns {any}
|
|
1003
|
+
*/
|
|
1004
|
+
surfaceAt(lon, lat) {
|
|
1005
|
+
const ret = wasm.engine_surfaceAt(this.__wbg_ptr, lon, lat);
|
|
1006
|
+
return ret;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* What is drawn under a screen point (CSS pixels): longitude, latitude and its height above the relief (metres),
|
|
1010
|
+
* on a roof, a wall or a mesh as on the ground; undefined where nothing was drawn. The scene is drawn again and
|
|
1011
|
+
* read back (a stall): for clicks and drags
|
|
1012
|
+
* @param {number} x
|
|
1013
|
+
* @param {number} y
|
|
1014
|
+
* @returns {[lon: number, lat: number, height: number] | undefined}
|
|
1015
|
+
*/
|
|
1016
|
+
surface(x, y) {
|
|
1017
|
+
const ret = wasm.engine_surface(this.__wbg_ptr, x, y);
|
|
1018
|
+
return ret;
|
|
1019
|
+
}
|
|
913
1020
|
/**
|
|
914
1021
|
* A region of the first page of the glyph atlas: `width` × `height` bytes at (`x`, `y`)
|
|
915
1022
|
* @param {number} x
|
|
@@ -971,6 +1078,18 @@ export class Engine {
|
|
|
971
1078
|
const len0 = WASM_VECTOR_LEN;
|
|
972
1079
|
wasm.engine_updateIconAtlas(this.__wbg_ptr, x, y, width, height, ptr0, len0);
|
|
973
1080
|
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Tiles a raster layer wants for the view of the last frame, three numbers per tile (z, x, y), the nearest to
|
|
1083
|
+
* the eye first: the level each area of the ground is drawn at, for the labels of a vector style to follow it
|
|
1084
|
+
* @param {number} id
|
|
1085
|
+
* @returns {Uint32Array}
|
|
1086
|
+
*/
|
|
1087
|
+
wantedTiles(id) {
|
|
1088
|
+
const ret = wasm.engine_wantedTiles(this.__wbg_ptr, id);
|
|
1089
|
+
var v1 = getArrayU32FromWasm0(ret[0], ret[1]).slice();
|
|
1090
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
|
|
1091
|
+
return v1;
|
|
1092
|
+
}
|
|
974
1093
|
/**
|
|
975
1094
|
* @param {number} delta
|
|
976
1095
|
* @param {number} x
|
|
@@ -1597,6 +1716,10 @@ function __wbg_get_imports() {
|
|
|
1597
1716
|
const ret = new Object();
|
|
1598
1717
|
return ret;
|
|
1599
1718
|
},
|
|
1719
|
+
__wbg_new_83ca405eae412a62: function() { return handleError(function () {
|
|
1720
|
+
const ret = new Headers();
|
|
1721
|
+
return ret;
|
|
1722
|
+
}, arguments); },
|
|
1600
1723
|
__wbg_new_ee2291f50781bf1d: function() {
|
|
1601
1724
|
const ret = new Array();
|
|
1602
1725
|
return ret;
|
|
@@ -1621,6 +1744,10 @@ function __wbg_get_imports() {
|
|
|
1621
1744
|
const ret = Array.of(arg0, arg1);
|
|
1622
1745
|
return ret;
|
|
1623
1746
|
},
|
|
1747
|
+
__wbg_of_dde0b9d3265685ee: function(arg0, arg1, arg2) {
|
|
1748
|
+
const ret = Array.of(arg0, arg1, arg2);
|
|
1749
|
+
return ret;
|
|
1750
|
+
},
|
|
1624
1751
|
__wbg_performance_d0d7b03fc649b694: function(arg0) {
|
|
1625
1752
|
const ret = arg0.performance;
|
|
1626
1753
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
@@ -1681,6 +1808,9 @@ function __wbg_get_imports() {
|
|
|
1681
1808
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
1682
1809
|
return ret;
|
|
1683
1810
|
}, arguments); },
|
|
1811
|
+
__wbg_set_af5932e3f78b5648: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
1812
|
+
arg0.set(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
1813
|
+
}, arguments); },
|
|
1684
1814
|
__wbg_set_alpha_6dea851a46253adf: function(arg0, arg1) {
|
|
1685
1815
|
arg0.alpha = arg1 !== 0;
|
|
1686
1816
|
},
|
|
@@ -1696,6 +1826,9 @@ function __wbg_get_imports() {
|
|
|
1696
1826
|
__wbg_set_depth_8b49de49803d4e60: function(arg0, arg1) {
|
|
1697
1827
|
arg0.depth = arg1 !== 0;
|
|
1698
1828
|
},
|
|
1829
|
+
__wbg_set_headers_40ad33dcf016613f: function(arg0, arg1) {
|
|
1830
|
+
arg0.headers = arg1;
|
|
1831
|
+
},
|
|
1699
1832
|
__wbg_set_power_preference_6ef22d4c8baf517f: function(arg0, arg1) {
|
|
1700
1833
|
arg0.powerPreference = __wbindgen_enum_WebGlPowerPreference[arg1];
|
|
1701
1834
|
},
|
|
@@ -2314,6 +2447,16 @@ function passArrayF64ToWasm0(arg, malloc) {
|
|
|
2314
2447
|
return ptr;
|
|
2315
2448
|
}
|
|
2316
2449
|
|
|
2450
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
2451
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
2452
|
+
for (let i = 0; i < array.length; i++) {
|
|
2453
|
+
const add = addToExternrefTable0(array[i]);
|
|
2454
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
2455
|
+
}
|
|
2456
|
+
WASM_VECTOR_LEN = array.length;
|
|
2457
|
+
return ptr;
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2317
2460
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
2318
2461
|
if (realloc === undefined) {
|
|
2319
2462
|
const buf = cachedTextEncoder.encode(arg);
|
package/dist/wmts.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* sizes), the layer's limits in it and its extent, for `addRaster({ url, grid })`.
|
|
4
4
|
*/
|
|
5
5
|
import { epsgCode, isGeographic } from "./crs.js";
|
|
6
|
+
import { withHeaders } from "./requests.js";
|
|
6
7
|
import { child, children, childText, parseXml } from "./xml.js";
|
|
7
8
|
/** Metres per degree, as WMTS counts the scale of a grid in degrees (OGC 07-057r7, 6.1) */
|
|
8
9
|
const METRES_PER_DEGREE = (2 * Math.PI * 6378137) / 360;
|
|
@@ -68,7 +69,7 @@ export function parseWmtsGrid(xml, layer, matrixSet) {
|
|
|
68
69
|
* raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
|
|
69
70
|
*/
|
|
70
71
|
export async function wmtsGrid(capabilities, layer, matrixSet, options = {}) {
|
|
71
|
-
const response = await fetch(capabilities, options.signal ? { signal: options.signal } : {});
|
|
72
|
+
const response = await fetch(capabilities, withHeaders(capabilities, options.signal ? { signal: options.signal } : {}));
|
|
72
73
|
if (!response.ok)
|
|
73
74
|
throw new Error(`isard: ${response.status} for the WMTS capabilities`);
|
|
74
75
|
return parseWmtsGrid(await response.text(), layer, matrixSet);
|
package/dist/wmts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wmts.js","sourceRoot":"","sources":["../src/wmts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhE,2FAA2F;AAC3F,MAAM,iBAAiB,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC;AACxD,0FAA0F;AAC1F,MAAM,KAAK,GAAG,OAAO,CAAC;AAEtB,MAAM,OAAO,GAAG,CAAC,IAAwB,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;AAE3F;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW,EAAE,KAAa,EAAE,SAAkB;IAC1E,MAAM,QAAQ,GAAG,KAAK,CA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AQ,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAA0C,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACjG,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,YAA0B,EAC1B,KAAa,EACb,SAAkB,EAClB,UAAoC,EAAE;IAEtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,YAAY,EACZ,WAAW,CAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5E,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,MAAM,IAAI,KAAK,CAAC,UAAU,QAAQ,CAAC,MAAM,4BAA4B,CAAC,CAAC;IACzF,OAAO,aAAa,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAChE,CAAC","sourcesContent":["/**\n * The tile grid of a WMTS layer, read from the service's capabilities: its tile matrix set (CRS, levels, origin, tile\n * sizes), the layer's limits in it and its extent, for `addRaster({ url, grid })`.\n */\nimport { epsgCode, isGeographic } from './crs.ts';\nimport type { TileGrid, TileMatrix } from './grid.ts';\nimport { withHeaders } from './requests.ts';\nimport { child, children, childText, parseXml } from './xml.ts';\n\n/** Metres per degree, as WMTS counts the scale of a grid in degrees (OGC 07-057r7, 6.1) */\nconst METRES_PER_DEGREE = (2 * Math.PI * 6378137) / 360;\n/** The size of a pixel by which WMTS turns scale denominators into resolutions, metres */\nconst PIXEL = 0.00028;\n\nconst numbers = (text: string | undefined) => (text ?? '').trim().split(/\\s+/).map(Number);\n\n/**\n * The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's\n * first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing\n */\nexport function parseWmtsGrid(xml: string, layer: string, matrixSet?: string): TileGrid {\n const contents = child(parseXml(xml), 'Contents');\n const entry = children(contents, 'Layer').find((l) => childText(l, 'Identifier') === layer);\n if (!entry) throw new Error(`isard: no WMTS layer ${layer}`);\n const links = children(entry, 'TileMatrixSetLink');\n const link = matrixSet === undefined ? links[0] : links.find((l) => childText(l, 'TileMatrixSet') === matrixSet);\n const name = childText(link, 'TileMatrixSet');\n const set = children(contents, 'TileMatrixSet').find((s) => childText(s, 'Identifier') === name);\n if (!name || !set) throw new Error(`isard: no tile matrix set ${matrixSet ?? ''} for the WMTS layer ${layer}`);\n const crs = childText(set, 'SupportedCRS') ?? '';\n const geographic = isGeographic(crs);\n // EPSG's geographic CRSs have their latitude first (CRS:84 and the IGN's WGS84G do not)\n const latFirst = geographic && epsgCode(crs) === 4326 && /EPSG/i.test(crs);\n const unit = geographic ? METRES_PER_DEGREE : 1;\n const limits = new Map<string, TileMatrix['limits']>();\n for (const l of children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits')) {\n const [minRow, maxRow, minCol, maxCol] = ['MinTileRow', 'MaxTileRow', 'MinTileCol', 'MaxTileCol'].map((k) =>\n Number(childText(l, k)),\n ) as [number, number, number, number];\n limits.set(childText(l, 'TileMatrix') ?? '', [minCol, minRow, maxCol, maxRow]);\n }\n const matrices = children(set, 'TileMatrix').map((m): TileMatrix => {\n const id = childText(m, 'Identifier') ?? '';\n const [a = 0, b = 0] = numbers(childText(m, 'TopLeftCorner'));\n const limit = limits.get(id);\n return {\n id,\n resolution: (Number(childText(m, 'ScaleDenominator')) * PIXEL) / unit,\n origin: latFirst ? [b, a] : [a, b],\n tileWidth: Number(childText(m, 'TileWidth') ?? 256),\n tileHeight: Number(childText(m, 'TileHeight') ?? 256),\n matrixWidth: Number(childText(m, 'MatrixWidth') ?? Infinity),\n matrixHeight: Number(childText(m, 'MatrixHeight') ?? Infinity),\n ...(limit ? { limits: limit } : {}),\n };\n });\n // A layer's limits leave out the matrices it does not have\n const served = limits.size > 0 ? matrices.filter((m) => limits.has(String(m.id))) : matrices;\n const box = child(entry, 'WGS84BoundingBox');\n const [west, south] = numbers(childText(box, 'LowerCorner'));\n const [east, north] = numbers(childText(box, 'UpperCorner'));\n const bounds = [west, south, east, north];\n return {\n crs,\n matrices: served,\n name,\n ...(bounds.every(Number.isFinite) ? { bounds: bounds as [number, number, number, number] } : {}),\n };\n}\n\n/**\n * The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for\n * `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The\n * raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row\n */\nexport async function wmtsGrid(\n capabilities: string | URL,\n layer: string,\n matrixSet?: string,\n options: { signal?: AbortSignal } = {},\n): Promise<TileGrid> {\n const response = await fetch(\n capabilities,\n withHeaders(capabilities, options.signal ? { signal: options.signal } : {}),\n );\n if (!response.ok) throw new Error(`isard: ${response.status} for the WMTS capabilities`);\n return parseWmtsGrid(await response.text(), layer, matrixSet);\n}\n"]}
|
package/package.json
CHANGED