isard 2.1.1 → 2.1.3
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 +24 -0
- package/dist/basemap/mvt.d.ts +12 -4
- package/dist/basemap/mvt.js +119 -22
- package/dist/basemap/mvt.js.map +1 -1
- package/dist/basemap/vectortiles.js +1 -1
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +9 -9
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_webgl2_bg.wasm +0 -0
- package/dist/isard_webgpu_bg.wasm +0 -0
- package/dist/map/quality.d.ts +3 -2
- package/dist/map/quality.js +3 -3
- package/dist/map/quality.js.map +1 -1
- package/dist/util/lru.d.ts +9 -0
- package/dist/util/lru.js +30 -6
- package/dist/util/lru.js.map +1 -1
- package/dist/workers/basemap/geometry.d.ts +4 -4
- package/dist/workers/basemap/protocol.d.ts +1 -1
- package/dist/workers/basemap/tiles.d.ts +3 -2
- package/dist/workers/basemap/trees.d.ts +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ versions [Semantic Versioning](https://semver.org) (before 1.0.0, a minor versio
|
|
|
5
5
|
|
|
6
6
|
## [Unreleased]
|
|
7
7
|
|
|
8
|
+
## [2.1.3] - 2026-11-01
|
|
9
|
+
|
|
10
|
+
With `isard-react-native` and `isard-map` (Python) 2.1.3.
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- The basemap workers' decoded vector tiles lighter again: each layer's features' properties kept as indices into its
|
|
15
|
+
keys and values, a feature's properties' object made as they are read and kept until the worker's task ends (a tile
|
|
16
|
+
of Paris's middle some 3.5 MB of a worker's heap against 4.2, decoded in 4.6 ms against 5.4)
|
|
17
|
+
|
|
18
|
+
## [2.1.2] - 2026-11-01
|
|
19
|
+
|
|
20
|
+
With `isard-react-native` and `isard-map` (Python) 2.1.2.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- `isard-map` asks for Python 3.11 or later (3.10 at its end of life since October 2026): its development tools'
|
|
25
|
+
Tornado at 6.6, past three advisories that 3.10 had no fix for
|
|
26
|
+
- The basemap workers' decoded vector tiles lighter: each layer's coordinates in one buffer, a feature's point lists
|
|
27
|
+
views of it made as they are read (a tile of Paris's middle some 5 MB of a worker's heap against 14), and the tiles
|
|
28
|
+
the workers keep counted in megabytes (`quality`: 192, 64, 32) rather than in tiles. Paris by night at a phone's
|
|
29
|
+
size: its basemap workers' memory from 103 to 38 MB (Chrome), its page from some 540 to 420 MB (iOS's simulator);
|
|
30
|
+
the frames as before
|
|
31
|
+
|
|
8
32
|
## [2.1.1] - 2026-11-01
|
|
9
33
|
|
|
10
34
|
With `isard-react-native` and `isard-map` (Python) 2.1.1.
|
package/dist/basemap/mvt.d.ts
CHANGED
|
@@ -4,16 +4,24 @@
|
|
|
4
4
|
* outer ones clockwise in tile coordinates, y down, holes the other way round, as the specification says).
|
|
5
5
|
*/
|
|
6
6
|
export type Value = string | number | boolean;
|
|
7
|
+
/** A point list: x0, y0, x1, y1… in tile units */
|
|
8
|
+
export type Ring = ArrayLike<number>;
|
|
7
9
|
export interface TileFeature {
|
|
8
10
|
/** 1 point, 2 line, 3 polygon */
|
|
9
|
-
type: 1 | 2 | 3;
|
|
10
|
-
properties:
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
readonly type: 1 | 2 | 3;
|
|
12
|
+
/** Its properties (a decoded tile's: an object made from its layer's keys and values when read, kept for the task) */
|
|
13
|
+
readonly properties: Record<string, Value>;
|
|
14
|
+
/** Point lists (a decoded tile's: views made as they are read, of one buffer for its whole layer) */
|
|
15
|
+
readonly geometry: readonly Ring[];
|
|
13
16
|
}
|
|
14
17
|
export interface TileLayer {
|
|
15
18
|
extent: number;
|
|
16
19
|
features: TileFeature[];
|
|
20
|
+
/** The heap it takes, about (`decodedBytes`) */
|
|
21
|
+
bytes: number;
|
|
17
22
|
}
|
|
23
|
+
/** The heap a decoded tile takes, about (bytes): its features, their tags and coordinates, its keys and values
|
|
24
|
+
* (measured on a city's tile in Bun's JavaScriptCore, Safari's engine) */
|
|
25
|
+
export declare const decodedBytes: (tile: Map<string, TileLayer>) => number;
|
|
18
26
|
/** Decodes a tile; only the layers in `wanted` (all if undefined) */
|
|
19
27
|
export declare const decode: (bytes: Uint8Array, wanted?: Set<string>) => Map<string, TileLayer>;
|
package/dist/basemap/mvt.js
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
3
3
|
* (`extent`, usually 4096 across). Points are lists of points, lines lists of lines, polygons lists of rings (the
|
|
4
4
|
* outer ones clockwise in tile coordinates, y down, holes the other way round, as the specification says).
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* A decoded feature: its index in its layer's `Store`, its point lists' views made each time they are read, its
|
|
8
|
+
* properties' object once a task. A city's tile holds some hundred thousand points in thirty thousand lists and a hundred thousand
|
|
9
|
+
* properties: as arrays and objects, which a worker's full collections go through again and again, some 15 MB of its
|
|
10
|
+
* heap a tile; in buffers, under 3 MB
|
|
11
|
+
*/
|
|
12
|
+
class Feature {
|
|
13
|
+
type;
|
|
14
|
+
store;
|
|
15
|
+
index;
|
|
16
|
+
constructor(type, store, index) {
|
|
17
|
+
this.type = type;
|
|
18
|
+
this.store = store;
|
|
19
|
+
this.index = index;
|
|
20
|
+
}
|
|
21
|
+
get geometry() {
|
|
22
|
+
const { values, ranges, spans } = this.store;
|
|
23
|
+
const rings = [];
|
|
24
|
+
const end = spans[this.index * 4 + 1] ?? 0;
|
|
25
|
+
for (let r = spans[this.index * 4] ?? 0; r < end; r += 2)
|
|
26
|
+
rings.push(values.subarray(ranges[r], ranges[r + 1]));
|
|
27
|
+
return rings;
|
|
28
|
+
}
|
|
29
|
+
get properties() {
|
|
30
|
+
const { store } = this;
|
|
31
|
+
if (!store.made) {
|
|
32
|
+
store.made = [];
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
store.made = undefined;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const made = store.made[this.index] ?? this.made();
|
|
38
|
+
store.made[this.index] = made;
|
|
39
|
+
return made;
|
|
40
|
+
}
|
|
41
|
+
made() {
|
|
42
|
+
const { tags, keys, properties, spans } = this.store;
|
|
43
|
+
const out = {};
|
|
44
|
+
const end = spans[this.index * 4 + 3] ?? 0;
|
|
45
|
+
// The tags were checked against the keys and values as they were decoded
|
|
46
|
+
for (let t = spans[this.index * 4 + 2] ?? 0; t < end; t += 2) {
|
|
47
|
+
out[keys[tags[t] ?? 0] ?? ''] = properties[tags[t + 1] ?? 0] ?? '';
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
6
52
|
/** Protobuf reader of a buffer range */
|
|
7
53
|
class Pbf {
|
|
8
54
|
buf;
|
|
@@ -126,19 +172,43 @@ const value = (p) => {
|
|
|
126
172
|
}
|
|
127
173
|
return v;
|
|
128
174
|
};
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
175
|
+
/** The coordinates of a layer's features, one after the other, and where each point list starts and ends */
|
|
176
|
+
class Coordinates {
|
|
177
|
+
values = new Int32Array(1024);
|
|
178
|
+
length = 0;
|
|
179
|
+
/** Per point list: its first value and its end */
|
|
180
|
+
ranges = [];
|
|
181
|
+
push(x, y) {
|
|
182
|
+
if (this.length + 2 > this.values.length) {
|
|
183
|
+
const grown = new Int32Array(this.values.length * 2);
|
|
184
|
+
grown.set(this.values);
|
|
185
|
+
this.values = grown;
|
|
186
|
+
}
|
|
187
|
+
this.values[this.length++] = x;
|
|
188
|
+
this.values[this.length++] = y;
|
|
189
|
+
}
|
|
190
|
+
/** The values and ranges cut to their lengths (once all are pushed) */
|
|
191
|
+
shapes() {
|
|
192
|
+
return { values: this.values.slice(0, this.length), ranges: Uint32Array.from(this.ranges) };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/** Pushes the point lists of a geometry's commands (MoveTo, LineTo, ClosePath) */
|
|
196
|
+
const geometry = (p, out) => {
|
|
133
197
|
let [x, y] = [0, 0];
|
|
198
|
+
// The first value of the current point list (none before a MoveTo)
|
|
199
|
+
let start = -1;
|
|
200
|
+
const close = () => {
|
|
201
|
+
if (start >= 0)
|
|
202
|
+
out.ranges.push(start, out.length);
|
|
203
|
+
};
|
|
134
204
|
while (p.more) {
|
|
135
205
|
const command = p.varint();
|
|
136
206
|
const id = command & 7;
|
|
137
207
|
const count = command >> 3;
|
|
138
208
|
if (id === 7) {
|
|
139
209
|
// ClosePath: back to the first point
|
|
140
|
-
if (
|
|
141
|
-
|
|
210
|
+
if (start >= 0 && out.length > start)
|
|
211
|
+
out.push(out.values[start] ?? 0, out.values[start + 1] ?? 0);
|
|
142
212
|
continue;
|
|
143
213
|
}
|
|
144
214
|
// A count past the end (a truncated geometry) stops there
|
|
@@ -146,14 +216,22 @@ const geometry = (p) => {
|
|
|
146
216
|
x += p.sint();
|
|
147
217
|
y += p.sint();
|
|
148
218
|
if (id === 1) {
|
|
149
|
-
|
|
150
|
-
out.
|
|
219
|
+
close();
|
|
220
|
+
start = out.length;
|
|
151
221
|
}
|
|
152
|
-
|
|
222
|
+
if (start >= 0)
|
|
223
|
+
out.push(x, y);
|
|
153
224
|
}
|
|
154
225
|
}
|
|
155
|
-
|
|
226
|
+
close();
|
|
156
227
|
};
|
|
228
|
+
/** The heap a decoded tile takes, about (bytes): its features, their tags and coordinates, its keys and values
|
|
229
|
+
* (measured on a city's tile in Bun's JavaScriptCore, Safari's engine) */
|
|
230
|
+
export const decodedBytes = (tile) => [...tile.values()].reduce((sum, layer) => sum + layer.bytes, 0);
|
|
231
|
+
/** A feature, about (bytes) */
|
|
232
|
+
const FEATURE_BYTES = 70;
|
|
233
|
+
/** A key or a value (a string's characters counted apart), about (bytes) */
|
|
234
|
+
const VALUE_BYTES = 40;
|
|
157
235
|
/** Decodes a tile; only the layers in `wanted` (all if undefined) */
|
|
158
236
|
export const decode = (bytes, wanted) => {
|
|
159
237
|
const layers = new Map();
|
|
@@ -194,21 +272,24 @@ export const decode = (bytes, wanted) => {
|
|
|
194
272
|
}
|
|
195
273
|
if (wanted && !wanted.has(name))
|
|
196
274
|
continue;
|
|
197
|
-
const
|
|
275
|
+
const types = [];
|
|
276
|
+
const spans = [];
|
|
277
|
+
const coordinates = new Coordinates();
|
|
278
|
+
const tags = [];
|
|
198
279
|
for (const f of raw) {
|
|
199
280
|
let type = 1;
|
|
200
|
-
const
|
|
201
|
-
|
|
281
|
+
const first = coordinates.ranges.length;
|
|
282
|
+
const tagsFirst = tags.length;
|
|
202
283
|
while (f.more) {
|
|
203
284
|
const t = f.varint();
|
|
204
285
|
switch (t >> 3) {
|
|
205
286
|
case 2: {
|
|
206
|
-
const
|
|
207
|
-
while (
|
|
208
|
-
const k =
|
|
209
|
-
const v =
|
|
210
|
-
if (k
|
|
211
|
-
|
|
287
|
+
const pairs = f.sub();
|
|
288
|
+
while (pairs.more) {
|
|
289
|
+
const k = pairs.varint();
|
|
290
|
+
const v = pairs.varint();
|
|
291
|
+
if (k < keys.length && v < values.length)
|
|
292
|
+
tags.push(k, v);
|
|
212
293
|
}
|
|
213
294
|
break;
|
|
214
295
|
}
|
|
@@ -216,15 +297,31 @@ export const decode = (bytes, wanted) => {
|
|
|
216
297
|
type = Math.min(3, Math.max(1, f.varint()));
|
|
217
298
|
break;
|
|
218
299
|
case 4:
|
|
219
|
-
|
|
300
|
+
geometry(f.sub(), coordinates);
|
|
220
301
|
break;
|
|
221
302
|
default:
|
|
222
303
|
f.skip(t & 7);
|
|
223
304
|
}
|
|
224
305
|
}
|
|
225
|
-
|
|
306
|
+
types.push(type);
|
|
307
|
+
spans.push(first, coordinates.ranges.length, tagsFirst, tags.length);
|
|
226
308
|
}
|
|
227
|
-
|
|
309
|
+
const store = {
|
|
310
|
+
...coordinates.shapes(),
|
|
311
|
+
tags: Math.max(keys.length, values.length) <= 0x10000 ? Uint16Array.from(tags) : Uint32Array.from(tags),
|
|
312
|
+
keys,
|
|
313
|
+
properties: values,
|
|
314
|
+
spans: Uint32Array.from(spans),
|
|
315
|
+
};
|
|
316
|
+
const features = types.map((type, i) => new Feature(type, store, i));
|
|
317
|
+
const strings = [...keys, ...values].reduce((n, v) => n + VALUE_BYTES + (typeof v === 'string' ? v.length : 0), 0);
|
|
318
|
+
const bytes = features.length * FEATURE_BYTES +
|
|
319
|
+
store.values.byteLength +
|
|
320
|
+
store.ranges.byteLength +
|
|
321
|
+
store.tags.byteLength +
|
|
322
|
+
store.spans.byteLength +
|
|
323
|
+
strings;
|
|
324
|
+
layers.set(name, { extent, features, bytes });
|
|
228
325
|
}
|
|
229
326
|
return layers;
|
|
230
327
|
};
|
package/dist/basemap/mvt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,KAAK,GAAG,CAAC,CAAC;QAEd,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAC3C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YAEpC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC;YACjC,IAAI,CAAC,GAAG,IAAI;g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AAU,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"]}
|
|
1
|
+
{"version":3,"file":"mvt.js","sourceRoot":"","sources":["../../src/basemap/mvt.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH;;;;;GAKG;AACH,MAAM,OAAO;IAEA;IACQ;IACA;IAHnB,YACW,IAAe,EACP,KAAY,EACZ,KAAa;QAFrB,SAAI,GAAJ,IAAI,CAAW;QACP,UAAK,GAAL,KAAK,CAAO;QACZ,UAAK,GAAL,KAAK,CAAQ;IAC7B,CAAC;IAEJ,IAAI,QAAQ;QACV,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7C,MAAM,KAAK,GAAiB,EAAE,CAAC;QAC/B,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QAE3C,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAEhH,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,UAAU;QACZ,MAA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AAU;YACrB,KAAK,CAAC,KAAK,CAAC,UAAU;YACtB,OAAO,CAAC;QAEV,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;IAChD,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\n/** A point list: x0, y0, x1, y1… in tile units */\nexport type Ring = ArrayLike<number>;\n\nexport interface TileFeature {\n /** 1 point, 2 line, 3 polygon */\n readonly type: 1 | 2 | 3;\n /** Its properties (a decoded tile's: an object made from its layer's keys and values when read, kept for the task) */\n readonly properties: Record<string, Value>;\n /** Point lists (a decoded tile's: views made as they are read, of one buffer for its whole layer) */\n readonly geometry: readonly Ring[];\n}\n\n/**\n * A layer's features in buffers: their coordinates one feature's after the other and where each point list starts and\n * ends; their tags one feature's after the other (a key's index then a value's) and the keys and values they index;\n * per feature, where its point lists and its tags start and end\n */\ninterface Store {\n values: Int32Array;\n ranges: Uint32Array;\n tags: Uint16Array | Uint32Array;\n keys: string[];\n properties: Value[];\n /** Per feature: its first point list and their end (in `ranges`), its first tag and their end (in `tags`) */\n spans: Uint32Array;\n /** The properties' objects made in the current task, per feature: the layers of a style read a feature's again and\n * again, the tile kept only as buffers between tasks */\n made?: Record<string, Value>[] | undefined;\n}\n\n/**\n * A decoded feature: its index in its layer's `Store`, its point lists' views made each time they are read, its\n * properties' object once a task. A city's tile holds some hundred thousand points in thirty thousand lists and a hundred thousand\n * properties: as arrays and objects, which a worker's full collections go through again and again, some 15 MB of its\n * heap a tile; in buffers, under 3 MB\n */\nclass Feature implements TileFeature {\n constructor(\n readonly type: 1 | 2 | 3,\n private readonly store: Store,\n private readonly index: number,\n ) {}\n\n get geometry(): Int32Array[] {\n const { values, ranges, spans } = this.store;\n const rings: Int32Array[] = [];\n const end = spans[this.index * 4 + 1] ?? 0;\n\n for (let r = spans[this.index * 4] ?? 0; r < end; r += 2) rings.push(values.subarray(ranges[r], ranges[r + 1]));\n\n return rings;\n }\n\n get properties(): Record<string, Value> {\n const { store } = this;\n\n if (!store.made) {\n store.made = [];\n setTimeout(() => {\n store.made = undefined;\n });\n }\n\n const made = store.made[this.index] ?? this.made();\n\n store.made[this.index] = made;\n\n return made;\n }\n\n private made(): Record<string, Value> {\n const { tags, keys, properties, spans } = this.store;\n const out: Record<string, Value> = {};\n const end = spans[this.index * 4 + 3] ?? 0;\n\n // The tags were checked against the keys and values as they were decoded\n for (let t = spans[this.index * 4 + 2] ?? 0; t < end; t += 2) {\n out[keys[tags[t] ?? 0] ?? ''] = properties[tags[t + 1] ?? 0] ?? '';\n }\n\n return out;\n }\n}\n\nexport interface TileLayer {\n extent: number;\n features: TileFeature[];\n /** The heap it takes, about (`decodedBytes`) */\n bytes: number;\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/** The coordinates of a layer's features, one after the other, and where each point list starts and ends */\nclass Coordinates {\n values = new Int32Array(1024);\n length = 0;\n /** Per point list: its first value and its end */\n readonly ranges: number[] = [];\n\n push(x: number, y: number): void {\n if (this.length + 2 > this.values.length) {\n const grown = new Int32Array(this.values.length * 2);\n\n grown.set(this.values);\n this.values = grown;\n }\n this.values[this.length++] = x;\n this.values[this.length++] = y;\n }\n\n /** The values and ranges cut to their lengths (once all are pushed) */\n shapes(): Pick<Store, 'values' | 'ranges'> {\n return { values: this.values.slice(0, this.length), ranges: Uint32Array.from(this.ranges) };\n }\n}\n\n/** Pushes the point lists of a geometry's commands (MoveTo, LineTo, ClosePath) */\nconst geometry = (p: Pbf, out: Coordinates): void => {\n let [x, y] = [0, 0];\n // The first value of the current point list (none before a MoveTo)\n let start = -1;\n const close = () => {\n if (start >= 0) out.ranges.push(start, out.length);\n };\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 (start >= 0 && out.length > start) out.push(out.values[start] ?? 0, out.values[start + 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 close();\n start = out.length;\n }\n if (start >= 0) out.push(x, y);\n }\n }\n close();\n};\n\n/** The heap a decoded tile takes, about (bytes): its features, their tags and coordinates, its keys and values\n * (measured on a city's tile in Bun's JavaScriptCore, Safari's engine) */\nexport const decodedBytes = (tile: Map<string, TileLayer>): number =>\n [...tile.values()].reduce((sum, layer) => sum + layer.bytes, 0);\n/** A feature, about (bytes) */\nconst FEATURE_BYTES = 70;\n/** A key or a value (a string's characters counted apart), about (bytes) */\nconst VALUE_BYTES = 40;\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 types: (1 | 2 | 3)[] = [];\n const spans: number[] = [];\n const coordinates = new Coordinates();\n const tags: number[] = [];\n\n for (const f of raw) {\n let type: 1 | 2 | 3 = 1;\n const first = coordinates.ranges.length;\n const tagsFirst = tags.length;\n\n while (f.more) {\n const t = f.varint();\n\n switch (t >> 3) {\n case 2: {\n const pairs = f.sub();\n\n while (pairs.more) {\n const k = pairs.varint();\n const v = pairs.varint();\n\n if (k < keys.length && v < values.length) tags.push(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 geometry(f.sub(), coordinates);\n break;\n default:\n f.skip(t & 7);\n }\n }\n types.push(type);\n spans.push(first, coordinates.ranges.length, tagsFirst, tags.length);\n }\n\n const store: Store = {\n ...coordinates.shapes(),\n tags: Math.max(keys.length, values.length) <= 0x10000 ? Uint16Array.from(tags) : Uint32Array.from(tags),\n keys,\n properties: values,\n spans: Uint32Array.from(spans),\n };\n const features = types.map((type, i) => new Feature(type, store, i));\n const strings = [...keys, ...values].reduce(\n (n: number, v) => n + VALUE_BYTES + (typeof v === 'string' ? v.length : 0),\n 0,\n );\n const bytes =\n features.length * FEATURE_BYTES +\n store.values.byteLength +\n store.ranges.byteLength +\n store.tags.byteLength +\n store.spans.byteLength +\n strings;\n\n layers.set(name, { extent, features, bytes });\n }\n\n return layers;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;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Vector basemaps from a MapLibre style (OpenFreeMap's Positron by default): the fills, lines, circles and raster\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n *\n * The layers other than the raster ones are made in `vectortiles/` (one module each), from what they use of the\n * instance (`VectorTilesContext`); the style's loading is in `vectortiles/style.ts`.\n */\n\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport { type LoadedSprite, loadSprites, readPixels, spriteSources } from '../layers/icons.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelLayer } from '../layers/models.ts';\nimport type { RasterLayer } from '../layers/raster.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Placement } from '../types.ts';\nimport { clamp } from '../util/math.ts';\nimport type { BasemapWork, Sprite } from '../workers/basemap/protocol.ts';\nimport type { LabelCandidate, Style, StyleLayer } from './vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './vectortiles/context.ts';\nimport { extrusions, type VectorExtrusionOptions } from './vectortiles/extrusions.ts';\nimport { type FurnitureOptions, furniture } from './vectortiles/furniture.ts';\nimport { type LabelsOptions, labels, size, tileLabels } from './vectortiles/labels.ts';\nimport { type LampsOptions, lamps } from './vectortiles/lamps.ts';\nimport type { TileRequests } from './vectortiles/requests.ts';\nimport { type StreetWindLayer, type StreetWindOptions, streetWind } from './vectortiles/street-wind.ts';\nimport {\n type LoadedStyle,\n loadStyle,\n OPENFREEMAP_STYLES,\n PLAN_STYLES,\n styleAttribution,\n VECTOR_BASEMAPS,\n} from './vectortiles/style.ts';\nimport { VECTOR_MOVE_REFRESH_MS } from './vectortiles/tiles.ts';\nimport { type TreesOptions, trees } from './vectortiles/trees.ts';\nimport { dashes, type VectorsOptions, vectors } from './vectortiles/vectors.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n// The names the package and its tests import from here, now made in `vectortiles/`\nexport { dashes, OPENFREEMAP_STYLES, PLAN_STYLES, size, styleAttribution, tileLabels, VECTOR_BASEMAPS };\n\n/** The options of `VectorTiles.raster` */\nexport interface VectorRasterOptions extends Placement {\n /** The style layers drawn (default all but the symbols) */\n layers?: (layer: StyleLayer) => boolean;\n /** Style layers of the same source drawn after them */\n extraLayers?: StyleLayer[];\n /** Texture size of its tiles (512 by default: sharp lines) */\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n}\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** Its first raster layer: the ground its labels follow */\n private ground: RasterLayer | undefined;\n /** What its layers made in `vectortiles/` use of it */\n private readonly context: VectorTilesContext;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<LoadedStyle>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = loadStyle(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n this.context = {\n map,\n ready: this.ready,\n layers: this.layers,\n cleanup: this.cleanup,\n iconPrefix: this.iconPrefix,\n destroyed: () => this.destroyed,\n ground: () => this.ground,\n broadcast: (message) => {\n this.pool.broadcast(message);\n },\n request: (vz, vx, vy, work, signal) => this.request(vz, vx, vy, work, signal),\n renderer: (select, extra, again) => this.renderer(select, extra, { again }),\n loadSprites: (sprite) => this.loadSprites(sprite),\n addSprites: () => this.addSprites(),\n followView: (layer, update, requests, moving) => {\n this.followView(layer, update, requests, moving);\n },\n stopWith: (layer, stop) => {\n this.stopWith(layer, stop);\n },\n };\n }\n\n /** The style's sprites (their JSON and their images), loaded once, for the fill patterns and the icons */\n private sprites: Promise<LoadedSprite[]> | undefined;\n\n /** The style's sprites, kept once all of them came: one that failed is asked for again by the next layer */\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n if (this.sprites) return this.sprites;\n\n const wanted = spriteSources(sprite).length;\n const loading: Promise<LoadedSprite[]> = loadSprites(sprite)\n .catch(() => [])\n .then((loaded) => {\n if (loaded.length < wanted && this.sprites === loading) {\n console.warn(\n `isard: ${wanted - loaded.length} of the style's sprites not loaded, its icons and patterns missing`,\n );\n this.sprites = undefined;\n }\n\n return loaded;\n });\n\n this.sprites = loading;\n\n return loading;\n }\n\n /** The style's sprites added to the map's icons, once */\n private spritesAdded: Promise<void> | undefined;\n\n /** The style's sprites among the map's icons (under `iconPrefix`), added once: the labels' icons, the fills'\n * patterns */\n private addSprites(): Promise<void> {\n this.spritesAdded ??= this.ready.then(async ({ style }) => {\n if (!style.sprite) return;\n (await this.loadSprites(style.sprite)).forEach((sprite) => {\n if (!this.destroyed) this.map.icons.addSprite(this.iconPrefix, sprite.icons, () => readPixels(sprite.image));\n });\n });\n\n return this.spritesAdded;\n }\n\n /** Prefix of the names of its sprites' images among the map's icons */\n private get iconPrefix(): string {\n return `${this.namespace}/`;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n\n return this.map.track(this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal));\n }\n\n /** Sends a renderer of these layers to every worker (`again`: under that key, restyled), with the style's sprites if\n * it `draws` the tiles into images with patterns (the raster path: the others take their images in the page) */\n private async renderer(\n select: (layer: StyleLayer) => boolean,\n extra: StyleLayer[],\n { again, draws = false }: { again?: string | undefined; draws?: boolean } = {},\n ): Promise<Renderer> {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = again ?? rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = draws && layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The images are downloaded once, copied to each worker\n const sprites: Sprite[] = patterns && style.sprite ? await this.loadSprites(style.sprite) : [];\n\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({\n type: 'init',\n key,\n tiles,\n maxzoom,\n layers,\n rasters,\n cached: this.map.quality.cachedTiles,\n ...(sprites.length ? { sprites } : {}),\n });\n if (!again) this.renderers.push(key);\n\n return { key, maxzoom, layers };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(options: VectorRasterOptions = {}): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers, { draws: true });\n\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = clamp(z - 1, 0, maxzoom);\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n\n this.layers.push(layer);\n this.ground ??= layer;\n\n return layer;\n }\n\n /**\n * An extrusion layer of the polygons of the style's fill layers that `layers` keeps (by default its buildings: the\n * fill or fill-extrusion layers of PLAN IGN's `bati_surf` or OpenMapTiles' `building`), raised by the style\n * given (`height`, `base`, `color`, `ramp`…; the properties of the tiles' features). Its tiles follow the view: at\n * the source's deepest level, the `maxTiles` nearest to the center, from `minZoom` on (15 by default); the tiles\n * leaving the view are dropped.\n */\n extrusions<P = Record<string, unknown>>(options: VectorExtrusionOptions<P> = {}): ExtrusionLayer<P> {\n return extrusions<P>(this.context, options);\n }\n\n /**\n * The wind through the streets around the view, as particles at street level (`height`, default 3 metres) between\n * the style's buildings (`layers`, default its `building` and `bati_surf` layers): their footprints laid on a grid of\n * `cell` metres (default 4) over a square of `size` metres (default 1200) around the view's center, the flow of the\n * air round them a potential flow (it goes round the blocks and faster through the narrow streets; no wake behind\n * them), computed in a worker by the grid module from street level (`minZoom`, default 15) and again when the view\n * leaves the square's middle. `wind` is the wind far away (east and north, m/s, default a light breeze from the\n * south-west); `setWind` changes it at once (the flow is linear in it: nothing computed again), from a model's hour\n * (`windAt`) for instance; `computed` resolves once the first square's flow is there. The other options are the flow\n * layer's (`addFlow`)\n */\n streetWind(options: StreetWindOptions = {}): StreetWindLayer {\n return streetWind(this.context, options);\n }\n\n /**\n * Trees on the style's woods, forests and grass (or the fill layers `layers` keeps) as 3D models, from street level\n * (`minZoom`, default 15): the workers scatter them over the polygons of the vector tiles around the view, `spacing`\n * metres apart (by style layer: 9 in woods, 25 on grass, by default) on a jittered grid, the same trees whenever a\n * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its\n * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the\n * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default\n * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).\n */\n trees(options: TreesOptions = {}): ModelLayer {\n return trees(this.context, options);\n }\n\n /**\n * Street lamps along the style's streets (the road line layers, or those `layers` keeps) as 3D models, from street\n * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every\n * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of\n * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).\n */\n lamps(options: LampsOptions = {}): ModelLayer {\n return lamps(this.context, options);\n }\n\n /**\n * The street furniture as 3D models, from OpenMapTiles' points of interest of the street: bus shelters at the bus\n * stops, waste baskets, post boxes, drinking fountains (Wallace's in Paris), bicycle racks, each facing its street;\n * benches along the pedestrian streets and the paths of the parks and gardens. Placed by the workers, one instanced\n * draw a kind, all of them near the camera and fewer away from it. The layer returned holds the other kinds' (its\n * `companions`); removed with it\n */\n furniture(options: FurnitureOptions = {}): ModelLayer {\n return furniture(this.context, options);\n }\n\n /**\n * A layer drawing the style's fills, lines and buildings (or those `layers` keeps; backgrounds as fills, the\n * `fill-extrusion` layers raised into buildings by their height and base height) as geometry instead of images: the\n * workers cut the vector tiles in view into polygons and lines, which the engine draws on the globe and the relief,\n * in the style's order, each style layer over its zoom range. Sharp at any zoom\n * and pitch, picked by feature (`pick` gives its properties and style layer), restyled without cutting the tiles\n * again (`setPaintProperty`, `setLayoutProperty`). Its tiles follow the view, while it moves too, coarser far away in a\n * tilted view, and those leaving it stay until the ones replacing them are there; past the source's deepest level,\n * cut again from its tiles down to level 18 (overzoom: their styles those of their level; a filter reading the zoom\n * holds at the whole zoom under the camera's, as MapLibre evaluates it). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says, their joins as their `line-join` says (and `line-miter-limit`),\n * offset by `line-offset`; the colors follow the camera's zoom; the fills', lines' and buildings' patterns from the\n * style's sprite (the fills' over the relief too; on the globe, their average color there), the circle layers' points\n * as circles facing the screen, the lines' blur, the fills' and lines' translations. The buildings' roofs (`roofs`)\n * as their data says (`roof:shape`, `roof:height`; flat without, the default), generated from their outline where\n * they have none (`'generated'`), or all flat. `raster` stays the lighter path for heavy styles and small devices.\n * At night (`setSun`) the line layers `streets` keeps glow (by default those whose id names\n * a road, not its casing, a railway, a path or a tunnel).\n */\n vectors(options: VectorsOptions = {}): VectorLayer {\n return vectors(this.context, options);\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. With a raster layer of\n * the style (`raster`), the tiles follow the levels the ground is drawn at: a tilted view takes coarser tiles far\n * away, with the few labels of a lower zoom, as near the camera it takes the fine ones. Without, the tiles around\n * the center at the zoom of the view. It stays above the layers added after it unless one is moved over it.\n */\n labels(options: LabelsOptions = {}): SymbolLayer<LabelCandidate> {\n return labels(this.context, options);\n }\n\n /**\n * Makes a layer's tiles follow the view: `update` now and where the camera stops (`moveend`), `moving` every\n * `VECTOR_MOVE_REFRESH_MS` while it moves, and again after a pause when tiles failed; the `requests` aborted when\n * destroyed or the layer removed\n */\n private followView(\n layer: Layer,\n update: () => Promise<unknown>,\n requests: TileRequests,\n moving: () => unknown,\n ): void {\n const refresh = () => {\n update().catch(() => undefined);\n };\n const pace = { timer: 0 };\n const follow = () => {\n if (pace.timer) return;\n pace.timer = window.setTimeout(() => {\n pace.timer = 0;\n Promise.resolve(moving()).catch(() => undefined);\n }, VECTOR_MOVE_REFRESH_MS);\n };\n const [offMove, offEnd] = [this.map.on('move', follow), this.map.on('moveend', refresh)];\n\n requests.retryWith(refresh);\n\n this.stopWith(layer, () => {\n offMove();\n offEnd();\n clearTimeout(pace.timer);\n requests.abortAll();\n });\n refresh();\n }\n\n /** Calls `stop` when destroyed or once `layer` is removed, whichever comes first */\n private stopWith(layer: Layer, stop: () => void): void {\n const once = { done: false };\n const run = () => {\n if (once.done) return;\n once.done = true;\n stop();\n };\n\n this.cleanup.push(run);\n layer.whenRemoved.push(run);\n }\n\n /** Removes its layers from the map (those still there) and stops its workers' work */\n remove(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.cleanup.forEach((off) => {\n off();\n });\n this.cleanup.length = 0;\n this.layers.forEach((layer) => {\n if (this.map.hasLayer(layer)) layer.remove();\n });\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprites (the workers have theirs), and their icons\n this.sprites\n ?.then((sprites) => {\n sprites.forEach((sprite) => {\n sprite.image.close();\n });\n this.map.icons.remove(this.iconPrefix, true);\n })\n .catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n this.renderers.forEach((key) => {\n this.pool.broadcast({ type: 'drop', key });\n });\n }\n this.renderers.length = 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"vectortiles.js","sourceRoot":"","sources":["../../src/basemap/vectortiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAqB,WAAW,EAAE,UAAU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\n * layers drawn tile by tile in workers into the raster pool, so that they lie on the relief like any basemap and\n * composite with the hillshade in one pass; and the labels of the style's symbol layers in a symbol layer of their own,\n * kept above the application's layers (as MapLibre's `beforeId: firstSymbol` does), listed by the workers, shaped in\n * the page once per vector tile, placed by the engine.\n *\n * Any subset of the style can be drawn on its own raster layer (`raster({ layers })`), at its own place in the stack:\n * rivers from the basemap's data over a flood layer, for instance, restyled with `extraLayers`.\n *\n * The layers other than the raster ones are made in `vectortiles/` (one module each), from what they use of the\n * instance (`VectorTilesContext`); the style's loading is in `vectortiles/style.ts`.\n */\n\nimport type { ExtrusionLayer } from '../layers/extrusions.ts';\nimport { type LoadedSprite, loadSprites, readPixels, spriteSources } from '../layers/icons.ts';\nimport type { Layer } from '../layers/layers.ts';\nimport type { ModelLayer } from '../layers/models.ts';\nimport type { RasterLayer } from '../layers/raster.ts';\nimport type { SymbolLayer } from '../layers/symbols.ts';\nimport type { VectorLayer } from '../layers/vectors.ts';\nimport type { GeoMap } from '../map.ts';\nimport type { Placement } from '../types.ts';\nimport { clamp } from '../util/math.ts';\nimport type { BasemapWork, Sprite } from '../workers/basemap/protocol.ts';\nimport type { LabelCandidate, Style, StyleLayer } from './vectorstyle.ts';\nimport type { Renderer, VectorTilesContext } from './vectortiles/context.ts';\nimport { extrusions, type VectorExtrusionOptions } from './vectortiles/extrusions.ts';\nimport { type FurnitureOptions, furniture } from './vectortiles/furniture.ts';\nimport { type LabelsOptions, labels, size, tileLabels } from './vectortiles/labels.ts';\nimport { type LampsOptions, lamps } from './vectortiles/lamps.ts';\nimport type { TileRequests } from './vectortiles/requests.ts';\nimport { type StreetWindLayer, type StreetWindOptions, streetWind } from './vectortiles/street-wind.ts';\nimport {\n type LoadedStyle,\n loadStyle,\n OPENFREEMAP_STYLES,\n PLAN_STYLES,\n styleAttribution,\n VECTOR_BASEMAPS,\n} from './vectortiles/style.ts';\nimport { VECTOR_MOVE_REFRESH_MS } from './vectortiles/tiles.ts';\nimport { type TreesOptions, trees } from './vectortiles/trees.ts';\nimport { dashes, type VectorsOptions, vectors } from './vectortiles/vectors.ts';\nimport { type BasemapWorkers, rendererKey, tilePriority } from './workerpool.ts';\n\n// The names the package and its tests import from here, now made in `vectortiles/`\nexport { dashes, OPENFREEMAP_STYLES, PLAN_STYLES, size, styleAttribution, tileLabels, VECTOR_BASEMAPS };\n\n/** The options of `VectorTiles.raster` */\nexport interface VectorRasterOptions extends Placement {\n /** The style layers drawn (default all but the symbols) */\n layers?: (layer: StyleLayer) => boolean;\n /** Style layers of the same source drawn after them */\n extraLayers?: StyleLayer[];\n /** Texture size of its tiles (512 by default: sharp lines) */\n size?: number;\n opacity?: number;\n minZoom?: number;\n maxZoom?: number;\n}\n\nexport interface VectorTilesOptions {\n /** A style URL or object (default OpenFreeMap's Positron) */\n style?: string | Style;\n /** Workers drawing the tiles (default cores - 1, 1 to 4). The vector tiles of a map share its workers (and their\n * decoded tiles); another count gives these tiles workers of their own */\n workers?: number;\n /** Where to load the worker from, when a bundler does not resolve the default URL (default the map's\n * `basemapWorkerUrl`); another URL than the map's gives these tiles workers of their own */\n workerUrl?: string | URL;\n /** Credits of the tiles, shown while its raster layers are on the map (default: OpenFreeMap's for its styles, the\n * IGN's for PLAN.IGN's) */\n attribution?: string;\n}\n\nexport class VectorTiles {\n private readonly pool: BasemapWorkers;\n /** The pool is this instance's own (a worker count or URL other than the map's): stopped with it */\n private readonly ownPool: boolean;\n /** Prefix of its renderer keys in the pool's workers */\n private readonly namespace: string;\n private destroyed = false;\n private keys = 0;\n /** Renderers sent to the workers, dropped on destroy */\n private readonly renderers: string[] = [];\n private readonly cleanup: (() => void)[] = [];\n /** Credits of its raster layers */\n private readonly attribution: string | undefined;\n /** Its raster and label layers, removed with it */\n private readonly layers: Layer[] = [];\n /** Its first raster layer: the ground its labels follow */\n private ground: RasterLayer | undefined;\n /** What its layers made in `vectortiles/` use of it */\n private readonly context: VectorTilesContext;\n /** The style once loaded, with its source resolved */\n readonly ready: Promise<LoadedStyle>;\n\n /**\n * Its workers are the map's (shared by every `VectorTiles` of the map, a vector tile decoded once for all of them),\n * unless `workers` or `workerUrl` asks for others than the map's: then it has workers of its own\n */\n constructor(\n private readonly map: GeoMap,\n options: VectorTilesOptions = {},\n ) {\n const { pool, own } = map.basemapWorkers(options.workers, options.workerUrl);\n\n this.pool = pool;\n this.ownPool = own;\n this.namespace = pool.namespace();\n\n const style = options.style ?? OPENFREEMAP_STYLES.positron;\n\n this.attribution = options.attribution ?? styleAttribution(style);\n this.ready = loadStyle(style);\n // Reported once here; `ready`, the raster tiles and the labels fail with it\n this.ready.catch((error: unknown) => {\n if (!this.destroyed) console.warn('isard: vector tiles', error);\n });\n this.context = {\n map,\n ready: this.ready,\n layers: this.layers,\n cleanup: this.cleanup,\n iconPrefix: this.iconPrefix,\n destroyed: () => this.destroyed,\n ground: () => this.ground,\n broadcast: (message) => {\n this.pool.broadcast(message);\n },\n request: (vz, vx, vy, work, signal) => this.request(vz, vx, vy, work, signal),\n renderer: (select, extra, again) => this.renderer(select, extra, { again }),\n loadSprites: (sprite) => this.loadSprites(sprite),\n addSprites: () => this.addSprites(),\n followView: (layer, update, requests, moving) => {\n this.followView(layer, update, requests, moving);\n },\n stopWith: (layer, stop) => {\n this.stopWith(layer, stop);\n },\n };\n }\n\n /** The style's sprites (their JSON and their images), loaded once, for the fill patterns and the icons */\n private sprites: Promise<LoadedSprite[]> | undefined;\n\n /** The style's sprites, kept once all of them came: one that failed is asked for again by the next layer */\n private loadSprites(sprite: Style['sprite']): Promise<LoadedSprite[]> {\n if (this.sprites) return this.sprites;\n\n const wanted = spriteSources(sprite).length;\n const loading: Promise<LoadedSprite[]> = loadSprites(sprite)\n .catch(() => [])\n .then((loaded) => {\n if (loaded.length < wanted && this.sprites === loading) {\n console.warn(\n `isard: ${wanted - loaded.length} of the style's sprites not loaded, its icons and patterns missing`,\n );\n this.sprites = undefined;\n }\n\n return loaded;\n });\n\n this.sprites = loading;\n\n return loading;\n }\n\n /** The style's sprites added to the map's icons, once */\n private spritesAdded: Promise<void> | undefined;\n\n /** The style's sprites among the map's icons (under `iconPrefix`), added once: the labels' icons, the fills'\n * patterns */\n private addSprites(): Promise<void> {\n this.spritesAdded ??= this.ready.then(async ({ style }) => {\n if (!style.sprite) return;\n (await this.loadSprites(style.sprite)).forEach((sprite) => {\n if (!this.destroyed) this.map.icons.addSprite(this.iconPrefix, sprite.icons, () => readPixels(sprite.image));\n });\n });\n\n return this.spritesAdded;\n }\n\n /** Prefix of the names of its sprites' images among the map's icons */\n private get iconPrefix(): string {\n return `${this.namespace}/`;\n }\n\n private request(vz: number, vx: number, vy: number, work: BasemapWork, signal?: AbortSignal) {\n if (this.destroyed) return Promise.reject(new DOMException('isard: vector tiles destroyed', 'AbortError'));\n\n return this.map.track(this.pool.request(this.pool.worker(vz, vx, vy), work, this, signal));\n }\n\n /** Sends a renderer of these layers to every worker (`again`: under that key, restyled), with the style's sprites if\n * it `draws` the tiles into images with patterns (the raster path: the others take their images in the page) */\n private async renderer(\n select: (layer: StyleLayer) => boolean,\n extra: StyleLayer[],\n { again, draws = false }: { again?: string | undefined; draws?: boolean } = {},\n ): Promise<Renderer> {\n const { style, tiles, maxzoom, rasters } = await this.ready;\n const key = again ?? rendererKey(this.namespace, this.keys++);\n const layers = [...style.layers.filter(select), ...extra];\n const patterns = draws && layers.some((l) => l.paint?.['fill-pattern'] !== undefined);\n // The images are downloaded once, copied to each worker\n const sprites: Sprite[] = patterns && style.sprite ? await this.loadSprites(style.sprite) : [];\n\n if (this.destroyed) throw new DOMException('isard: vector tiles destroyed', 'AbortError');\n this.pool.broadcast({\n type: 'init',\n key,\n tiles,\n maxzoom,\n layers,\n rasters,\n cached: this.map.quality.cachedMegabytes,\n ...(sprites.length ? { sprites } : {}),\n });\n if (!again) this.renderers.push(key);\n\n return { key, maxzoom, layers };\n }\n\n /**\n * A raster layer drawing the style's fills, lines and circles (or those `layers` keeps, then `extraLayers`, of the\n * same source); `size`: texture size of its tiles (512 by default: sharp lines)\n */\n raster(options: VectorRasterOptions = {}): RasterLayer {\n const { layers = () => true, extraLayers = [], size: texture = 512, opacity = 1, before } = options;\n const drawn = (l: StyleLayer) => l.type !== 'symbol' && layers(l);\n const renderer = this.renderer(drawn, extraLayers, { draws: true });\n\n // Its failure is reported by `ready` and each tile\n renderer.catch(() => undefined);\n\n const loader = async (z: number, x: number, y: number, signal: AbortSignal) => {\n const { key, maxzoom } = await renderer;\n // The vector tile it is drawn from (see the worker)\n const vz = clamp(z - 1, 0, maxzoom);\n const shift = z - vz;\n const priority = tilePriority(z, x, y, this.map.getCamera());\n const response = await this.request(\n vz,\n x >> shift,\n y >> shift,\n { type: 'render', key, z, x, y, size: texture, priority },\n signal,\n );\n\n return 'image' in response ? response.image : null;\n };\n const layer = this.map.addRaster({\n url: '',\n size: texture,\n opacity,\n minZoom: options.minZoom ?? 0,\n maxZoom: options.maxZoom ?? 20,\n loader,\n ...(this.attribution ? { attribution: this.attribution } : {}),\n ...(before ? { before } : {}),\n });\n\n this.layers.push(layer);\n this.ground ??= layer;\n\n return layer;\n }\n\n /**\n * An extrusion layer of the polygons of the style's fill layers that `layers` keeps (by default its buildings: the\n * fill or fill-extrusion layers of PLAN IGN's `bati_surf` or OpenMapTiles' `building`), raised by the style\n * given (`height`, `base`, `color`, `ramp`…; the properties of the tiles' features). Its tiles follow the view: at\n * the source's deepest level, the `maxTiles` nearest to the center, from `minZoom` on (15 by default); the tiles\n * leaving the view are dropped.\n */\n extrusions<P = Record<string, unknown>>(options: VectorExtrusionOptions<P> = {}): ExtrusionLayer<P> {\n return extrusions<P>(this.context, options);\n }\n\n /**\n * The wind through the streets around the view, as particles at street level (`height`, default 3 metres) between\n * the style's buildings (`layers`, default its `building` and `bati_surf` layers): their footprints laid on a grid of\n * `cell` metres (default 4) over a square of `size` metres (default 1200) around the view's center, the flow of the\n * air round them a potential flow (it goes round the blocks and faster through the narrow streets; no wake behind\n * them), computed in a worker by the grid module from street level (`minZoom`, default 15) and again when the view\n * leaves the square's middle. `wind` is the wind far away (east and north, m/s, default a light breeze from the\n * south-west); `setWind` changes it at once (the flow is linear in it: nothing computed again), from a model's hour\n * (`windAt`) for instance; `computed` resolves once the first square's flow is there. The other options are the flow\n * layer's (`addFlow`)\n */\n streetWind(options: StreetWindOptions = {}): StreetWindLayer {\n return streetWind(this.context, options);\n }\n\n /**\n * Trees on the style's woods, forests and grass (or the fill layers `layers` keeps) as 3D models, from street level\n * (`minZoom`, default 15): the workers scatter them over the polygons of the vector tiles around the view, `spacing`\n * metres apart (by style layer: 9 in woods, 25 on grass, by default) on a jittered grid, the same trees whenever a\n * tile comes back; the engine draws them all in one instanced draw, on the relief. A low-poly tree by default (its\n * `colors`), or your own glTF (`url`, `data`, about 10 metres high, standing on its origin). Dense around the\n * view's center, fewer and fewer away from it (as the camera moves too), at most `maxInstances` drawn (default\n * 25000); at most `maxTiles` tiles (default 9) and `maxTrees` trees in each (default 30000).\n */\n trees(options: TreesOptions = {}): ModelLayer {\n return trees(this.context, options);\n }\n\n /**\n * Street lamps along the style's streets (the road line layers, or those `layers` keeps) as 3D models, from street\n * level (`minZoom`, default 16): the workers place them `spacing` metres apart (default 30) along each street, every\n * other one on its other side, as far from its middle as its class says; their heads lit at night (`light`). All of\n * them near the ground under the camera, fewer and fewer away from it, at most `maxInstances` drawn (default 15000).\n */\n lamps(options: LampsOptions = {}): ModelLayer {\n return lamps(this.context, options);\n }\n\n /**\n * The street furniture as 3D models, from OpenMapTiles' points of interest of the street: bus shelters at the bus\n * stops, waste baskets, post boxes, drinking fountains (Wallace's in Paris), bicycle racks, each facing its street;\n * benches along the pedestrian streets and the paths of the parks and gardens. Placed by the workers, one instanced\n * draw a kind, all of them near the camera and fewer away from it. The layer returned holds the other kinds' (its\n * `companions`); removed with it\n */\n furniture(options: FurnitureOptions = {}): ModelLayer {\n return furniture(this.context, options);\n }\n\n /**\n * A layer drawing the style's fills, lines and buildings (or those `layers` keeps; backgrounds as fills, the\n * `fill-extrusion` layers raised into buildings by their height and base height) as geometry instead of images: the\n * workers cut the vector tiles in view into polygons and lines, which the engine draws on the globe and the relief,\n * in the style's order, each style layer over its zoom range. Sharp at any zoom\n * and pitch, picked by feature (`pick` gives its properties and style layer), restyled without cutting the tiles\n * again (`setPaintProperty`, `setLayoutProperty`). Its tiles follow the view, while it moves too, coarser far away in a\n * tilted view, and those leaving it stay until the ones replacing them are there; past the source's deepest level,\n * cut again from its tiles down to level 18 (overzoom: their styles those of their level; a filter reading the zoom\n * holds at the whole zoom under the camera's, as MapLibre evaluates it). The fills' outlines are drawn one\n * pixel wide, the lines' ends as their `line-cap` says, their joins as their `line-join` says (and `line-miter-limit`),\n * offset by `line-offset`; the colors follow the camera's zoom; the fills', lines' and buildings' patterns from the\n * style's sprite (the fills' over the relief too; on the globe, their average color there), the circle layers' points\n * as circles facing the screen, the lines' blur, the fills' and lines' translations. The buildings' roofs (`roofs`)\n * as their data says (`roof:shape`, `roof:height`; flat without, the default), generated from their outline where\n * they have none (`'generated'`), or all flat. `raster` stays the lighter path for heavy styles and small devices.\n * At night (`setSun`) the line layers `streets` keeps glow (by default those whose id names\n * a road, not its casing, a railway, a path or a tunnel).\n */\n vectors(options: VectorsOptions = {}): VectorLayer {\n return vectors(this.context, options);\n }\n\n /**\n * A symbol layer with the labels of the style's symbol layers (or those `layers` keeps), updated as the view\n * moves: the labels of the vector tiles in view, the higher style layers placed first. With a raster layer of\n * the style (`raster`), the tiles follow the levels the ground is drawn at: a tilted view takes coarser tiles far\n * away, with the few labels of a lower zoom, as near the camera it takes the fine ones. Without, the tiles around\n * the center at the zoom of the view. It stays above the layers added after it unless one is moved over it.\n */\n labels(options: LabelsOptions = {}): SymbolLayer<LabelCandidate> {\n return labels(this.context, options);\n }\n\n /**\n * Makes a layer's tiles follow the view: `update` now and where the camera stops (`moveend`), `moving` every\n * `VECTOR_MOVE_REFRESH_MS` while it moves, and again after a pause when tiles failed; the `requests` aborted when\n * destroyed or the layer removed\n */\n private followView(\n layer: Layer,\n update: () => Promise<unknown>,\n requests: TileRequests,\n moving: () => unknown,\n ): void {\n const refresh = () => {\n update().catch(() => undefined);\n };\n const pace = { timer: 0 };\n const follow = () => {\n if (pace.timer) return;\n pace.timer = window.setTimeout(() => {\n pace.timer = 0;\n Promise.resolve(moving()).catch(() => undefined);\n }, VECTOR_MOVE_REFRESH_MS);\n };\n const [offMove, offEnd] = [this.map.on('move', follow), this.map.on('moveend', refresh)];\n\n requests.retryWith(refresh);\n\n this.stopWith(layer, () => {\n offMove();\n offEnd();\n clearTimeout(pace.timer);\n requests.abortAll();\n });\n refresh();\n }\n\n /** Calls `stop` when destroyed or once `layer` is removed, whichever comes first */\n private stopWith(layer: Layer, stop: () => void): void {\n const once = { done: false };\n const run = () => {\n if (once.done) return;\n once.done = true;\n stop();\n };\n\n this.cleanup.push(run);\n layer.whenRemoved.push(run);\n }\n\n /** Removes its layers from the map (those still there) and stops its workers' work */\n remove(): void {\n if (this.destroyed) return;\n this.destroyed = true;\n this.cleanup.forEach((off) => {\n off();\n });\n this.cleanup.length = 0;\n this.layers.forEach((layer) => {\n if (this.map.hasLayer(layer)) layer.remove();\n });\n this.layers.length = 0;\n this.map.dropVectorTiles(this);\n // The page's copy of the sprites (the workers have theirs), and their icons\n this.sprites\n ?.then((sprites) => {\n sprites.forEach((sprite) => {\n sprite.image.close();\n });\n this.map.icons.remove(this.iconPrefix, true);\n })\n .catch(() => undefined);\n if (this.ownPool) {\n this.pool.terminate();\n } else {\n // Shared workers: only its requests stop and its renderers go\n this.pool.cancel(this);\n this.renderers.forEach((key) => {\n this.pool.broadcast({ type: 'drop', key });\n });\n }\n this.renderers.length = 0;\n }\n}\n"]}
|