isard 0.2.1 → 0.4.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 +93 -0
- package/README.md +8 -4
- 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 -4
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +9 -5
- 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 +28 -0
- package/dist/engine-loader.js +112 -0
- package/dist/engine-loader.js.map +1 -0
- 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 +13 -3
- package/dist/glyphs.js +26 -4
- 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/icons.d.ts +146 -0
- package/dist/icons.js +333 -0
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +11 -4
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/interaction.d.ts +0 -4
- package/dist/interaction.js +8 -4
- 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 +89 -2
- package/dist/layers.js +171 -15
- 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 +45 -7
- package/dist/map.js +138 -310
- 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 +54 -9
- package/dist/symbols.js +278 -55
- package/dist/symbols.js.map +1 -1
- package/dist/terrain.d.ts +19 -7
- package/dist/terrain.js +40 -28
- 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 +14 -6
- package/dist/types.js.map +1 -1
- package/dist/vectorstyle.d.ts +32 -3
- package/dist/vectorstyle.js.map +1 -1
- package/dist/vectortiles.d.ts +19 -7
- package/dist/vectortiles.js +117 -69
- package/dist/vectortiles.js.map +1 -1
- package/dist/wasm/isard.d.ts +55 -7
- package/dist/wasm/isard.js +117 -6
- package/dist/wasm/isard_core.d.ts +29 -4
- package/dist/wasm/isard_core.js +84 -5
- 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 -143
- package/dist/equirectangular.js.map +0 -1
package/dist/icons.js
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/** The sprites of a style's `sprite`: one URL, or several with their ids (MapLibre's style specification) */
|
|
2
|
+
export function spriteSources(sprite) {
|
|
3
|
+
if (typeof sprite === 'string')
|
|
4
|
+
return sprite ? [{ id: 'default', url: sprite }] : [];
|
|
5
|
+
return Array.isArray(sprite) ? sprite.filter((s) => typeof s?.url === 'string' && typeof s.id === 'string') : [];
|
|
6
|
+
}
|
|
7
|
+
/** The name of an image of a sprite in the style: its own in the `default` sprite, `id:name` in another */
|
|
8
|
+
export function spriteName(id, name) {
|
|
9
|
+
return id === 'default' ? name : `${id}:${name}`;
|
|
10
|
+
}
|
|
11
|
+
/** The URL of a sprite's index or sheet: `.json` or `.png`, `@2x` before it for high-density screens, before the
|
|
12
|
+
* query of the URL if it has one */
|
|
13
|
+
export function spriteFile(url, extension, ratio) {
|
|
14
|
+
const suffix = `${ratio > 1 ? '@2x' : ''}.${extension}`;
|
|
15
|
+
const query = url.search(/[?#]/);
|
|
16
|
+
return query < 0 ? `${url}${suffix}` : `${url.slice(0, query)}${suffix}${url.slice(query)}`;
|
|
17
|
+
}
|
|
18
|
+
/** Loads a style's sprites (`@2x` above a device pixel ratio of 1, the 1x ones if a server has none); the sprites
|
|
19
|
+
* that fail are left out */
|
|
20
|
+
export async function loadSprites(sprite, ratio = typeof devicePixelRatio === 'number' ? devicePixelRatio : 1) {
|
|
21
|
+
const one = async ({ id, url }, r) => {
|
|
22
|
+
const [json, png] = await Promise.all([fetch(spriteFile(url, 'json', r)), fetch(spriteFile(url, 'png', r))]);
|
|
23
|
+
if (!json.ok || !png.ok)
|
|
24
|
+
return r > 1 ? one({ id, url }, 1) : undefined;
|
|
25
|
+
const index = (await json.json());
|
|
26
|
+
const icons = {};
|
|
27
|
+
for (const [name, icon] of Object.entries(index))
|
|
28
|
+
icons[spriteName(id, name)] = icon;
|
|
29
|
+
return { icons, image: await createImageBitmap(await png.blob()) };
|
|
30
|
+
};
|
|
31
|
+
const loaded = await Promise.all(spriteSources(sprite).map((s) => one(s, ratio).catch(() => undefined)));
|
|
32
|
+
return loaded.filter((s) => s !== undefined);
|
|
33
|
+
}
|
|
34
|
+
/** The pixels of an image (read back through a canvas) */
|
|
35
|
+
export function readPixels(image) {
|
|
36
|
+
const { width, height } = image;
|
|
37
|
+
if (!(width > 0 && height > 0))
|
|
38
|
+
return undefined;
|
|
39
|
+
const canvas = typeof OffscreenCanvas === 'function'
|
|
40
|
+
? new OffscreenCanvas(width, height)
|
|
41
|
+
: Object.assign(document.createElement('canvas'), { width, height });
|
|
42
|
+
const g = canvas.getContext('2d');
|
|
43
|
+
if (!g)
|
|
44
|
+
return undefined;
|
|
45
|
+
g.drawImage(image, 0, 0);
|
|
46
|
+
return g.getImageData(0, 0, width, height);
|
|
47
|
+
}
|
|
48
|
+
/** The icons of a map and their atlas: a square that doubles as it fills, up to the texture size limit */
|
|
49
|
+
export class Icons {
|
|
50
|
+
size = 256;
|
|
51
|
+
data = new Uint8Array(256 * 256 * 4);
|
|
52
|
+
shelves = [];
|
|
53
|
+
sources = new Map();
|
|
54
|
+
/** Icons packed, null for those that cannot be (no pixels, the atlas full) */
|
|
55
|
+
packed = new Map();
|
|
56
|
+
engine;
|
|
57
|
+
/** Rows changed since the last upload: first, end */
|
|
58
|
+
dirty;
|
|
59
|
+
full = false;
|
|
60
|
+
maxSize;
|
|
61
|
+
/** Bumped each time icons are added or removed: labels laid out without some of theirs are laid out again */
|
|
62
|
+
version = 0;
|
|
63
|
+
/** `maxSize`: the GPU's texture size limit if known (the atlas is at most 4096 × 4096) */
|
|
64
|
+
constructor(maxSize = 4096) {
|
|
65
|
+
this.maxSize = Math.max(256, Math.min(4096, maxSize));
|
|
66
|
+
}
|
|
67
|
+
/** Sends the whole atlas to an engine (a new one after a context loss) */
|
|
68
|
+
attach(engine) {
|
|
69
|
+
this.engine = engine;
|
|
70
|
+
this.dirty = undefined;
|
|
71
|
+
this.upload();
|
|
72
|
+
}
|
|
73
|
+
/** Side of the atlas */
|
|
74
|
+
get atlasSize() {
|
|
75
|
+
return this.size;
|
|
76
|
+
}
|
|
77
|
+
/** An image of the application under `name` (another image of that name is replaced) */
|
|
78
|
+
add(name, pixels, options = {}) {
|
|
79
|
+
this.define(name, { pixels: () => pixels, x: 0, y: 0, width: pixels.width, height: pixels.height, options });
|
|
80
|
+
}
|
|
81
|
+
/** The images of a sprite's index, `prefix` before their names, their pixels read from the sheet on first use */
|
|
82
|
+
addSprite(prefix, index, sheet) {
|
|
83
|
+
let pixels;
|
|
84
|
+
let read = false;
|
|
85
|
+
const once = () => {
|
|
86
|
+
if (!read) {
|
|
87
|
+
read = true;
|
|
88
|
+
pixels = sheet();
|
|
89
|
+
}
|
|
90
|
+
return pixels;
|
|
91
|
+
};
|
|
92
|
+
for (const [name, icon] of Object.entries(index)) {
|
|
93
|
+
if (!icon || typeof icon !== 'object')
|
|
94
|
+
continue;
|
|
95
|
+
const { x, y, width, height, ...options } = icon;
|
|
96
|
+
this.define(`${prefix}${name}`, { pixels: once, x, y, width, height, options }, false);
|
|
97
|
+
}
|
|
98
|
+
this.version += 1;
|
|
99
|
+
}
|
|
100
|
+
define(name, source, bump = true) {
|
|
101
|
+
this.sources.set(name, source);
|
|
102
|
+
// Packed again on its next use (its old place stays taken)
|
|
103
|
+
this.packed.delete(name);
|
|
104
|
+
if (bump)
|
|
105
|
+
this.version += 1;
|
|
106
|
+
}
|
|
107
|
+
has(name) {
|
|
108
|
+
return this.sources.has(name);
|
|
109
|
+
}
|
|
110
|
+
/** Forgets an image, or every image whose name starts with `prefix` (a sprite's) */
|
|
111
|
+
remove(name, prefix = false) {
|
|
112
|
+
for (const key of [...this.sources.keys()]) {
|
|
113
|
+
if (prefix ? key.startsWith(name) : key === name) {
|
|
114
|
+
this.sources.delete(key);
|
|
115
|
+
this.packed.delete(key);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
this.version += 1;
|
|
119
|
+
}
|
|
120
|
+
/** The icon of this name, packed into the atlas on first use; undefined if there is none (`flush` uploads it) */
|
|
121
|
+
get(name) {
|
|
122
|
+
const hit = this.packed.get(name);
|
|
123
|
+
if (hit !== undefined)
|
|
124
|
+
return hit ?? undefined;
|
|
125
|
+
const source = this.sources.get(name);
|
|
126
|
+
if (!source)
|
|
127
|
+
return undefined;
|
|
128
|
+
const icon = this.pack(source);
|
|
129
|
+
this.packed.set(name, icon ?? null);
|
|
130
|
+
return icon;
|
|
131
|
+
}
|
|
132
|
+
/** Sends the rows changed since the last upload to the engine */
|
|
133
|
+
flush() {
|
|
134
|
+
const dirty = this.dirty;
|
|
135
|
+
this.dirty = undefined;
|
|
136
|
+
if (!dirty || !this.engine)
|
|
137
|
+
return;
|
|
138
|
+
const [y0, y1] = dirty;
|
|
139
|
+
const row = this.size * 4;
|
|
140
|
+
this.engine.updateIconAtlas(0, y0, this.size, y1 - y0, this.data.subarray(y0 * row, y1 * row));
|
|
141
|
+
}
|
|
142
|
+
upload() {
|
|
143
|
+
const engine = this.engine;
|
|
144
|
+
if (!engine)
|
|
145
|
+
return;
|
|
146
|
+
engine.setIconAtlas(this.size, this.size);
|
|
147
|
+
const used = this.shelves.reduce((m, s) => Math.max(m, s.y + s.height), 0);
|
|
148
|
+
if (used > 0)
|
|
149
|
+
engine.updateIconAtlas(0, 0, this.size, used, this.data.subarray(0, used * this.size * 4));
|
|
150
|
+
}
|
|
151
|
+
/** Copies an icon's pixels into the atlas, premultiplied, with a texel of room around it */
|
|
152
|
+
pack(source) {
|
|
153
|
+
const pixels = source.pixels();
|
|
154
|
+
const { x, y, width: w, height: h } = source;
|
|
155
|
+
if (!pixels || !(w > 0 && h > 0) || x < 0 || y < 0 || x + w > pixels.width || y + h > pixels.height) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
const place = this.place(w + 2, h + 2);
|
|
159
|
+
if (!place)
|
|
160
|
+
return undefined;
|
|
161
|
+
const [px, py] = [place[0] + 1, place[1] + 1];
|
|
162
|
+
for (let row = 0; row < h; row += 1) {
|
|
163
|
+
for (let col = 0; col < w; col += 1) {
|
|
164
|
+
const from = ((y + row) * pixels.width + x + col) * 4;
|
|
165
|
+
const to = ((py + row) * this.size + px + col) * 4;
|
|
166
|
+
const a = pixels.data[from + 3] ?? 0;
|
|
167
|
+
this.data[to] = ((pixels.data[from] ?? 0) * a + 127) / 255;
|
|
168
|
+
this.data[to + 1] = ((pixels.data[from + 1] ?? 0) * a + 127) / 255;
|
|
169
|
+
this.data[to + 2] = ((pixels.data[from + 2] ?? 0) * a + 127) / 255;
|
|
170
|
+
this.data[to + 3] = a;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
const [d0, d1] = this.dirty ?? [place[1], place[1]];
|
|
174
|
+
this.dirty = [Math.min(d0, place[1]), Math.max(d1, place[1] + h + 2)];
|
|
175
|
+
const { pixelRatio, sdf, stretchX, stretchY, content } = source.options;
|
|
176
|
+
return {
|
|
177
|
+
x: px,
|
|
178
|
+
y: py,
|
|
179
|
+
width: w,
|
|
180
|
+
height: h,
|
|
181
|
+
pixelRatio: pixelRatio && pixelRatio > 0 ? pixelRatio : 1,
|
|
182
|
+
sdf: sdf === true,
|
|
183
|
+
stretchX: Array.isArray(stretchX) ? stretchX : undefined,
|
|
184
|
+
stretchY: Array.isArray(stretchY) ? stretchY : undefined,
|
|
185
|
+
content: Array.isArray(content) && content.length === 4 ? content : undefined,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** A free place of `w` × `h` texels (shelves, the atlas doubled when full); undefined once it cannot grow */
|
|
189
|
+
place(w, h) {
|
|
190
|
+
for (;;) {
|
|
191
|
+
const shelf = this.shelves.find((s) => s.height >= h && s.height <= h + 8 && s.x + w <= this.size);
|
|
192
|
+
if (shelf) {
|
|
193
|
+
shelf.x += w;
|
|
194
|
+
return [shelf.x - w, shelf.y];
|
|
195
|
+
}
|
|
196
|
+
const last = this.shelves.at(-1);
|
|
197
|
+
const y = last ? last.y + last.height : 0;
|
|
198
|
+
if (y + h <= this.size && w <= this.size) {
|
|
199
|
+
this.shelves.push({ y, height: h, x: w });
|
|
200
|
+
return [0, y];
|
|
201
|
+
}
|
|
202
|
+
if (this.size * 2 > this.maxSize) {
|
|
203
|
+
if (!this.full)
|
|
204
|
+
console.warn(`isard: the icon atlas is full (${this.size} × ${this.size})`);
|
|
205
|
+
this.full = true;
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
this.grow();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** Doubles the atlas; the icons keep their places (texels) */
|
|
212
|
+
grow() {
|
|
213
|
+
const size = this.size * 2;
|
|
214
|
+
const data = new Uint8Array(size * size * 4);
|
|
215
|
+
for (let row = 0; row < this.size; row += 1) {
|
|
216
|
+
data.set(this.data.subarray(row * this.size * 4, (row + 1) * this.size * 4), row * size * 4);
|
|
217
|
+
}
|
|
218
|
+
this.size = size;
|
|
219
|
+
this.data = data;
|
|
220
|
+
this.dirty = undefined;
|
|
221
|
+
this.upload();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* An axis of an icon fitted to `lo`…`hi` (CSS pixels): its content (the whole image by default) spans them, its
|
|
226
|
+
* stretchable zones (the whole image by default) taking the room the fixed parts (at `scale` CSS pixels per image
|
|
227
|
+
* pixel) leave
|
|
228
|
+
*/
|
|
229
|
+
export function stretch(length, zones, content, lo, hi, scale) {
|
|
230
|
+
const clamp = (v) => Math.max(0, Math.min(length, Number(v) || 0));
|
|
231
|
+
const spans = (zones?.length ? zones : [[0, length]])
|
|
232
|
+
.map(([a, b]) => [clamp(Math.min(a, b)), clamp(Math.max(a, b))])
|
|
233
|
+
.filter(([a, b]) => b > a);
|
|
234
|
+
const cuts = [...new Set([0, length, ...spans.flat()])].sort((a, b) => a - b);
|
|
235
|
+
const pieces = cuts.slice(1).map((b, i) => {
|
|
236
|
+
const a = cuts[i] ?? 0;
|
|
237
|
+
return [a, b, spans.some(([s, e]) => s <= a && b <= e)];
|
|
238
|
+
});
|
|
239
|
+
const [c0, c1] = content ? [clamp(content[0]), clamp(content[1])] : [0, length];
|
|
240
|
+
const overlap = (a, b) => Math.max(0, Math.min(b, c1) - Math.max(a, c0));
|
|
241
|
+
const stretchable = pieces.reduce((n, [a, b, s]) => n + (s ? overlap(a, b) : 0), 0);
|
|
242
|
+
const fixed = c1 - c0 - stretchable;
|
|
243
|
+
// CSS pixels per stretchable image pixel: what the fixed parts of the content leave of the room
|
|
244
|
+
const k = stretchable > 0 ? Math.max(0, (hi - lo - fixed * scale) / stretchable) : scale;
|
|
245
|
+
// Laid out position of an image coordinate
|
|
246
|
+
const at = (x) => pieces.reduce((n, [a, b, s]) => n + Math.max(0, Math.min(x, b) - a) * (s ? k : scale), 0);
|
|
247
|
+
const origin = lo - at(c0);
|
|
248
|
+
return pieces.map(([a, b]) => [a, b, origin + at(a), origin + at(b)]);
|
|
249
|
+
}
|
|
250
|
+
/** Where an anchor's side lies along an axis of the icon: at its start 0, at its end 1, else the middle */
|
|
251
|
+
function align(start, end) {
|
|
252
|
+
if (start)
|
|
253
|
+
return 0;
|
|
254
|
+
return end ? 1 : 0.5;
|
|
255
|
+
}
|
|
256
|
+
/** Lays an icon out around its anchor: placed by its anchor and offset, or fitted to its text */
|
|
257
|
+
export function layoutIcon(icon, options) {
|
|
258
|
+
const { size, anchor, offset, rotate, fit, padding, text } = options;
|
|
259
|
+
const { width: w, height: h, pixelRatio } = icon;
|
|
260
|
+
let xs;
|
|
261
|
+
let ys;
|
|
262
|
+
if (fit !== 'none' && text) {
|
|
263
|
+
const [top, right, bottom, left] = padding;
|
|
264
|
+
const [x0, y0, x1, y1] = [text[0] - left, text[1] - top, text[2] + right, text[3] + bottom];
|
|
265
|
+
// The fixed parts at the image's own size; an axis not fitted at the icon's size, centered on the text
|
|
266
|
+
const own = 1 / pixelRatio;
|
|
267
|
+
const scaled = size / pixelRatio;
|
|
268
|
+
const centered = (length, lo, hi) => {
|
|
269
|
+
const c = (lo + hi) / 2;
|
|
270
|
+
return [[0, length, c - (length * scaled) / 2, c + (length * scaled) / 2]];
|
|
271
|
+
};
|
|
272
|
+
const content = icon.content;
|
|
273
|
+
xs =
|
|
274
|
+
fit === 'height'
|
|
275
|
+
? centered(w, x0, x1)
|
|
276
|
+
: stretch(w, icon.stretchX, content && [content[0], content[2]], x0, x1, own);
|
|
277
|
+
ys =
|
|
278
|
+
fit === 'width'
|
|
279
|
+
? centered(h, y0, y1)
|
|
280
|
+
: stretch(h, icon.stretchY, content && [content[1], content[3]], y0, y1, own);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
const [dw, dh] = [(w / pixelRatio) * size, (h / pixelRatio) * size];
|
|
284
|
+
const ax = align(anchor.includes('left'), anchor.includes('right'));
|
|
285
|
+
const ay = align(anchor.startsWith('top'), anchor.startsWith('bottom'));
|
|
286
|
+
const [left, top] = [offset[0] * size - dw * ax, offset[1] * size - dh * ay];
|
|
287
|
+
xs = [[0, w, left, left + dw]];
|
|
288
|
+
ys = [[0, h, top, top + dh]];
|
|
289
|
+
}
|
|
290
|
+
const angle = ((Number(rotate) || 0) * Math.PI) / 180;
|
|
291
|
+
const kind = icon.sdf ? -2 : -1;
|
|
292
|
+
const quads = [];
|
|
293
|
+
const [cs, sn] = [Math.cos(angle), Math.sin(angle)];
|
|
294
|
+
const box = [
|
|
295
|
+
Number.POSITIVE_INFINITY,
|
|
296
|
+
Number.POSITIVE_INFINITY,
|
|
297
|
+
Number.NEGATIVE_INFINITY,
|
|
298
|
+
Number.NEGATIVE_INFINITY,
|
|
299
|
+
];
|
|
300
|
+
for (const [v0, v1, top, bottom] of ys) {
|
|
301
|
+
for (const [u0, u1, left, right] of xs) {
|
|
302
|
+
if (right <= left || bottom <= top)
|
|
303
|
+
continue;
|
|
304
|
+
quads.push([
|
|
305
|
+
left,
|
|
306
|
+
top,
|
|
307
|
+
right - left,
|
|
308
|
+
bottom - top,
|
|
309
|
+
icon.x + u0,
|
|
310
|
+
icon.y + v0,
|
|
311
|
+
icon.x + u1,
|
|
312
|
+
icon.y + v1,
|
|
313
|
+
kind,
|
|
314
|
+
angle,
|
|
315
|
+
]);
|
|
316
|
+
// The box of the turned corners
|
|
317
|
+
for (const [px, py] of [
|
|
318
|
+
[left, top],
|
|
319
|
+
[right, top],
|
|
320
|
+
[left, bottom],
|
|
321
|
+
[right, bottom],
|
|
322
|
+
]) {
|
|
323
|
+
const [rx, ry] = [px * cs - py * sn, px * sn + py * cs];
|
|
324
|
+
box[0] = Math.min(box[0], rx);
|
|
325
|
+
box[1] = Math.min(box[1], ry);
|
|
326
|
+
box[2] = Math.max(box[2], rx);
|
|
327
|
+
box[3] = Math.max(box[3], ry);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
return { quads, box: quads.length ? box : [0, 0, 0, 0] };
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=icons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../src/icons.ts"],"names":[],"mappings":"AA2DA,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CAAC,MAAoD;IAChF,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnH,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,UAAU,CAAC,EAAU,EAAE,IAAY;IACjD,OAAO,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC;AACnD,CAAC;AAED;oCACoC;AACpC,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,SAAyB,EAAE,KAAa;IAC9E,MAAM,MAAM,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC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,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * Icons for the symbol layers: the images of a style's sprite (MapLibre's sprite format: a JSON index and a PNG sheet,\n * `@2x` on high-density screens, one sprite or several with their ids) and the application's own (`map.addImage`),\n * packed on first use into an RGBA atlas the engine samples (premultiplied: no dark fringe where it is scaled); and the\n * layout of an icon around its anchor: by its anchor and offset, or stretched around its text (`icon-text-fit`), by\n * the stretchable zones and the content box of its image when it has them (`stretchX`, `stretchY`, `content`).\n */\nimport type { Anchor } from './overlay.ts';\nimport type { Engine } from './wasm/isard.js';\n\n/** An image of a sprite's index: its place in the sheet (pixels) and how it is drawn */\nexport interface SpriteIcon {\n x: number;\n y: number;\n width: number;\n height: number;\n /** Image pixels per CSS pixel (default 1; 2 in an `@2x` sheet) */\n pixelRatio?: number;\n /** A signed distance field in alpha, drawn in the icon color */\n sdf?: boolean;\n /** Columns and rows that stretch when the icon is fitted to its text (image pixels): the others keep their size */\n stretchX?: [number, number][];\n stretchY?: [number, number][];\n /** Where the text goes when the icon is fitted to it: left, top, right, bottom (image pixels) */\n content?: [number, number, number, number];\n}\n\nexport type SpriteIndex = Record<string, SpriteIcon>;\n\n/** RGBA pixels, straight alpha, row after row */\nexport interface Pixels {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n}\n\n/** How an image of the application is drawn (`map.addImage`): `SpriteIcon` without its place */\nexport type ImageOptions = Omit<SpriteIcon, 'x' | 'y' | 'width' | 'height'>;\n\n/** An icon in the atlas: its place (texels) and how it is drawn */\nexport interface Icon {\n x: number;\n y: number;\n width: number;\n height: number;\n pixelRatio: number;\n sdf: boolean;\n stretchX: [number, number][] | undefined;\n stretchY: [number, number][] | undefined;\n content: [number, number, number, number] | undefined;\n}\n\n/** A sprite of a style: its id (`default`: its images keep their names, else `id:name`) and its URL without\n * extension */\nexport interface SpriteSource {\n id: string;\n url: string;\n}\n\n/** The sprites of a style's `sprite`: one URL, or several with their ids (MapLibre's style specification) */\nexport function spriteSources(sprite: string | readonly SpriteSource[] | undefined): SpriteSource[] {\n if (typeof sprite === 'string') return sprite ? [{ id: 'default', url: sprite }] : [];\n return Array.isArray(sprite) ? sprite.filter((s) => typeof s?.url === 'string' && typeof s.id === 'string') : [];\n}\n\n/** The name of an image of a sprite in the style: its own in the `default` sprite, `id:name` in another */\nexport function spriteName(id: string, name: string): string {\n return id === 'default' ? name : `${id}:${name}`;\n}\n\n/** The URL of a sprite's index or sheet: `.json` or `.png`, `@2x` before it for high-density screens, before the\n * query of the URL if it has one */\nexport function spriteFile(url: string, extension: 'json' | 'png', ratio: number): string {\n const suffix = `${ratio > 1 ? '@2x' : ''}.${extension}`;\n const query = url.search(/[?#]/);\n return query < 0 ? `${url}${suffix}` : `${url.slice(0, query)}${suffix}${url.slice(query)}`;\n}\n\n/** A sprite loaded: its images by name (with the sprite's prefix) and its sheet */\nexport interface LoadedSprite {\n icons: SpriteIndex;\n image: ImageBitmap;\n}\n\n/** Loads a style's sprites (`@2x` above a device pixel ratio of 1, the 1x ones if a server has none); the sprites\n * that fail are left out */\nexport async function loadSprites(\n sprite: string | readonly SpriteSource[] | undefined,\n ratio = typeof devicePixelRatio === 'number' ? devicePixelRatio : 1,\n): Promise<LoadedSprite[]> {\n const one = async ({ id, url }: SpriteSource, r: number): Promise<LoadedSprite | undefined> => {\n const [json, png] = await Promise.all([fetch(spriteFile(url, 'json', r)), fetch(spriteFile(url, 'png', r))]);\n if (!json.ok || !png.ok) return r > 1 ? one({ id, url }, 1) : undefined;\n const index = (await json.json()) as SpriteIndex;\n const icons: SpriteIndex = {};\n for (const [name, icon] of Object.entries(index)) icons[spriteName(id, name)] = icon;\n return { icons, image: await createImageBitmap(await png.blob()) };\n };\n const loaded = await Promise.all(spriteSources(sprite).map((s) => one(s, ratio).catch(() => undefined)));\n return loaded.filter((s): s is LoadedSprite => s !== undefined);\n}\n\n/** The pixels of an image (read back through a canvas) */\nexport function readPixels(image: CanvasImageSource & { width: number; height: number }): Pixels | undefined {\n const { width, height } = image;\n if (!(width > 0 && height > 0)) return undefined;\n const canvas =\n typeof OffscreenCanvas === 'function'\n ? new OffscreenCanvas(width, height)\n : Object.assign(document.createElement('canvas'), { width, height });\n const g = canvas.getContext('2d') as CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D | null;\n if (!g) return undefined;\n g.drawImage(image, 0, 0);\n return g.getImageData(0, 0, width, height);\n}\n\n/** Where an icon's pixels are: a region of an image, read when first packed */\ninterface IconSource {\n pixels: () => Pixels | undefined;\n x: number;\n y: number;\n width: number;\n height: number;\n options: ImageOptions;\n}\n\n/** A shelf of the packer: its y, height, and the x of the next free place */\ninterface Shelf {\n y: number;\n height: number;\n x: number;\n}\n\n/** The icons of a map and their atlas: a square that doubles as it fills, up to the texture size limit */\nexport class Icons {\n private size = 256;\n private data = new Uint8Array(256 * 256 * 4);\n private shelves: Shelf[] = [];\n private readonly sources = new Map<string, IconSource>();\n /** Icons packed, null for those that cannot be (no pixels, the atlas full) */\n private readonly packed = new Map<string, Icon | null>();\n private engine: Engine | undefined;\n /** Rows changed since the last upload: first, end */\n private dirty: [number, number] | undefined;\n private full = false;\n private readonly maxSize: number;\n /** Bumped each time icons are added or removed: labels laid out without some of theirs are laid out again */\n version = 0;\n\n /** `maxSize`: the GPU's texture size limit if known (the atlas is at most 4096 × 4096) */\n constructor(maxSize = 4096) {\n this.maxSize = Math.max(256, Math.min(4096, maxSize));\n }\n\n /** Sends the whole atlas to an engine (a new one after a context loss) */\n attach(engine: Engine): void {\n this.engine = engine;\n this.dirty = undefined;\n this.upload();\n }\n\n /** Side of the atlas */\n get atlasSize(): number {\n return this.size;\n }\n\n /** An image of the application under `name` (another image of that name is replaced) */\n add(name: string, pixels: Pixels, options: ImageOptions = {}): void {\n this.define(name, { pixels: () => pixels, x: 0, y: 0, width: pixels.width, height: pixels.height, options });\n }\n\n /** The images of a sprite's index, `prefix` before their names, their pixels read from the sheet on first use */\n addSprite(prefix: string, index: SpriteIndex, sheet: () => Pixels | undefined): void {\n let pixels: Pixels | undefined;\n let read = false;\n const once = () => {\n if (!read) {\n read = true;\n pixels = sheet();\n }\n return pixels;\n };\n for (const [name, icon] of Object.entries(index)) {\n if (!icon || typeof icon !== 'object') continue;\n const { x, y, width, height, ...options } = icon;\n this.define(`${prefix}${name}`, { pixels: once, x, y, width, height, options }, false);\n }\n this.version += 1;\n }\n\n private define(name: string, source: IconSource, bump = true): void {\n this.sources.set(name, source);\n // Packed again on its next use (its old place stays taken)\n this.packed.delete(name);\n if (bump) this.version += 1;\n }\n\n has(name: string): boolean {\n return this.sources.has(name);\n }\n\n /** Forgets an image, or every image whose name starts with `prefix` (a sprite's) */\n remove(name: string, prefix = false): void {\n for (const key of [...this.sources.keys()]) {\n if (prefix ? key.startsWith(name) : key === name) {\n this.sources.delete(key);\n this.packed.delete(key);\n }\n }\n this.version += 1;\n }\n\n /** The icon of this name, packed into the atlas on first use; undefined if there is none (`flush` uploads it) */\n get(name: string): Icon | undefined {\n const hit = this.packed.get(name);\n if (hit !== undefined) return hit ?? undefined;\n const source = this.sources.get(name);\n if (!source) return undefined;\n const icon = this.pack(source);\n this.packed.set(name, icon ?? null);\n return icon;\n }\n\n /** Sends the rows changed since the last upload to the engine */\n flush(): void {\n const dirty = this.dirty;\n this.dirty = undefined;\n if (!dirty || !this.engine) return;\n const [y0, y1] = dirty;\n const row = this.size * 4;\n this.engine.updateIconAtlas(0, y0, this.size, y1 - y0, this.data.subarray(y0 * row, y1 * row));\n }\n\n private upload(): void {\n const engine = this.engine;\n if (!engine) return;\n engine.setIconAtlas(this.size, this.size);\n const used = this.shelves.reduce((m, s) => Math.max(m, s.y + s.height), 0);\n if (used > 0) engine.updateIconAtlas(0, 0, this.size, used, this.data.subarray(0, used * this.size * 4));\n }\n\n /** Copies an icon's pixels into the atlas, premultiplied, with a texel of room around it */\n private pack(source: IconSource): Icon | undefined {\n const pixels = source.pixels();\n const { x, y, width: w, height: h } = source;\n if (!pixels || !(w > 0 && h > 0) || x < 0 || y < 0 || x + w > pixels.width || y + h > pixels.height) {\n return undefined;\n }\n const place = this.place(w + 2, h + 2);\n if (!place) return undefined;\n const [px, py] = [place[0] + 1, place[1] + 1];\n for (let row = 0; row < h; row += 1) {\n for (let col = 0; col < w; col += 1) {\n const from = ((y + row) * pixels.width + x + col) * 4;\n const to = ((py + row) * this.size + px + col) * 4;\n const a = pixels.data[from + 3] ?? 0;\n this.data[to] = ((pixels.data[from] ?? 0) * a + 127) / 255;\n this.data[to + 1] = ((pixels.data[from + 1] ?? 0) * a + 127) / 255;\n this.data[to + 2] = ((pixels.data[from + 2] ?? 0) * a + 127) / 255;\n this.data[to + 3] = a;\n }\n }\n const [d0, d1] = this.dirty ?? [place[1], place[1]];\n this.dirty = [Math.min(d0, place[1]), Math.max(d1, place[1] + h + 2)];\n const { pixelRatio, sdf, stretchX, stretchY, content } = source.options;\n return {\n x: px,\n y: py,\n width: w,\n height: h,\n pixelRatio: pixelRatio && pixelRatio > 0 ? pixelRatio : 1,\n sdf: sdf === true,\n stretchX: Array.isArray(stretchX) ? stretchX : undefined,\n stretchY: Array.isArray(stretchY) ? stretchY : undefined,\n content: Array.isArray(content) && content.length === 4 ? content : undefined,\n };\n }\n\n /** A free place of `w` × `h` texels (shelves, the atlas doubled when full); undefined once it cannot grow */\n private place(w: number, h: number): [number, number] | undefined {\n for (;;) {\n const shelf = this.shelves.find((s) => s.height >= h && s.height <= h + 8 && s.x + w <= this.size);\n if (shelf) {\n shelf.x += w;\n return [shelf.x - w, shelf.y];\n }\n const last = this.shelves.at(-1);\n const y = last ? last.y + last.height : 0;\n if (y + h <= this.size && w <= this.size) {\n this.shelves.push({ y, height: h, x: w });\n return [0, y];\n }\n if (this.size * 2 > this.maxSize) {\n if (!this.full) console.warn(`isard: the icon atlas is full (${this.size} × ${this.size})`);\n this.full = true;\n return undefined;\n }\n this.grow();\n }\n }\n\n /** Doubles the atlas; the icons keep their places (texels) */\n private grow(): void {\n const size = this.size * 2;\n const data = new Uint8Array(size * size * 4);\n for (let row = 0; row < this.size; row += 1) {\n data.set(this.data.subarray(row * this.size * 4, (row + 1) * this.size * 4), row * size * 4);\n }\n this.size = size;\n this.data = data;\n this.dirty = undefined;\n this.upload();\n }\n}\n\n/** How an icon is laid out around its anchor */\nexport interface IconLayoutOptions {\n /** Scale of the image (`icon-size`) */\n size: number;\n anchor: Anchor;\n /** CSS pixels at size 1 */\n offset: [number, number];\n /** Degrees, clockwise */\n rotate: number;\n /** Stretched around the text: its width, its height, both (`icon-text-fit`) */\n fit: 'none' | 'width' | 'height' | 'both';\n /** Room around the text when fitted: top, right, bottom, left (CSS pixels) */\n padding: [number, number, number, number];\n /** The text's box around the anchor (CSS pixels), if it has one */\n text?: [number, number, number, number] | undefined;\n}\n\n/** An icon laid out: its quads (x, y, width, height in CSS pixels from the anchor, atlas u0, v0, u1, v1 in texels, -1\n * or -2 for a distance field, turn in radians) and its box from the anchor */\nexport interface IconLayout {\n quads: number[][];\n box: [number, number, number, number];\n}\n\n/** Pieces of an image along one axis: image start, end, laid out start, end */\ntype Pieces = [number, number, number, number][];\n\n/**\n * An axis of an icon fitted to `lo`…`hi` (CSS pixels): its content (the whole image by default) spans them, its\n * stretchable zones (the whole image by default) taking the room the fixed parts (at `scale` CSS pixels per image\n * pixel) leave\n */\nexport function stretch(\n length: number,\n zones: readonly [number, number][] | undefined,\n content: [number, number] | undefined,\n lo: number,\n hi: number,\n scale: number,\n): Pieces {\n const clamp = (v: number) => Math.max(0, Math.min(length, Number(v) || 0));\n const spans = (zones?.length ? zones : [[0, length] as [number, number]])\n .map(([a, b]): [number, number] => [clamp(Math.min(a, b)), clamp(Math.max(a, b))])\n .filter(([a, b]) => b > a);\n const cuts = [...new Set([0, length, ...spans.flat()])].sort((a, b) => a - b);\n const pieces = cuts.slice(1).map((b, i): [number, number, boolean] => {\n const a = cuts[i] ?? 0;\n return [a, b, spans.some(([s, e]) => s <= a && b <= e)];\n });\n const [c0, c1] = content ? [clamp(content[0]), clamp(content[1])] : [0, length];\n const overlap = (a: number, b: number) => Math.max(0, Math.min(b, c1) - Math.max(a, c0));\n const stretchable = pieces.reduce((n, [a, b, s]) => n + (s ? overlap(a, b) : 0), 0);\n const fixed = c1 - c0 - stretchable;\n // CSS pixels per stretchable image pixel: what the fixed parts of the content leave of the room\n const k = stretchable > 0 ? Math.max(0, (hi - lo - fixed * scale) / stretchable) : scale;\n // Laid out position of an image coordinate\n const at = (x: number) => pieces.reduce((n, [a, b, s]) => n + Math.max(0, Math.min(x, b) - a) * (s ? k : scale), 0);\n const origin = lo - at(c0);\n return pieces.map(([a, b]) => [a, b, origin + at(a), origin + at(b)]);\n}\n\n/** Where an anchor's side lies along an axis of the icon: at its start 0, at its end 1, else the middle */\nfunction align(start: boolean, end: boolean): number {\n if (start) return 0;\n return end ? 1 : 0.5;\n}\n\n/** Lays an icon out around its anchor: placed by its anchor and offset, or fitted to its text */\nexport function layoutIcon(icon: Icon, options: IconLayoutOptions): IconLayout {\n const { size, anchor, offset, rotate, fit, padding, text } = options;\n const { width: w, height: h, pixelRatio } = icon;\n let xs: Pieces;\n let ys: Pieces;\n if (fit !== 'none' && text) {\n const [top, right, bottom, left] = padding;\n const [x0, y0, x1, y1] = [text[0] - left, text[1] - top, text[2] + right, text[3] + bottom];\n // The fixed parts at the image's own size; an axis not fitted at the icon's size, centered on the text\n const own = 1 / pixelRatio;\n const scaled = size / pixelRatio;\n const centered = (length: number, lo: number, hi: number): Pieces => {\n const c = (lo + hi) / 2;\n return [[0, length, c - (length * scaled) / 2, c + (length * scaled) / 2]];\n };\n const content = icon.content;\n xs =\n fit === 'height'\n ? centered(w, x0, x1)\n : stretch(w, icon.stretchX, content && [content[0], content[2]], x0, x1, own);\n ys =\n fit === 'width'\n ? centered(h, y0, y1)\n : stretch(h, icon.stretchY, content && [content[1], content[3]], y0, y1, own);\n } else {\n const [dw, dh] = [(w / pixelRatio) * size, (h / pixelRatio) * size];\n const ax = align(anchor.includes('left'), anchor.includes('right'));\n const ay = align(anchor.startsWith('top'), anchor.startsWith('bottom'));\n const [left, top] = [offset[0] * size - dw * ax, offset[1] * size - dh * ay];\n xs = [[0, w, left, left + dw]];\n ys = [[0, h, top, top + dh]];\n }\n const angle = ((Number(rotate) || 0) * Math.PI) / 180;\n const kind = icon.sdf ? -2 : -1;\n const quads: number[][] = [];\n const [cs, sn] = [Math.cos(angle), Math.sin(angle)];\n const box: [number, number, number, number] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ];\n for (const [v0, v1, top, bottom] of ys) {\n for (const [u0, u1, left, right] of xs) {\n if (right <= left || bottom <= top) continue;\n quads.push([\n left,\n top,\n right - left,\n bottom - top,\n icon.x + u0,\n icon.y + v0,\n icon.x + u1,\n icon.y + v1,\n kind,\n angle,\n ]);\n // The box of the turned corners\n for (const [px, py] of [\n [left, top],\n [right, top],\n [left, bottom],\n [right, bottom],\n ] as const) {\n const [rx, ry] = [px * cs - py * sn, px * sn + py * cs];\n box[0] = Math.min(box[0], rx);\n box[1] = Math.min(box[1], ry);\n box[2] = Math.max(box[2], rx);\n box[3] = Math.max(box[3], ry);\n }\n }\n }\n return { quads, box: quads.length ? box : [0, 0, 0, 0] };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemaps.ts';
|
|
15
15
|
export { AttributionControl, type AttributionOptions, type Control, type ControlPosition, DEFAULT_ATTRIBUTION, NavigationControl, type NavigationOptions, } from './controls.ts';
|
|
16
|
+
export { type Crs, type CrsLike, getCrs, lambertConformalConic, registerCrs, reproject, transverseMercator, } from './crs.ts';
|
|
16
17
|
export type { DecoderUrls } from './decoders.ts';
|
|
17
18
|
export type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './extrusions.ts';
|
|
18
19
|
export { ExtrusionLayer } from './extrusions.ts';
|
|
@@ -21,14 +22,20 @@ export { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColo
|
|
|
21
22
|
export { geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION } from './geoplateforme.ts';
|
|
22
23
|
export type { TextPart } from './glyphs.ts';
|
|
23
24
|
export { DEFAULT_FONT, GLYPHS_URL } from './glyphs.ts';
|
|
24
|
-
export
|
|
25
|
-
export {
|
|
25
|
+
export { parseGpx } from './gpx.ts';
|
|
26
|
+
export type { TileGrid, TileMatrix } from './grid.ts';
|
|
27
|
+
export type { ImageOptions, Pixels, SpriteIcon } from './icons.ts';
|
|
28
|
+
export { parseKml } from './kml.ts';
|
|
29
|
+
export type { CustomFrame, CustomLayerInterface, GroundOptions, GroundTexture, ModelInstance, ModelOptions, } from './layers.ts';
|
|
30
|
+
export { CustomLayer, GroundLayer, Layer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from './layers.ts';
|
|
26
31
|
export { GeoMap } from './map.ts';
|
|
27
32
|
export { type Anchor, Marker, type MarkerEvent, type MarkerEvents, type MarkerOptions, Popup, type PopupEvents, type PopupOptions, } from './overlay.ts';
|
|
28
|
-
export type { SymbolOptions, SymbolStyle } from './symbols.ts';
|
|
33
|
+
export type { Overlap, SymbolOptions, SymbolStyle } from './symbols.ts';
|
|
29
34
|
export { SymbolLayer } from './symbols.ts';
|
|
35
|
+
export { parseTopoJson, type TopoGeometry, type Topology } from './topojson.ts';
|
|
30
36
|
export type { AnimationOptions, AtmosphereOptions, Basemap, BasemapName, BodyOptions, CelestialBody, FeatureHit, FlyToOptions, GeoMapOptions, LegacyBasemap, LoadingMode, LonLat, MapEvents, MapHoverFeatureEvent, MapPointerEvent, NetworkOptions, NetworkStyle, Point, Projection, RasterGrid, RasterOptions, RasterStyle, TerrainEncoding, TerrainModel, TerrainOptions, Tiles3dOptions, Tiles3dStyle, } from './types.ts';
|
|
31
|
-
export type { Json, LabelCandidate, RasterSource, Style, StyleLayer } from './vectorstyle.ts';
|
|
37
|
+
export type { CandidateIcon, CandidateOverlap, Json, LabelCandidate, RasterSource, Style, StyleLayer, } from './vectorstyle.ts';
|
|
32
38
|
export type { VectorTilesOptions } from './vectortiles.ts';
|
|
33
39
|
export { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './vectortiles.ts';
|
|
34
40
|
export type { Camera, NetworkStats, PickHit, PickResult, RasterLayerStats, Tiles3dStats } from './wasm/isard.js';
|
|
41
|
+
export { parseWmtsGrid, wmtsGrid } from './wmts.ts';
|
package/dist/index.js
CHANGED
|
@@ -13,13 +13,18 @@
|
|
|
13
13
|
*/
|
|
14
14
|
export { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from "./basemaps.js";
|
|
15
15
|
export { AttributionControl, DEFAULT_ATTRIBUTION, NavigationControl, } from "./controls.js";
|
|
16
|
+
export { getCrs, lambertConformalConic, registerCrs, reproject, transverseMercator, } from "./crs.js";
|
|
16
17
|
export { ExtrusionLayer } from "./extrusions.js";
|
|
17
18
|
export { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from "./features.js";
|
|
18
19
|
export { geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION } from "./geoplateforme.js";
|
|
19
20
|
export { DEFAULT_FONT, GLYPHS_URL } from "./glyphs.js";
|
|
20
|
-
export {
|
|
21
|
+
export { parseGpx } from "./gpx.js";
|
|
22
|
+
export { parseKml } from "./kml.js";
|
|
23
|
+
export { CustomLayer, GroundLayer, Layer, ModelLayer, NetworkLayer, RasterLayer, Tiles3dLayer, } from "./layers.js";
|
|
21
24
|
export { GeoMap } from "./map.js";
|
|
22
25
|
export { Marker, Popup, } from "./overlay.js";
|
|
23
26
|
export { SymbolLayer } from "./symbols.js";
|
|
27
|
+
export { parseTopoJson } from "./topojson.js";
|
|
24
28
|
export { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from "./vectortiles.js";
|
|
29
|
+
export { parseWmtsGrid, wmtsGrid } from "./wmts.js";
|
|
25
30
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EACL,kBAAkB,EAIlB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EACL,kBAAkB,EAIlB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAqBjD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGpC,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AASpC,OAAO,EACL,WAAW,EACX,WAAW,EACX,KAAK,EACL,UAAU,EACV,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAEL,MAAM,EAIN,KAAK,GAGN,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAoC,MAAM,eAAe,CAAC;AAwChF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemaps.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n DEFAULT_ATTRIBUTION,\n NavigationControl,\n type NavigationOptions,\n} from './controls.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './crs.ts';\nexport type { DecoderUrls } from './decoders.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './extrusions.ts';\nexport { ExtrusionLayer } from './extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Placement,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './features.ts';\nexport { geoplateformeWfs, geoplateformeWms, geoplateformeWmts, IGN_ATTRIBUTION } from './geoplateforme.ts';\nexport type { TextPart } from './glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './glyphs.ts';\nexport { parseGpx } from './gpx.ts';\nexport type { TileGrid, TileMatrix } from './grid.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './icons.ts';\nexport { parseKml } from './kml.ts';\nexport type {\n CustomFrame,\n CustomLayerInterface,\n GroundOptions,\n GroundTexture,\n ModelInstance,\n ModelOptions,\n} from './layers.ts';\nexport {\n CustomLayer,\n GroundLayer,\n Layer,\n ModelLayer,\n NetworkLayer,\n RasterLayer,\n Tiles3dLayer,\n} from './layers.ts';\nexport { GeoMap } from './map.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './overlay.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './symbols.ts';\nexport { SymbolLayer } from './symbols.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './topojson.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n FeatureHit,\n FlyToOptions,\n GeoMapOptions,\n LegacyBasemap,\n LoadingMode,\n LonLat,\n MapEvents,\n MapHoverFeatureEvent,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n Point,\n Projection,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dOptions,\n Tiles3dStyle,\n} from './types.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './vectorstyle.ts';\nexport type { VectorTilesOptions } from './vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './vectortiles.ts';\nexport type { Camera, NetworkStats, PickHit, PickResult, RasterLayerStats, Tiles3dStats } from './wasm/isard.js';\nexport { parseWmtsGrid, wmtsGrid } from './wmts.ts';\n"]}
|
package/dist/interaction.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Mouse, touch and keyboard controls. Every gesture only updates the camera and asks for a frame: the engine draws at most
|
|
3
|
-
* once per display refresh, whatever the event rate of the device.
|
|
4
|
-
*/
|
|
5
1
|
import type { GeoMap } from './map.ts';
|
|
6
2
|
import type { Point } from './types.ts';
|
|
7
3
|
import type { Camera } from './wasm/isard.js';
|
package/dist/interaction.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mouse, touch and keyboard controls. Every gesture only updates the camera and asks for a frame: the engine draws at most
|
|
3
|
+
* once per display refresh, whatever the event rate of the device.
|
|
4
|
+
*/
|
|
5
|
+
import { latitude, mercatorX, mercatorY } from "./geo.js";
|
|
1
6
|
/** Zoom levels per wheel pixel (a mouse notch is about 100 px: 1/3 of a level) */
|
|
2
7
|
const WHEEL_RATE = 1 / 300;
|
|
3
8
|
/** Share of the remaining wheel zoom applied per frame (smooth, about 150 ms to settle) */
|
|
@@ -58,11 +63,10 @@ export function keyCamera(action, camera) {
|
|
|
58
63
|
const dx = (sx * Math.cos(b) - sy * Math.sin(b)) / world;
|
|
59
64
|
const dy = (sx * Math.sin(b) + sy * Math.cos(b)) / world;
|
|
60
65
|
const [lon, lat] = camera.center;
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const y = Math.max(0, Math.min(1, (1 - Math.log(Math.tan(phi) + 1 / Math.cos(phi)) / Math.PI) / 2 + dy));
|
|
66
|
+
const x = mercatorX(lon) + dx;
|
|
67
|
+
const y = Math.max(0, Math.min(1, mercatorY(lat) + dy));
|
|
64
68
|
const wrapped = ((((x * 360) % 360) + 360) % 360) - 180;
|
|
65
|
-
return { center: [wrapped, (
|
|
69
|
+
return { center: [wrapped, latitude(y)] };
|
|
66
70
|
}
|
|
67
71
|
/** An element that takes the keys typed in it */
|
|
68
72
|
function editable(target) {
|