isard 0.2.0 → 0.3.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 +134 -14
- package/README.md +2 -2
- package/dist/animation.d.ts +18 -0
- package/dist/animation.js +84 -0
- package/dist/animation.js.map +1 -0
- package/dist/basemap.worker.d.ts +26 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +8 -4
- package/dist/basemaps.d.ts +5 -3
- package/dist/basemaps.js +5 -3
- package/dist/basemaps.js.map +1 -1
- package/dist/crs.d.ts +72 -0
- package/dist/crs.js +243 -0
- package/dist/crs.js.map +1 -0
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +4 -4
- package/dist/engine-loader.d.ts +27 -0
- package/dist/engine-loader.js +112 -0
- package/dist/engine-loader.js.map +1 -0
- package/dist/extrusions.js +11 -2
- package/dist/extrusions.js.map +1 -1
- package/dist/features.d.ts +8 -0
- package/dist/features.js +17 -10
- package/dist/features.js.map +1 -1
- package/dist/geo.d.ts +16 -0
- package/dist/geo.js +32 -0
- package/dist/geo.js.map +1 -0
- package/dist/geoplateforme.d.ts +21 -5
- package/dist/geoplateforme.js +47 -12
- package/dist/geoplateforme.js.map +1 -1
- package/dist/glyphs.d.ts +10 -3
- package/dist/glyphs.js +14 -2
- package/dist/glyphs.js.map +1 -1
- package/dist/gpx.d.ts +11 -0
- package/dist/gpx.js +74 -0
- package/dist/gpx.js.map +1 -0
- package/dist/grid.d.ts +81 -0
- package/dist/grid.js +270 -0
- package/dist/grid.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +3 -4
- package/dist/interaction.js +27 -7
- package/dist/interaction.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/kml.d.ts +12 -0
- package/dist/kml.js +159 -0
- package/dist/kml.js.map +1 -0
- package/dist/layers.d.ts +5 -2
- package/dist/layers.js +22 -18
- package/dist/layers.js.map +1 -1
- package/dist/lru.d.ts +22 -0
- package/dist/lru.js +52 -0
- package/dist/lru.js.map +1 -0
- package/dist/map.d.ts +26 -6
- package/dist/map.js +196 -287
- package/dist/map.js.map +1 -1
- package/dist/resample.d.ts +41 -0
- package/dist/resample.js +164 -0
- package/dist/resample.js.map +1 -0
- package/dist/settings.d.ts +39 -0
- package/dist/settings.js +104 -0
- package/dist/settings.js.map +1 -0
- package/dist/symbols.d.ts +12 -1
- package/dist/symbols.js +124 -26
- package/dist/symbols.js.map +1 -1
- package/dist/terrain.d.ts +19 -7
- package/dist/terrain.js +50 -26
- package/dist/terrain.js.map +1 -1
- package/dist/topojson.d.ts +29 -0
- package/dist/topojson.js +66 -0
- package/dist/topojson.js.map +1 -0
- package/dist/types.d.ts +23 -7
- package/dist/types.js.map +1 -1
- package/dist/vectortiles.d.ts +13 -3
- package/dist/vectortiles.js +85 -46
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +14 -7
- package/dist/wasm/isard.js +33 -10
- package/dist/wasm/isard_core.d.ts +6 -5
- package/dist/wasm/isard_core.js +41 -10
- package/dist/wmts.d.ts +14 -0
- package/dist/wmts.js +76 -0
- package/dist/wmts.js.map +1 -0
- package/dist/xml.d.ts +26 -0
- package/dist/xml.js +109 -0
- package/dist/xml.js.map +1 -0
- package/package.json +1 -1
- package/dist/equirectangular.d.ts +0 -35
- package/dist/equirectangular.js +0 -113
- package/dist/equirectangular.js.map +0 -1
package/dist/wasm/isard.js
CHANGED
|
@@ -400,8 +400,8 @@ export class Engine {
|
|
|
400
400
|
* The body the map is drawn on: its equatorial radius (metres) and flattening (0 for a sphere), the halo of its
|
|
401
401
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
402
402
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
403
|
-
* blue halo and the
|
|
404
|
-
* size (`
|
|
403
|
+
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
404
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
405
405
|
* @param {number} radius
|
|
406
406
|
* @param {number} flattening
|
|
407
407
|
* @param {Float32Array | null | undefined} halo
|
|
@@ -824,7 +824,8 @@ export class Engine {
|
|
|
824
824
|
* the Mercator metres of another body) or `{z}/{x}/{y}`; `undefined` turns it off. `exaggeration` scales the
|
|
825
825
|
* heights (1: true relief); `max_z`: finest level loaded (up to 15, from 6 on the Earth, coarser on bodies of a
|
|
826
826
|
* larger relief for their size: `terrain_levels`); `geoid`: altitudes raised by the RAF20 geoid height (heights
|
|
827
|
-
* above the ellipsoid, those of 3D Tiles), else left as served (
|
|
827
|
+
* above the ellipsoid, those of 3D Tiles; over France, on the Earth only), else left as served (the default);
|
|
828
|
+
* `loader`: gives the
|
|
828
829
|
* altitudes of each tile instead of fetching `url` (an encoding decoded by the page: Terrarium, Terrain-RGB)
|
|
829
830
|
* @param {string | null | undefined} url
|
|
830
831
|
* @param {number} exaggeration
|
|
@@ -1203,6 +1204,10 @@ function __wbg_get_imports() {
|
|
|
1203
1204
|
const ret = arg0.createFramebuffer();
|
|
1204
1205
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1205
1206
|
},
|
|
1207
|
+
__wbg_createImageBitmap_1b985e01e4c81baa: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1208
|
+
const ret = arg0.createImageBitmap(arg1, arg2);
|
|
1209
|
+
return ret;
|
|
1210
|
+
}, arguments); },
|
|
1206
1211
|
__wbg_createImageBitmap_69996a36c51d409f: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1207
1212
|
const ret = arg0.createImageBitmap(arg1, arg2);
|
|
1208
1213
|
return ret;
|
|
@@ -1420,6 +1425,10 @@ function __wbg_get_imports() {
|
|
|
1420
1425
|
const ret = arg0.getParameter(arg1 >>> 0);
|
|
1421
1426
|
return ret;
|
|
1422
1427
|
}, arguments); },
|
|
1428
|
+
__wbg_getParameter_a97f491753b05668: function() { return handleError(function (arg0, arg1) {
|
|
1429
|
+
const ret = arg0.getParameter(arg1 >>> 0);
|
|
1430
|
+
return ret;
|
|
1431
|
+
}, arguments); },
|
|
1423
1432
|
__wbg_getProgramInfoLog_208fb1ff31006495: function(arg0, arg1, arg2) {
|
|
1424
1433
|
const ret = arg1.getProgramInfoLog(arg2);
|
|
1425
1434
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -1666,7 +1675,7 @@ function __wbg_get_imports() {
|
|
|
1666
1675
|
const a = state0.a;
|
|
1667
1676
|
state0.a = 0;
|
|
1668
1677
|
try {
|
|
1669
|
-
return
|
|
1678
|
+
return 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, state0.b, arg0, arg1);
|
|
1670
1679
|
} finally {
|
|
1671
1680
|
state0.a = a;
|
|
1672
1681
|
}
|
|
@@ -1717,6 +1726,10 @@ function __wbg_get_imports() {
|
|
|
1717
1726
|
const ret = Date.now();
|
|
1718
1727
|
return ret;
|
|
1719
1728
|
},
|
|
1729
|
+
__wbg_now_d0b7f4bea9f38490: function(arg0) {
|
|
1730
|
+
const ret = arg0.now();
|
|
1731
|
+
return ret;
|
|
1732
|
+
},
|
|
1720
1733
|
__wbg_of_20798cb14708764f: function(arg0, arg1) {
|
|
1721
1734
|
const ret = Array.of(arg0, arg1);
|
|
1722
1735
|
return ret;
|
|
@@ -1733,6 +1746,10 @@ function __wbg_get_imports() {
|
|
|
1733
1746
|
const ret = arg0.ok;
|
|
1734
1747
|
return ret;
|
|
1735
1748
|
},
|
|
1749
|
+
__wbg_performance_d0d7b03fc649b694: function(arg0) {
|
|
1750
|
+
const ret = arg0.performance;
|
|
1751
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1752
|
+
},
|
|
1736
1753
|
__wbg_pixelStorei_af18e636b3e7b725: function(arg0, arg1, arg2) {
|
|
1737
1754
|
arg0.pixelStorei(arg1 >>> 0, arg2);
|
|
1738
1755
|
},
|
|
@@ -1868,6 +1885,12 @@ function __wbg_get_imports() {
|
|
|
1868
1885
|
__wbg_stencilFunc_bab7e0b7c443f093: function(arg0, arg1, arg2, arg3) {
|
|
1869
1886
|
arg0.stencilFunc(arg1 >>> 0, arg2, arg3 >>> 0);
|
|
1870
1887
|
},
|
|
1888
|
+
__wbg_stencilMask_9e18cc018897c747: function(arg0, arg1) {
|
|
1889
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1890
|
+
},
|
|
1891
|
+
__wbg_stencilMask_a22be64c66abd825: function(arg0, arg1) {
|
|
1892
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1893
|
+
},
|
|
1871
1894
|
__wbg_stencilOpSeparate_7d01185cbdb89d99: function(arg0, arg1, arg2, arg3, arg4) {
|
|
1872
1895
|
arg0.stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0);
|
|
1873
1896
|
},
|
|
@@ -2077,8 +2100,8 @@ function __wbg_get_imports() {
|
|
|
2077
2100
|
return ret;
|
|
2078
2101
|
},
|
|
2079
2102
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
2080
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
2081
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
2103
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 149, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
2104
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_);
|
|
2082
2105
|
return ret;
|
|
2083
2106
|
},
|
|
2084
2107
|
__wbindgen_generic_0000000000000002: function(arg0) {
|
|
@@ -2142,15 +2165,15 @@ function __wbg_get_imports() {
|
|
|
2142
2165
|
};
|
|
2143
2166
|
}
|
|
2144
2167
|
|
|
2145
|
-
function
|
|
2146
|
-
const ret = wasm.
|
|
2168
|
+
function wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_(arg0, arg1, arg2) {
|
|
2169
|
+
const ret = wasm.wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_(arg0, arg1, arg2);
|
|
2147
2170
|
if (ret[1]) {
|
|
2148
2171
|
throw takeFromExternrefTable0(ret[0]);
|
|
2149
2172
|
}
|
|
2150
2173
|
}
|
|
2151
2174
|
|
|
2152
|
-
function
|
|
2153
|
-
wasm.
|
|
2175
|
+
function 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_(arg0, arg1, arg2, arg3) {
|
|
2176
|
+
wasm.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_(arg0, arg1, arg2, arg3);
|
|
2154
2177
|
}
|
|
2155
2178
|
|
|
2156
2179
|
|
|
@@ -192,8 +192,8 @@ export class Engine {
|
|
|
192
192
|
* The body the map is drawn on: its equatorial radius (metres) and flattening (0 for a sphere), the halo of its
|
|
193
193
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
194
194
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
195
|
-
* blue halo and the
|
|
196
|
-
* size (`
|
|
195
|
+
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
196
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
197
197
|
*/
|
|
198
198
|
setBody(radius: number, flattening: number, halo: Float32Array | null | undefined, lowest: number, highest: number): void;
|
|
199
199
|
setCamera(lon: number, lat: number, zoom: number, pitch: number, bearing: number): void;
|
|
@@ -334,7 +334,8 @@ export class Engine {
|
|
|
334
334
|
* the Mercator metres of another body) or `{z}/{x}/{y}`; `undefined` turns it off. `exaggeration` scales the
|
|
335
335
|
* heights (1: true relief); `max_z`: finest level loaded (up to 15, from 6 on the Earth, coarser on bodies of a
|
|
336
336
|
* larger relief for their size: `terrain_levels`); `geoid`: altitudes raised by the RAF20 geoid height (heights
|
|
337
|
-
* above the ellipsoid, those of 3D Tiles), else left as served (
|
|
337
|
+
* above the ellipsoid, those of 3D Tiles; over France, on the Earth only), else left as served (the default);
|
|
338
|
+
* `loader`: gives the
|
|
338
339
|
* altitudes of each tile instead of fetching `url` (an encoding decoded by the page: Terrarium, Terrain-RGB)
|
|
339
340
|
*/
|
|
340
341
|
setTerrain(url: string | null | undefined, exaggeration: number, max_z: number | null | undefined, geoid: boolean | null | undefined, loader: ((z: number, x: number, y: number, signal: AbortSignal) => Promise<Float32Array | null>) | undefined): void;
|
|
@@ -432,8 +433,8 @@ export interface InitOutput {
|
|
|
432
433
|
readonly engine_updateGlyphPage: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
433
434
|
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];
|
|
434
435
|
readonly engine_zoomAt: (a: number, b: number, c: number, d: number) => void;
|
|
435
|
-
readonly
|
|
436
|
-
readonly
|
|
436
|
+
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;
|
|
437
|
+
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];
|
|
437
438
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
438
439
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
439
440
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/dist/wasm/isard_core.js
CHANGED
|
@@ -384,8 +384,8 @@ export class Engine {
|
|
|
384
384
|
* The body the map is drawn on: its equatorial radius (metres) and flattening (0 for a sphere), the halo of its
|
|
385
385
|
* atmosphere around the globe (RGB 0-1 and its strength, 4 numbers; `undefined` for an airless body), and the
|
|
386
386
|
* lowest and highest altitudes of its ground (metres: what its relief may raise into view). WGS 84, the Earth's
|
|
387
|
-
* blue halo and the
|
|
388
|
-
* size (`
|
|
387
|
+
* blue halo and the range of its relief worldwide (-450 m to 8900 m) by default; set before the layers and the
|
|
388
|
+
* relief, whose shaders may take its size (`ISARD_CIRCUMFERENCE` of the ground layers)
|
|
389
389
|
* @param {number} radius
|
|
390
390
|
* @param {number} flattening
|
|
391
391
|
* @param {Float32Array | null | undefined} halo
|
|
@@ -808,7 +808,8 @@ export class Engine {
|
|
|
808
808
|
* the Mercator metres of another body) or `{z}/{x}/{y}`; `undefined` turns it off. `exaggeration` scales the
|
|
809
809
|
* heights (1: true relief); `max_z`: finest level loaded (up to 15, from 6 on the Earth, coarser on bodies of a
|
|
810
810
|
* larger relief for their size: `terrain_levels`); `geoid`: altitudes raised by the RAF20 geoid height (heights
|
|
811
|
-
* above the ellipsoid, those of 3D Tiles), else left as served (
|
|
811
|
+
* above the ellipsoid, those of 3D Tiles; over France, on the Earth only), else left as served (the default);
|
|
812
|
+
* `loader`: gives the
|
|
812
813
|
* altitudes of each tile instead of fetching `url` (an encoding decoded by the page: Terrarium, Terrain-RGB)
|
|
813
814
|
* @param {string | null | undefined} url
|
|
814
815
|
* @param {number} exaggeration
|
|
@@ -1086,6 +1087,10 @@ function __wbg_get_imports() {
|
|
|
1086
1087
|
const ret = arg0.createFramebuffer();
|
|
1087
1088
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1088
1089
|
},
|
|
1090
|
+
__wbg_createImageBitmap_1b985e01e4c81baa: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1091
|
+
const ret = arg0.createImageBitmap(arg1, arg2);
|
|
1092
|
+
return ret;
|
|
1093
|
+
}, arguments); },
|
|
1089
1094
|
__wbg_createImageBitmap_69996a36c51d409f: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1090
1095
|
const ret = arg0.createImageBitmap(arg1, arg2);
|
|
1091
1096
|
return ret;
|
|
@@ -1290,6 +1295,10 @@ function __wbg_get_imports() {
|
|
|
1290
1295
|
const ret = arg0.getParameter(arg1 >>> 0);
|
|
1291
1296
|
return ret;
|
|
1292
1297
|
}, arguments); },
|
|
1298
|
+
__wbg_getParameter_a97f491753b05668: function() { return handleError(function (arg0, arg1) {
|
|
1299
|
+
const ret = arg0.getParameter(arg1 >>> 0);
|
|
1300
|
+
return ret;
|
|
1301
|
+
}, arguments); },
|
|
1293
1302
|
__wbg_getProgramInfoLog_208fb1ff31006495: function(arg0, arg1, arg2) {
|
|
1294
1303
|
const ret = arg1.getProgramInfoLog(arg2);
|
|
1295
1304
|
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -1354,6 +1363,10 @@ function __wbg_get_imports() {
|
|
|
1354
1363
|
const ret = arg0[arg1 >>> 0];
|
|
1355
1364
|
return ret;
|
|
1356
1365
|
},
|
|
1366
|
+
__wbg_height_9dca4d43c3e4b84b: function(arg0) {
|
|
1367
|
+
const ret = arg0.height;
|
|
1368
|
+
return ret;
|
|
1369
|
+
},
|
|
1357
1370
|
__wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
|
|
1358
1371
|
let result;
|
|
1359
1372
|
try {
|
|
@@ -1468,7 +1481,7 @@ function __wbg_get_imports() {
|
|
|
1468
1481
|
const a = state0.a;
|
|
1469
1482
|
state0.a = 0;
|
|
1470
1483
|
try {
|
|
1471
|
-
return
|
|
1484
|
+
return 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, state0.b, arg0, arg1);
|
|
1472
1485
|
} finally {
|
|
1473
1486
|
state0.a = a;
|
|
1474
1487
|
}
|
|
@@ -1499,10 +1512,18 @@ function __wbg_get_imports() {
|
|
|
1499
1512
|
const ret = Date.now();
|
|
1500
1513
|
return ret;
|
|
1501
1514
|
},
|
|
1515
|
+
__wbg_now_d0b7f4bea9f38490: function(arg0) {
|
|
1516
|
+
const ret = arg0.now();
|
|
1517
|
+
return ret;
|
|
1518
|
+
},
|
|
1502
1519
|
__wbg_of_20798cb14708764f: function(arg0, arg1) {
|
|
1503
1520
|
const ret = Array.of(arg0, arg1);
|
|
1504
1521
|
return ret;
|
|
1505
1522
|
},
|
|
1523
|
+
__wbg_performance_d0d7b03fc649b694: function(arg0) {
|
|
1524
|
+
const ret = arg0.performance;
|
|
1525
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1526
|
+
},
|
|
1506
1527
|
__wbg_pixelStorei_af18e636b3e7b725: function(arg0, arg1, arg2) {
|
|
1507
1528
|
arg0.pixelStorei(arg1 >>> 0, arg2);
|
|
1508
1529
|
},
|
|
@@ -1632,6 +1653,12 @@ function __wbg_get_imports() {
|
|
|
1632
1653
|
__wbg_stencilFunc_bab7e0b7c443f093: function(arg0, arg1, arg2, arg3) {
|
|
1633
1654
|
arg0.stencilFunc(arg1 >>> 0, arg2, arg3 >>> 0);
|
|
1634
1655
|
},
|
|
1656
|
+
__wbg_stencilMask_9e18cc018897c747: function(arg0, arg1) {
|
|
1657
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1658
|
+
},
|
|
1659
|
+
__wbg_stencilMask_a22be64c66abd825: function(arg0, arg1) {
|
|
1660
|
+
arg0.stencilMask(arg1 >>> 0);
|
|
1661
|
+
},
|
|
1635
1662
|
__wbg_stencilOpSeparate_7d01185cbdb89d99: function(arg0, arg1, arg2, arg3, arg4) {
|
|
1636
1663
|
arg0.stencilOpSeparate(arg1 >>> 0, arg2 >>> 0, arg3 >>> 0, arg4 >>> 0);
|
|
1637
1664
|
},
|
|
@@ -1830,9 +1857,13 @@ function __wbg_get_imports() {
|
|
|
1830
1857
|
__wbg_warn_13abc63e0d4b3527: function(arg0) {
|
|
1831
1858
|
console.warn(arg0);
|
|
1832
1859
|
},
|
|
1860
|
+
__wbg_width_8a9cc26363f10d5f: function(arg0) {
|
|
1861
|
+
const ret = arg0.width;
|
|
1862
|
+
return ret;
|
|
1863
|
+
},
|
|
1833
1864
|
__wbindgen_generic_0000000000000001: function(arg0, arg1) {
|
|
1834
|
-
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx:
|
|
1835
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
1865
|
+
// Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 78, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1866
|
+
const ret = makeMutClosure(arg0, arg1, wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_);
|
|
1836
1867
|
return ret;
|
|
1837
1868
|
},
|
|
1838
1869
|
__wbindgen_generic_0000000000000002: function(arg0) {
|
|
@@ -1896,15 +1927,15 @@ function __wbg_get_imports() {
|
|
|
1896
1927
|
};
|
|
1897
1928
|
}
|
|
1898
1929
|
|
|
1899
|
-
function
|
|
1900
|
-
const ret = wasm.
|
|
1930
|
+
function wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_(arg0, arg1, arg2) {
|
|
1931
|
+
const ret = wasm.wasm_bindgen_2e566c63402fe7fa___convert__closures_____invoke___wasm_bindgen_2e566c63402fe7fa___JsValue__core_37ee0ce0c4cd57d5___result__Result_____wasm_bindgen_2e566c63402fe7fa___JsError___true_(arg0, arg1, arg2);
|
|
1901
1932
|
if (ret[1]) {
|
|
1902
1933
|
throw takeFromExternrefTable0(ret[0]);
|
|
1903
1934
|
}
|
|
1904
1935
|
}
|
|
1905
1936
|
|
|
1906
|
-
function
|
|
1907
|
-
wasm.
|
|
1937
|
+
function 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_(arg0, arg1, arg2, arg3) {
|
|
1938
|
+
wasm.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_(arg0, arg1, arg2, arg3);
|
|
1908
1939
|
}
|
|
1909
1940
|
|
|
1910
1941
|
|
package/dist/wmts.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TileGrid } from './grid.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's
|
|
4
|
+
* first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseWmtsGrid(xml: string, layer: string, matrixSet?: string): TileGrid;
|
|
7
|
+
/**
|
|
8
|
+
* The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for
|
|
9
|
+
* `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The
|
|
10
|
+
* raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
|
|
11
|
+
*/
|
|
12
|
+
export declare function wmtsGrid(capabilities: string | URL, layer: string, matrixSet?: string, options?: {
|
|
13
|
+
signal?: AbortSignal;
|
|
14
|
+
}): Promise<TileGrid>;
|
package/dist/wmts.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tile grid of a WMTS layer, read from the service's capabilities: its tile matrix set (CRS, levels, origin, tile
|
|
3
|
+
* sizes), the layer's limits in it and its extent, for `addRaster({ url, grid })`.
|
|
4
|
+
*/
|
|
5
|
+
import { epsgCode, isGeographic } from "./crs.js";
|
|
6
|
+
import { child, children, childText, parseXml } from "./xml.js";
|
|
7
|
+
/** Metres per degree, as WMTS counts the scale of a grid in degrees (OGC 07-057r7, 6.1) */
|
|
8
|
+
const METRES_PER_DEGREE = (2 * Math.PI * 6378137) / 360;
|
|
9
|
+
/** The size of a pixel by which WMTS turns scale denominators into resolutions, metres */
|
|
10
|
+
const PIXEL = 0.00028;
|
|
11
|
+
const numbers = (text) => (text ?? '').trim().split(/\s+/).map(Number);
|
|
12
|
+
/**
|
|
13
|
+
* The tile grid of `layer` in the capabilities document `xml`: its tile matrix set `matrixSet` (default the layer's
|
|
14
|
+
* first), with the layer's tile limits and longitude-latitude extent. Throws if the layer or the set is missing
|
|
15
|
+
*/
|
|
16
|
+
export function parseWmtsGrid(xml, layer, matrixSet) {
|
|
17
|
+
const contents = child(parseXml(xml), 'Contents');
|
|
18
|
+
const entry = children(contents, 'Layer').find((l) => childText(l, 'Identifier') === layer);
|
|
19
|
+
if (!entry)
|
|
20
|
+
throw new Error(`isard: no WMTS layer ${layer}`);
|
|
21
|
+
const links = children(entry, 'TileMatrixSetLink');
|
|
22
|
+
const link = matrixSet === undefined ? links[0] : links.find((l) => childText(l, 'TileMatrixSet') === matrixSet);
|
|
23
|
+
const name = childText(link, 'TileMatrixSet');
|
|
24
|
+
const set = children(contents, 'TileMatrixSet').find((s) => childText(s, 'Identifier') === name);
|
|
25
|
+
if (!name || !set)
|
|
26
|
+
throw new Error(`isard: no tile matrix set ${matrixSet ?? ''} for the WMTS layer ${layer}`);
|
|
27
|
+
const crs = childText(set, 'SupportedCRS') ?? '';
|
|
28
|
+
const geographic = isGeographic(crs);
|
|
29
|
+
// EPSG's geographic CRSs have their latitude first (CRS:84 and the IGN's WGS84G do not)
|
|
30
|
+
const latFirst = geographic && epsgCode(crs) === 4326 && /EPSG/i.test(crs);
|
|
31
|
+
const unit = geographic ? METRES_PER_DEGREE : 1;
|
|
32
|
+
const limits = new Map();
|
|
33
|
+
for (const l of children(child(link, 'TileMatrixSetLimits'), 'TileMatrixLimits')) {
|
|
34
|
+
const [minRow, maxRow, minCol, maxCol] = ['MinTileRow', 'MaxTileRow', 'MinTileCol', 'MaxTileCol'].map((k) => Number(childText(l, k)));
|
|
35
|
+
limits.set(childText(l, 'TileMatrix') ?? '', [minCol, minRow, maxCol, maxRow]);
|
|
36
|
+
}
|
|
37
|
+
const matrices = children(set, 'TileMatrix').map((m) => {
|
|
38
|
+
const id = childText(m, 'Identifier') ?? '';
|
|
39
|
+
const [a = 0, b = 0] = numbers(childText(m, 'TopLeftCorner'));
|
|
40
|
+
const limit = limits.get(id);
|
|
41
|
+
return {
|
|
42
|
+
id,
|
|
43
|
+
resolution: (Number(childText(m, 'ScaleDenominator')) * PIXEL) / unit,
|
|
44
|
+
origin: latFirst ? [b, a] : [a, b],
|
|
45
|
+
tileWidth: Number(childText(m, 'TileWidth') ?? 256),
|
|
46
|
+
tileHeight: Number(childText(m, 'TileHeight') ?? 256),
|
|
47
|
+
matrixWidth: Number(childText(m, 'MatrixWidth') ?? Infinity),
|
|
48
|
+
matrixHeight: Number(childText(m, 'MatrixHeight') ?? Infinity),
|
|
49
|
+
...(limit ? { limits: limit } : {}),
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
// A layer's limits leave out the matrices it does not have
|
|
53
|
+
const served = limits.size > 0 ? matrices.filter((m) => limits.has(String(m.id))) : matrices;
|
|
54
|
+
const box = child(entry, 'WGS84BoundingBox');
|
|
55
|
+
const [west, south] = numbers(childText(box, 'LowerCorner'));
|
|
56
|
+
const [east, north] = numbers(childText(box, 'UpperCorner'));
|
|
57
|
+
const bounds = [west, south, east, north];
|
|
58
|
+
return {
|
|
59
|
+
crs,
|
|
60
|
+
matrices: served,
|
|
61
|
+
name,
|
|
62
|
+
...(bounds.every(Number.isFinite) ? { bounds: bounds } : {}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The tile grid of a WMTS layer, from the service's capabilities at `capabilities` (fetched with CORS), for
|
|
67
|
+
* `addRaster`: `await wmtsGrid('https://…/wmts?SERVICE=WMTS&REQUEST=GetCapabilities', 'LAYER', 'MATRIXSET')`. The
|
|
68
|
+
* raster's URL writes the matrix set, {z} for the matrix, {x} and {y} for the column and the row
|
|
69
|
+
*/
|
|
70
|
+
export async function wmtsGrid(capabilities, layer, matrixSet, options = {}) {
|
|
71
|
+
const response = await fetch(capabilities, options.signal ? { signal: options.signal } : {});
|
|
72
|
+
if (!response.ok)
|
|
73
|
+
throw new Error(`isard: ${response.status} for the WMTS capabilities`);
|
|
74
|
+
return parseWmtsGrid(await response.text(), layer, matrixSet);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=wmts.js.map
|
package/dist/wmts.js.map
ADDED
|
@@ -0,0 +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;AACx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AC,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;IAC7D,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1C,OAAO;QACL,GAAG;QACH,QAAQ,EAAE,MAAM;QAChB,IAAI;QACJ,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,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,CAAC,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7F,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 { 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(capabilities, options.signal ? { signal: options.signal } : {});\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/dist/xml.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small XML reader for the formats read here (KML, GPX, WMTS capabilities): elements, their attributes and text,
|
|
3
|
+
* CDATA, comments, entities. The same in the page, in workers and in tests (which have no `DOMParser`), and lenient:
|
|
4
|
+
* a closing tag without its opening one is ignored, an unclosed element ends with its parent. Names are kept without
|
|
5
|
+
* their namespace prefix (`ows:Identifier` is `Identifier`): the formats read here never mix two meanings of a name.
|
|
6
|
+
* No DTD is read (no external entity, no entity expansion).
|
|
7
|
+
*/
|
|
8
|
+
export interface XmlElement {
|
|
9
|
+
/** Local name, without its prefix */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Attributes by local name */
|
|
12
|
+
attributes: Record<string, string>;
|
|
13
|
+
children: XmlElement[];
|
|
14
|
+
/** Text directly inside, CDATA included, entities decoded */
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
/** The document's root element; throws if there is none */
|
|
18
|
+
export declare function parseXml(source: string): XmlElement;
|
|
19
|
+
/** The first child element of a name */
|
|
20
|
+
export declare function child(element: XmlElement | undefined, name: string): XmlElement | undefined;
|
|
21
|
+
/** The child elements of a name */
|
|
22
|
+
export declare function children(element: XmlElement | undefined, name: string): XmlElement[];
|
|
23
|
+
/** The trimmed text of the first child of a name; undefined without one */
|
|
24
|
+
export declare function childText(element: XmlElement | undefined, name: string): string | undefined;
|
|
25
|
+
/** Every element of a name under an element, in document order (not inside a match) */
|
|
26
|
+
export declare function descendants(element: XmlElement, name: string, out?: XmlElement[]): XmlElement[];
|
package/dist/xml.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small XML reader for the formats read here (KML, GPX, WMTS capabilities): elements, their attributes and text,
|
|
3
|
+
* CDATA, comments, entities. The same in the page, in workers and in tests (which have no `DOMParser`), and lenient:
|
|
4
|
+
* a closing tag without its opening one is ignored, an unclosed element ends with its parent. Names are kept without
|
|
5
|
+
* their namespace prefix (`ows:Identifier` is `Identifier`): the formats read here never mix two meanings of a name.
|
|
6
|
+
* No DTD is read (no external entity, no entity expansion).
|
|
7
|
+
*/
|
|
8
|
+
const ENTITIES = { lt: '<', gt: '>', amp: '&', quot: '"', apos: "'" };
|
|
9
|
+
/** Text with its entities decoded (unknown ones kept as they are) */
|
|
10
|
+
function decode(text) {
|
|
11
|
+
if (!text.includes('&'))
|
|
12
|
+
return text;
|
|
13
|
+
return text.replace(/&(#x[\da-f]+|#\d+|\w+);/gi, (whole, entity) => {
|
|
14
|
+
if (entity[0] === '#') {
|
|
15
|
+
const code = entity[1] === 'x' || entity[1] === 'X' ? Number.parseInt(entity.slice(2), 16) : Number(entity.slice(1));
|
|
16
|
+
return Number.isFinite(code) && code >= 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;
|
|
17
|
+
}
|
|
18
|
+
return ENTITIES[entity] ?? whole;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
const local = (name) => name.slice(name.indexOf(':') + 1);
|
|
22
|
+
/** A start tag at the reader's position: its name, its attributes (quoted values may hold '>'), whether it closes */
|
|
23
|
+
const START = /<([^\s/>]+)((?:\s+[^\s=/>]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>/y;
|
|
24
|
+
/** The document's root element; throws if there is none */
|
|
25
|
+
export function parseXml(source) {
|
|
26
|
+
const root = { name: '#document', attributes: {}, children: [], text: '' };
|
|
27
|
+
const stack = [root];
|
|
28
|
+
const top = () => stack[stack.length - 1];
|
|
29
|
+
let i = 0;
|
|
30
|
+
while (i < source.length) {
|
|
31
|
+
const lt = source.indexOf('<', i);
|
|
32
|
+
const end = lt < 0 ? source.length : lt;
|
|
33
|
+
if (end > i)
|
|
34
|
+
top().text += decode(source.slice(i, end));
|
|
35
|
+
if (lt < 0)
|
|
36
|
+
break;
|
|
37
|
+
if (source.startsWith('<!--', lt)) {
|
|
38
|
+
const close = source.indexOf('-->', lt + 4);
|
|
39
|
+
i = close < 0 ? source.length : close + 3;
|
|
40
|
+
}
|
|
41
|
+
else if (source.startsWith('<![CDATA[', lt)) {
|
|
42
|
+
const close = source.indexOf(']]>', lt + 9);
|
|
43
|
+
top().text += source.slice(lt + 9, close < 0 ? source.length : close);
|
|
44
|
+
i = close < 0 ? source.length : close + 3;
|
|
45
|
+
}
|
|
46
|
+
else if (source[lt + 1] === '?' || source[lt + 1] === '!') {
|
|
47
|
+
// A declaration, a processing instruction, a DOCTYPE (its internal subset skipped whole)
|
|
48
|
+
const bracket = source.indexOf('[', lt);
|
|
49
|
+
const gt = source.indexOf('>', lt);
|
|
50
|
+
const subset = source[lt + 1] === '!' && bracket >= 0 && bracket < gt ? source.indexOf(']', bracket) : lt;
|
|
51
|
+
const close = source.indexOf('>', subset);
|
|
52
|
+
i = close < 0 ? source.length : close + 1;
|
|
53
|
+
}
|
|
54
|
+
else if (source[lt + 1] === '/') {
|
|
55
|
+
const gt = source.indexOf('>', lt);
|
|
56
|
+
const name = local(source.slice(lt + 2, gt < 0 ? source.length : gt).trim());
|
|
57
|
+
let at = stack.length - 1;
|
|
58
|
+
while (at > 0 && stack[at]?.name !== name)
|
|
59
|
+
at -= 1;
|
|
60
|
+
if (at > 0)
|
|
61
|
+
stack.length = at;
|
|
62
|
+
i = gt < 0 ? source.length : gt + 1;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
START.lastIndex = lt;
|
|
66
|
+
const tag = START.exec(source);
|
|
67
|
+
if (!tag) {
|
|
68
|
+
top().text += '<';
|
|
69
|
+
i = lt + 1;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const element = { name: local(tag[1]), attributes: {}, children: [], text: '' };
|
|
73
|
+
for (const [, key, double, single] of tag[2].matchAll(/([^\s=]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g)) {
|
|
74
|
+
element.attributes[local(key)] = decode(double ?? single ?? '');
|
|
75
|
+
}
|
|
76
|
+
top().children.push(element);
|
|
77
|
+
if (!tag[3])
|
|
78
|
+
stack.push(element);
|
|
79
|
+
i = START.lastIndex;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const first = root.children[0];
|
|
83
|
+
if (!first)
|
|
84
|
+
throw new Error('isard: no XML element');
|
|
85
|
+
return first;
|
|
86
|
+
}
|
|
87
|
+
/** The first child element of a name */
|
|
88
|
+
export function child(element, name) {
|
|
89
|
+
return element?.children.find((c) => c.name === name);
|
|
90
|
+
}
|
|
91
|
+
/** The child elements of a name */
|
|
92
|
+
export function children(element, name) {
|
|
93
|
+
return element?.children.filter((c) => c.name === name) ?? [];
|
|
94
|
+
}
|
|
95
|
+
/** The trimmed text of the first child of a name; undefined without one */
|
|
96
|
+
export function childText(element, name) {
|
|
97
|
+
return child(element, name)?.text.trim();
|
|
98
|
+
}
|
|
99
|
+
/** Every element of a name under an element, in document order (not inside a match) */
|
|
100
|
+
export function descendants(element, name, out = []) {
|
|
101
|
+
for (const c of element.children) {
|
|
102
|
+
if (c.name === name)
|
|
103
|
+
out.push(c);
|
|
104
|
+
else
|
|
105
|
+
descendants(c, name, out);
|
|
106
|
+
}
|
|
107
|
+
return out;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=xml.js.map
|
package/dist/xml.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xml.js","sourceRoot":"","sources":["../src/xml.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,MAAM,QAAQ,GAA2B,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;AAE9F,qEAAqE;AACrE,SAAS,MAAM,CAAC,IAAY;IAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,KAAK,EAAE,MAAc,EAAE,EAAE;QACzE,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACtB,MAAM,IAAI,GACR,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,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AQ,CAAC,OAA+B,EAAE,IAAY;IACpE,OAAO,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;AAChE,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,SAAS,CAAC,OAA+B,EAAE,IAAY;IACrE,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,OAAmB,EAAE,IAAY,EAAE,MAAoB,EAAE;IACnF,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACjC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;;YAC5B,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * A small XML reader for the formats read here (KML, GPX, WMTS capabilities): elements, their attributes and text,\n * CDATA, comments, entities. The same in the page, in workers and in tests (which have no `DOMParser`), and lenient:\n * a closing tag without its opening one is ignored, an unclosed element ends with its parent. Names are kept without\n * their namespace prefix (`ows:Identifier` is `Identifier`): the formats read here never mix two meanings of a name.\n * No DTD is read (no external entity, no entity expansion).\n */\n\nexport interface XmlElement {\n /** Local name, without its prefix */\n name: string;\n /** Attributes by local name */\n attributes: Record<string, string>;\n children: XmlElement[];\n /** Text directly inside, CDATA included, entities decoded */\n text: string;\n}\n\nconst ENTITIES: Record<string, string> = { lt: '<', gt: '>', amp: '&', quot: '\"', apos: \"'\" };\n\n/** Text with its entities decoded (unknown ones kept as they are) */\nfunction decode(text: string): string {\n if (!text.includes('&')) return text;\n return text.replace(/&(#x[\\da-f]+|#\\d+|\\w+);/gi, (whole, entity: string) => {\n if (entity[0] === '#') {\n const code =\n entity[1] === 'x' || entity[1] === 'X' ? Number.parseInt(entity.slice(2), 16) : Number(entity.slice(1));\n return Number.isFinite(code) && code >= 0 && code <= 0x10ffff ? String.fromCodePoint(code) : whole;\n }\n return ENTITIES[entity] ?? whole;\n });\n}\n\nconst local = (name: string) => name.slice(name.indexOf(':') + 1);\n\n/** A start tag at the reader's position: its name, its attributes (quoted values may hold '>'), whether it closes */\nconst START = /<([^\\s/>]+)((?:\\s+[^\\s=/>]+\\s*=\\s*(?:\"[^\"]*\"|'[^']*'))*)\\s*(\\/?)>/y;\n\n/** The document's root element; throws if there is none */\nexport function parseXml(source: string): XmlElement {\n const root: XmlElement = { name: '#document', attributes: {}, children: [], text: '' };\n const stack = [root];\n const top = () => stack[stack.length - 1] as XmlElement;\n let i = 0;\n while (i < source.length) {\n const lt = source.indexOf('<', i);\n const end = lt < 0 ? source.length : lt;\n if (end > i) top().text += decode(source.slice(i, end));\n if (lt < 0) break;\n if (source.startsWith('<!--', lt)) {\n const close = source.indexOf('-->', lt + 4);\n i = close < 0 ? source.length : close + 3;\n } else if (source.startsWith('<![CDATA[', lt)) {\n const close = source.indexOf(']]>', lt + 9);\n top().text += source.slice(lt + 9, close < 0 ? source.length : close);\n i = close < 0 ? source.length : close + 3;\n } else if (source[lt + 1] === '?' || source[lt + 1] === '!') {\n // A declaration, a processing instruction, a DOCTYPE (its internal subset skipped whole)\n const bracket = source.indexOf('[', lt);\n const gt = source.indexOf('>', lt);\n const subset = source[lt + 1] === '!' && bracket >= 0 && bracket < gt ? source.indexOf(']', bracket) : lt;\n const close = source.indexOf('>', subset);\n i = close < 0 ? source.length : close + 1;\n } else if (source[lt + 1] === '/') {\n const gt = source.indexOf('>', lt);\n const name = local(source.slice(lt + 2, gt < 0 ? source.length : gt).trim());\n let at = stack.length - 1;\n while (at > 0 && stack[at]?.name !== name) at -= 1;\n if (at > 0) stack.length = at;\n i = gt < 0 ? source.length : gt + 1;\n } else {\n START.lastIndex = lt;\n const tag = START.exec(source);\n if (!tag) {\n top().text += '<';\n i = lt + 1;\n continue;\n }\n const element: XmlElement = { name: local(tag[1] as string), attributes: {}, children: [], text: '' };\n for (const [, key, double, single] of (tag[2] as string).matchAll(/([^\\s=]+)\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/g)) {\n element.attributes[local(key as string)] = decode(double ?? single ?? '');\n }\n top().children.push(element);\n if (!tag[3]) stack.push(element);\n i = START.lastIndex;\n }\n }\n const first = root.children[0];\n if (!first) throw new Error('isard: no XML element');\n return first;\n}\n\n/** The first child element of a name */\nexport function child(element: XmlElement | undefined, name: string): XmlElement | undefined {\n return element?.children.find((c) => c.name === name);\n}\n\n/** The child elements of a name */\nexport function children(element: XmlElement | undefined, name: string): XmlElement[] {\n return element?.children.filter((c) => c.name === name) ?? [];\n}\n\n/** The trimmed text of the first child of a name; undefined without one */\nexport function childText(element: XmlElement | undefined, name: string): string | undefined {\n return child(element, name)?.text.trim();\n}\n\n/** Every element of a name under an element, in document order (not inside a match) */\nexport function descendants(element: XmlElement, name: string, out: XmlElement[] = []): XmlElement[] {\n for (const c of element.children) {\n if (c.name === name) out.push(c);\n else descendants(c, name, out);\n }\n return out;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Equirectangular tiles (longitudes and latitudes, two 256 px tiles side by side at level 0, rows from the north)
|
|
3
|
-
* reprojected into the Web Mercator tiles the engine draws: a raster loader that fetches the source tiles a Mercator
|
|
4
|
-
* tile spans and draws them into it, one row of pixels at a time (along a row the latitude is constant, so each row is
|
|
5
|
-
* a horizontal strip of the source, scaled). The planetary services (NASA's Trek, USGS) serve this grid only.
|
|
6
|
-
*/
|
|
7
|
-
/** One strip drawn: from source tile (`tx`, `ty`) at the plan's level, the source rectangle (`sx`, `sy`, `sw`, one
|
|
8
|
-
* row high) to the destination rectangle (`dx`, `dy`, `dw`, one row high) */
|
|
9
|
-
export interface Strip {
|
|
10
|
-
tx: number;
|
|
11
|
-
ty: number;
|
|
12
|
-
sx: number;
|
|
13
|
-
sy: number;
|
|
14
|
-
sw: number;
|
|
15
|
-
dx: number;
|
|
16
|
-
dy: number;
|
|
17
|
-
dw: number;
|
|
18
|
-
}
|
|
19
|
-
/** Where the pixels of a Mercator tile come from: the source level, and a strip per row and source column */
|
|
20
|
-
export interface Plan {
|
|
21
|
-
level: number;
|
|
22
|
-
strips: Strip[];
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* The strips filling Mercator tile `z`/`x`/`y` (`size` pixels a side) from equirectangular tiles of levels 0 to
|
|
26
|
-
* `maxLevel`. The source level has the same pixel size along the parallels (one less than `z`: the source is twice as
|
|
27
|
-
* wide at level 0), finer towards the poles, where the Mercator pixels shrink along the meridians.
|
|
28
|
-
*/
|
|
29
|
-
export declare function plan(z: number, x: number, y: number, size: number, maxLevel: number): Plan;
|
|
30
|
-
/**
|
|
31
|
-
* A raster loader drawing Web Mercator tiles of `size` pixels from the equirectangular tiles of `url` ({z}, {x}, {y};
|
|
32
|
-
* levels 0 to `maxLevel`). A missing source tile (404) leaves its part empty; a tile with no source at all is
|
|
33
|
-
* missing; other errors reject (retried by the engine).
|
|
34
|
-
*/
|
|
35
|
-
export declare function equirectangularLoader(url: string, maxLevel: number, size: number): (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;
|