@spellkave/world-map 0.0.0-bootstrap → 0.0.0-stage
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/README.md +2 -66
- package/package.json +4 -69
- package/LICENSE +0 -89
- package/bin/world-map.js +0 -16
- package/bin/world-osm.js +0 -15
- package/src/cli.ts +0 -204
- package/src/coords.ts +0 -479
- package/src/export.ts +0 -861
- package/src/ids.ts +0 -81
- package/src/index.ts +0 -105
- package/src/load-bundle.ts +0 -155
- package/src/model.ts +0 -106
- package/src/node/backdrop-resolve.ts +0 -172
- package/src/node/index.ts +0 -39
- package/src/node/jpeg-write.ts +0 -266
- package/src/node/rasterize.ts +0 -27
- package/src/node/terminal-capabilities.ts +0 -89
- package/src/node/terminal.ts +0 -12
- package/src/node/timg-backend.ts +0 -136
- package/src/node/tool-result-image.ts +0 -53
- package/src/poi.ts +0 -61
- package/src/rows.ts +0 -480
- package/src/svg/compose.ts +0 -185
- package/src/svg/h3-layout.ts +0 -268
- package/src/svg/index.ts +0 -327
- package/src/svg/inventory.ts +0 -168
- package/src/svg/layout.ts +0 -431
- package/src/svg/model.ts +0 -459
- package/src/svg/render-ascii.ts +0 -486
- package/src/svg/render-braille.ts +0 -130
- package/src/svg/render-svg.ts +0 -578
- package/src/svg/scale.ts +0 -99
- package/src/svg/types.ts +0 -244
- package/src/tags.ts +0 -68
- package/src/tiles/encode.ts +0 -35
- package/src/tiles/index.ts +0 -25
- package/src/tiles/layers.ts +0 -338
- package/src/tiles/style.ts +0 -518
- package/src/writers/geojson.ts +0 -104
- package/src/writers/json.ts +0 -126
- package/src/writers/xml.ts +0 -87
package/src/tiles/style.ts
DELETED
|
@@ -1,518 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TileJSON + MapLibre style + backdrop URL helpers (no HTTP).
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { validateStyleMin } from "@maplibre/maplibre-gl-style-spec";
|
|
6
|
-
|
|
7
|
-
import type { BackdropEntry } from "../model.ts";
|
|
8
|
-
import { backdropsOf, vectorLayerFields, type WorldTilesCache } from "./layers.ts";
|
|
9
|
-
|
|
10
|
-
export function buildTileJson(cache: WorldTilesCache, baseUrl: string): Record<string, unknown> {
|
|
11
|
-
const tilesBase = `${baseUrl.replace(/\/$/, "")}/w/${cache.slug}`;
|
|
12
|
-
const licenses = [
|
|
13
|
-
...new Set(
|
|
14
|
-
cache.export.backdrops
|
|
15
|
-
.map((b) => b.license)
|
|
16
|
-
.filter((l) => typeof l === "string" && l.trim() !== ""),
|
|
17
|
-
),
|
|
18
|
-
];
|
|
19
|
-
const attributionParts = [...licenses, "Spellkave"];
|
|
20
|
-
return {
|
|
21
|
-
tilejson: "3.0.0",
|
|
22
|
-
name: `spellkave:${cache.slug}`,
|
|
23
|
-
description: `Spellkave place-graph MVT for catalog world ${cache.slug}`,
|
|
24
|
-
version: "1.0.0",
|
|
25
|
-
scheme: "xyz",
|
|
26
|
-
tiles: [`${tilesBase}/tiles/{z}/{x}/{y}.pbf`],
|
|
27
|
-
minzoom: 0,
|
|
28
|
-
maxzoom: 22,
|
|
29
|
-
bounds: cache.bounds,
|
|
30
|
-
center: [...cache.center, 16],
|
|
31
|
-
attribution: attributionParts.join(" · "),
|
|
32
|
-
vector_layers: vectorLayerFields(cache).map((l) => ({
|
|
33
|
-
id: l.id,
|
|
34
|
-
description: l.description,
|
|
35
|
-
fields: l.fields,
|
|
36
|
-
})),
|
|
37
|
-
// Extension for the maps-demo level picker.
|
|
38
|
-
levels: cache.levels,
|
|
39
|
-
generator: cache.export.manifest.generator,
|
|
40
|
-
tick: cache.tick,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function resolveBackdropUrls(
|
|
45
|
-
backdrops: readonly BackdropEntry[],
|
|
46
|
-
baseUrl: string,
|
|
47
|
-
slug: string,
|
|
48
|
-
): Array<BackdropEntry & { url: string }> {
|
|
49
|
-
const base = baseUrl.replace(/\/$/, "");
|
|
50
|
-
return backdrops.map((b) => ({
|
|
51
|
-
...b,
|
|
52
|
-
url: `${base}/w/${slug}/assets/${b.asset.module}/${b.asset.path}`,
|
|
53
|
-
}));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** MapLibre style v8 — no basemap; self-hosted glyphs; level via setFilter. */
|
|
57
|
-
export function buildMapLibreStyle(
|
|
58
|
-
cache: WorldTilesCache,
|
|
59
|
-
baseUrl: string,
|
|
60
|
-
): Record<string, unknown> {
|
|
61
|
-
const base = baseUrl.replace(/\/$/, "");
|
|
62
|
-
const slug = cache.slug;
|
|
63
|
-
const sourceUrl = `${base}/w/${slug}/tiles.json`;
|
|
64
|
-
const glyphs = `${base}/w/${slug}/fonts/{fontstack}/{range}.pbf`;
|
|
65
|
-
const backdrops = resolveBackdropUrls(backdropsOf(cache), base, slug);
|
|
66
|
-
|
|
67
|
-
const sources: Record<string, unknown> = {
|
|
68
|
-
spellkave: {
|
|
69
|
-
type: "vector",
|
|
70
|
-
url: sourceUrl,
|
|
71
|
-
promoteId: {
|
|
72
|
-
spellkave_node: "spellkave:node_id",
|
|
73
|
-
spellkave_room: "spellkave:node_id",
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
for (const bd of backdrops) {
|
|
78
|
-
sources[`bd-${bd.id}`] = {
|
|
79
|
-
type: "image",
|
|
80
|
-
url: bd.url,
|
|
81
|
-
coordinates: bd.coordinates,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const indoorGraphs = new Set<string>();
|
|
86
|
-
for (const f of cache.layers.spellkave_room.features) {
|
|
87
|
-
if (f.properties.indoor !== "room") continue;
|
|
88
|
-
const graph = f.properties["spellkave:graph"];
|
|
89
|
-
if (typeof graph === "string" && graph !== "") indoorGraphs.add(graph);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const layers: Record<string, unknown>[] = [
|
|
93
|
-
{
|
|
94
|
-
id: "background",
|
|
95
|
-
type: "background",
|
|
96
|
-
paint: { "background-color": "#0b1215" },
|
|
97
|
-
},
|
|
98
|
-
];
|
|
99
|
-
|
|
100
|
-
const indoorBackdrops: Array<{ layer: string; graph: string }> = [];
|
|
101
|
-
for (const bd of backdrops) {
|
|
102
|
-
const layerId = `raster-${bd.id}`;
|
|
103
|
-
const indoor = indoorGraphs.has(bd.graph);
|
|
104
|
-
if (indoor) indoorBackdrops.push({ layer: layerId, graph: bd.graph });
|
|
105
|
-
layers.push({
|
|
106
|
-
id: layerId,
|
|
107
|
-
type: "raster",
|
|
108
|
-
source: `bd-${bd.id}`,
|
|
109
|
-
paint: { "raster-opacity": 1 },
|
|
110
|
-
...(indoor ? { layout: { visibility: "none" } } : {}),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Indoor layers use a plain filter (no global-state in pinned style-spec).
|
|
115
|
-
// Client swaps the level via map.setFilter — see maps-demo.html.
|
|
116
|
-
// Default shows features with no level OR level == "0".
|
|
117
|
-
const defaultLevelFilter: unknown[] = [
|
|
118
|
-
"any",
|
|
119
|
-
["!", ["has", "level"]],
|
|
120
|
-
["==", ["get", "level"], "0"],
|
|
121
|
-
["in", "0", ["get", "level"]],
|
|
122
|
-
];
|
|
123
|
-
|
|
124
|
-
layers.push(
|
|
125
|
-
{
|
|
126
|
-
id: "building-fill",
|
|
127
|
-
type: "fill",
|
|
128
|
-
source: "spellkave",
|
|
129
|
-
"source-layer": "spellkave_building",
|
|
130
|
-
paint: {
|
|
131
|
-
"fill-color": "#1b263b",
|
|
132
|
-
"fill-opacity": 0.35,
|
|
133
|
-
"fill-outline-color": "#415a77",
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
id: "room-fill",
|
|
138
|
-
type: "fill",
|
|
139
|
-
source: "spellkave",
|
|
140
|
-
"source-layer": "spellkave_room",
|
|
141
|
-
filter: defaultLevelFilter,
|
|
142
|
-
paint: {
|
|
143
|
-
"fill-color": [
|
|
144
|
-
"match",
|
|
145
|
-
["coalesce", ["get", "level"], ""],
|
|
146
|
-
"-1",
|
|
147
|
-
"#3d5a80",
|
|
148
|
-
"0",
|
|
149
|
-
"#98c1d9",
|
|
150
|
-
"1",
|
|
151
|
-
"#ee6c4d",
|
|
152
|
-
"#6b9080",
|
|
153
|
-
],
|
|
154
|
-
"fill-opacity": ["case", ["boolean", ["feature-state", "selected"], false], 0.55, 0.28],
|
|
155
|
-
"fill-outline-color": [
|
|
156
|
-
"case",
|
|
157
|
-
["boolean", ["feature-state", "selected"], false],
|
|
158
|
-
"#f4a261",
|
|
159
|
-
"#cce3de",
|
|
160
|
-
],
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
id: "water-fill",
|
|
165
|
-
type: "fill",
|
|
166
|
-
source: "spellkave",
|
|
167
|
-
"source-layer": "spellkave_room",
|
|
168
|
-
filter: ["all", defaultLevelFilter, ["==", ["get", "natural"], "water"]],
|
|
169
|
-
paint: {
|
|
170
|
-
"fill-color": "#0284c7",
|
|
171
|
-
"fill-opacity": ["case", ["boolean", ["feature-state", "selected"], false], 0.65, 0.42],
|
|
172
|
-
"fill-outline-color": [
|
|
173
|
-
"case",
|
|
174
|
-
["boolean", ["feature-state", "selected"], false],
|
|
175
|
-
"#f4a261",
|
|
176
|
-
"#38bdf8",
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: "difficult-terrain-fill",
|
|
182
|
-
type: "fill",
|
|
183
|
-
source: "spellkave",
|
|
184
|
-
"source-layer": "spellkave_room",
|
|
185
|
-
filter: ["all", defaultLevelFilter, ["==", ["get", "spellkave:terrain"], "difficult"]],
|
|
186
|
-
paint: {
|
|
187
|
-
"fill-color": "#d97706",
|
|
188
|
-
"fill-opacity": ["case", ["boolean", ["feature-state", "selected"], false], 0.55, 0.28],
|
|
189
|
-
"fill-outline-color": [
|
|
190
|
-
"case",
|
|
191
|
-
["boolean", ["feature-state", "selected"], false],
|
|
192
|
-
"#f4a261",
|
|
193
|
-
"#f59e0b",
|
|
194
|
-
],
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
id: "hazard-fill",
|
|
199
|
-
type: "fill",
|
|
200
|
-
source: "spellkave",
|
|
201
|
-
"source-layer": "spellkave_room",
|
|
202
|
-
filter: ["all", defaultLevelFilter, ["has", "spellkave:hazard"]],
|
|
203
|
-
paint: {
|
|
204
|
-
"fill-color": [
|
|
205
|
-
"case",
|
|
206
|
-
["==", ["get", "spellkave:hazard"], "acid"],
|
|
207
|
-
"#84cc16",
|
|
208
|
-
["==", ["get", "spellkave:hazard"], "slime"],
|
|
209
|
-
"#10b981",
|
|
210
|
-
["==", ["get", "spellkave:hazard"], "lava"],
|
|
211
|
-
"#f97316",
|
|
212
|
-
"#10b981",
|
|
213
|
-
],
|
|
214
|
-
"fill-opacity": ["case", ["boolean", ["feature-state", "selected"], false], 0.75, 0.52],
|
|
215
|
-
"fill-outline-color": [
|
|
216
|
-
"case",
|
|
217
|
-
["boolean", ["feature-state", "selected"], false],
|
|
218
|
-
"#f4a261",
|
|
219
|
-
"#ef4444",
|
|
220
|
-
],
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
id: "corridor-line",
|
|
225
|
-
type: "line",
|
|
226
|
-
source: "spellkave",
|
|
227
|
-
"source-layer": "spellkave_corridor",
|
|
228
|
-
filter: defaultLevelFilter,
|
|
229
|
-
paint: {
|
|
230
|
-
"line-color": [
|
|
231
|
-
"match",
|
|
232
|
-
["coalesce", ["get", "highway"], ""],
|
|
233
|
-
"steps",
|
|
234
|
-
"#f4a261",
|
|
235
|
-
"corridor",
|
|
236
|
-
"#e9c46a",
|
|
237
|
-
"#8d99ae",
|
|
238
|
-
],
|
|
239
|
-
"line-width": 2.5,
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
id: "steps-dash",
|
|
244
|
-
type: "line",
|
|
245
|
-
source: "spellkave",
|
|
246
|
-
"source-layer": "spellkave_corridor",
|
|
247
|
-
filter: ["all", defaultLevelFilter, ["==", ["get", "highway"], "steps"]],
|
|
248
|
-
paint: {
|
|
249
|
-
"line-color": "#f4a261",
|
|
250
|
-
"line-width": 3,
|
|
251
|
-
"line-dasharray": [1, 1],
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
id: "flight-dash",
|
|
256
|
-
type: "line",
|
|
257
|
-
source: "spellkave",
|
|
258
|
-
"source-layer": "spellkave_corridor",
|
|
259
|
-
filter: ["all", defaultLevelFilter, ["==", ["get", "spellkave:traversal_mode"], "fly"]],
|
|
260
|
-
paint: {
|
|
261
|
-
"line-color": "#c084fc",
|
|
262
|
-
"line-width": 3.5,
|
|
263
|
-
"line-dasharray": [2, 2],
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
id: "swim-dash",
|
|
268
|
-
type: "line",
|
|
269
|
-
source: "spellkave",
|
|
270
|
-
"source-layer": "spellkave_corridor",
|
|
271
|
-
filter: ["all", defaultLevelFilter, ["==", ["get", "spellkave:traversal_mode"], "swim"]],
|
|
272
|
-
paint: {
|
|
273
|
-
"line-color": "#0284c7",
|
|
274
|
-
"line-width": 3.5,
|
|
275
|
-
"line-dasharray": [3, 1],
|
|
276
|
-
},
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
id: "barrier-dash",
|
|
280
|
-
type: "line",
|
|
281
|
-
source: "spellkave",
|
|
282
|
-
"source-layer": "spellkave_corridor",
|
|
283
|
-
filter: ["all", defaultLevelFilter, ["has", "spellkave:seal"]],
|
|
284
|
-
paint: {
|
|
285
|
-
"line-color": ["case", ["==", ["get", "spellkave:locked"], "no"], "#10b981", "#ef4444"],
|
|
286
|
-
"line-width": 4.5,
|
|
287
|
-
"line-dasharray": [1, 2],
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
id: "door-symbol",
|
|
292
|
-
type: "circle",
|
|
293
|
-
source: "spellkave",
|
|
294
|
-
"source-layer": "spellkave_corridor",
|
|
295
|
-
filter: ["all", defaultLevelFilter, ["==", ["get", "door"], "yes"]],
|
|
296
|
-
paint: {
|
|
297
|
-
"circle-radius": 4,
|
|
298
|
-
"circle-color": "#e63946",
|
|
299
|
-
"circle-stroke-width": 1,
|
|
300
|
-
"circle-stroke-color": "#f1faee",
|
|
301
|
-
},
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
id: "traversal-label",
|
|
305
|
-
type: "symbol",
|
|
306
|
-
source: "spellkave",
|
|
307
|
-
"source-layer": "spellkave_corridor",
|
|
308
|
-
filter: [
|
|
309
|
-
"all",
|
|
310
|
-
defaultLevelFilter,
|
|
311
|
-
[
|
|
312
|
-
"any",
|
|
313
|
-
["==", ["get", "spellkave:traversal_mode"], "fly"],
|
|
314
|
-
["==", ["get", "spellkave:traversal_mode"], "swim"],
|
|
315
|
-
["has", "spellkave:seal"],
|
|
316
|
-
],
|
|
317
|
-
],
|
|
318
|
-
layout: {
|
|
319
|
-
"symbol-placement": "line-center",
|
|
320
|
-
"text-field": [
|
|
321
|
-
"case",
|
|
322
|
-
["==", ["get", "spellkave:traversal_mode"], "fly"],
|
|
323
|
-
"🪽 Fly",
|
|
324
|
-
["==", ["get", "spellkave:traversal_mode"], "swim"],
|
|
325
|
-
"🏊 Swim",
|
|
326
|
-
["has", "spellkave:seal"],
|
|
327
|
-
["case", ["==", ["get", "spellkave:locked"], "no"], "🔓 Open", "🔒 Locked"],
|
|
328
|
-
"",
|
|
329
|
-
],
|
|
330
|
-
"text-font": ["Noto Sans Regular"],
|
|
331
|
-
"text-size": 11,
|
|
332
|
-
"text-offset": [0, -1],
|
|
333
|
-
},
|
|
334
|
-
paint: {
|
|
335
|
-
"text-color": [
|
|
336
|
-
"case",
|
|
337
|
-
["==", ["get", "spellkave:traversal_mode"], "fly"],
|
|
338
|
-
"#c084fc",
|
|
339
|
-
["==", ["get", "spellkave:traversal_mode"], "swim"],
|
|
340
|
-
"#38bdf8",
|
|
341
|
-
["==", ["get", "spellkave:locked"], "no"],
|
|
342
|
-
"#10b981",
|
|
343
|
-
"#ef4444",
|
|
344
|
-
],
|
|
345
|
-
"text-halo-color": "#0b1215",
|
|
346
|
-
"text-halo-width": 2,
|
|
347
|
-
},
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
id: "node-selected-ring",
|
|
351
|
-
type: "circle",
|
|
352
|
-
source: "spellkave",
|
|
353
|
-
"source-layer": "spellkave_node",
|
|
354
|
-
filter: ["all", defaultLevelFilter],
|
|
355
|
-
minzoom: 12,
|
|
356
|
-
paint: {
|
|
357
|
-
"circle-radius": ["case", ["boolean", ["feature-state", "selected"], false], 14, 0],
|
|
358
|
-
"circle-color": "rgba(244, 162, 97, 0.2)",
|
|
359
|
-
"circle-stroke-color": "#f4a261",
|
|
360
|
-
"circle-stroke-width": ["case", ["boolean", ["feature-state", "selected"], false], 3, 0],
|
|
361
|
-
"circle-stroke-opacity": [
|
|
362
|
-
"case",
|
|
363
|
-
["boolean", ["feature-state", "selected"], false],
|
|
364
|
-
0.9,
|
|
365
|
-
0,
|
|
366
|
-
],
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
id: "node-circle",
|
|
371
|
-
type: "circle",
|
|
372
|
-
source: "spellkave",
|
|
373
|
-
"source-layer": "spellkave_node",
|
|
374
|
-
minzoom: 14,
|
|
375
|
-
filter: ["all", defaultLevelFilter, ["!", ["has", "spellkave:poi_icon"]]],
|
|
376
|
-
paint: {
|
|
377
|
-
"circle-radius": [
|
|
378
|
-
"case",
|
|
379
|
-
["boolean", ["feature-state", "selected"], false],
|
|
380
|
-
7,
|
|
381
|
-
["==", ["get", "entrance"], "yes"],
|
|
382
|
-
6,
|
|
383
|
-
5,
|
|
384
|
-
],
|
|
385
|
-
"circle-color": [
|
|
386
|
-
"case",
|
|
387
|
-
["boolean", ["feature-state", "selected"], false],
|
|
388
|
-
"#f4a261",
|
|
389
|
-
["==", ["get", "entrance"], "yes"],
|
|
390
|
-
"#e76f51",
|
|
391
|
-
"#f1faee",
|
|
392
|
-
],
|
|
393
|
-
"circle-stroke-width": [
|
|
394
|
-
"case",
|
|
395
|
-
["boolean", ["feature-state", "selected"], false],
|
|
396
|
-
3,
|
|
397
|
-
["==", ["get", "entrance"], "yes"],
|
|
398
|
-
2,
|
|
399
|
-
1,
|
|
400
|
-
],
|
|
401
|
-
"circle-stroke-color": [
|
|
402
|
-
"case",
|
|
403
|
-
["boolean", ["feature-state", "selected"], false],
|
|
404
|
-
"#edf2f4",
|
|
405
|
-
["==", ["get", "entrance"], "yes"],
|
|
406
|
-
"#f4a261",
|
|
407
|
-
"#1d3557",
|
|
408
|
-
],
|
|
409
|
-
},
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
id: "node-label",
|
|
413
|
-
type: "symbol",
|
|
414
|
-
source: "spellkave",
|
|
415
|
-
"source-layer": "spellkave_node",
|
|
416
|
-
filter: ["all", defaultLevelFilter, ["!", ["has", "spellkave:poi_icon"]]],
|
|
417
|
-
minzoom: 14,
|
|
418
|
-
layout: {
|
|
419
|
-
"text-field": ["coalesce", ["get", "name"], ""],
|
|
420
|
-
"text-font": ["Noto Sans Regular"],
|
|
421
|
-
"text-size": 12,
|
|
422
|
-
"text-variable-anchor": [
|
|
423
|
-
"top",
|
|
424
|
-
"bottom",
|
|
425
|
-
"left",
|
|
426
|
-
"right",
|
|
427
|
-
"top-left",
|
|
428
|
-
"top-right",
|
|
429
|
-
"bottom-left",
|
|
430
|
-
"bottom-right",
|
|
431
|
-
],
|
|
432
|
-
"text-radial-offset": 2.2,
|
|
433
|
-
"text-justify": "auto",
|
|
434
|
-
"text-padding": 4,
|
|
435
|
-
"text-optional": true,
|
|
436
|
-
"text-allow-overlap": false,
|
|
437
|
-
"text-ignore-placement": false,
|
|
438
|
-
},
|
|
439
|
-
paint: {
|
|
440
|
-
"text-color": [
|
|
441
|
-
"case",
|
|
442
|
-
["boolean", ["feature-state", "selected"], false],
|
|
443
|
-
"#f4a261",
|
|
444
|
-
"#edf2f4",
|
|
445
|
-
],
|
|
446
|
-
"text-halo-color": "#0b1215",
|
|
447
|
-
"text-halo-width": ["case", ["boolean", ["feature-state", "selected"], false], 2.2, 1.2],
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
id: "poi-symbol",
|
|
452
|
-
type: "symbol",
|
|
453
|
-
source: "spellkave",
|
|
454
|
-
"source-layer": "spellkave_node",
|
|
455
|
-
filter: ["all", defaultLevelFilter, ["has", "spellkave:poi_icon"]],
|
|
456
|
-
minzoom: 12,
|
|
457
|
-
layout: {
|
|
458
|
-
"icon-image": ["concat", "poi-", ["coalesce", ["get", "spellkave:poi_icon"], "default"]],
|
|
459
|
-
"icon-anchor": "bottom",
|
|
460
|
-
"icon-offset": [0, 2],
|
|
461
|
-
"icon-size": 1.0,
|
|
462
|
-
"icon-padding": 3,
|
|
463
|
-
"icon-allow-overlap": true,
|
|
464
|
-
"icon-ignore-placement": false,
|
|
465
|
-
"text-field": ["coalesce", ["get", "name"], ""],
|
|
466
|
-
"text-font": ["Noto Sans Regular"],
|
|
467
|
-
"text-size": 11,
|
|
468
|
-
"text-anchor": "top",
|
|
469
|
-
"text-offset": [0, 1.0],
|
|
470
|
-
"text-optional": true,
|
|
471
|
-
"text-padding": 3,
|
|
472
|
-
"text-allow-overlap": false,
|
|
473
|
-
"text-ignore-placement": false,
|
|
474
|
-
},
|
|
475
|
-
paint: {
|
|
476
|
-
"text-color": [
|
|
477
|
-
"case",
|
|
478
|
-
["boolean", ["feature-state", "selected"], false],
|
|
479
|
-
"#f4a261",
|
|
480
|
-
"#edf2f4",
|
|
481
|
-
],
|
|
482
|
-
"text-halo-color": "#0b1215",
|
|
483
|
-
"text-halo-width": ["case", ["boolean", ["feature-state", "selected"], false], 2.2, 1.2],
|
|
484
|
-
},
|
|
485
|
-
},
|
|
486
|
-
);
|
|
487
|
-
|
|
488
|
-
return {
|
|
489
|
-
version: 8,
|
|
490
|
-
name: `spellkave:${slug}`,
|
|
491
|
-
glyphs,
|
|
492
|
-
sources,
|
|
493
|
-
layers,
|
|
494
|
-
center: cache.center,
|
|
495
|
-
zoom: 16,
|
|
496
|
-
// Documented for clients: level filter is plain (not global-state);
|
|
497
|
-
// swap via setFilter on room-fill / corridor-line / steps-dash /
|
|
498
|
-
// door-symbol / node-circle / node-label / poi-symbol.
|
|
499
|
-
metadata: {
|
|
500
|
-
"spellkave:level_filter":
|
|
501
|
-
"Client swaps indoor level via map.setFilter; global-state not used (pinned maplibre-gl-style-spec).",
|
|
502
|
-
"spellkave:levels": cache.levels,
|
|
503
|
-
"spellkave:tick": cache.tick,
|
|
504
|
-
"spellkave:indoor_backdrops": indoorBackdrops,
|
|
505
|
-
"spellkave:backdrops": backdrops.map((bd) => ({
|
|
506
|
-
layer: `raster-${bd.id}`,
|
|
507
|
-
graph: bd.graph,
|
|
508
|
-
indoor: indoorGraphs.has(bd.graph),
|
|
509
|
-
})),
|
|
510
|
-
},
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/** Validate a style object; returns error messages (empty = ok). */
|
|
515
|
-
export function validateMapLibreStyle(style: unknown): string[] {
|
|
516
|
-
const errors = validateStyleMin(style as never);
|
|
517
|
-
return (errors ?? []).map((e) => String(e?.message ?? e));
|
|
518
|
-
}
|
package/src/writers/geojson.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* String-id-safe GeoJSON projection of an OSM document.
|
|
3
|
-
*
|
|
4
|
-
* - nodes → Point features
|
|
5
|
-
* - edge ways (2 refs) → LineString
|
|
6
|
-
* - extent ways (closed ring, ≥ 4 unique corners) → Polygon
|
|
7
|
-
* - tags become properties; `id` is always a string
|
|
8
|
-
*
|
|
9
|
-
* Used by sk-adr8.14 tiles. Never coerces OSM ids through Number.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import type { OsmDocument, OsmNode, OsmWay } from "../model.ts";
|
|
13
|
-
|
|
14
|
-
export interface GeoJsonFeatureCollection {
|
|
15
|
-
type: "FeatureCollection";
|
|
16
|
-
features: GeoJsonFeature[];
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface GeoJsonFeature {
|
|
20
|
-
type: "Feature";
|
|
21
|
-
id: string;
|
|
22
|
-
geometry:
|
|
23
|
-
| { type: "Point"; coordinates: [number, number] }
|
|
24
|
-
| { type: "LineString"; coordinates: [number, number][] }
|
|
25
|
-
| { type: "Polygon"; coordinates: [number, number][][] };
|
|
26
|
-
properties: Record<string, string | number | boolean | null>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function nodeCoords(nodesById: Map<string, OsmNode>, id: string): [number, number] | null {
|
|
30
|
-
const n = nodesById.get(id);
|
|
31
|
-
if (!n) return null;
|
|
32
|
-
return [n.lon, n.lat];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function propsFromTags(tags: Record<string, string>): Record<string, string> {
|
|
36
|
-
return { ...tags };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function wayToFeature(w: OsmWay, nodesById: Map<string, OsmNode>): GeoJsonFeature | null {
|
|
40
|
-
const coords: [number, number][] = [];
|
|
41
|
-
for (const ref of w.refs) {
|
|
42
|
-
const c = nodeCoords(nodesById, ref);
|
|
43
|
-
if (!c) return null;
|
|
44
|
-
coords.push(c);
|
|
45
|
-
}
|
|
46
|
-
if (coords.length < 2) return null;
|
|
47
|
-
|
|
48
|
-
const first = coords[0];
|
|
49
|
-
const last = coords[coords.length - 1];
|
|
50
|
-
const isClosed =
|
|
51
|
-
coords.length >= 4 &&
|
|
52
|
-
first !== undefined &&
|
|
53
|
-
last !== undefined &&
|
|
54
|
-
first[0] === last[0] &&
|
|
55
|
-
first[1] === last[1];
|
|
56
|
-
const isExtent =
|
|
57
|
-
isClosed &&
|
|
58
|
-
(w.tags.indoor === "room" ||
|
|
59
|
-
w.tags["spellkave:extent"] === "yes" ||
|
|
60
|
-
Boolean(w.tags["spellkave:extent_shape"]));
|
|
61
|
-
|
|
62
|
-
if (isExtent) {
|
|
63
|
-
return {
|
|
64
|
-
type: "Feature",
|
|
65
|
-
id: w.id,
|
|
66
|
-
geometry: { type: "Polygon", coordinates: [coords] },
|
|
67
|
-
properties: propsFromTags(w.tags),
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
type: "Feature",
|
|
73
|
-
id: w.id,
|
|
74
|
-
geometry: { type: "LineString", coordinates: coords },
|
|
75
|
-
properties: propsFromTags(w.tags),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function renderGeoJson(doc: OsmDocument): GeoJsonFeatureCollection {
|
|
80
|
-
const nodesById = new Map(doc.nodes.map((n) => [n.id, n]));
|
|
81
|
-
const features: GeoJsonFeature[] = [];
|
|
82
|
-
|
|
83
|
-
for (const n of doc.nodes) {
|
|
84
|
-
// Skip untagged extent corner nodes (noise for map consumers).
|
|
85
|
-
if (Object.keys(n.tags).length === 0) continue;
|
|
86
|
-
features.push({
|
|
87
|
-
type: "Feature",
|
|
88
|
-
id: n.id,
|
|
89
|
-
geometry: { type: "Point", coordinates: [n.lon, n.lat] },
|
|
90
|
-
properties: propsFromTags(n.tags),
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
for (const w of doc.ways) {
|
|
95
|
-
const f = wayToFeature(w, nodesById);
|
|
96
|
-
if (f) features.push(f);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return { type: "FeatureCollection", features };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function renderGeoJsonString(doc: OsmDocument, pretty = true): string {
|
|
103
|
-
return JSON.stringify(renderGeoJson(doc), null, pretty ? 2 : undefined) + (pretty ? "\n" : "");
|
|
104
|
-
}
|