isard 1.1.0 → 1.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 +121 -0
- package/README.md +44 -39
- package/dist/basemap/basemaps.d.ts +1 -1
- package/dist/basemap/basemaps.js +2 -2
- package/dist/basemap/basemaps.js.map +1 -1
- package/dist/basemap/grid.d.ts +5 -5
- package/dist/basemap/grid.js +59 -65
- package/dist/basemap/grid.js.map +1 -1
- package/dist/basemap/mvt.d.ts +1 -1
- package/dist/basemap/mvt.js +6 -6
- package/dist/basemap/mvt.js.map +1 -1
- package/dist/basemap/pmtiles.d.ts +10 -10
- package/dist/basemap/pmtiles.js +39 -31
- package/dist/basemap/pmtiles.js.map +1 -1
- package/dist/basemap/pmtileslayer.d.ts +33 -0
- package/dist/basemap/pmtileslayer.js +97 -0
- package/dist/basemap/pmtileslayer.js.map +1 -0
- package/dist/basemap/resample.d.ts +2 -2
- package/dist/basemap/resample.js +16 -14
- package/dist/basemap/resample.js.map +1 -1
- package/dist/basemap/terrain.d.ts +3 -3
- package/dist/basemap/terrain.js +6 -6
- package/dist/basemap/terrain.js.map +1 -1
- package/dist/basemap/trees.d.ts +26 -0
- package/dist/basemap/trees.js +141 -0
- package/dist/basemap/trees.js.map +1 -0
- package/dist/basemap/vectorstyle.d.ts +22 -10
- package/dist/basemap/vectorstyle.js +163 -110
- package/dist/basemap/vectorstyle.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +70 -47
- package/dist/basemap/vectortiles.js +480 -358
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.d.ts +3 -3
- package/dist/basemap/wmts.js +16 -11
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap/workerpool.d.ts +17 -0
- package/dist/basemap/workerpool.js +194 -0
- package/dist/basemap/workerpool.js.map +1 -0
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +21 -13
- package/dist/bind/layers.d.ts +13 -4
- package/dist/bind/layers.js +64 -40
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/crs.d.ts +10 -10
- package/dist/data/crs.js +38 -34
- package/dist/data/crs.js.map +1 -1
- package/dist/data/gpx.d.ts +1 -1
- package/dist/data/gpx.js +20 -20
- package/dist/data/gpx.js.map +1 -1
- package/dist/data/kml.d.ts +1 -1
- package/dist/data/kml.js +42 -39
- package/dist/data/kml.js.map +1 -1
- package/dist/data/topojson.d.ts +1 -1
- package/dist/data/topojson.js +15 -10
- package/dist/data/topojson.js.map +1 -1
- package/dist/data/xml.d.ts +5 -5
- package/dist/data/xml.js +19 -18
- package/dist/data/xml.js.map +1 -1
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +6 -6
- package/dist/engine/decoders.d.ts +2 -2
- package/dist/engine/decoders.js +28 -25
- package/dist/engine/decoders.js.map +1 -1
- package/dist/engine/loader.js +13 -14
- package/dist/engine/loader.js.map +1 -1
- package/dist/engine/requests.d.ts +1 -1
- package/dist/engine/requests.js +19 -16
- package/dist/engine/requests.js.map +1 -1
- package/dist/engine-loader.d.ts +13 -9
- package/dist/engine-loader.js +38 -28
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +26 -10
- package/dist/geoplateforme.js +45 -20
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_points_bg.wasm +0 -0
- package/dist/isard_tess_bg.wasm +0 -0
- package/dist/layers/extrusions.d.ts +1 -1
- package/dist/layers/extrusions.js +10 -5
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +10 -10
- package/dist/layers/features.js +41 -42
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/glyphs.d.ts +3 -3
- package/dist/layers/glyphs.js +34 -40
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/icons.d.ts +8 -8
- package/dist/layers/icons.js +76 -68
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +1 -1
- package/dist/layers/layers.js +42 -29
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/panoramas.d.ts +2 -2
- package/dist/layers/panoramas.js +52 -41
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -3
- package/dist/layers/pointclouds.js +25 -33
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/symbols.d.ts +1 -1
- package/dist/layers/symbols.js +68 -71
- package/dist/layers/symbols.js.map +1 -1
- package/dist/layers/vectors.d.ts +60 -0
- package/dist/layers/vectors.js +130 -0
- package/dist/layers/vectors.js.map +1 -0
- package/dist/map/basemap-layers.d.ts +26 -0
- package/dist/map/basemap-layers.js +61 -0
- package/dist/map/basemap-layers.js.map +1 -0
- package/dist/map/canvas.d.ts +17 -0
- package/dist/map/canvas.js +56 -0
- package/dist/map/canvas.js.map +1 -0
- package/dist/map/checks.d.ts +11 -0
- package/dist/map/checks.js +39 -0
- package/dist/map/checks.js.map +1 -0
- package/dist/map/credits.d.ts +17 -0
- package/dist/map/credits.js +34 -0
- package/dist/map/credits.js.map +1 -0
- package/dist/map/engine-settings.d.ts +15 -0
- package/dist/map/engine-settings.js +45 -0
- package/dist/map/engine-settings.js.map +1 -0
- package/dist/map/engines.d.ts +41 -0
- package/dist/map/engines.js +77 -0
- package/dist/map/engines.js.map +1 -0
- package/dist/map/events.d.ts +14 -0
- package/dist/map/events.js +46 -0
- package/dist/map/events.js.map +1 -0
- package/dist/map/frame-loop.d.ts +64 -0
- package/dist/map/frame-loop.js +145 -0
- package/dist/map/frame-loop.js.map +1 -0
- package/dist/map/hover-pick.d.ts +30 -0
- package/dist/map/hover-pick.js +56 -0
- package/dist/map/hover-pick.js.map +1 -0
- package/dist/map/layer-spec.d.ts +42 -0
- package/dist/map/layer-spec.js +34 -0
- package/dist/map/layer-spec.js.map +1 -0
- package/dist/map/layer-stack.d.ts +36 -0
- package/dist/map/layer-stack.js +101 -0
- package/dist/map/layer-stack.js.map +1 -0
- package/dist/map/overlay-host.d.ts +36 -0
- package/dist/map/overlay-host.js +101 -0
- package/dist/map/overlay-host.js.map +1 -0
- package/dist/map/panorama-host.d.ts +5 -0
- package/dist/map/panorama-host.js +32 -0
- package/dist/map/panorama-host.js.map +1 -0
- package/dist/map/raster-source.d.ts +11 -0
- package/dist/map/raster-source.js +26 -0
- package/dist/map/raster-source.js.map +1 -0
- package/dist/map/symbol-atlases.d.ts +26 -0
- package/dist/map/symbol-atlases.js +59 -0
- package/dist/map/symbol-atlases.js.map +1 -0
- package/dist/map/viewshed.d.ts +5 -0
- package/dist/map/viewshed.js +28 -0
- package/dist/map/viewshed.js.map +1 -0
- package/dist/map/workers.d.ts +46 -0
- package/dist/map/workers.js +73 -0
- package/dist/map/workers.js.map +1 -0
- package/dist/map.d.ts +54 -126
- package/dist/map.js +227 -698
- package/dist/map.js.map +1 -1
- package/dist/react/Control.d.ts +11 -0
- package/dist/react/Control.js +18 -0
- package/dist/react/Control.js.map +1 -0
- package/dist/react/CustomLayer.d.ts +11 -0
- package/dist/react/CustomLayer.js +30 -0
- package/dist/react/CustomLayer.js.map +1 -0
- package/dist/react/IsardMap.d.ts +43 -0
- package/dist/react/IsardMap.js +147 -0
- package/dist/react/IsardMap.js.map +1 -0
- package/dist/react/Layer.d.ts +42 -0
- package/dist/react/Layer.js +74 -0
- package/dist/react/Layer.js.map +1 -0
- package/dist/react/Marker.d.ts +24 -0
- package/dist/react/Marker.js +53 -0
- package/dist/react/Marker.js.map +1 -0
- package/dist/react/Panel.d.ts +11 -0
- package/dist/react/Panel.js +37 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/Popup.d.ts +18 -0
- package/dist/react/Popup.js +60 -0
- package/dist/react/Popup.js.map +1 -0
- package/dist/react/Swipe.d.ts +16 -0
- package/dist/react/Swipe.js +52 -0
- package/dist/react/Swipe.js.map +1 -0
- package/dist/react/VectorGeometry.d.ts +35 -0
- package/dist/react/VectorGeometry.js +82 -0
- package/dist/react/VectorGeometry.js.map +1 -0
- package/dist/react/Viewshed.d.ts +5 -0
- package/dist/react/Viewshed.js +28 -0
- package/dist/react/Viewshed.js.map +1 -0
- package/dist/react/context.d.ts +33 -0
- package/dist/react/context.js +20 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +16 -108
- package/dist/react/index.js +11 -397
- package/dist/react/index.js.map +1 -1
- package/dist/settings.d.ts +5 -9
- package/dist/settings.js +17 -15
- package/dist/settings.js.map +1 -1
- package/dist/types.d.ts +27 -4
- package/dist/types.js.map +1 -1
- package/dist/ui/controls.js +6 -4
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/interaction.d.ts +2 -2
- package/dist/ui/interaction.js +8 -7
- package/dist/ui/interaction.js.map +1 -1
- package/dist/ui/minimap.d.ts +25 -0
- package/dist/ui/minimap.js +90 -0
- package/dist/ui/minimap.js.map +1 -0
- package/dist/ui/overlay.js +18 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/scale.d.ts +19 -0
- package/dist/ui/scale.js +44 -0
- package/dist/ui/scale.js.map +1 -0
- package/dist/ui/search.d.ts +25 -0
- package/dist/ui/search.js +119 -0
- package/dist/ui/search.js.map +1 -0
- package/dist/ui/style.d.ts +1 -1
- package/dist/ui/style.js +19 -2
- package/dist/ui/style.js.map +1 -1
- package/dist/util/animation.d.ts +3 -3
- package/dist/util/animation.js +6 -6
- package/dist/util/animation.js.map +1 -1
- package/dist/util/color.d.ts +1 -1
- package/dist/util/color.js +14 -16
- package/dist/util/color.js.map +1 -1
- package/dist/util/geo.d.ts +6 -6
- package/dist/util/geo.js +12 -12
- package/dist/util/geo.js.map +1 -1
- package/dist/util/guards.d.ts +7 -0
- package/dist/util/guards.js +8 -0
- package/dist/util/guards.js.map +1 -0
- package/dist/util/lru.js.map +1 -1
- package/dist/util/sun.d.ts +11 -0
- package/dist/util/sun.js +26 -0
- package/dist/util/sun.js.map +1 -0
- package/dist/wasm/isard.d.ts +250 -7
- package/dist/wasm/isard.js +375 -8
- package/dist/wasm/isard_core.d.ts +226 -7
- package/dist/wasm/isard_core.js +351 -8
- package/dist/wasm/isard_tess.d.ts +109 -0
- package/dist/wasm/isard_tess.js +398 -0
- package/dist/workers/basemap/geometry.d.ts +72 -0
- package/dist/workers/basemap/labels.d.ts +8 -0
- package/dist/workers/basemap/raster.d.ts +10 -0
- package/dist/workers/basemap/tiles.d.ts +65 -0
- package/dist/workers/basemap/trees.d.ts +19 -0
- package/dist/workers/basemap.worker.d.ts +126 -22
- package/dist/workers/basemap.worker.js +76 -544
- package/dist/workers/basemap.worker.js.map +1 -1
- package/package.json +5 -4
- package/vite.js +10 -2
package/dist/basemap/grid.js
CHANGED
|
@@ -16,7 +16,7 @@ const MAX_BOOST = 3;
|
|
|
16
16
|
/** Pixels of a mosaic at most: coarser levels beyond, nothing if even the coarsest is larger */
|
|
17
17
|
const MAX_MOSAIC = 2048 * 2048;
|
|
18
18
|
/** A box of the CRS around points of it (x, y, x, y…), NaN ignored; undefined without any */
|
|
19
|
-
|
|
19
|
+
const box = (points) => {
|
|
20
20
|
let [x0, y0, x1, y1] = [Infinity, Infinity, -Infinity, -Infinity];
|
|
21
21
|
for (let k = 0; k + 1 < points.length; k += 2) {
|
|
22
22
|
const [x, y] = [points[k], points[k + 1]];
|
|
@@ -28,9 +28,9 @@ function box(points) {
|
|
|
28
28
|
y1 = Math.max(y1, y);
|
|
29
29
|
}
|
|
30
30
|
return x0 <= x1 ? [x0, y0, x1, y1] : undefined;
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
/** A tile grid ready to plan tiles: its CRS found, its matrices completed, its bounds projected */
|
|
33
|
-
export
|
|
33
|
+
export const resolveGrid = (grid) => {
|
|
34
34
|
const crs = getCrs(grid.crs);
|
|
35
35
|
const matrices = (grid.matrices ?? [])
|
|
36
36
|
.map((m, i) => ({
|
|
@@ -44,35 +44,32 @@ export function resolveGrid(grid) {
|
|
|
44
44
|
limits: m.limits,
|
|
45
45
|
}))
|
|
46
46
|
.sort((a, b) => b.resolution - a.resolution);
|
|
47
|
-
|
|
48
|
-
if (grid.bounds) {
|
|
47
|
+
const projected = (bounds) => {
|
|
49
48
|
// Its outline and inside, projected: the box of the CRS around them, a little larger (curved edges)
|
|
50
|
-
const [w, s, e, n] =
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
for (let j = 0; j <= 8; j += 1)
|
|
54
|
-
points.push(...crs.forward([w + ((e - w) * i) / 8, s + ((n - s) * j) / 8]));
|
|
55
|
-
}
|
|
49
|
+
const [w, s, e, n] = bounds;
|
|
50
|
+
const steps = Array.from({ length: 9 }, (_, i) => i);
|
|
51
|
+
const points = steps.flatMap((i) => steps.flatMap((j) => crs.forward([w + ((e - w) * i) / 8, s + ((n - s) * j) / 8])));
|
|
56
52
|
const b = box(points);
|
|
57
|
-
if (b)
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
53
|
+
if (!b)
|
|
54
|
+
return undefined;
|
|
55
|
+
const margin = 0.01 * Math.max(b[2] - b[0], b[3] - b[1]);
|
|
56
|
+
return [b[0] - margin, b[1] - margin, b[2] + margin, b[3] + margin];
|
|
57
|
+
};
|
|
58
|
+
const extent = grid.bounds ? projected(grid.bounds) : undefined;
|
|
62
59
|
return { crs, matrices, bounds: grid.bounds, extent };
|
|
63
|
-
}
|
|
60
|
+
};
|
|
64
61
|
/** The longitudes and latitudes of tiles in longitudes and latitudes, two 256 px tiles side by side at level 0, rows
|
|
65
62
|
* from the north (NASA's Trek, WorldCRS84Quad), levels `minLevel` to `maxLevel` ({z} is the level) */
|
|
66
|
-
export
|
|
67
|
-
const matrices =
|
|
68
|
-
|
|
63
|
+
export const equirectangularGrid = (minLevel, maxLevel) => {
|
|
64
|
+
const matrices = Array.from({ length: maxLevel - minLevel + 1 }, (_, i) => {
|
|
65
|
+
const level = minLevel + i;
|
|
69
66
|
const n = 2 ** level;
|
|
70
|
-
|
|
71
|
-
}
|
|
67
|
+
return { id: level, resolution: 180 / 256 / n, origin: [-180, 90], matrixWidth: 2 * n, matrixHeight: n };
|
|
68
|
+
});
|
|
72
69
|
return { crs: 'EPSG:4326', matrices };
|
|
73
|
-
}
|
|
70
|
+
};
|
|
74
71
|
/** A URL of the source: {z}, {x}, {y}, {bbox}, {width} and {height} replaced */
|
|
75
|
-
|
|
72
|
+
const sourceUrl = (template, z, x, y, bbox, w, h) => {
|
|
76
73
|
return template
|
|
77
74
|
.replaceAll('{z}', String(z))
|
|
78
75
|
.replaceAll('{x}', String(x))
|
|
@@ -80,20 +77,20 @@ function sourceUrl(template, z, x, y, bbox, w, h) {
|
|
|
80
77
|
.replaceAll('{bbox}', bbox.join(','))
|
|
81
78
|
.replaceAll('{width}', String(w))
|
|
82
79
|
.replaceAll('{height}', String(h));
|
|
83
|
-
}
|
|
80
|
+
};
|
|
84
81
|
/** CRS units per pixel along the mesh's x and y around its middle (NaN where the CRS has nothing there) */
|
|
85
|
-
|
|
82
|
+
const pixelSize = (points, size) => {
|
|
86
83
|
const c = N / 2;
|
|
87
84
|
const at = (i, j) => 2 * (j * (N + 1) + i);
|
|
88
|
-
const d = (p, q) => Math.hypot(points[q] - points[p], points[q + 1] - points[p + 1]);
|
|
85
|
+
const d = (p, q) => Math.hypot((points[q] ?? Number.NaN) - (points[p] ?? Number.NaN), (points[q + 1] ?? Number.NaN) - (points[p + 1] ?? Number.NaN));
|
|
89
86
|
const step = (2 * size) / N;
|
|
90
87
|
return [d(at(c - 1, c), at(c + 1, c)) / step, d(at(c, c - 1), at(c, c + 1)) / step];
|
|
91
|
-
}
|
|
88
|
+
};
|
|
92
89
|
/**
|
|
93
90
|
* The box (CRS) of the points a tile samples: the centers of its edge pixels, interpolated in the mesh as `resample`
|
|
94
91
|
* does, and the inner points of the mesh (should the projection bend); within `clip`. Undefined if none is
|
|
95
92
|
*/
|
|
96
|
-
|
|
93
|
+
const sampled = (points, size, clip) => {
|
|
97
94
|
const at = (i, j, k) => points[2 * (j * (N + 1) + i) + k];
|
|
98
95
|
const centers = [];
|
|
99
96
|
for (let j = 1; j < N; j += 1)
|
|
@@ -126,12 +123,12 @@ function sampled(points, size, clip) {
|
|
|
126
123
|
Math.min(b[3], clip[3]),
|
|
127
124
|
];
|
|
128
125
|
return out[0] <= out[2] && out[1] <= out[3] ? out : undefined;
|
|
129
|
-
}
|
|
126
|
+
};
|
|
130
127
|
/**
|
|
131
128
|
* The plan of Mercator tile `z`/`x`/`y` (`size` pixels a side) from a source of URL template `url` in grid `g`; null
|
|
132
129
|
* where the source has nothing
|
|
133
130
|
*/
|
|
134
|
-
export
|
|
131
|
+
export const planTile = (g, url, z, x, y, size) => {
|
|
135
132
|
const tiles = 2 ** z;
|
|
136
133
|
if (g.bounds) {
|
|
137
134
|
const [w, s, e, n] = g.bounds;
|
|
@@ -150,15 +147,15 @@ export function planTile(g, url, z, x, y, size) {
|
|
|
150
147
|
points[2 * (j * (N + 1) + i) + 1] = py;
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
|
-
|
|
154
|
-
if (!
|
|
150
|
+
const outer = box(points);
|
|
151
|
+
if (!outer)
|
|
152
|
+
return null;
|
|
153
|
+
const e = g.extent;
|
|
154
|
+
const b = e
|
|
155
|
+
? [Math.max(outer[0], e[0]), Math.max(outer[1], e[1]), Math.min(outer[2], e[2]), Math.min(outer[3], e[3])]
|
|
156
|
+
: outer;
|
|
157
|
+
if (e && (b[0] >= b[2] || b[1] >= b[3]))
|
|
155
158
|
return null;
|
|
156
|
-
if (g.extent) {
|
|
157
|
-
const e = g.extent;
|
|
158
|
-
b = [Math.max(b[0], e[0]), Math.max(b[1], e[1]), Math.min(b[2], e[2]), Math.min(b[3], e[3])];
|
|
159
|
-
if (b[0] >= b[2] || b[1] >= b[3])
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
159
|
const mesh = new Float32Array(points.length);
|
|
163
160
|
if (g.matrices.length === 0) {
|
|
164
161
|
// One image of the tile's box, a pixel larger on each side
|
|
@@ -180,14 +177,14 @@ export function planTile(g, url, z, x, y, size) {
|
|
|
180
177
|
const centers = sampled(points, size, b);
|
|
181
178
|
if (!centers)
|
|
182
179
|
return null;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
best = i;
|
|
188
|
-
});
|
|
180
|
+
const best = g.matrices.reduce((found, m, i) => {
|
|
181
|
+
const r = g.matrices[found]?.resolution ?? m.resolution;
|
|
182
|
+
return Math.abs(Math.log2(m.resolution / target)) < Math.abs(Math.log2(r / target)) ? i : found;
|
|
183
|
+
}, 0);
|
|
189
184
|
for (let level = best; level >= 0; level -= 1) {
|
|
190
185
|
const m = g.matrices[level];
|
|
186
|
+
if (!m)
|
|
187
|
+
continue;
|
|
191
188
|
const [ox, oy] = m.origin;
|
|
192
189
|
const [tw, th, res] = [m.tileWidth, m.tileHeight, m.resolution];
|
|
193
190
|
const [l0, r0, l1, r1] = m.limits ?? [0, 0, Infinity, Infinity];
|
|
@@ -202,14 +199,12 @@ export function planTile(g, url, z, x, y, size) {
|
|
|
202
199
|
const [width, height] = [(c1 - c0 + 1) * tw, (t1 - t0 + 1) * th];
|
|
203
200
|
if (width * height > MAX_MOSAIC)
|
|
204
201
|
continue;
|
|
205
|
-
const sources =
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
}
|
|
202
|
+
const sources = Array.from({ length: t1 - t0 + 1 }, (_, r) => t0 + r).flatMap((row) => Array.from({ length: c1 - c0 + 1 }, (_, c) => {
|
|
203
|
+
const col = c0 + c;
|
|
204
|
+
const bbox = [ox + col * tw * res, oy - (row + 1) * th * res, ox + (col + 1) * tw * res, oy - row * th * res];
|
|
205
|
+
const placed = { x: (col - c0) * tw, y: (row - t0) * th, w: tw, h: th };
|
|
206
|
+
return { url: sourceUrl(url, m.id, col, row, bbox, tw, th), ...placed };
|
|
207
|
+
}));
|
|
213
208
|
for (let k = 0; k < points.length; k += 2) {
|
|
214
209
|
mesh[k] = (points[k] - ox) / res - c0 * tw;
|
|
215
210
|
mesh[k + 1] = (oy - points[k + 1]) / res - t0 * th;
|
|
@@ -217,26 +212,25 @@ export function planTile(g, url, z, x, y, size) {
|
|
|
217
212
|
return { size, width, height, sources, n: N, mesh };
|
|
218
213
|
}
|
|
219
214
|
return null;
|
|
220
|
-
}
|
|
215
|
+
};
|
|
221
216
|
/**
|
|
222
217
|
* The map zooms a grid's matrices span (the pixel size of the finest and of the coarsest, two levels coarser, where
|
|
223
218
|
* the tiles still fit a mosaic), measured at the middle of its bounds, or of its coarsest matrix
|
|
224
219
|
*/
|
|
225
|
-
export
|
|
220
|
+
export const gridZooms = (g) => {
|
|
226
221
|
const coarse = g.matrices[0];
|
|
227
222
|
const fine = g.matrices.at(-1);
|
|
228
223
|
if (!coarse || !fine)
|
|
229
224
|
return { minZoom: 0, maxZoom: 19 };
|
|
230
|
-
|
|
231
|
-
if (g.bounds)
|
|
232
|
-
lonLat = [(g.bounds[0] + g.bounds[2]) / 2, (g.bounds[1] + g.bounds[3]) / 2];
|
|
233
|
-
else {
|
|
225
|
+
const middle = () => {
|
|
234
226
|
const [l0, r0, l1, r1] = coarse.limits ?? [0, 0, coarse.matrixWidth - 1, coarse.matrixHeight - 1];
|
|
235
227
|
const span = coarse.resolution * coarse.tileWidth;
|
|
236
228
|
const [cx, cy] = [(l0 + l1 + 1) / 2, (r0 + r1 + 1) / 2];
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
229
|
+
return Number.isFinite(cx + cy)
|
|
230
|
+
? g.crs.inverse([coarse.origin[0] + cx * span, coarse.origin[1] - cy * span])
|
|
231
|
+
: [0, 0];
|
|
232
|
+
};
|
|
233
|
+
const lonLat = g.bounds ? [(g.bounds[0] + g.bounds[2]) / 2, (g.bounds[1] + g.bounds[3]) / 2] : middle();
|
|
240
234
|
// CRS units per pixel of a 256 px tile at zoom 0 there
|
|
241
235
|
const [mx, my] = [mercatorX(lonLat[0] ?? 0), mercatorY(lonLat[1] ?? 0)];
|
|
242
236
|
const d = 1e-7;
|
|
@@ -249,12 +243,12 @@ export function gridZooms(g) {
|
|
|
249
243
|
minZoom: Math.max(0, Math.floor(Math.log2(zero / coarse.resolution)) - 2),
|
|
250
244
|
maxZoom: Math.max(0, Math.round(Math.log2(zero / fine.resolution))),
|
|
251
245
|
};
|
|
252
|
-
}
|
|
246
|
+
};
|
|
253
247
|
/**
|
|
254
248
|
* A raster loader drawing Web Mercator tiles of `size` pixels from a source of URL template `url` in tile grid `grid`:
|
|
255
249
|
* planned here, drawn in a worker of the map through `remote` when it can, else in the page
|
|
256
250
|
*/
|
|
257
|
-
export
|
|
251
|
+
export const gridLoader = (url, grid, size, remote) => {
|
|
258
252
|
let local;
|
|
259
253
|
return async (z, x, y, signal) => {
|
|
260
254
|
const job = planTile(grid, url, z, x, y, size);
|
|
@@ -266,5 +260,5 @@ export function gridLoader(url, grid, size, remote) {
|
|
|
266
260
|
local ??= resampler().draw;
|
|
267
261
|
return local(job, signal);
|
|
268
262
|
};
|
|
269
|
-
}
|
|
263
|
+
};
|
|
270
264
|
//# sourceMappingURL=grid.js.map
|
package/dist/basemap/grid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/basemap/grid.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA0B,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3E,OAAO,EAAyB,SAAS,EAAE,MAAM,eAAe,CAAC;AAoCjE,kDAAkD;AAClD,MAAM,CAAC,GAAG,EAAE,CAAC;AACb;+BAC+B;AAC/B,MAAM,SAAS,GAAG,CAAC,CAAC;AACpB,gGAAgG;AAChG,MA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,CAAC,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IACpD,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC;QACzE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC;AAYD;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAc,EAAE,IAAY,EAAE,MAA2B;IAC/F,IAAI,KAAuD,CAAC;IAC5D,OAAO,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACtB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAC/C,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,KAAK,KAAK,SAAS,EAAE,CAAC,IAAI,CAAC;QAC3B,OAAO,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Rasters in another tile grid, the planning half: a WMTS-like tile matrix set in any CRS (Lambert-93, UTM, longitudes\n * and latitudes…), or a WMS asked for a box in that CRS, reprojected into the Web Mercator tiles the engine draws. For\n * each Mercator tile the page projects a mesh of 17 × 17 points of the tile into the source CRS (the only projection\n * work: 289 points a tile, whatever its size), picks the source level of the same pixel size, and lists the source\n * images the tile spans; the drawing (`resample.ts`) is done by a worker of the map, or in the page without workers.\n */\nimport { type Crs, type CrsLike, getCrs } from '../data/crs.ts';\nimport { latitude, longitude, mercatorX, mercatorY } from '../util/geo.ts';\nimport { type Job, type Placed, resampler } from './resample.ts';\n\n/** One level of a tile grid, as a `TileMatrix` of WMTS */\nexport interface TileMatrix {\n /** What replaces {z} in the URL (the `TILEMATRIX` of a WMTS; default the index of the matrix in the grid) */\n id?: string | number;\n /** Size of a pixel, CRS units (WMTS: its `ScaleDenominator` × 0.00028 m, in CRS units) */\n resolution: number;\n /** Top-left corner of the tile (0, 0), CRS units (x east, y north) */\n origin: [x: number, y: number];\n /** Size of a tile, pixels (default 256) */\n tileWidth?: number;\n tileHeight?: number;\n /** Tiles across and down (default unbounded) */\n matrixWidth?: number;\n matrixHeight?: number;\n /** The tiles the source has (a WMTS's `TileMatrixLimits`), inclusive: none is asked for outside */\n limits?: [minCol: number, minRow: number, maxCol: number, maxRow: number];\n}\n\n/**\n * A raster's tile grid in a CRS of its own, reprojected into Web Mercator by the map: `matrices` for tiles ({z}, {x},\n * {y} in the URL: matrix, column, row, rows from the north), none for a WMS whose URL has `{bbox}` (the box of each\n * Mercator tile in that CRS: minimum x, minimum y, maximum x, maximum y, asked for at the tile's size)\n */\nexport interface TileGrid {\n /** `'EPSG:2154'`, another built-in or registered name, or an object with `forward` and `inverse` (proj4's) */\n crs: CrsLike;\n /** The levels of the grid, in any order */\n matrices?: TileMatrix[];\n /** Longitudes and latitudes the source covers (west, south, east, north): nothing is asked for outside */\n bounds?: [west: number, south: number, east: number, north: number];\n /** Identifier of the tile matrix set (a WMTS's `TILEMATRIXSET`), for the helpers that write the URL */\n name?: string;\n}\n\n/** Cells of the mesh along each side of a tile */\nconst N = 16;\n/** Source levels finer at most than the pixel size across, where the grid stretches one axis (towards the poles in\n * longitudes and latitudes) */\nconst MAX_BOOST = 3;\n/** Pixels of a mosaic at most: coarser levels beyond, nothing if even the coarsest is larger */\nconst MAX_MOSAIC = 2048 * 2048;\n\ninterface Matrix extends Required<Omit<TileMatrix, 'limits' | 'id'>> {\n id: string | number;\n limits: [number, number, number, number] | undefined;\n}\n\ninterface Resolved {\n crs: Crs;\n /** Coarsest first */\n matrices: Matrix[];\n bounds: [number, number, number, number] | undefined;\n /** The bounds in the CRS: minimum x, minimum y, maximum x, maximum y */\n extent: [number, number, number, number] | undefined;\n}\n\n/** A box of the CRS around points of it (x, y, x, y…), NaN ignored; undefined without any */\nfunction box(points: ArrayLike<number>): [number, number, number, number] | undefined {\n let [x0, y0, x1, y1] = [Infinity, Infinity, -Infinity, -Infinity];\n for (let k = 0; k + 1 < points.length; k += 2) {\n const [x, y] = [points[k] as number, points[k + 1] as number];\n if (!Number.isFinite(x) || !Number.isFinite(y)) continue;\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n return x0 <= x1 ? [x0, y0, x1, y1] : undefined;\n}\n\n/** A tile grid ready to plan tiles: its CRS found, its matrices completed, its bounds projected */\nexport function resolveGrid(grid: TileGrid): Resolved {\n const crs = getCrs(grid.crs);\n const matrices = (grid.matrices ?? [])\n .map(\n (m, i): Matrix => ({\n id: m.id ?? i,\n resolution: m.resolution,\n origin: m.origin,\n tileWidth: m.tileWidth ?? 256,\n tileHeight: m.tileHeight ?? 256,\n matrixWidth: m.matrixWidth ?? Infinity,\n matrixHeight: m.matrixHeight ?? Infinity,\n limits: m.limits,\n }),\n )\n .sort((a, b) => b.resolution - a.resolution);\n let extent: Resolved['extent'];\n if (grid.bounds) {\n // Its outline and inside, projected: the box of the CRS around them, a little larger (curved edges)\n const [w, s, e, n] = grid.bounds;\n const points: number[] = [];\n for (let i = 0; i <= 8; i += 1) {\n for (let j = 0; j <= 8; j += 1) points.push(...crs.forward([w + ((e - w) * i) / 8, s + ((n - s) * j) / 8]));\n }\n const b = box(points);\n if (b) {\n const margin = 0.01 * Math.max(b[2] - b[0], b[3] - b[1]);\n extent = [b[0] - margin, b[1] - margin, b[2] + margin, b[3] + margin];\n }\n }\n return { crs, matrices, bounds: grid.bounds, extent };\n}\n\n/** The longitudes and latitudes of tiles in longitudes and latitudes, two 256 px tiles side by side at level 0, rows\n * from the north (NASA's Trek, WorldCRS84Quad), levels `minLevel` to `maxLevel` ({z} is the level) */\nexport function equirectangularGrid(minLevel: number, maxLevel: number): TileGrid {\n const matrices: TileMatrix[] = [];\n for (let level = minLevel; level <= maxLevel; level += 1) {\n const n = 2 ** level;\n matrices.push({ id: level, resolution: 180 / 256 / n, origin: [-180, 90], matrixWidth: 2 * n, matrixHeight: n });\n }\n return { crs: 'EPSG:4326', matrices };\n}\n\n/** A URL of the source: {z}, {x}, {y}, {bbox}, {width} and {height} replaced */\nfunction sourceUrl(template: string, z: string | number, x: number, y: number, bbox: number[], w: number, h: number) {\n return template\n .replaceAll('{z}', String(z))\n .replaceAll('{x}', String(x))\n .replaceAll('{y}', String(y))\n .replaceAll('{bbox}', bbox.join(','))\n .replaceAll('{width}', String(w))\n .replaceAll('{height}', String(h));\n}\n\n/** CRS units per pixel along the mesh's x and y around its middle (NaN where the CRS has nothing there) */\nfunction pixelSize(points: Float64Array, size: number): [number, number] {\n const c = N / 2;\n const at = (i: number, j: number) => 2 * (j * (N + 1) + i);\n const d = (p: number, q: number) =>\n Math.hypot((points[q] as number) - (points[p] as number), (points[q + 1] as number) - (points[p + 1] as number));\n const step = (2 * size) / N;\n return [d(at(c - 1, c), at(c + 1, c)) / step, d(at(c, c - 1), at(c, c + 1)) / step];\n}\n\n/**\n * The box (CRS) of the points a tile samples: the centers of its edge pixels, interpolated in the mesh as `resample`\n * does, and the inner points of the mesh (should the projection bend); within `clip`. Undefined if none is\n */\nfunction sampled(points: Float64Array, size: number, clip: number[]): [number, number, number, number] | undefined {\n const at = (i: number, j: number, k: number) => points[2 * (j * (N + 1) + i) + k] as number;\n const centers: number[] = [];\n for (let j = 1; j < N; j += 1) for (let i = 1; i < N; i += 1) centers.push(at(i, j, 0), at(i, j, 1));\n const cell = size / N;\n const add = (px: number, py: number) => {\n const [fx, fy] = [px / cell, py / cell];\n const [i, j] = [Math.min(N - 1, Math.floor(fx)), Math.min(N - 1, Math.floor(fy))];\n const [tx, ty] = [fx - i, fy - j];\n for (const k of [0, 1]) {\n const top = at(i, j, k) + (at(i + 1, j, k) - at(i, j, k)) * tx;\n const bottom = at(i, j + 1, k) + (at(i + 1, j + 1, k) - at(i, j + 1, k)) * tx;\n centers.push(top + (bottom - top) * ty);\n }\n };\n for (let p = 0.5; p < size; p += 1) {\n add(p, 0.5);\n add(p, size - 0.5);\n add(0.5, p);\n add(size - 0.5, p);\n }\n const b = box(centers);\n if (!b) return undefined;\n const out: [number, number, number, number] = [\n Math.max(b[0], clip[0] as number),\n Math.max(b[1], clip[1] as number),\n Math.min(b[2], clip[2] as number),\n Math.min(b[3], clip[3] as number),\n ];\n return out[0] <= out[2] && out[1] <= out[3] ? out : undefined;\n}\n\n/**\n * The plan of Mercator tile `z`/`x`/`y` (`size` pixels a side) from a source of URL template `url` in grid `g`; null\n * where the source has nothing\n */\nexport function planTile(g: Resolved, url: string, z: number, x: number, y: number, size: number): Job | null {\n const tiles = 2 ** z;\n if (g.bounds) {\n const [w, s, e, n] = g.bounds;\n if (longitude((x + 1) / tiles) <= w || longitude(x / tiles) >= e) return null;\n if (latitude(y / tiles) <= s || latitude((y + 1) / tiles) >= n) return null;\n }\n // The mesh in the source CRS\n const points = new Float64Array(2 * (N + 1) ** 2);\n for (let j = 0; j <= N; j += 1) {\n const lat = latitude((y + j / N) / tiles);\n for (let i = 0; i <= N; i += 1) {\n const [px = Number.NaN, py = Number.NaN] = g.crs.forward([longitude((x + i / N) / tiles), lat]);\n points[2 * (j * (N + 1) + i)] = px;\n points[2 * (j * (N + 1) + i) + 1] = py;\n }\n }\n let b = box(points);\n if (!b) return null;\n if (g.extent) {\n const e = g.extent;\n b = [Math.max(b[0], e[0]), Math.max(b[1], e[1]), Math.min(b[2], e[2]), Math.min(b[3], e[3])];\n if (b[0] >= b[2] || b[1] >= b[3]) return null;\n }\n const mesh = new Float32Array(points.length);\n if (g.matrices.length === 0) {\n // One image of the tile's box, a pixel larger on each side\n const [sx, sy] = pixelSize(points, size);\n const m = Number.isFinite(sx + sy) ? Math.max(sx, sy) : 0;\n const [x0, y0, x1, y1] = [b[0] - m, b[1] - m, b[2] + m, b[3] + m];\n for (let k = 0; k < points.length; k += 2) {\n mesh[k] = (((points[k] as number) - x0) / (x1 - x0)) * size;\n mesh[k + 1] = ((y1 - (points[k + 1] as number)) / (y1 - y0)) * size;\n }\n const source = { url: sourceUrl(url, z, x, y, [x0, y0, x1, y1], size, size), x: 0, y: 0, w: size, h: size };\n return { size, width: size, height: size, sources: [source], n: N, mesh };\n }\n // The level of the same pixel size, along the axis the grid stretches least (up to MAX_BOOST levels finer)\n const [sx, sy] = pixelSize(points, size);\n const across = Math.max(sx, sy);\n const target = Number.isFinite(across) ? Math.max(Math.min(sx, sy), across / 2 ** MAX_BOOST) : (b[2] - b[0]) / size;\n // Where the pixels of the tile are sampled: the centers of its edge pixels and the mesh, within the source's extent\n const centers = sampled(points, size, b);\n if (!centers) return null;\n let best = 0;\n g.matrices.forEach((m, i) => {\n const r = g.matrices[best]?.resolution ?? m.resolution;\n if (Math.abs(Math.log2(m.resolution / target)) < Math.abs(Math.log2(r / target))) best = i;\n });\n for (let level = best; level >= 0; level -= 1) {\n const m = g.matrices[level] as Matrix;\n const [ox, oy] = m.origin;\n const [tw, th, res] = [m.tileWidth, m.tileHeight, m.resolution];\n const [l0, r0, l1, r1] = m.limits ?? [0, 0, Infinity, Infinity];\n // The tiles of the source pixels sampled (those of a weight over a thousandth: a tile edge on a source tile edge\n // does not fetch the next source tile for nothing)\n const c0 = Math.max(0, l0, Math.floor(((centers[0] - ox) / res - 0.5 + 1e-3) / tw));\n const c1 = Math.min(m.matrixWidth - 1, l1, Math.floor(((centers[2] - ox) / res + 0.5 - 1e-3) / tw));\n const t0 = Math.max(0, r0, Math.floor(((oy - centers[3]) / res - 0.5 + 1e-3) / th));\n const t1 = Math.min(m.matrixHeight - 1, r1, Math.floor(((oy - centers[1]) / res + 0.5 - 1e-3) / th));\n if (c0 > c1 || t0 > t1) return null;\n const [width, height] = [(c1 - c0 + 1) * tw, (t1 - t0 + 1) * th];\n if (width * height > MAX_MOSAIC) continue;\n const sources: Placed[] = [];\n for (let row = t0; row <= t1; row += 1) {\n for (let col = c0; col <= c1; col += 1) {\n const bbox = [ox + col * tw * res, oy - (row + 1) * th * res, ox + (col + 1) * tw * res, oy - row * th * res];\n const placed = { x: (col - c0) * tw, y: (row - t0) * th, w: tw, h: th };\n sources.push({ url: sourceUrl(url, m.id, col, row, bbox, tw, th), ...placed });\n }\n }\n for (let k = 0; k < points.length; k += 2) {\n mesh[k] = ((points[k] as number) - ox) / res - c0 * tw;\n mesh[k + 1] = (oy - (points[k + 1] as number)) / res - t0 * th;\n }\n return { size, width, height, sources, n: N, mesh };\n }\n return null;\n}\n\n/**\n * The map zooms a grid's matrices span (the pixel size of the finest and of the coarsest, two levels coarser, where\n * the tiles still fit a mosaic), measured at the middle of its bounds, or of its coarsest matrix\n */\nexport function gridZooms(g: Resolved): { minZoom: number; maxZoom: number } {\n const coarse = g.matrices[0];\n const fine = g.matrices.at(-1);\n if (!coarse || !fine) return { minZoom: 0, maxZoom: 19 };\n let lonLat: readonly number[] = [0, 0];\n if (g.bounds) lonLat = [(g.bounds[0] + g.bounds[2]) / 2, (g.bounds[1] + g.bounds[3]) / 2];\n else {\n const [l0, r0, l1, r1] = coarse.limits ?? [0, 0, coarse.matrixWidth - 1, coarse.matrixHeight - 1];\n const span = coarse.resolution * coarse.tileWidth;\n const [cx, cy] = [(l0 + l1 + 1) / 2, (r0 + r1 + 1) / 2];\n if (Number.isFinite(cx + cy)) lonLat = g.crs.inverse([coarse.origin[0] + cx * span, coarse.origin[1] - cy * span]);\n }\n // CRS units per pixel of a 256 px tile at zoom 0 there\n const [mx, my] = [mercatorX(lonLat[0] ?? 0), mercatorY(lonLat[1] ?? 0)];\n const d = 1e-7;\n const p = g.crs.forward([longitude(mx), latitude(my)]);\n const q = g.crs.forward([longitude(mx + d), latitude(my)]);\n const zero = Math.hypot((q[0] ?? 0) - (p[0] ?? 0), (q[1] ?? 0) - (p[1] ?? 0)) / (d * 256);\n if (!(zero > 0)) return { minZoom: 0, maxZoom: 19 };\n return {\n minZoom: Math.max(0, Math.floor(Math.log2(zero / coarse.resolution)) - 2),\n maxZoom: Math.max(0, Math.round(Math.log2(zero / fine.resolution))),\n };\n}\n\n/** Draws a Mercator tile `z`/`x`/`y`: its image, null where the source has nothing; rejects on errors */\ntype Draw = (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n\n/** A planned tile drawn in a worker; undefined when the map has no workers (drawn in the page) */\nexport type RemoteReprojection = (\n job: Job,\n tile: [z: number, x: number, y: number],\n signal: AbortSignal,\n) => Promise<ImageBitmap | null> | undefined;\n\n/**\n * A raster loader drawing Web Mercator tiles of `size` pixels from a source of URL template `url` in tile grid `grid`:\n * planned here, drawn in a worker of the map through `remote` when it can, else in the page\n */\nexport function gridLoader(url: string, grid: Resolved, size: number, remote?: RemoteReprojection): Draw {\n let local: ReturnType<typeof resampler>['draw'] | undefined;\n return async (z, x, y, signal) => {\n const job = planTile(grid, url, z, x, y, size);\n if (!job) return null;\n const drawn = remote?.(job, [z, x, y], signal);\n if (drawn) return drawn;\n local ??= resampler().draw;\n return local(job, signal);\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"grid.js","sourceRoot":"","sources":["../../src/basemap/grid.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA0B,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EA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CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC;QACzE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;KACpE,CAAC;AACJ,CAAC,CAAC;AAYF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,GAAW,EAAE,IAAc,EAAE,IAAY,EAAE,MAA2B,EAAQ,EAAE;IACzG,IAAI,KAAuD,CAAC;IAE5D,OAAO,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAE/C,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QAEtB,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAE/C,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,KAAK,KAAK,SAAS,EAAE,CAAC,IAAI,CAAC;QAE3B,OAAO,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Rasters in another tile grid, the planning half: a WMTS-like tile matrix set in any CRS (Lambert-93, UTM, longitudes\n * and latitudes…), or a WMS asked for a box in that CRS, reprojected into the Web Mercator tiles the engine draws. For\n * each Mercator tile the page projects a mesh of 17 × 17 points of the tile into the source CRS (the only projection\n * work: 289 points a tile, whatever its size), picks the source level of the same pixel size, and lists the source\n * images the tile spans; the drawing (`resample.ts`) is done by a worker of the map, or in the page without workers.\n */\nimport { type Crs, type CrsLike, getCrs } from '../data/crs.ts';\nimport { latitude, longitude, mercatorX, mercatorY } from '../util/geo.ts';\nimport { type Job, type Placed, resampler } from './resample.ts';\n\n/** One level of a tile grid, as a `TileMatrix` of WMTS */\nexport interface TileMatrix {\n /** What replaces {z} in the URL (the `TILEMATRIX` of a WMTS; default the index of the matrix in the grid) */\n id?: string | number;\n /** Size of a pixel, CRS units (WMTS: its `ScaleDenominator` × 0.00028 m, in CRS units) */\n resolution: number;\n /** Top-left corner of the tile (0, 0), CRS units (x east, y north) */\n origin: [x: number, y: number];\n /** Size of a tile, pixels (default 256) */\n tileWidth?: number;\n tileHeight?: number;\n /** Tiles across and down (default unbounded) */\n matrixWidth?: number;\n matrixHeight?: number;\n /** The tiles the source has (a WMTS's `TileMatrixLimits`), inclusive: none is asked for outside */\n limits?: [minCol: number, minRow: number, maxCol: number, maxRow: number];\n}\n\n/**\n * A raster's tile grid in a CRS of its own, reprojected into Web Mercator by the map: `matrices` for tiles ({z}, {x},\n * {y} in the URL: matrix, column, row, rows from the north), none for a WMS whose URL has `{bbox}` (the box of each\n * Mercator tile in that CRS: minimum x, minimum y, maximum x, maximum y, asked for at the tile's size)\n */\nexport interface TileGrid {\n /** `'EPSG:2154'`, another built-in or registered name, or an object with `forward` and `inverse` (proj4's) */\n crs: CrsLike;\n /** The levels of the grid, in any order */\n matrices?: TileMatrix[];\n /** Longitudes and latitudes the source covers (west, south, east, north): nothing is asked for outside */\n bounds?: [west: number, south: number, east: number, north: number];\n /** Identifier of the tile matrix set (a WMTS's `TILEMATRIXSET`), for the helpers that write the URL */\n name?: string;\n}\n\n/** Cells of the mesh along each side of a tile */\nconst N = 16;\n/** Source levels finer at most than the pixel size across, where the grid stretches one axis (towards the poles in\n * longitudes and latitudes) */\nconst MAX_BOOST = 3;\n/** Pixels of a mosaic at most: coarser levels beyond, nothing if even the coarsest is larger */\nconst MAX_MOSAIC = 2048 * 2048;\n\ninterface Matrix extends Required<Omit<TileMatrix, 'limits' | 'id'>> {\n id: string | number;\n limits: [number, number, number, number] | undefined;\n}\n\ninterface Resolved {\n crs: Crs;\n /** Coarsest first */\n matrices: Matrix[];\n bounds: [number, number, number, number] | undefined;\n /** The bounds in the CRS: minimum x, minimum y, maximum x, maximum y */\n extent: [number, number, number, number] | undefined;\n}\n\n/** A box of the CRS around points of it (x, y, x, y…), NaN ignored; undefined without any */\nconst box = (points: ArrayLike<number>): [number, number, number, number] | undefined => {\n let [x0, y0, x1, y1] = [Infinity, Infinity, -Infinity, -Infinity];\n\n for (let k = 0; k + 1 < points.length; k += 2) {\n const [x, y] = [points[k] as number, points[k + 1] as number];\n\n if (!Number.isFinite(x) || !Number.isFinite(y)) continue;\n x0 = Math.min(x0, x);\n y0 = Math.min(y0, y);\n x1 = Math.max(x1, x);\n y1 = Math.max(y1, y);\n }\n\n return x0 <= x1 ? [x0, y0, x1, y1] : undefined;\n};\n\n/** A tile grid ready to plan tiles: its CRS found, its matrices completed, its bounds projected */\nexport const resolveGrid = (grid: TileGrid): Resolved => {\n const crs = getCrs(grid.crs);\n const matrices = (grid.matrices ?? [])\n .map(\n (m, i): Matrix => ({\n id: m.id ?? i,\n resolution: m.resolution,\n origin: m.origin,\n tileWidth: m.tileWidth ?? 256,\n tileHeight: m.tileHeight ?? 256,\n matrixWidth: m.matrixWidth ?? Infinity,\n matrixHeight: m.matrixHeight ?? Infinity,\n limits: m.limits,\n }),\n )\n .sort((a, b) => b.resolution - a.resolution);\n const projected = (bounds: [number, number, number, number]): Resolved['extent'] => {\n // Its outline and inside, projected: the box of the CRS around them, a little larger (curved edges)\n const [w, s, e, n] = bounds;\n const steps = Array.from({ length: 9 }, (_, i) => i);\n const points = steps.flatMap((i) =>\n steps.flatMap((j) => crs.forward([w + ((e - w) * i) / 8, s + ((n - s) * j) / 8])),\n );\n const b = box(points);\n\n if (!b) return undefined;\n\n const margin = 0.01 * Math.max(b[2] - b[0], b[3] - b[1]);\n\n return [b[0] - margin, b[1] - margin, b[2] + margin, b[3] + margin];\n };\n const extent = grid.bounds ? projected(grid.bounds) : undefined;\n\n return { crs, matrices, bounds: grid.bounds, extent };\n};\n\n/** The longitudes and latitudes of tiles in longitudes and latitudes, two 256 px tiles side by side at level 0, rows\n * from the north (NASA's Trek, WorldCRS84Quad), levels `minLevel` to `maxLevel` ({z} is the level) */\nexport const equirectangularGrid = (minLevel: number, maxLevel: number): TileGrid => {\n const matrices = Array.from({ length: maxLevel - minLevel + 1 }, (_, i): TileMatrix => {\n const level = minLevel + i;\n const n = 2 ** level;\n\n return { id: level, resolution: 180 / 256 / n, origin: [-180, 90], matrixWidth: 2 * n, matrixHeight: n };\n });\n\n return { crs: 'EPSG:4326', matrices };\n};\n\n/** A URL of the source: {z}, {x}, {y}, {bbox}, {width} and {height} replaced */\nconst sourceUrl = (\n template: string,\n z: string | number,\n x: number,\n y: number,\n bbox: number[],\n w: number,\n h: number,\n) => {\n return template\n .replaceAll('{z}', String(z))\n .replaceAll('{x}', String(x))\n .replaceAll('{y}', String(y))\n .replaceAll('{bbox}', bbox.join(','))\n .replaceAll('{width}', String(w))\n .replaceAll('{height}', String(h));\n};\n\n/** CRS units per pixel along the mesh's x and y around its middle (NaN where the CRS has nothing there) */\nconst pixelSize = (points: Float64Array, size: number): [number, number] => {\n const c = N / 2;\n const at = (i: number, j: number) => 2 * (j * (N + 1) + i);\n const d = (p: number, q: number) =>\n Math.hypot(\n (points[q] ?? Number.NaN) - (points[p] ?? Number.NaN),\n (points[q + 1] ?? Number.NaN) - (points[p + 1] ?? Number.NaN),\n );\n const step = (2 * size) / N;\n\n return [d(at(c - 1, c), at(c + 1, c)) / step, d(at(c, c - 1), at(c, c + 1)) / step];\n};\n\n/**\n * The box (CRS) of the points a tile samples: the centers of its edge pixels, interpolated in the mesh as `resample`\n * does, and the inner points of the mesh (should the projection bend); within `clip`. Undefined if none is\n */\nconst sampled = (\n points: Float64Array,\n size: number,\n clip: [number, number, number, number],\n): [number, number, number, number] | undefined => {\n const at = (i: number, j: number, k: number) => points[2 * (j * (N + 1) + i) + k] as number;\n const centers: number[] = [];\n\n for (let j = 1; j < N; j += 1) for (let i = 1; i < N; i += 1) centers.push(at(i, j, 0), at(i, j, 1));\n\n const cell = size / N;\n const add = (px: number, py: number) => {\n const [fx, fy] = [px / cell, py / cell];\n const [i, j] = [Math.min(N - 1, Math.floor(fx)), Math.min(N - 1, Math.floor(fy))];\n const [tx, ty] = [fx - i, fy - j];\n\n for (const k of [0, 1]) {\n const top = at(i, j, k) + (at(i + 1, j, k) - at(i, j, k)) * tx;\n const bottom = at(i, j + 1, k) + (at(i + 1, j + 1, k) - at(i, j + 1, k)) * tx;\n\n centers.push(top + (bottom - top) * ty);\n }\n };\n\n for (let p = 0.5; p < size; p += 1) {\n add(p, 0.5);\n add(p, size - 0.5);\n add(0.5, p);\n add(size - 0.5, p);\n }\n\n const b = box(centers);\n\n if (!b) return undefined;\n\n const out: [number, number, number, number] = [\n Math.max(b[0], clip[0]),\n Math.max(b[1], clip[1]),\n Math.min(b[2], clip[2]),\n Math.min(b[3], clip[3]),\n ];\n\n return out[0] <= out[2] && out[1] <= out[3] ? out : undefined;\n};\n\n/**\n * The plan of Mercator tile `z`/`x`/`y` (`size` pixels a side) from a source of URL template `url` in grid `g`; null\n * where the source has nothing\n */\nexport const planTile = (g: Resolved, url: string, z: number, x: number, y: number, size: number): Job | null => {\n const tiles = 2 ** z;\n\n if (g.bounds) {\n const [w, s, e, n] = g.bounds;\n\n if (longitude((x + 1) / tiles) <= w || longitude(x / tiles) >= e) return null;\n if (latitude(y / tiles) <= s || latitude((y + 1) / tiles) >= n) return null;\n }\n\n // The mesh in the source CRS\n const points = new Float64Array(2 * (N + 1) ** 2);\n\n for (let j = 0; j <= N; j += 1) {\n const lat = latitude((y + j / N) / tiles);\n\n for (let i = 0; i <= N; i += 1) {\n const [px = Number.NaN, py = Number.NaN] = g.crs.forward([longitude((x + i / N) / tiles), lat]);\n\n points[2 * (j * (N + 1) + i)] = px;\n points[2 * (j * (N + 1) + i) + 1] = py;\n }\n }\n\n const outer = box(points);\n\n if (!outer) return null;\n\n const e = g.extent;\n const b: [number, number, number, number] = e\n ? [Math.max(outer[0], e[0]), Math.max(outer[1], e[1]), Math.min(outer[2], e[2]), Math.min(outer[3], e[3])]\n : outer;\n\n if (e && (b[0] >= b[2] || b[1] >= b[3])) return null;\n\n const mesh = new Float32Array(points.length);\n\n if (g.matrices.length === 0) {\n // One image of the tile's box, a pixel larger on each side\n const [sx, sy] = pixelSize(points, size);\n const m = Number.isFinite(sx + sy) ? Math.max(sx, sy) : 0;\n const [x0, y0, x1, y1] = [b[0] - m, b[1] - m, b[2] + m, b[3] + m];\n\n for (let k = 0; k < points.length; k += 2) {\n mesh[k] = (((points[k] as number) - x0) / (x1 - x0)) * size;\n mesh[k + 1] = ((y1 - (points[k + 1] as number)) / (y1 - y0)) * size;\n }\n\n const source = { url: sourceUrl(url, z, x, y, [x0, y0, x1, y1], size, size), x: 0, y: 0, w: size, h: size };\n\n return { size, width: size, height: size, sources: [source], n: N, mesh };\n }\n\n // The level of the same pixel size, along the axis the grid stretches least (up to MAX_BOOST levels finer)\n const [sx, sy] = pixelSize(points, size);\n const across = Math.max(sx, sy);\n const target = Number.isFinite(across) ? Math.max(Math.min(sx, sy), across / 2 ** MAX_BOOST) : (b[2] - b[0]) / size;\n // Where the pixels of the tile are sampled: the centers of its edge pixels and the mesh, within the source's extent\n const centers = sampled(points, size, b);\n\n if (!centers) return null;\n\n const best = g.matrices.reduce((found, m, i) => {\n const r = g.matrices[found]?.resolution ?? m.resolution;\n\n return Math.abs(Math.log2(m.resolution / target)) < Math.abs(Math.log2(r / target)) ? i : found;\n }, 0);\n\n for (let level = best; level >= 0; level -= 1) {\n const m = g.matrices[level];\n\n if (!m) continue;\n\n const [ox, oy] = m.origin;\n const [tw, th, res] = [m.tileWidth, m.tileHeight, m.resolution];\n const [l0, r0, l1, r1] = m.limits ?? [0, 0, Infinity, Infinity];\n // The tiles of the source pixels sampled (those of a weight over a thousandth: a tile edge on a source tile edge\n // does not fetch the next source tile for nothing)\n const c0 = Math.max(0, l0, Math.floor(((centers[0] - ox) / res - 0.5 + 1e-3) / tw));\n const c1 = Math.min(m.matrixWidth - 1, l1, Math.floor(((centers[2] - ox) / res + 0.5 - 1e-3) / tw));\n const t0 = Math.max(0, r0, Math.floor(((oy - centers[3]) / res - 0.5 + 1e-3) / th));\n const t1 = Math.min(m.matrixHeight - 1, r1, Math.floor(((oy - centers[1]) / res + 0.5 - 1e-3) / th));\n\n if (c0 > c1 || t0 > t1) return null;\n\n const [width, height] = [(c1 - c0 + 1) * tw, (t1 - t0 + 1) * th];\n\n if (width * height > MAX_MOSAIC) continue;\n\n const sources = Array.from({ length: t1 - t0 + 1 }, (_, r) => t0 + r).flatMap((row) =>\n Array.from({ length: c1 - c0 + 1 }, (_, c): Placed => {\n const col = c0 + c;\n const bbox = [ox + col * tw * res, oy - (row + 1) * th * res, ox + (col + 1) * tw * res, oy - row * th * res];\n const placed = { x: (col - c0) * tw, y: (row - t0) * th, w: tw, h: th };\n\n return { url: sourceUrl(url, m.id, col, row, bbox, tw, th), ...placed };\n }),\n );\n\n for (let k = 0; k < points.length; k += 2) {\n mesh[k] = ((points[k] as number) - ox) / res - c0 * tw;\n mesh[k + 1] = (oy - (points[k + 1] as number)) / res - t0 * th;\n }\n\n return { size, width, height, sources, n: N, mesh };\n }\n\n return null;\n};\n\n/**\n * The map zooms a grid's matrices span (the pixel size of the finest and of the coarsest, two levels coarser, where\n * the tiles still fit a mosaic), measured at the middle of its bounds, or of its coarsest matrix\n */\nexport const gridZooms = (g: Resolved): { minZoom: number; maxZoom: number } => {\n const coarse = g.matrices[0];\n const fine = g.matrices.at(-1);\n\n if (!coarse || !fine) return { minZoom: 0, maxZoom: 19 };\n\n const middle = (): readonly number[] => {\n const [l0, r0, l1, r1] = coarse.limits ?? [0, 0, coarse.matrixWidth - 1, coarse.matrixHeight - 1];\n const span = coarse.resolution * coarse.tileWidth;\n const [cx, cy] = [(l0 + l1 + 1) / 2, (r0 + r1 + 1) / 2];\n\n return Number.isFinite(cx + cy)\n ? g.crs.inverse([coarse.origin[0] + cx * span, coarse.origin[1] - cy * span])\n : [0, 0];\n };\n const lonLat = g.bounds ? [(g.bounds[0] + g.bounds[2]) / 2, (g.bounds[1] + g.bounds[3]) / 2] : middle();\n // CRS units per pixel of a 256 px tile at zoom 0 there\n const [mx, my] = [mercatorX(lonLat[0] ?? 0), mercatorY(lonLat[1] ?? 0)];\n const d = 1e-7;\n const p = g.crs.forward([longitude(mx), latitude(my)]);\n const q = g.crs.forward([longitude(mx + d), latitude(my)]);\n const zero = Math.hypot((q[0] ?? 0) - (p[0] ?? 0), (q[1] ?? 0) - (p[1] ?? 0)) / (d * 256);\n\n if (!(zero > 0)) return { minZoom: 0, maxZoom: 19 };\n\n return {\n minZoom: Math.max(0, Math.floor(Math.log2(zero / coarse.resolution)) - 2),\n maxZoom: Math.max(0, Math.round(Math.log2(zero / fine.resolution))),\n };\n};\n\n/** Draws a Mercator tile `z`/`x`/`y`: its image, null where the source has nothing; rejects on errors */\ntype Draw = (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n\n/** A planned tile drawn in a worker; undefined when the map has no workers (drawn in the page) */\nexport type RemoteReprojection = (\n job: Job,\n tile: [z: number, x: number, y: number],\n signal: AbortSignal,\n) => Promise<ImageBitmap | null> | undefined;\n\n/**\n * A raster loader drawing Web Mercator tiles of `size` pixels from a source of URL template `url` in tile grid `grid`:\n * planned here, drawn in a worker of the map through `remote` when it can, else in the page\n */\nexport const gridLoader = (url: string, grid: Resolved, size: number, remote?: RemoteReprojection): Draw => {\n let local: ReturnType<typeof resampler>['draw'] | undefined;\n\n return async (z, x, y, signal) => {\n const job = planTile(grid, url, z, x, y, size);\n\n if (!job) return null;\n\n const drawn = remote?.(job, [z, x, y], signal);\n\n if (drawn) return drawn;\n local ??= resampler().draw;\n\n return local(job, signal);\n };\n};\n"]}
|
package/dist/basemap/mvt.d.ts
CHANGED
|
@@ -16,4 +16,4 @@ export interface TileLayer {
|
|
|
16
16
|
features: TileFeature[];
|
|
17
17
|
}
|
|
18
18
|
/** Decodes a tile; only the layers in `wanted` (all if undefined) */
|
|
19
|
-
export declare
|
|
19
|
+
export declare const decode: (bytes: Uint8Array, wanted?: Set<string>) => Map<string, TileLayer>;
|
package/dist/basemap/mvt.js
CHANGED
|
@@ -94,7 +94,7 @@ class Pbf {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
const decoder = new TextDecoder();
|
|
97
|
-
|
|
97
|
+
const value = (p) => {
|
|
98
98
|
let v = '';
|
|
99
99
|
while (p.more) {
|
|
100
100
|
const tag = p.varint();
|
|
@@ -125,9 +125,9 @@ function value(p) {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
return v;
|
|
128
|
-
}
|
|
128
|
+
};
|
|
129
129
|
/** Point lists of a geometry's commands (MoveTo, LineTo, ClosePath) */
|
|
130
|
-
|
|
130
|
+
const geometry = (p) => {
|
|
131
131
|
const out = [];
|
|
132
132
|
let current;
|
|
133
133
|
let [x, y] = [0, 0];
|
|
@@ -153,9 +153,9 @@ function geometry(p) {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
return out;
|
|
156
|
-
}
|
|
156
|
+
};
|
|
157
157
|
/** Decodes a tile; only the layers in `wanted` (all if undefined) */
|
|
158
|
-
export
|
|
158
|
+
export const decode = (bytes, wanted) => {
|
|
159
159
|
const layers = new Map();
|
|
160
160
|
const tile = new Pbf(bytes);
|
|
161
161
|
while (tile.more) {
|
|
@@ -227,5 +227,5 @@ export function decode(bytes, wanted) {
|
|
|
227
227
|
layers.set(name, { extent, features });
|
|
228
228
|
}
|
|
229
229
|
return layers;
|
|
230
|
-
}
|
|
230
|
+
};
|
|
231
231
|
//# sourceMappingURL=mvt.js.map
|
package/dist/basemap/mvt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvt.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,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Mapbox Vector Tiles (MVT 2.1) decoding: layers of features with their properties and geometry, in tile units\n * (`extent`, usually 4096 across). Points are lists of points, lines lists of lines, polygons lists of rings (the\n * outer ones clockwise in tile coordinates, y down, holes the other way round, as the specification says).\n */\n\nexport type Value = string | number | boolean;\n\nexport interface TileFeature {\n /** 1 point, 2 line, 3 polygon */\n type: 1 | 2 | 3;\n properties: Record<string, Value>;\n /** Point lists: x0, y0, x1, y1… in tile units */\n geometry: number[][];\n}\n\nexport interface TileLayer {\n extent: number;\n features: TileFeature[];\n}\n\n/** Protobuf reader of a buffer range */\nclass Pbf {\n pos: number;\n constructor(\n private readonly buf: Uint8Array,\n start = 0,\n readonly end = buf.length,\n ) {\n this.pos = start;\n }\n /** An unsigned varint, approximated beyond 2^53; all its bytes are read (up to 10), so the next field is right */\n varint(): number {\n let value = 0;\n for (let shift = 0; shift < 70; shift += 7) {\n const b = this.buf[this.pos++] ?? 0;\n value += (b & 0x7f) * 2 ** shift;\n if (b < 0x80) break;\n }\n return value;\n }\n /** A signed 64-bit varint (two's complement: a negative value takes 10 bytes) */\n int64(): number {\n let lo = 0;\n let hi = 0;\n for (let i = 0; i < 10; i += 1) {\n const b = this.buf[this.pos++] ?? 0;\n const bits = b & 0x7f;\n // Bits 0-27 in the low word, bits 28-31 split, the rest in the high word\n if (i < 4) lo |= bits << (7 * i);\n else if (i === 4) {\n lo |= (bits & 0x0f) << 28;\n hi |= bits >> 4;\n } else hi |= bits << (7 * i - 32);\n if (b < 0x80) break;\n }\n // The high word signed: values from 2^63 up are negative\n return (hi | 0) * 2 ** 32 + (lo >>> 0);\n }\n sint(): number {\n const v = this.varint();\n return v % 2 === 1 ? -(v + 1) / 2 : v / 2;\n }\n /** A length-delimited field as a sub-reader */\n sub(): Pbf {\n const n = this.varint();\n // A length past the end (a truncated tile) stops at the end\n const end = Math.min(this.pos + n, this.end);\n const r = new Pbf(this.buf, this.pos, end);\n this.pos = end;\n return r;\n }\n string(): string {\n const n = this.varint();\n const end = Math.min(this.pos + n, this.end);\n const s = decoder.decode(this.buf.subarray(this.pos, end));\n this.pos = end;\n return s;\n }\n float(): number {\n const v = this.pos + 4 <= this.end ? this.view().getFloat32(this.pos, true) : 0;\n this.pos += 4;\n return v;\n }\n double(): number {\n const v = this.pos + 8 <= this.end ? this.view().getFloat64(this.pos, true) : 0;\n this.pos += 8;\n return v;\n }\n private view(): DataView {\n return new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.byteLength);\n }\n skip(wire: number): void {\n if (wire === 0) this.varint();\n else if (wire === 1) this.pos += 8;\n else if (wire === 2) this.pos += this.varint();\n else if (wire === 5) this.pos += 4;\n }\n get more(): boolean {\n return this.pos < this.end;\n }\n}\n\nconst decoder = new TextDecoder();\n\nfunction value(p: Pbf): Value {\n let v: Value = '';\n while (p.more) {\n const tag = p.varint();\n switch (tag >> 3) {\n case 1:\n v = p.string();\n break;\n case 2:\n v = p.float();\n break;\n case 3:\n v = p.double();\n break;\n case 4:\n v = p.int64();\n break;\n case 5:\n v = p.varint();\n break;\n case 6:\n v = p.sint();\n break;\n case 7:\n v = p.varint() !== 0;\n break;\n default:\n p.skip(tag & 7);\n }\n }\n return v;\n}\n\n/** Point lists of a geometry's commands (MoveTo, LineTo, ClosePath) */\nfunction geometry(p: Pbf): number[][] {\n const out: number[][] = [];\n let current: number[] | undefined;\n let [x, y] = [0, 0];\n while (p.more) {\n const command = p.varint();\n const id = command & 7;\n const count = command >> 3;\n if (id === 7) {\n // ClosePath: back to the first point\n if (current && current.length >= 2) current.push(current[0] ?? 0, current[1] ?? 0);\n continue;\n }\n // A count past the end (a truncated geometry) stops there\n for (let i = 0; i < count && p.more; i += 1) {\n x += p.sint();\n y += p.sint();\n if (id === 1) {\n current = [];\n out.push(current);\n }\n current?.push(x, y);\n }\n }\n return out;\n}\n\n/** Decodes a tile; only the layers in `wanted` (all if undefined) */\nexport function decode(bytes: Uint8Array, wanted?: Set<string>): Map<string, TileLayer> {\n const layers = new Map<string, TileLayer>();\n const tile = new Pbf(bytes);\n while (tile.more) {\n const tag = tile.varint();\n if (tag >> 3 !== 3) {\n tile.skip(tag & 7);\n continue;\n }\n const l = tile.sub();\n let name = '';\n let extent = 4096;\n const keys: string[] = [];\n const values: Value[] = [];\n const raw: Pbf[] = [];\n while (l.more) {\n const t = l.varint();\n switch (t >> 3) {\n case 1:\n name = l.string();\n break;\n case 2:\n raw.push(l.sub());\n break;\n case 3:\n keys.push(l.string());\n break;\n case 4:\n values.push(value(l.sub()));\n break;\n case 5:\n extent = l.varint();\n break;\n default:\n l.skip(t & 7);\n }\n }\n if (wanted && !wanted.has(name)) continue;\n const features: TileFeature[] = [];\n for (const f of raw) {\n let type: 1 | 2 | 3 = 1;\n const properties: Record<string, Value> = {};\n let geom: number[][] = [];\n while (f.more) {\n const t = f.varint();\n switch (t >> 3) {\n case 2: {\n const tags = f.sub();\n while (tags.more) {\n const k = keys[tags.varint()];\n const v = values[tags.varint()];\n if (k !== undefined && v !== undefined) properties[k] = v;\n }\n break;\n }\n case 3:\n type = Math.min(3, Math.max(1, f.varint())) as 1 | 2 | 3;\n break;\n case 4:\n geom = geometry(f.sub());\n break;\n default:\n f.skip(t & 7);\n }\n }\n features.push({ type, properties, geometry: geom });\n }\n layers.set(name, { extent, features });\n }\n return layers;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"mvt.js","sourceRoot":"","sources":["../../src/basemap/mvt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAiBH,wCAAwC;AACxC,MAAM,GAAG;IAGY;IAER;IAJX,GAAG,CAAS;IACZ,YACmB,GAAe,EAChC,KAAK,GAAG,CAAC,EACA,MAAM,GAAG,CAAC,MAAM;QAFR,QAAG,GAAH,GAAG,CAAY;QAEvB,QAAG,GAAH,GAAG,CAAa;QAEzB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,kHAAkH;IAClH,MAAM;QACJ,IAAI,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CAAC,CAAC,CAAC;wBACP,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;wBAErB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;4BACjB,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;4BAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;4BAEhC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS;gCAAE,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;wBAC5D,CAAC;wBACD,MAAM;oBACR,CAAC;oBACD,KAAK,CAAC;wBACJ,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAc,CAAC;wBACzD,MAAM;oBACR,KAAK,CAAC;wBACJ,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;wBACzB,MAAM;oBACR;wBACE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBAClB,CAAC;YACH,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["/**\n * Mapbox Vector Tiles (MVT 2.1) decoding: layers of features with their properties and geometry, in tile units\n * (`extent`, usually 4096 across). Points are lists of points, lines lists of lines, polygons lists of rings (the\n * outer ones clockwise in tile coordinates, y down, holes the other way round, as the specification says).\n */\n\nexport type Value = string | number | boolean;\n\nexport interface TileFeature {\n /** 1 point, 2 line, 3 polygon */\n type: 1 | 2 | 3;\n properties: Record<string, Value>;\n /** Point lists: x0, y0, x1, y1… in tile units */\n geometry: number[][];\n}\n\nexport interface TileLayer {\n extent: number;\n features: TileFeature[];\n}\n\n/** Protobuf reader of a buffer range */\nclass Pbf {\n pos: number;\n constructor(\n private readonly buf: Uint8Array,\n start = 0,\n readonly end = buf.length,\n ) {\n this.pos = start;\n }\n /** An unsigned varint, approximated beyond 2^53; all its bytes are read (up to 10), so the next field is right */\n varint(): number {\n let value = 0;\n\n for (let shift = 0; shift < 70; shift += 7) {\n const b = this.buf[this.pos++] ?? 0;\n\n value += (b & 0x7f) * 2 ** shift;\n if (b < 0x80) break;\n }\n\n return value;\n }\n /** A signed 64-bit varint (two's complement: a negative value takes 10 bytes) */\n int64(): number {\n let lo = 0;\n let hi = 0;\n\n for (let i = 0; i < 10; i += 1) {\n const b = this.buf[this.pos++] ?? 0;\n const bits = b & 0x7f;\n\n // Bits 0-27 in the low word, bits 28-31 split, the rest in the high word\n if (i < 4) lo |= bits << (7 * i);\n else if (i === 4) {\n lo |= (bits & 0x0f) << 28;\n hi |= bits >> 4;\n } else hi |= bits << (7 * i - 32);\n if (b < 0x80) break;\n }\n\n // The high word signed: values from 2^63 up are negative\n return (hi | 0) * 2 ** 32 + (lo >>> 0);\n }\n sint(): number {\n const v = this.varint();\n\n return v % 2 === 1 ? -(v + 1) / 2 : v / 2;\n }\n /** A length-delimited field as a sub-reader */\n sub(): Pbf {\n const n = this.varint();\n // A length past the end (a truncated tile) stops at the end\n const end = Math.min(this.pos + n, this.end);\n const r = new Pbf(this.buf, this.pos, end);\n\n this.pos = end;\n\n return r;\n }\n string(): string {\n const n = this.varint();\n const end = Math.min(this.pos + n, this.end);\n const s = decoder.decode(this.buf.subarray(this.pos, end));\n\n this.pos = end;\n\n return s;\n }\n float(): number {\n const v = this.pos + 4 <= this.end ? this.view().getFloat32(this.pos, true) : 0;\n\n this.pos += 4;\n\n return v;\n }\n double(): number {\n const v = this.pos + 8 <= this.end ? this.view().getFloat64(this.pos, true) : 0;\n\n this.pos += 8;\n\n return v;\n }\n private view(): DataView {\n return new DataView(this.buf.buffer, this.buf.byteOffset, this.buf.byteLength);\n }\n skip(wire: number): void {\n if (wire === 0) this.varint();\n else if (wire === 1) this.pos += 8;\n else if (wire === 2) this.pos += this.varint();\n else if (wire === 5) this.pos += 4;\n }\n get more(): boolean {\n return this.pos < this.end;\n }\n}\n\nconst decoder = new TextDecoder();\n\nconst value = (p: Pbf): Value => {\n let v: Value = '';\n\n while (p.more) {\n const tag = p.varint();\n\n switch (tag >> 3) {\n case 1:\n v = p.string();\n break;\n case 2:\n v = p.float();\n break;\n case 3:\n v = p.double();\n break;\n case 4:\n v = p.int64();\n break;\n case 5:\n v = p.varint();\n break;\n case 6:\n v = p.sint();\n break;\n case 7:\n v = p.varint() !== 0;\n break;\n default:\n p.skip(tag & 7);\n }\n }\n\n return v;\n};\n\n/** Point lists of a geometry's commands (MoveTo, LineTo, ClosePath) */\nconst geometry = (p: Pbf): number[][] => {\n const out: number[][] = [];\n let current: number[] | undefined;\n let [x, y] = [0, 0];\n\n while (p.more) {\n const command = p.varint();\n const id = command & 7;\n const count = command >> 3;\n\n if (id === 7) {\n // ClosePath: back to the first point\n if (current && current.length >= 2) current.push(current[0] ?? 0, current[1] ?? 0);\n continue;\n }\n // A count past the end (a truncated geometry) stops there\n for (let i = 0; i < count && p.more; i += 1) {\n x += p.sint();\n y += p.sint();\n if (id === 1) {\n current = [];\n out.push(current);\n }\n current?.push(x, y);\n }\n }\n\n return out;\n};\n\n/** Decodes a tile; only the layers in `wanted` (all if undefined) */\nexport const decode = (bytes: Uint8Array, wanted?: Set<string>): Map<string, TileLayer> => {\n const layers = new Map<string, TileLayer>();\n const tile = new Pbf(bytes);\n\n while (tile.more) {\n const tag = tile.varint();\n\n if (tag >> 3 !== 3) {\n tile.skip(tag & 7);\n continue;\n }\n\n const l = tile.sub();\n let name = '';\n let extent = 4096;\n const keys: string[] = [];\n const values: Value[] = [];\n const raw: Pbf[] = [];\n\n while (l.more) {\n const t = l.varint();\n\n switch (t >> 3) {\n case 1:\n name = l.string();\n break;\n case 2:\n raw.push(l.sub());\n break;\n case 3:\n keys.push(l.string());\n break;\n case 4:\n values.push(value(l.sub()));\n break;\n case 5:\n extent = l.varint();\n break;\n default:\n l.skip(t & 7);\n }\n }\n if (wanted && !wanted.has(name)) continue;\n\n const features: TileFeature[] = [];\n\n for (const f of raw) {\n let type: 1 | 2 | 3 = 1;\n const properties: Record<string, Value> = {};\n let geom: number[][] = [];\n\n while (f.more) {\n const t = f.varint();\n\n switch (t >> 3) {\n case 2: {\n const tags = f.sub();\n\n while (tags.more) {\n const k = keys[tags.varint()];\n const v = values[tags.varint()];\n\n if (k !== undefined && v !== undefined) properties[k] = v;\n }\n break;\n }\n case 3:\n type = Math.min(3, Math.max(1, f.varint())) as 1 | 2 | 3;\n break;\n case 4:\n geom = geometry(f.sub());\n break;\n default:\n f.skip(t & 7);\n }\n }\n features.push({ type, properties, geometry: geom });\n }\n layers.set(name, { extent, features });\n }\n\n return layers;\n};\n"]}
|
|
@@ -34,17 +34,17 @@ export interface PmtilesEntry {
|
|
|
34
34
|
runLength: number;
|
|
35
35
|
}
|
|
36
36
|
/** The tile id of z/x/y: the tiles of the lower levels, then the position along the level's Hilbert curve */
|
|
37
|
-
export declare
|
|
37
|
+
export declare const zxyToTileId: (z: number, x: number, y: number) => number;
|
|
38
38
|
/** The z/x/y of a tile id (the inverse of `zxyToTileId`) */
|
|
39
|
-
export declare
|
|
39
|
+
export declare const tileIdToZxy: (id: number) => [z: number, x: number, y: number];
|
|
40
40
|
/** The entries of a directory (decompressed) */
|
|
41
|
-
export declare
|
|
41
|
+
export declare const parseDirectory: (bytes: Uint8Array) => PmtilesEntry[];
|
|
42
42
|
/** The entry holding a tile id: its run of tiles, or the leaf directory it falls in; undefined if none */
|
|
43
|
-
export declare
|
|
43
|
+
export declare const findEntry: (entries: readonly PmtilesEntry[], id: number) => PmtilesEntry | undefined;
|
|
44
44
|
/** The header of an archive from its first bytes */
|
|
45
|
-
export declare
|
|
45
|
+
export declare const parseHeader: (bytes: Uint8Array) => PmtilesHeader;
|
|
46
46
|
/** Bytes as they are stored, decompressed (1: none, 2: gzip; 0, unknown, is read as none) */
|
|
47
|
-
export declare
|
|
47
|
+
export declare const decompress: (bytes: Uint8Array<ArrayBuffer>, compression: number) => Promise<Uint8Array<ArrayBuffer>>;
|
|
48
48
|
/** A PMTiles archive at a URL (range requests) or in a `Blob` (a dropped file) */
|
|
49
49
|
export declare class PMTiles {
|
|
50
50
|
readonly source: string | Blob;
|
|
@@ -63,12 +63,12 @@ export declare class PMTiles {
|
|
|
63
63
|
metadata(): Promise<Record<string, unknown>>;
|
|
64
64
|
private leaf;
|
|
65
65
|
/** The bytes of tile z/x/y, decompressed (a vector tile ungzipped); undefined where the archive has none */
|
|
66
|
-
tile(z: number, x: number, y: number, signal?: AbortSignal): Promise<Uint8Array | undefined>;
|
|
66
|
+
tile(z: number, x: number, y: number, signal?: AbortSignal): Promise<Uint8Array<ArrayBuffer> | undefined>;
|
|
67
67
|
}
|
|
68
68
|
/** The reader of an archive URL (without `pmtiles://`), shared */
|
|
69
|
-
export declare
|
|
69
|
+
export declare const pmtiles: (url: string) => PMTiles;
|
|
70
70
|
/** The archive URL of a `pmtiles://` URL, absolute (relative to the page), or undefined for another URL */
|
|
71
|
-
export declare
|
|
71
|
+
export declare const pmtilesUrl: (url: string, base?: string) => string | undefined;
|
|
72
72
|
/** A tile URL `pmtiles://<archive>/{z}/{x}/{y}` (with its numbers in) read from its archive: its bytes, undefined
|
|
73
73
|
* where there is none; undefined too (`false`) for a URL that is not one */
|
|
74
|
-
export declare
|
|
74
|
+
export declare const pmtilesTile: (url: string, signal?: AbortSignal) => Promise<Uint8Array<ArrayBuffer> | undefined> | false;
|