@tangram.gl/basemap-layers 0.0.0-stage → 0.0.1
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 +34 -2
- package/THIRD-PARTY-NOTICES.md +205 -0
- package/dist/geojson-worker.js +2160 -0
- package/dist/geojson-worker.js.map +6 -0
- package/dist/index.cjs +11388 -0
- package/dist/index.cjs.map +6 -0
- package/dist/index.js +11369 -0
- package/dist/index.js.map +6 -0
- package/dist/map-style.cjs +445 -0
- package/dist/map-style.cjs.map +6 -0
- package/dist/map-style.js +431 -0
- package/dist/map-style.js.map +6 -0
- package/dist/types/arabic-shaping.d.ts +7 -0
- package/dist/types/atmosphere-layer.d.ts +10 -0
- package/dist/types/basemap-layer.d.ts +150 -0
- package/dist/types/bidi.d.ts +8 -0
- package/dist/types/circle-layer.d.ts +49 -0
- package/dist/types/fill-extrusion-lighting-extension.d.ts +49 -0
- package/dist/types/fill-outline-extension.d.ts +22 -0
- package/dist/types/fill-pattern.d.ts +99 -0
- package/dist/types/fill-style-extensions.d.ts +100 -0
- package/dist/types/geojson-source.d.ts +29 -0
- package/dist/types/geojson-tiler.d.ts +48 -0
- package/dist/types/geojson-worker.d.ts +40 -0
- package/dist/types/globe-horizon-extension.d.ts +61 -0
- package/dist/types/globe-layers.d.ts +239 -0
- package/dist/types/globe-line-angle-extension.d.ts +37 -0
- package/dist/types/glyph-font-renderer.d.ts +37 -0
- package/dist/types/glyph-pbf.d.ts +37 -0
- package/dist/types/glyph-store.d.ts +103 -0
- package/dist/types/grid-index.d.ts +47 -0
- package/dist/types/hillshade-layer.d.ts +154 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/is-globe-viewport.d.ts +2 -0
- package/dist/types/label-font-renderer.d.ts +18 -0
- package/dist/types/label-placement.d.ts +247 -0
- package/dist/types/label-text-layer.d.ts +231 -0
- package/dist/types/line-blur-extension.d.ts +73 -0
- package/dist/types/line-glyphs.d.ts +60 -0
- package/dist/types/line-placement.d.ts +93 -0
- package/dist/types/map-style-loader.d.ts +48 -0
- package/dist/types/map-style-schema.d.ts +72 -0
- package/dist/types/map-style.d.ts +6 -0
- package/dist/types/mapbox-style.d.ts +40 -0
- package/dist/types/mvt-label-layer.d.ts +923 -0
- package/dist/types/polylabel.d.ts +17 -0
- package/dist/types/raster-color-extension.d.ts +146 -0
- package/dist/types/shared-texture.d.ts +34 -0
- package/dist/types/sort-key.d.ts +10 -0
- package/dist/types/sprite.d.ts +82 -0
- package/dist/types/style-accessor.d.ts +45 -0
- package/dist/types/style-expression.d.ts +83 -0
- package/dist/types/style-resolver.d.ts +94 -0
- package/dist/types/text-font.d.ts +36 -0
- package/dist/types/text-halo-blur-extension.d.ts +55 -0
- package/dist/types/text-layout.d.ts +71 -0
- package/dist/types/util.d.ts +22 -0
- package/dist/types/zoom-paint-extension.d.ts +72 -0
- package/package.json +80 -3
- package/src/arabic-shaping.ts +366 -0
- package/src/atmosphere-layer.ts +19 -0
- package/src/basemap-layer.ts +533 -0
- package/src/bidi.ts +199 -0
- package/src/circle-layer.ts +191 -0
- package/src/fill-extrusion-lighting-extension.ts +206 -0
- package/src/fill-outline-extension.ts +70 -0
- package/src/fill-pattern.ts +400 -0
- package/src/fill-style-extensions.ts +177 -0
- package/src/geojson-source.ts +318 -0
- package/src/geojson-tiler.ts +185 -0
- package/src/geojson-worker.ts +98 -0
- package/src/globe-horizon-extension.ts +64 -0
- package/src/globe-layers.ts +3487 -0
- package/src/globe-line-angle-extension.ts +131 -0
- package/src/glyph-font-renderer.ts +173 -0
- package/src/glyph-pbf.ts +164 -0
- package/src/glyph-store.ts +326 -0
- package/src/grid-index.ts +177 -0
- package/src/hillshade-layer.ts +775 -0
- package/src/index.ts +18 -0
- package/src/is-globe-viewport.ts +24 -0
- package/src/label-font-renderer.ts +159 -0
- package/src/label-placement.ts +727 -0
- package/src/label-text-layer.ts +913 -0
- package/src/line-blur-extension.ts +237 -0
- package/src/line-glyphs.ts +364 -0
- package/src/line-placement.ts +446 -0
- package/src/map-style-loader.ts +56 -0
- package/src/map-style-schema.ts +83 -0
- package/src/map-style.ts +23 -0
- package/src/mapbox-style.ts +168 -0
- package/src/mvt-label-layer.ts +3744 -0
- package/src/polylabel.ts +312 -0
- package/src/raster-color-extension.ts +245 -0
- package/src/shared-texture.ts +153 -0
- package/src/sort-key.ts +63 -0
- package/src/sprite.ts +244 -0
- package/src/style-accessor.ts +95 -0
- package/src/style-expression.ts +327 -0
- package/src/style-resolver.ts +301 -0
- package/src/text-font.ts +150 -0
- package/src/text-halo-blur-extension.ts +115 -0
- package/src/text-layout.ts +441 -0
- package/src/util.ts +47 -0
- package/src/zoom-paint-extension.ts +207 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
// src/style-expression.ts
|
|
2
|
+
import { log } from "@deck.gl/core";
|
|
3
|
+
import {
|
|
4
|
+
Color,
|
|
5
|
+
ColorArray,
|
|
6
|
+
NumberArray,
|
|
7
|
+
Padding,
|
|
8
|
+
VariableAnchorOffsetCollection,
|
|
9
|
+
expression,
|
|
10
|
+
featureFilter,
|
|
11
|
+
latest as Reference
|
|
12
|
+
} from "@maplibre/maplibre-gl-style-spec";
|
|
13
|
+
var GEOMETRY_TYPES = {
|
|
14
|
+
Point: 1,
|
|
15
|
+
MultiPoint: 1,
|
|
16
|
+
LineString: 2,
|
|
17
|
+
MultiLineString: 2,
|
|
18
|
+
Polygon: 3,
|
|
19
|
+
MultiPolygon: 3
|
|
20
|
+
};
|
|
21
|
+
var compiledPropertyCache = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
var compiledFilterCache = /* @__PURE__ */ new WeakMap();
|
|
23
|
+
var warnedValues = /* @__PURE__ */ new Set();
|
|
24
|
+
function warnInvalidValue(propertyName, value, error) {
|
|
25
|
+
const key = `${propertyName}:${JSON.stringify(value)}`;
|
|
26
|
+
if (!warnedValues.has(key)) {
|
|
27
|
+
warnedValues.add(key);
|
|
28
|
+
log.warn(`Ignoring invalid style value for ${propertyName}: ${String(error)}`)();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function getStylePropertyType(propertyName) {
|
|
32
|
+
return Reference.layout.some((group) => Reference[group]?.[propertyName]) ? "layout" : "paint";
|
|
33
|
+
}
|
|
34
|
+
function getStylePropertyReference(propertyName) {
|
|
35
|
+
for (const group of [...Reference.layout, ...Reference.paint]) {
|
|
36
|
+
const reference = Reference[group]?.[propertyName];
|
|
37
|
+
if (reference) {
|
|
38
|
+
return reference;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
function getStyleGeometryType(feature) {
|
|
44
|
+
if (feature.type === 1 || feature.type === 2 || feature.type === 3) {
|
|
45
|
+
return feature.type;
|
|
46
|
+
}
|
|
47
|
+
return GEOMETRY_TYPES[feature.geometry?.type || ""];
|
|
48
|
+
}
|
|
49
|
+
function toEvaluationFeature(feature) {
|
|
50
|
+
if (!feature) {
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
type: getStyleGeometryType(feature),
|
|
55
|
+
id: feature.id,
|
|
56
|
+
properties: feature.properties || {}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function colorToArray(color) {
|
|
60
|
+
const [r, g, b, a] = color.rgb;
|
|
61
|
+
return a === 0 ? [0, 0, 0, 0] : [r * 255, g * 255, b * 255, a];
|
|
62
|
+
}
|
|
63
|
+
function toPlainValue(value) {
|
|
64
|
+
if (value instanceof Padding || value instanceof NumberArray) {
|
|
65
|
+
return value.values;
|
|
66
|
+
}
|
|
67
|
+
if (value instanceof ColorArray) {
|
|
68
|
+
return value.values.map(colorToArray);
|
|
69
|
+
}
|
|
70
|
+
if (value instanceof VariableAnchorOffsetCollection) {
|
|
71
|
+
return value.values;
|
|
72
|
+
}
|
|
73
|
+
return value instanceof Color ? colorToArray(value) : value;
|
|
74
|
+
}
|
|
75
|
+
function compileStylePropertyValue(propertyName, value) {
|
|
76
|
+
const reference = getStylePropertyReference(propertyName);
|
|
77
|
+
let compiled;
|
|
78
|
+
try {
|
|
79
|
+
const takesArray = reference?.type === "array" || reference?.type === "padding" || reference?.type === "numberArray" || reference?.type === "colorArray" || reference?.type === "variableAnchorOffsetCollection";
|
|
80
|
+
if (Array.isArray(value) && !takesArray && !expression.isExpression(value)) {
|
|
81
|
+
throw new Error(`Unknown expression "${String(value[0])}"`);
|
|
82
|
+
}
|
|
83
|
+
compiled = expression.normalizePropertyExpression(value, reference);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
warnInvalidValue(propertyName, value, error);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const kind = compiled.kind;
|
|
89
|
+
return {
|
|
90
|
+
isZoomDependent: kind === "camera" || kind === "composite",
|
|
91
|
+
isFeatureDependent: kind === "source" || kind === "composite",
|
|
92
|
+
evaluate: (zoom, feature, availableImages) => toPlainValue(
|
|
93
|
+
compiled.evaluate(
|
|
94
|
+
{ zoom },
|
|
95
|
+
toEvaluationFeature(feature),
|
|
96
|
+
void 0,
|
|
97
|
+
void 0,
|
|
98
|
+
availableImages
|
|
99
|
+
)
|
|
100
|
+
),
|
|
101
|
+
evaluateWithGlobals: (globals, feature) => toPlainValue(compiled.evaluate(globals, toEvaluationFeature(feature)))
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function getCompiledStyleProperty(styleLayer, propertyName) {
|
|
105
|
+
let layerCache = compiledPropertyCache.get(styleLayer);
|
|
106
|
+
if (!layerCache) {
|
|
107
|
+
layerCache = /* @__PURE__ */ new Map();
|
|
108
|
+
compiledPropertyCache.set(styleLayer, layerCache);
|
|
109
|
+
}
|
|
110
|
+
let entry = layerCache.get(propertyName);
|
|
111
|
+
const propertyType = entry?.propertyType ?? getStylePropertyType(propertyName);
|
|
112
|
+
const value = styleLayer[propertyType]?.[propertyName];
|
|
113
|
+
if (!entry || entry.value !== value) {
|
|
114
|
+
entry = {
|
|
115
|
+
propertyType,
|
|
116
|
+
value,
|
|
117
|
+
compiled: value === void 0 ? null : compileStylePropertyValue(propertyName, value)
|
|
118
|
+
};
|
|
119
|
+
layerCache.set(propertyName, entry);
|
|
120
|
+
}
|
|
121
|
+
return entry.compiled;
|
|
122
|
+
}
|
|
123
|
+
function compileStyleFilter(filter) {
|
|
124
|
+
const isCacheable = Boolean(filter) && typeof filter === "object";
|
|
125
|
+
const snapshot = isCacheable ? JSON.stringify(filter) : "";
|
|
126
|
+
const cached = isCacheable ? compiledFilterCache.get(filter) : void 0;
|
|
127
|
+
if (cached && cached.snapshot === snapshot) {
|
|
128
|
+
return cached.compiled;
|
|
129
|
+
}
|
|
130
|
+
let compiled;
|
|
131
|
+
try {
|
|
132
|
+
const filterFn = featureFilter(filter).filter;
|
|
133
|
+
compiled = (globalProperties, feature) => filterFn(globalProperties, toEvaluationFeature(feature));
|
|
134
|
+
} catch (error) {
|
|
135
|
+
warnInvalidValue("filter", filter, error);
|
|
136
|
+
compiled = () => false;
|
|
137
|
+
}
|
|
138
|
+
if (isCacheable) {
|
|
139
|
+
compiledFilterCache.set(filter, { snapshot, compiled });
|
|
140
|
+
}
|
|
141
|
+
return compiled;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// src/mapbox-style.ts
|
|
145
|
+
function filterFeatures({
|
|
146
|
+
features,
|
|
147
|
+
filter,
|
|
148
|
+
globalProperties = {}
|
|
149
|
+
}) {
|
|
150
|
+
if (!features || features.length === 0) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
const filterFn = compileStyleFilter(filter);
|
|
154
|
+
return features.filter((feature) => filterFn(globalProperties, feature));
|
|
155
|
+
}
|
|
156
|
+
function findFeaturesStyledByLayer({
|
|
157
|
+
features,
|
|
158
|
+
layer,
|
|
159
|
+
globalProperties
|
|
160
|
+
}) {
|
|
161
|
+
const sourceLayerFeatures = features[layer.source || ""]?.[layer["source-layer"] || ""];
|
|
162
|
+
if (!sourceLayerFeatures) {
|
|
163
|
+
return [];
|
|
164
|
+
}
|
|
165
|
+
if (layer.filter && layer.filter.length > 0) {
|
|
166
|
+
return filterFeatures({
|
|
167
|
+
features: sourceLayerFeatures,
|
|
168
|
+
filter: layer.filter,
|
|
169
|
+
globalProperties
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return sourceLayerFeatures;
|
|
173
|
+
}
|
|
174
|
+
function parseProperties(layer, globalProperties) {
|
|
175
|
+
const layerProperties = [];
|
|
176
|
+
visitProperties(layer, { paint: true }, (property) => {
|
|
177
|
+
layerProperties.push(parseProperty(property, globalProperties));
|
|
178
|
+
});
|
|
179
|
+
return layerProperties;
|
|
180
|
+
}
|
|
181
|
+
function visitProperties(layer, options, callback) {
|
|
182
|
+
function inner(targetLayer, propertyType) {
|
|
183
|
+
const properties = targetLayer[propertyType];
|
|
184
|
+
if (!properties) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
Object.keys(properties).forEach((key) => {
|
|
188
|
+
callback({
|
|
189
|
+
layer: targetLayer,
|
|
190
|
+
path: [targetLayer.id, propertyType, key],
|
|
191
|
+
key,
|
|
192
|
+
value: properties[key],
|
|
193
|
+
reference: getStylePropertyReference(key),
|
|
194
|
+
set(value) {
|
|
195
|
+
properties[key] = value;
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
if (options.paint) {
|
|
201
|
+
inner(layer, "paint");
|
|
202
|
+
}
|
|
203
|
+
if (options.layout) {
|
|
204
|
+
inner(layer, "layout");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
function parseProperty(property, globalProperties) {
|
|
208
|
+
const compiled = getCompiledStyleProperty(property.layer, property.key);
|
|
209
|
+
return {
|
|
210
|
+
[property.key]: compiled?.evaluateWithGlobals({
|
|
211
|
+
...globalProperties,
|
|
212
|
+
zoom: globalProperties.zoom ?? 0
|
|
213
|
+
})
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/map-style-schema.ts
|
|
218
|
+
import { z } from "zod";
|
|
219
|
+
var BasemapSourceSchema = z.object({
|
|
220
|
+
type: z.string().optional(),
|
|
221
|
+
url: z.string().optional(),
|
|
222
|
+
tiles: z.array(z.string()).optional(),
|
|
223
|
+
minzoom: z.number().optional(),
|
|
224
|
+
maxzoom: z.number().optional(),
|
|
225
|
+
tileSize: z.number().optional()
|
|
226
|
+
}).catchall(z.unknown());
|
|
227
|
+
var BasemapStyleLayerSchema = z.object({
|
|
228
|
+
id: z.string(),
|
|
229
|
+
type: z.string().optional(),
|
|
230
|
+
ref: z.string().optional(),
|
|
231
|
+
source: z.string().optional(),
|
|
232
|
+
"source-layer": z.string().optional(),
|
|
233
|
+
minzoom: z.number().optional(),
|
|
234
|
+
maxzoom: z.number().optional(),
|
|
235
|
+
filter: z.array(z.unknown()).optional(),
|
|
236
|
+
paint: z.record(z.string(), z.unknown()).optional(),
|
|
237
|
+
layout: z.record(z.string(), z.unknown()).optional()
|
|
238
|
+
}).catchall(z.unknown()).superRefine((layer, context) => {
|
|
239
|
+
if (!layer.type && !layer.ref) {
|
|
240
|
+
context.addIssue({
|
|
241
|
+
code: z.ZodIssueCode.custom,
|
|
242
|
+
message: 'Style layers must define either "type" or "ref".',
|
|
243
|
+
path: ["type"]
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
var ResolvedBasemapStyleLayerSchema = z.object({
|
|
248
|
+
id: z.string(),
|
|
249
|
+
type: z.string(),
|
|
250
|
+
source: z.string().optional(),
|
|
251
|
+
"source-layer": z.string().optional(),
|
|
252
|
+
minzoom: z.number().optional(),
|
|
253
|
+
maxzoom: z.number().optional(),
|
|
254
|
+
filter: z.array(z.unknown()).optional(),
|
|
255
|
+
paint: z.record(z.string(), z.unknown()).optional(),
|
|
256
|
+
layout: z.record(z.string(), z.unknown()).optional()
|
|
257
|
+
}).catchall(z.unknown());
|
|
258
|
+
var BasemapStyleSchema = z.object({
|
|
259
|
+
version: z.number().optional(),
|
|
260
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
261
|
+
sources: z.record(z.string(), BasemapSourceSchema).optional(),
|
|
262
|
+
layers: z.array(BasemapStyleLayerSchema).optional()
|
|
263
|
+
}).catchall(z.unknown());
|
|
264
|
+
var ResolvedBasemapStyleSchema = z.object({
|
|
265
|
+
version: z.number().optional(),
|
|
266
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
267
|
+
sources: z.record(z.string(), BasemapSourceSchema),
|
|
268
|
+
layers: z.array(ResolvedBasemapStyleLayerSchema)
|
|
269
|
+
}).catchall(z.unknown());
|
|
270
|
+
|
|
271
|
+
// src/style-resolver.ts
|
|
272
|
+
import { log as log2 } from "@deck.gl/core";
|
|
273
|
+
import { derefLayers } from "@maplibre/maplibre-gl-style-spec";
|
|
274
|
+
function normalizeUrl(url, baseUrl) {
|
|
275
|
+
if (!url) {
|
|
276
|
+
return url;
|
|
277
|
+
}
|
|
278
|
+
try {
|
|
279
|
+
return decodeURI(new URL(url, baseUrl).toString());
|
|
280
|
+
} catch {
|
|
281
|
+
return url;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function normalizeTiles(tiles, baseUrl) {
|
|
285
|
+
return Array.isArray(tiles) ? tiles.map((tile) => normalizeUrl(tile, baseUrl) || tile) : tiles;
|
|
286
|
+
}
|
|
287
|
+
async function fetchJson(url, loadOptions) {
|
|
288
|
+
const fetchFn = loadOptions?.fetch || fetch;
|
|
289
|
+
const response = await fetchFn(url, loadOptions?.fetchOptions);
|
|
290
|
+
if (!response.ok) {
|
|
291
|
+
throw new Error(`Failed to load basemap resource: ${url} (${response.status})`);
|
|
292
|
+
}
|
|
293
|
+
return await response.json();
|
|
294
|
+
}
|
|
295
|
+
var TILEJSON_SOURCE_TYPES = /* @__PURE__ */ new Set(["vector", "raster", "raster-dem"]);
|
|
296
|
+
var TILEJSON_SOURCE_KEYS = [
|
|
297
|
+
"tiles",
|
|
298
|
+
"minzoom",
|
|
299
|
+
"maxzoom",
|
|
300
|
+
"attribution",
|
|
301
|
+
"bounds",
|
|
302
|
+
"scheme",
|
|
303
|
+
"tileSize",
|
|
304
|
+
"encoding"
|
|
305
|
+
];
|
|
306
|
+
function pickTileJsonFields(tileJson) {
|
|
307
|
+
const fields = {};
|
|
308
|
+
if (!tileJson || typeof tileJson !== "object" || Array.isArray(tileJson)) {
|
|
309
|
+
return fields;
|
|
310
|
+
}
|
|
311
|
+
for (const key of TILEJSON_SOURCE_KEYS) {
|
|
312
|
+
if (Object.prototype.hasOwnProperty.call(tileJson, key)) {
|
|
313
|
+
fields[key] = tileJson[key];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return fields;
|
|
317
|
+
}
|
|
318
|
+
async function resolveGeoJsonSource(source, baseUrl, loadOptions) {
|
|
319
|
+
if (typeof source.data !== "string") {
|
|
320
|
+
return { ...source };
|
|
321
|
+
}
|
|
322
|
+
const dataUrl = normalizeUrl(source.data, baseUrl) || source.data;
|
|
323
|
+
const data = await fetchJson(dataUrl, loadOptions);
|
|
324
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
325
|
+
throw new Error(`Invalid GeoJSON: ${dataUrl}`);
|
|
326
|
+
}
|
|
327
|
+
return { ...source, data };
|
|
328
|
+
}
|
|
329
|
+
async function resolveSource(source, baseUrl, loadOptions) {
|
|
330
|
+
if (!source) {
|
|
331
|
+
return source;
|
|
332
|
+
}
|
|
333
|
+
if (source.type === "geojson") {
|
|
334
|
+
return await resolveGeoJsonSource(source, baseUrl, loadOptions);
|
|
335
|
+
}
|
|
336
|
+
if (!source.url || !TILEJSON_SOURCE_TYPES.has(String(source.type))) {
|
|
337
|
+
return source.tiles ? { ...source, tiles: normalizeTiles(source.tiles, baseUrl) } : { ...source };
|
|
338
|
+
}
|
|
339
|
+
const tileJsonUrl = normalizeUrl(source.url, baseUrl);
|
|
340
|
+
const tileJsonFields = pickTileJsonFields(
|
|
341
|
+
await fetchJson(tileJsonUrl || source.url, loadOptions)
|
|
342
|
+
);
|
|
343
|
+
const resolvedSource = {
|
|
344
|
+
...tileJsonFields,
|
|
345
|
+
...source,
|
|
346
|
+
url: tileJsonUrl,
|
|
347
|
+
tiles: source.tiles ? normalizeTiles(source.tiles, baseUrl) : normalizeTiles(tileJsonFields.tiles, tileJsonUrl)
|
|
348
|
+
};
|
|
349
|
+
const result = BasemapSourceSchema.safeParse(resolvedSource);
|
|
350
|
+
if (!result.success) {
|
|
351
|
+
throw new Error(`Invalid TileJSON: ${tileJsonUrl} (${result.error.issues[0]?.message})`);
|
|
352
|
+
}
|
|
353
|
+
if (!resolvedSource.tiles?.length) {
|
|
354
|
+
throw new Error(`TileJSON has no tiles: ${tileJsonUrl}`);
|
|
355
|
+
}
|
|
356
|
+
return resolvedSource;
|
|
357
|
+
}
|
|
358
|
+
function isLoadCancelled(error, loadOptions) {
|
|
359
|
+
return Boolean(loadOptions?.fetchOptions?.signal?.aborted) || error?.name === "AbortError";
|
|
360
|
+
}
|
|
361
|
+
async function resolveBasemapStyle(style, loadOptions) {
|
|
362
|
+
const styleDefinition = BasemapStyleSchema.parse(
|
|
363
|
+
typeof style === "string" ? await fetchJson(style, loadOptions) : structuredClone(style)
|
|
364
|
+
);
|
|
365
|
+
const baseUrl = typeof style === "string" ? style : loadOptions?.baseUrl;
|
|
366
|
+
const resolvedSources = {};
|
|
367
|
+
await Promise.all(
|
|
368
|
+
Object.entries(styleDefinition.sources || {}).map(async ([sourceId, source]) => {
|
|
369
|
+
try {
|
|
370
|
+
resolvedSources[sourceId] = await resolveSource(source, baseUrl, loadOptions) || {};
|
|
371
|
+
} catch (error) {
|
|
372
|
+
if (isLoadCancelled(error, loadOptions)) {
|
|
373
|
+
throw loadOptions?.fetchOptions?.signal?.aborted ? loadOptions.fetchOptions.signal.reason ?? error : error;
|
|
374
|
+
}
|
|
375
|
+
const inlineTiles = source?.tiles?.length ? normalizeTiles(source.tiles, baseUrl) : void 0;
|
|
376
|
+
log2.warn(
|
|
377
|
+
`[BasemapLayer] Source "${sourceId}" could not be loaded; ${inlineTiles ? "using its inline tiles" : "its layers are skipped"}: ${String(error?.message ?? error)}`
|
|
378
|
+
)();
|
|
379
|
+
resolvedSources[sourceId] = source?.type === "geojson" ? { ...source, data: void 0 } : { ...source, url: void 0, tiles: inlineTiles };
|
|
380
|
+
}
|
|
381
|
+
})
|
|
382
|
+
);
|
|
383
|
+
return ResolvedBasemapStyleSchema.parse({
|
|
384
|
+
...styleDefinition,
|
|
385
|
+
sources: resolvedSources,
|
|
386
|
+
layers: derefLayers([...styleDefinition.layers || []])
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// src/map-style-loader.ts
|
|
391
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
392
|
+
function getMapStyleLoadOptions(options, context) {
|
|
393
|
+
return {
|
|
394
|
+
...options?.mapStyle,
|
|
395
|
+
baseUrl: options?.mapStyle?.baseUrl || context?.url || context?.baseUrl,
|
|
396
|
+
fetch: options?.mapStyle?.fetch || context?.fetch
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
var MapStyleLoader = {
|
|
400
|
+
dataType: null,
|
|
401
|
+
batchType: null,
|
|
402
|
+
name: "Map Style",
|
|
403
|
+
id: "map-style",
|
|
404
|
+
module: "basemap-layers",
|
|
405
|
+
version: VERSION,
|
|
406
|
+
worker: false,
|
|
407
|
+
extensions: ["json"],
|
|
408
|
+
mimeTypes: ["application/json", "application/vnd.mapbox.style+json"],
|
|
409
|
+
text: true,
|
|
410
|
+
options: {
|
|
411
|
+
mapStyle: {}
|
|
412
|
+
},
|
|
413
|
+
parse: async (data, options, context) => {
|
|
414
|
+
const text = typeof data === "string" ? data : new TextDecoder().decode(data);
|
|
415
|
+
const style = JSON.parse(text);
|
|
416
|
+
const resolved = await resolveBasemapStyle(style, getMapStyleLoadOptions(options, context));
|
|
417
|
+
return ResolvedBasemapStyleSchema.parse(resolved);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
export {
|
|
421
|
+
BasemapSourceSchema,
|
|
422
|
+
BasemapStyleLayerSchema,
|
|
423
|
+
BasemapStyleSchema,
|
|
424
|
+
MapStyleLoader,
|
|
425
|
+
ResolvedBasemapStyleSchema,
|
|
426
|
+
filterFeatures,
|
|
427
|
+
findFeaturesStyledByLayer,
|
|
428
|
+
parseProperties,
|
|
429
|
+
resolveBasemapStyle
|
|
430
|
+
};
|
|
431
|
+
//# sourceMappingURL=map-style.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/style-expression.ts", "../src/mapbox-style.ts", "../src/map-style-schema.ts", "../src/style-resolver.ts", "../src/map-style-loader.ts"],
|
|
4
|
+
"mappings": ";AAMA,SAAQ,WAAU;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,OACL;AAmCP,IAAM,iBAAyC;AAAA,EAC7C,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,SAAS;AAAA,EACT,cAAc;AAChB;AAQA,IAAM,wBAAwB,oBAAI,QAAoD;AAEtF,IAAM,sBAAsB,oBAAI,QAA2D;AAC3F,IAAM,eAAe,oBAAI,IAAY;AAKrC,SAAS,iBAAiB,cAAsB,OAAgB,OAAsB;AACpF,QAAM,MAAM,GAAG,YAAY,IAAI,KAAK,UAAU,KAAK,CAAC;AACpD,MAAI,CAAC,aAAa,IAAI,GAAG,GAAG;AAC1B,iBAAa,IAAI,GAAG;AACpB,QAAI,KAAK,oCAAoC,YAAY,KAAK,OAAO,KAAK,CAAC,EAAE,EAAE;AAAA,EACjF;AACF;AAGO,SAAS,qBAAqB,cAA0C;AAC7E,SAAO,UAAU,OAAO,KAAK,CAAC,UAAkB,UAAU,KAAK,IAAI,YAAY,CAAC,IAA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AO,IAAI,YAAY,EAAE,OAAO,IAAI;AAC5E,UAAM,QAAQ,KAAK,MAAM,IAAI;AAC7B,UAAM,WAAW,MAAM,oBAAoB,OAAO,uBAAuB,SAAS,OAAO,CAAC;AAC1F,WAAO,2BAA2B,MAAM,QAAQ;AAAA,EAClD;AACF;",
|
|
5
|
+
"names": ["log", "log"]
|
|
6
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrites Arabic letters as the shape they take in their word, named by their Arabic
|
|
3
|
+
* Presentation Forms code points (U+FB50–FDFF, U+FE70–FEFF), with lam-alef ligatures, as MapLibre
|
|
4
|
+
* GL JS does: glyphs are drawn one code point at a time, so the contextual shape has to be chosen
|
|
5
|
+
* before glyphs are looked up. Text with no Arabic in it is returned unchanged.
|
|
6
|
+
*/
|
|
7
|
+
export declare function applyArabicShaping(text: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the top-of-globe atmosphere overlay layer when atmosphere rendering
|
|
3
|
+
* is enabled.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getGlobeAtmosphereLayer(): null;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the background sky layer rendered behind the globe when atmosphere
|
|
8
|
+
* rendering is enabled.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getGlobeAtmosphereSkyLayer(): null;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { SharedTileset2D } from '@deck.gl-community/geo-layers';
|
|
2
|
+
import type { BasemapSource } from "./style-resolver.js";
|
|
3
|
+
import { CompositeLayer, type DefaultProps, type UpdateParameters, type Viewport } from '@deck.gl/core';
|
|
4
|
+
import { LabelPlacement } from "./label-placement.js";
|
|
5
|
+
import type { BasemapStyle, ResolvedBasemapStyle } from "./style-resolver.js";
|
|
6
|
+
import { GlyphStore } from "./glyph-store.js";
|
|
7
|
+
import type { SpriteAtlas } from "./sprite.js";
|
|
8
|
+
import type { LabelFontFamily } from "./text-font.js";
|
|
9
|
+
/**
|
|
10
|
+
* Globe-related runtime toggles used by {@link BasemapLayer}.
|
|
11
|
+
*/
|
|
12
|
+
export type BasemapGlobeConfig = {
|
|
13
|
+
/** Renders the atmosphere overlays returned by the globe helpers when available. */
|
|
14
|
+
atmosphere?: boolean;
|
|
15
|
+
/** Renders the main globe basemap content when `true`. */
|
|
16
|
+
basemap?: boolean;
|
|
17
|
+
/** Enables symbol-label rendering on the globe path when `true`. */
|
|
18
|
+
labels?: boolean;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Props accepted by {@link BasemapLayer}.
|
|
22
|
+
*/
|
|
23
|
+
export type BasemapLayerProps = {
|
|
24
|
+
/** Optional deck.gl layer identifier. */
|
|
25
|
+
id?: string;
|
|
26
|
+
/** MapLibre or Mapbox style JSON, or a URL that resolves to one. */
|
|
27
|
+
style: string | BasemapStyle | null;
|
|
28
|
+
/** Load options forwarded to {@link resolveBasemapStyle}. */
|
|
29
|
+
loadOptions?: Record<string, unknown> | null;
|
|
30
|
+
/** Selects whether deck layers are generated for a flat map or a globe. */
|
|
31
|
+
mode?: 'map' | 'globe';
|
|
32
|
+
/** Optional globe-specific configuration used when `mode` is `'globe'`. */
|
|
33
|
+
globe?: {
|
|
34
|
+
/** Rendering toggles for globe-specific basemap behavior. */
|
|
35
|
+
config?: BasemapGlobeConfig;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Draws labels with the browser's fonts instead of the style's `glyphs`. By default labels are
|
|
39
|
+
* drawn with the style's glyphs, as in MapLibre GL JS, and a style without `glyphs` maps each
|
|
40
|
+
* symbol layer's `text-font` to a CSS family list, weight and style (see the module docs). A
|
|
41
|
+
* string replaces the family list for every label; a function receives the `text-font` names
|
|
42
|
+
* and returns a family list or `LabelFont` fields. Pass a stable function: tiles regenerate when
|
|
43
|
+
* it changes.
|
|
44
|
+
*/
|
|
45
|
+
fontFamily?: LabelFontFamily | null;
|
|
46
|
+
/**
|
|
47
|
+
* Milliseconds between two placements of the labels while the view keeps changing, as MapLibre
|
|
48
|
+
* GL JS's `fadeDuration` (default 300). The view the map comes to rest in is always placed; 0
|
|
49
|
+
* places every frame.
|
|
50
|
+
*/
|
|
51
|
+
labelPlacementInterval?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Places this layer's labels apart from those of the other `BasemapLayer`s of the deck. By
|
|
54
|
+
* default (`false`) the labels of every `BasemapLayer` in a deck are placed together, as the
|
|
55
|
+
* layers of one style: a label hides those it overlaps, and those of a `BasemapLayer` drawn later
|
|
56
|
+
* are placed first. With `true`, this layer's labels collide only with each other.
|
|
57
|
+
*/
|
|
58
|
+
separateLabelPlacement?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Internal state tracked by {@link BasemapLayer}.
|
|
62
|
+
*/
|
|
63
|
+
type BasemapLayerState = {
|
|
64
|
+
/**
|
|
65
|
+
* Places the labels of every symbol style layer together (see `LabelPlacement`): the deck's
|
|
66
|
+
* shared placement, or this layer's own with `separateLabelPlacement`.
|
|
67
|
+
*/
|
|
68
|
+
labelPlacement: LabelPlacement | null;
|
|
69
|
+
/** The deck whose shared placement `labelPlacement` is, or null for a placement of its own. */
|
|
70
|
+
sharedLabelPlacementKey: object | null;
|
|
71
|
+
/** The fully resolved style definition currently backing the generated sublayers. */
|
|
72
|
+
resolvedStyle: ResolvedBasemapStyle | null;
|
|
73
|
+
/** The most recent style-resolution error, if one occurred. */
|
|
74
|
+
loadError: Error | null;
|
|
75
|
+
/** Monotonic token used to discard stale async style loads. */
|
|
76
|
+
loadToken: number;
|
|
77
|
+
/** `getStyleZoomKey` of the zoom the current sublayers were generated at. */
|
|
78
|
+
zoomKey: string | null;
|
|
79
|
+
/** Sprites of the resolved style, once loaded. */
|
|
80
|
+
spriteAtlases: SpriteAtlas[] | null;
|
|
81
|
+
/** The glyphs of the resolved style's `glyphs` URL, or null without one. */
|
|
82
|
+
glyphs: GlyphStore | null;
|
|
83
|
+
/** Decoded data caches owned by this basemap, shared across style runs. */
|
|
84
|
+
tilesets: Map<BasemapSource, SharedTileset2D>;
|
|
85
|
+
/**
|
|
86
|
+
* What each tileset decodes: for a vector source its source layers, as JSON (see
|
|
87
|
+
* `getStyleSourceLayers`), for a raster-dem source its encoding.
|
|
88
|
+
*/
|
|
89
|
+
tilesetSourceLayers: Map<BasemapSource, string>;
|
|
90
|
+
/** Loading configuration used to construct the current source caches. */
|
|
91
|
+
tileLoadOptions: unknown;
|
|
92
|
+
/** Fetch identity, kept separate from render-only props such as view mode. */
|
|
93
|
+
tileFetch: unknown;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* A deck.gl {@link CompositeLayer} that loads a style document and renders the
|
|
97
|
+
* corresponding basemap sublayers.
|
|
98
|
+
*/
|
|
99
|
+
export declare class BasemapLayer extends CompositeLayer<Required<BasemapLayerProps>> {
|
|
100
|
+
/** Deck.gl layer name. */
|
|
101
|
+
static layerName: string;
|
|
102
|
+
/** Default props for {@link BasemapLayer}. */
|
|
103
|
+
static defaultProps: DefaultProps<BasemapLayerProps>;
|
|
104
|
+
/** Current layer state. */
|
|
105
|
+
state: BasemapLayerState;
|
|
106
|
+
/** Initializes the asynchronous style-loading state. */
|
|
107
|
+
initializeState(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Sublayers depend on the zoom, but only through `getStyleZoomKey`: style values step every
|
|
110
|
+
* `STYLE_ZOOM_STEP`, filters at integer zooms, and layer visibility changes at
|
|
111
|
+
* `minzoom`/`maxzoom`. Re-render when that key changes, not on every viewport change.
|
|
112
|
+
*/
|
|
113
|
+
shouldUpdateState(params: UpdateParameters<this>): boolean;
|
|
114
|
+
/** Returns the key of what the sublayers depend on in `viewport`, for a resolved style. */
|
|
115
|
+
getZoomKey(resolvedStyle: ResolvedBasemapStyle, viewport: Viewport | undefined): string;
|
|
116
|
+
/**
|
|
117
|
+
* The mode the sublayers are drawn in. Above zoom 12, `GlobeView` draws with a Web Mercator
|
|
118
|
+
* viewport, so a globe basemap draws as a map there: globe depth and culling parameters assume
|
|
119
|
+
* longitude/latitude geometry on a sphere.
|
|
120
|
+
*/
|
|
121
|
+
getDrawMode(viewport: Viewport | undefined): 'map' | 'globe';
|
|
122
|
+
/** Reacts to changes in the input style definition. */
|
|
123
|
+
updateState({ props, oldProps, changeFlags }: UpdateParameters<this>): void;
|
|
124
|
+
/**
|
|
125
|
+
* Resolves the configured style input and stores the latest successful result
|
|
126
|
+
* in layer state.
|
|
127
|
+
*/
|
|
128
|
+
loadStyle(style: BasemapLayerProps['style'], loadOptions: BasemapLayerProps['loadOptions']): void;
|
|
129
|
+
/**
|
|
130
|
+
* Loads the resolved style's sprites, if it has any, and stores them for the icon layers.
|
|
131
|
+
* Relative sprite URLs resolve against the style URL.
|
|
132
|
+
*/
|
|
133
|
+
loadSprites(resolvedStyle: ResolvedBasemapStyle, style: BasemapLayerProps['style'], loadOptions: BasemapLayerProps['loadOptions'], loadToken: number): void;
|
|
134
|
+
/** The basemap owns caches; style-run consumers only attach/detach. */
|
|
135
|
+
finalizeState(): void;
|
|
136
|
+
/**
|
|
137
|
+
* Takes the deck's shared label placement, or one of its own with `separateLabelPlacement`, and
|
|
138
|
+
* gives back the one it had when that prop changed.
|
|
139
|
+
*/
|
|
140
|
+
private updateLabelPlacement;
|
|
141
|
+
/** Gives back the deck's shared placement, or releases this layer's own. */
|
|
142
|
+
private releaseLabelPlacement;
|
|
143
|
+
private clearSourceTilesets;
|
|
144
|
+
private updateSourceTilesets;
|
|
145
|
+
/** The label placement, with the interval of the current props. */
|
|
146
|
+
private getLabelPlacement;
|
|
147
|
+
/** Renders the sublayers generated from the resolved style definition. */
|
|
148
|
+
renderLayers(): any[];
|
|
149
|
+
}
|
|
150
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Whether `text` has right-to-left characters, so that it needs {@link processBidirectionalText}. */
|
|
2
|
+
export declare function containsRightToLeftText(text: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Puts text into the order it is drawn, broken into lines, as MapLibre GL JS does: the embedding
|
|
5
|
+
* levels are found for the whole label, then each line is reordered on its own. A label is broken
|
|
6
|
+
* at `lineBreakPoints` (UTF-16 code unit offsets) and wherever a paragraph ends.
|
|
7
|
+
*/
|
|
8
|
+
export declare function processBidirectionalText(text: string, lineBreakPoints: number[]): string[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LayerExtension } from '@deck.gl/core';
|
|
2
|
+
import type { Layer } from '@deck.gl/core';
|
|
3
|
+
import { ScatterplotLayer } from '@deck.gl/layers';
|
|
4
|
+
import type { ResolvedBasemapStyleLayer as BasemapStyleLayer } from "./style-resolver.js";
|
|
5
|
+
/**
|
|
6
|
+
* Adds `getBlur` to a `ScatterplotLayer`: per circle, the outer fraction of the circle (stroke
|
|
7
|
+
* included) that fades out, as MapLibre GL JS draws `circle-blur`. WebGL only; on WebGPU circles
|
|
8
|
+
* draw without blur.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CircleBlurExtension extends LayerExtension {
|
|
11
|
+
static extensionName: string;
|
|
12
|
+
static defaultProps: {
|
|
13
|
+
getBlur: {
|
|
14
|
+
type: string;
|
|
15
|
+
value: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
initializeState(this: Layer): void;
|
|
19
|
+
getShaders(this: Layer): {
|
|
20
|
+
inject?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
inject: {
|
|
23
|
+
'vs:#decl': string;
|
|
24
|
+
'vs:#main-end': string;
|
|
25
|
+
'fs:#decl': string;
|
|
26
|
+
'fs:DECKGL_FILTER_COLOR': string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Draws a `circle` style layer's points (and each point of a multipoint) with MapLibre's circle
|
|
32
|
+
* paint: the stroke is drawn outside `circle-radius`. Under pitch, circles shrink with distance,
|
|
33
|
+
* as with the default `circle-pitch-scale` of `map`; `viewport` is not applied.
|
|
34
|
+
* `circle-translate-anchor` follows `circle-pitch-alignment`: the offset is screen-aligned when
|
|
35
|
+
* circles face the viewer and map-aligned when they lie on the map.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createCircleSubLayer({ baseProps, id, styleLayer, features, zoom, globe, parameters }: {
|
|
38
|
+
baseProps: any;
|
|
39
|
+
id: string;
|
|
40
|
+
styleLayer: BasemapStyleLayer;
|
|
41
|
+
features: any[];
|
|
42
|
+
zoom: number;
|
|
43
|
+
/**
|
|
44
|
+
* On a globe, circles always face the viewer: `circle-pitch-alignment: map` is not verified
|
|
45
|
+
* there.
|
|
46
|
+
*/
|
|
47
|
+
globe: boolean;
|
|
48
|
+
parameters: any;
|
|
49
|
+
}): ScatterplotLayer<any, {}> | null;
|