@loaders.gl/mvt 4.0.0 → 4.0.2
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/dist/dist.dev.js +129 -49
- package/dist/index.cjs +115 -44
- package/dist/lib/parse-tilejson.d.ts +20 -4
- package/dist/lib/parse-tilejson.d.ts.map +1 -1
- package/dist/lib/parse-tilejson.js +82 -33
- package/dist/lib/parse-tilejson.js.map +1 -1
- package/dist/mvt-source.d.ts +7 -0
- package/dist/mvt-source.d.ts.map +1 -1
- package/dist/mvt-source.js +42 -16
- package/dist/mvt-source.js.map +1 -1
- package/dist/mvt-worker.js +33 -25
- package/dist/tilejson-loader.d.ts +3 -1
- package/dist/tilejson-loader.d.ts.map +1 -1
- package/dist/tilejson-loader.js +13 -3
- package/dist/tilejson-loader.js.map +1 -1
- package/package.json +6 -6
- package/src/lib/parse-tilejson.ts +137 -42
- package/src/mvt-source.ts +51 -11
- package/src/tilejson-loader.ts +11 -5
|
@@ -1,71 +1,90 @@
|
|
|
1
1
|
const isObject = x => x !== null && typeof x === 'object';
|
|
2
|
-
export function parseTileJSON(jsonMetadata) {
|
|
2
|
+
export function parseTileJSON(jsonMetadata, options) {
|
|
3
3
|
var _tileJSON$metaJson;
|
|
4
4
|
if (!jsonMetadata || !isObject(jsonMetadata)) {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
|
-
const boundingBox = parseBounds(jsonMetadata.bounds);
|
|
8
|
-
const center = parseCenter(jsonMetadata.center);
|
|
9
|
-
const maxZoom = safeParseFloat(jsonMetadata.maxzoom);
|
|
10
|
-
const minZoom = safeParseFloat(jsonMetadata.minzoom);
|
|
11
7
|
let tileJSON = {
|
|
12
8
|
name: jsonMetadata.name || '',
|
|
13
|
-
description: jsonMetadata.description || ''
|
|
14
|
-
boundingBox,
|
|
15
|
-
center,
|
|
16
|
-
maxZoom,
|
|
17
|
-
minZoom,
|
|
18
|
-
layers: []
|
|
9
|
+
description: jsonMetadata.description || ''
|
|
19
10
|
};
|
|
11
|
+
if (typeof jsonMetadata.generator === 'string') {
|
|
12
|
+
tileJSON.generator = jsonMetadata.generator;
|
|
13
|
+
}
|
|
14
|
+
if (typeof jsonMetadata.generator_options === 'string') {
|
|
15
|
+
tileJSON.generatorOptions = jsonMetadata.generator_options;
|
|
16
|
+
}
|
|
17
|
+
tileJSON.boundingBox = parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);
|
|
18
|
+
tileJSON.center = parseCenter(jsonMetadata.center);
|
|
19
|
+
tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);
|
|
20
|
+
tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);
|
|
20
21
|
if (typeof (jsonMetadata === null || jsonMetadata === void 0 ? void 0 : jsonMetadata.json) === 'string') {
|
|
21
22
|
try {
|
|
22
23
|
tileJSON.metaJson = JSON.parse(jsonMetadata.json);
|
|
23
|
-
} catch (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (layers.length === 0) {
|
|
27
|
-
layers = parseTileJSONLayers(jsonMetadata.vector_layers);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.warn('Failed to parse tilejson.json field', error);
|
|
26
|
+
}
|
|
28
27
|
}
|
|
28
|
+
const tilestats = jsonMetadata.tilestats || ((_tileJSON$metaJson = tileJSON.metaJson) === null || _tileJSON$metaJson === void 0 ? void 0 : _tileJSON$metaJson.tilestats);
|
|
29
|
+
const tileStatsLayers = parseTilestatsLayers(tilestats, options);
|
|
30
|
+
const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers);
|
|
31
|
+
const layers = mergeLayers(tileJSONlayers, tileStatsLayers);
|
|
29
32
|
tileJSON = {
|
|
30
33
|
...tileJSON,
|
|
31
34
|
layers
|
|
32
35
|
};
|
|
36
|
+
if (tileJSON.maxZoom === null && layers.length > 0) {
|
|
37
|
+
tileJSON.maxZoom = layers[0].maxZoom || null;
|
|
38
|
+
}
|
|
39
|
+
if (tileJSON.minZoom === null && layers.length > 0) {
|
|
40
|
+
tileJSON.minZoom = layers[0].minZoom || null;
|
|
41
|
+
}
|
|
33
42
|
return tileJSON;
|
|
34
43
|
}
|
|
35
44
|
function parseTileJSONLayers(layers) {
|
|
36
45
|
if (!Array.isArray(layers)) {
|
|
37
46
|
return [];
|
|
38
47
|
}
|
|
39
|
-
return layers.map(layer => (
|
|
48
|
+
return layers.map(layer => parseTileJSONLayer(layer));
|
|
49
|
+
}
|
|
50
|
+
function parseTileJSONLayer(layer) {
|
|
51
|
+
const fields = Object.entries(layer.fields || []).map(_ref => {
|
|
52
|
+
let [key, datatype] = _ref;
|
|
53
|
+
return {
|
|
54
|
+
name: key,
|
|
55
|
+
...attributeTypeToFieldType(String(datatype))
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
const layer2 = {
|
|
59
|
+
...layer
|
|
60
|
+
};
|
|
61
|
+
delete layer2.fields;
|
|
62
|
+
return {
|
|
40
63
|
name: layer.id || '',
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
name: key,
|
|
45
|
-
...attributeTypeToFieldType(String(datatype))
|
|
46
|
-
};
|
|
47
|
-
})
|
|
48
|
-
}));
|
|
64
|
+
...layer2,
|
|
65
|
+
fields
|
|
66
|
+
};
|
|
49
67
|
}
|
|
50
|
-
function parseTilestatsLayers(tilestats) {
|
|
68
|
+
function parseTilestatsLayers(tilestats, options) {
|
|
51
69
|
if (isObject(tilestats) && Array.isArray(tilestats.layers)) {
|
|
52
|
-
return tilestats.layers.map(layer => parseTilestatsForLayer(layer));
|
|
70
|
+
return tilestats.layers.map(layer => parseTilestatsForLayer(layer, options));
|
|
53
71
|
}
|
|
54
72
|
return [];
|
|
55
73
|
}
|
|
56
|
-
function parseTilestatsForLayer(layer) {
|
|
74
|
+
function parseTilestatsForLayer(layer, options) {
|
|
57
75
|
const fields = [];
|
|
58
76
|
const indexedAttributes = {};
|
|
59
77
|
const attributes = layer.attributes || [];
|
|
60
|
-
for (const
|
|
61
|
-
const name =
|
|
78
|
+
for (const attribute of attributes) {
|
|
79
|
+
const name = attribute.attribute;
|
|
62
80
|
if (typeof name === 'string') {
|
|
63
81
|
if (name.split('|').length > 1) {
|
|
64
82
|
const fname = name.split('|')[0];
|
|
65
83
|
indexedAttributes[fname] = indexedAttributes[fname] || [];
|
|
66
|
-
indexedAttributes[fname].push(
|
|
84
|
+
indexedAttributes[fname].push(attribute);
|
|
85
|
+
console.warn('ignoring tilestats indexed field', fname);
|
|
67
86
|
} else if (!fields[name]) {
|
|
68
|
-
fields
|
|
87
|
+
fields.push(attributeToField(attribute, options));
|
|
69
88
|
} else {}
|
|
70
89
|
}
|
|
71
90
|
}
|
|
@@ -75,6 +94,21 @@ function parseTilestatsForLayer(layer) {
|
|
|
75
94
|
fields
|
|
76
95
|
};
|
|
77
96
|
}
|
|
97
|
+
function mergeLayers(layers, tilestatsLayers) {
|
|
98
|
+
return layers.map(layer => {
|
|
99
|
+
const tilestatsLayer = tilestatsLayers.find(tsLayer => tsLayer.name === layer.name);
|
|
100
|
+
const fields = (tilestatsLayer === null || tilestatsLayer === void 0 ? void 0 : tilestatsLayer.fields) || [];
|
|
101
|
+
const layer2 = {
|
|
102
|
+
...layer
|
|
103
|
+
};
|
|
104
|
+
delete layer2.fields;
|
|
105
|
+
return {
|
|
106
|
+
...layer2,
|
|
107
|
+
...tilestatsLayer,
|
|
108
|
+
fields
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
}
|
|
78
112
|
function parseBounds(bounds) {
|
|
79
113
|
const result = fromArrayOrString(bounds);
|
|
80
114
|
if (Array.isArray(result) && result.length === 4 && [result[0], result[2]].every(isLng) && [result[1], result[3]].every(isLat)) {
|
|
@@ -141,11 +175,26 @@ const attrTypeMap = {
|
|
|
141
175
|
};
|
|
142
176
|
function attributeToField() {
|
|
143
177
|
let attribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
178
|
+
let options = arguments.length > 1 ? arguments[1] : undefined;
|
|
144
179
|
const fieldTypes = attributeTypeToFieldType(attribute.type);
|
|
145
|
-
|
|
180
|
+
const field = {
|
|
146
181
|
name: attribute.attribute,
|
|
147
182
|
...fieldTypes
|
|
148
183
|
};
|
|
184
|
+
if (typeof attribute.min === 'number') {
|
|
185
|
+
field.min = attribute.min;
|
|
186
|
+
}
|
|
187
|
+
if (typeof attribute.max === 'number') {
|
|
188
|
+
field.max = attribute.max;
|
|
189
|
+
}
|
|
190
|
+
if (typeof attribute.count === 'number') {
|
|
191
|
+
field.uniqueValueCount = attribute.count;
|
|
192
|
+
}
|
|
193
|
+
if (options.maxValues !== false && attribute.values) {
|
|
194
|
+
var _attribute$values;
|
|
195
|
+
field.values = (_attribute$values = attribute.values) === null || _attribute$values === void 0 ? void 0 : _attribute$values.slice(0, options.maxValues);
|
|
196
|
+
}
|
|
197
|
+
return field;
|
|
149
198
|
}
|
|
150
199
|
function attributeTypeToFieldType(aType) {
|
|
151
200
|
const type = aType.toLowerCase();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-tilejson.js","names":["isObject","x","parseTileJSON","jsonMetadata","_tileJSON$metaJson","boundingBox","parseBounds","bounds","center","parseCenter","maxZoom","safeParseFloat","maxzoom","minZoom","minzoom","tileJSON","name","description","layers","json","metaJson","JSON","parse","err","parseTilestatsLayers","tilestats","length","parseTileJSONLayers","vector_layers","Array","isArray","map","layer","id","fields","Object","entries","_ref","key","datatype","attributeTypeToFieldType","String","parseTilestatsForLayer","indexedAttributes","attributes","attr","attribute","split","fname","push","attributeToField","dominantGeometry","geometry","result","fromArrayOrString","every","isLng","isLat","undefined","isZoom","input","parseFloat","isNaN","num","Number","isFinite","data","attrTypeMap","number","type","numeric","string","vachar","float","int","int4","boolean","bool","arguments","fieldTypes","aType","toLowerCase"],"sources":["../../src/lib/parse-tilejson.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\n/** Parsed and typed TileJSON, merges Tilestats information if present */\nexport type TileJSON = {\n name?: string;\n description?: string;\n version?: string;\n scheme?: 'xyz' | 'tms';\n tiles?: string[];\n /** `[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS. */\n boundingBox?: [min: [w: number, s: number], max: [e: number, n: number]];\n center: number[] | null;\n maxZoom: number | null;\n minZoom: number | null;\n htmlAttribution?: string;\n htmlLegend?: string;\n layers?: TileJSONLayer[];\n metaJson?: any | null;\n};\n\nexport type TileJSONLayer = {\n /** The name (id) of this layer (tilejson.vector_layers[].id / tilestats.layers[].layer) */\n name: string;\n\n /** The description of this layer (tilejson.layer.description) */\n description?: string;\n\n // tilestats\n\n /** The number of features in this layer (tilestats.layer.count) */\n featureCount?: number;\n /** The dominant geometry type in this layer (tilestats.layer.geometry) */\n dominantGeometry?: string;\n /** An array of details about the first 100 attributes in this layer */\n\n /** */\n minZoom?: number;\n maxZoom?: number;\n fields: TileJSONField[];\n};\n\nexport type TileJSONField = {\n /** The name of this attribute */\n name: string;\n description?: string;\n\n // tilestats\n\n type: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** An array of this attribute's first 100 unique values */\n values?: unknown[];\n};\n\n/**\n * The raw/unparsed tilestats layer type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayer = {\n /** The name of this layer */\n layer: string;\n /** The number of features in this layer */\n count: number;\n /** The dominant geometry type in this layer */\n geometry: string;\n /** The number of unique attributes in this layer (max. 1000) */\n attributeCount: number;\n /** Fields for this layer */\n attributes?: TilestatsLayerAttribute[];\n};\n\n/**\n * The raw/unparsed tilestats attribute type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayerAttribute = {\n /** The name of this layer */\n attribute?: string;\n /** Each attribute has one of the following types:\n * - 'string' if all its values are strings (or null).\n * - 'number' if all its values are numbers (or null).\n * - 'boolean' if all its values are booleans (or null).\n * - 'null' if its only value is null.\n * - 'mixed' if it has values of multiple types.\n * - Array and object values are coerced to strings.\n */\n type?: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n};\n\nconst isObject: (x: unknown) => boolean = (x) => x !== null && typeof x === 'object';\n\nexport function parseTileJSON(jsonMetadata: any): TileJSON | null {\n if (!jsonMetadata || !isObject(jsonMetadata)) {\n return null;\n }\n\n const boundingBox = parseBounds(jsonMetadata.bounds);\n const center = parseCenter(jsonMetadata.center);\n const maxZoom = safeParseFloat(jsonMetadata.maxzoom);\n const minZoom = safeParseFloat(jsonMetadata.minzoom);\n\n let tileJSON: TileJSON = {\n name: jsonMetadata.name || '',\n description: jsonMetadata.description || '',\n boundingBox,\n center,\n maxZoom,\n minZoom,\n layers: []\n };\n\n // try to parse json\n if (typeof jsonMetadata?.json === 'string') {\n try {\n tileJSON.metaJson = JSON.parse(jsonMetadata.json);\n } catch (err) {\n // do nothing\n }\n }\n\n let layers = parseTilestatsLayers(tileJSON.metaJson?.tilestats);\n // TODO - merge in description from tilejson\n if (layers.length === 0) {\n layers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase\n }\n\n tileJSON = {\n ...tileJSON,\n layers\n };\n\n return tileJSON;\n}\n\nfunction parseTileJSONLayers(layers: any[]): TileJSONLayer[] {\n // Look for fields in vector_layers\n if (!Array.isArray(layers)) {\n return [];\n }\n return layers.map((layer) => ({\n name: layer.id || '',\n fields: Object.entries(layer.fields || []).map(([key, datatype]) => ({\n name: key,\n ...attributeTypeToFieldType(String(datatype))\n }))\n }));\n}\n\n/** parse Layers array from tilestats */\nfunction parseTilestatsLayers(tilestats: any): TileJSONLayer[] {\n if (isObject(tilestats) && Array.isArray(tilestats.layers)) {\n // we are in luck!\n return tilestats.layers.map((layer) => parseTilestatsForLayer(layer));\n }\n return [];\n}\n\nfunction parseTilestatsForLayer(layer: TilestatsLayer): TileJSONLayer {\n const fields: TileJSONField[] = [];\n const indexedAttributes: {[key: string]: TilestatsLayerAttribute[]} = {};\n\n const attributes = layer.attributes || [];\n for (const attr of attributes) {\n const name = attr.attribute;\n if (typeof name === 'string') {\n if (name.split('|').length > 1) {\n // indexed field\n const fname = name.split('|')[0];\n indexedAttributes[fname] = indexedAttributes[fname] || [];\n indexedAttributes[fname].push(attr);\n } else if (!fields[name]) {\n fields[name] = attributeToField(attr);\n } else {\n // return (fields[name], attr);\n }\n }\n }\n return {\n name: layer.layer || '',\n dominantGeometry: layer.geometry,\n fields\n };\n}\n\n/**\n * bounds should be [minLng, minLat, maxLng, maxLat]\n *`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.\n */\nfunction parseBounds(\n bounds: string | number[]\n): [[east: number, south: number], [west: number, north: number]] | undefined {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]\n const result = fromArrayOrString(bounds);\n // validate bounds\n if (\n Array.isArray(result) &&\n result.length === 4 &&\n [result[0], result[2]].every(isLng) &&\n [result[1], result[3]].every(isLat)\n ) {\n return [\n [result[0], result[1]],\n [result[2], result[3]]\n ];\n }\n return undefined;\n}\n\nfunction parseCenter(center: string | number[]): number[] | null {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [-91.505127,41.615442,14]\n const result = fromArrayOrString(center);\n if (\n Array.isArray(result) &&\n result.length === 3 &&\n isLng(result[0]) &&\n isLat(result[1]) &&\n isZoom(result[2])\n ) {\n return result;\n }\n return null;\n}\n\nfunction safeParseFloat(input: unknown): number | null {\n const result =\n typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;\n return result === null || isNaN(result) ? null : result;\n}\n\n// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0\nfunction isLat(num: any): boolean {\n return Number.isFinite(num) && num <= 90 && num >= -90;\n}\nfunction isLng(num: any): boolean {\n return Number.isFinite(num) && num <= 180 && num >= -180;\n}\nfunction isZoom(num: any): boolean {\n return Number.isFinite(num) && num >= 0 && num <= 22;\n}\nfunction fromArrayOrString(data: string | number[]): number[] | null {\n if (typeof data === 'string') {\n return data.split(',').map(parseFloat);\n } else if (Array.isArray(data)) {\n return data;\n }\n return null;\n}\n\n// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes\nconst attrTypeMap = {\n number: {\n type: 'float32'\n },\n numeric: {\n type: 'float32'\n },\n string: {\n type: 'utf8'\n },\n vachar: {\n type: 'utf8'\n },\n float: {\n type: 'float32'\n },\n int: {\n type: 'int32'\n },\n int4: {\n type: 'int32'\n },\n boolean: {\n type: 'boolean'\n },\n bool: {\n type: 'boolean'\n }\n};\n\nfunction attributeToField(attribute: TilestatsLayerAttribute = {}): TileJSONField {\n // attribute: \"_season_peaks_color\"\n // count: 1000\n // max: 0.95\n // min: 0.24375\n // type: \"number\"\n const fieldTypes = attributeTypeToFieldType(attribute.type!);\n return {\n name: attribute.attribute as string,\n // what happens if attribute type is string...\n // filterProps: getFilterProps(fieldTypes.type, attribute),\n ...fieldTypes\n };\n}\n\nfunction attributeTypeToFieldType(aType: string): {type: string} {\n const type = aType.toLowerCase();\n if (!type || !attrTypeMap[type]) {\n // console.warn(\n // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`\n // );\n }\n return attrTypeMap[type] || {type: 'string'};\n}\n"],"mappings":"AAiGA,MAAMA,QAAiC,GAAIC,CAAC,IAAKA,CAAC,KAAK,IAAI,IAAI,OAAOA,CAAC,KAAK,QAAQ;AAEpF,OAAO,SAASC,aAAaA,CAACC,YAAiB,EAAmB;EAAA,IAAAC,kBAAA;EAChE,IAAI,CAACD,YAAY,IAAI,CAACH,QAAQ,CAACG,YAAY,CAAC,EAAE;IAC5C,OAAO,IAAI;EACb;EAEA,MAAME,WAAW,GAAGC,WAAW,CAACH,YAAY,CAACI,MAAM,CAAC;EACpD,MAAMC,MAAM,GAAGC,WAAW,CAACN,YAAY,CAACK,MAAM,CAAC;EAC/C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CAAC;EACDM,IAAI,EAAE;IACJN,IAAI,EAAE;EACR,CAAC;EACDO,OAAO,EAAE;IACPP,IAAI,EAAE;EACR,CAAC;EACDQ,IAAI,EAAE;IACJR,IAAI,EAAE;EACR;AACF,CAAC;AAED,SAASnB,gBAAgBA,CAAA,EAAyD;EAAA,IAAxDJ,SAAkC,GAAAgC,SAAA,CAAApD,MAAA,QAAAoD,SAAA,QAAApB,SAAA,GAAAoB,SAAA,MAAG,CAAC,CAAC;EAM/D,MAAMC,UAAU,GAAGvC,wBAAwB,CAACM,SAAS,CAACuB,IAAK,CAAC;EAC5D,OAAO;IACLrD,IAAI,EAAE8B,SAAS,CAACA,SAAmB;IAGnC,GAAGiC;EACL,CAAC;AACH;AAEA,SAASvC,wBAAwBA,CAACwC,KAAa,EAAkB;EAC/D,MAAMX,IAAI,GAAGW,KAAK,CAACC,WAAW,CAAC,CAAC;EAChC,IAAI,CAACZ,IAAI,IAAI,CAACF,WAAW,CAACE,IAAI,CAAC,EAAE,CAIjC;EACA,OAAOF,WAAW,CAACE,IAAI,CAAC,IAAI;IAACA,IAAI,EAAE;EAAQ,CAAC;AAC9C"}
|
|
1
|
+
{"version":3,"file":"parse-tilejson.js","names":["isObject","x","parseTileJSON","jsonMetadata","options","_tileJSON$metaJson","tileJSON","name","description","generator","generator_options","generatorOptions","boundingBox","parseBounds","bounds","antimeridian_adjusted_bounds","center","parseCenter","maxZoom","safeParseFloat","maxzoom","minZoom","minzoom","json","metaJson","JSON","parse","error","console","warn","tilestats","tileStatsLayers","parseTilestatsLayers","tileJSONlayers","parseTileJSONLayers","vector_layers","layers","mergeLayers","length","Array","isArray","map","layer","parseTileJSONLayer","fields","Object","entries","_ref","key","datatype","attributeTypeToFieldType","String","layer2","id","parseTilestatsForLayer","indexedAttributes","attributes","attribute","split","fname","push","attributeToField","dominantGeometry","geometry","tilestatsLayers","tilestatsLayer","find","tsLayer","result","fromArrayOrString","every","isLng","isLat","undefined","isZoom","input","parseFloat","isNaN","num","Number","isFinite","data","attrTypeMap","number","type","numeric","string","vachar","float","int","int4","boolean","bool","arguments","fieldTypes","field","min","max","count","uniqueValueCount","maxValues","values","_attribute$values","slice","aType","toLowerCase"],"sources":["../../src/lib/parse-tilejson.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nexport type TileJSONOptions = {\n maxValues?: number | false;\n};\n\n/** Parsed and typed TileJSON, merges Tilestats information if present */\nexport type TileJSON = {\n name?: string;\n description?: string;\n version?: string;\n\n tileFormat?: string;\n tilesetType?: string;\n\n /** Generating application. Tippecanoe adds this. */\n generator?: string;\n /** Generating application options. Tippecanoe adds this. */\n generatorOptions?: string;\n\n /** Tile indexing scheme */\n scheme?: 'xyz' | 'tms';\n /** Sharded URLs */\n tiles?: string[];\n /** `[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS. */\n boundingBox?: [min: [w: number, s: number], max: [e: number, n: number]];\n /** May be set to the maxZoom of the first layer */\n maxZoom?: number | null;\n /** May be set to the minZoom of the first layer */\n minZoom?: number | null;\n center?: number[] | null;\n htmlAttribution?: string;\n htmlLegend?: string;\n\n // Combination of tilestats (if present) and tilejson layer information\n layers?: TileJSONLayer[];\n\n /** Any nested JSON metadata */\n metaJson?: any | null;\n};\n\nexport type TileJSONLayer = {\n /** The name (id) of this layer (tilejson.vector_layers[].id / tilestats.layers[].layer) */\n name: string;\n\n /** The description of this layer (tilejson.layer.description) */\n description?: string;\n\n // tilestats\n\n /** The number of features in this layer (tilestats.layer.count) */\n featureCount?: number;\n /** The dominant geometry type in this layer (tilestats.layer.geometry) */\n dominantGeometry?: string;\n /** An array of details about the first 100 attributes in this layer */\n\n /** */\n minZoom?: number;\n maxZoom?: number;\n fields: TileJSONField[];\n};\n\nexport type TileJSONField = {\n /** The name of this attribute */\n name: string;\n description?: string;\n\n // tilestats\n\n type: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** Number of unique values across the tileset */\n uniqueValueCount?: number;\n /** An array of this attribute's first 100 unique values */\n values?: unknown[];\n};\n\n/**\n * The raw/unparsed tilestats layer type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayer = {\n /** The name of this layer */\n layer: string;\n /** The number of features in this layer */\n count: number;\n /** The dominant geometry type in this layer */\n geometry: string;\n /** The number of unique attributes in this layer (max. 1000) */\n attributeCount: number;\n /** Fields for this layer */\n attributes?: TilestatsLayerAttribute[];\n};\n\n/**\n * The raw/unparsed tilestats attribute type\n * @see https://github.com/mapbox/mapbox-geostats#output-the-stats\n */\ntype TilestatsLayerAttribute = {\n /** The name of this layer */\n attribute?: string;\n /** Each attribute has one of the following types:\n * - 'string' if all its values are strings (or null).\n * - 'number' if all its values are numbers (or null).\n * - 'boolean' if all its values are booleans (or null).\n * - 'null' if its only value is null.\n * - 'mixed' if it has values of multiple types.\n * - Array and object values are coerced to strings.\n */\n type?: string;\n /** min value (if there are *any* numbers in the values) */\n min?: number;\n /** max value (if there are *any* numbers in the values) */\n max?: number;\n /** Number of unique values */\n count?: number;\n /** First 100 values */\n values?: unknown[];\n};\n\nconst isObject: (x: unknown) => boolean = (x) => x !== null && typeof x === 'object';\n\nexport function parseTileJSON(jsonMetadata: any, options: TileJSONOptions): TileJSON | null {\n if (!jsonMetadata || !isObject(jsonMetadata)) {\n return null;\n }\n\n let tileJSON: TileJSON = {\n name: jsonMetadata.name || '',\n description: jsonMetadata.description || ''\n };\n\n // tippecanoe\n\n if (typeof jsonMetadata.generator === 'string') {\n tileJSON.generator = jsonMetadata.generator;\n }\n if (typeof jsonMetadata.generator_options === 'string') {\n tileJSON.generatorOptions = jsonMetadata.generator_options;\n }\n\n // Tippecanoe emits `antimeridian_adjusted_bounds` instead of `bounds`\n tileJSON.boundingBox =\n parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);\n\n // TODO - can be undefined - we could set to center of bounds...\n tileJSON.center = parseCenter(jsonMetadata.center);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);\n // TODO - can be undefined, we could extract from layers...\n tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);\n\n // Look for nested metadata embedded in .json field\n // TODO - document what source this applies to, when is this needed?\n if (typeof jsonMetadata?.json === 'string') {\n // try to parse json\n try {\n tileJSON.metaJson = JSON.parse(jsonMetadata.json);\n } catch (error) {\n console.warn('Failed to parse tilejson.json field', error);\n // do nothing\n }\n }\n\n // Look for fields in tilestats\n\n const tilestats = jsonMetadata.tilestats || tileJSON.metaJson?.tilestats;\n const tileStatsLayers = parseTilestatsLayers(tilestats, options);\n const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase\n // TODO - merge in description from tilejson\n const layers = mergeLayers(tileJSONlayers, tileStatsLayers);\n\n tileJSON = {\n ...tileJSON,\n layers\n };\n\n if (tileJSON.maxZoom === null && layers.length > 0) {\n tileJSON.maxZoom = layers[0].maxZoom || null;\n }\n\n if (tileJSON.minZoom === null && layers.length > 0) {\n tileJSON.minZoom = layers[0].minZoom || null;\n }\n\n return tileJSON;\n}\n\nfunction parseTileJSONLayers(layers: any[]): TileJSONLayer[] {\n // Look for fields in vector_layers\n if (!Array.isArray(layers)) {\n return [];\n }\n return layers.map((layer) => parseTileJSONLayer(layer));\n}\n\nfunction parseTileJSONLayer(layer: any): TileJSONLayer {\n const fields = Object.entries(layer.fields || []).map(([key, datatype]) => ({\n name: key,\n ...attributeTypeToFieldType(String(datatype))\n }));\n const layer2 = {...layer};\n delete layer2.fields;\n return {\n name: layer.id || '',\n ...layer2,\n fields\n };\n}\n\n/** parse Layers array from tilestats */\nfunction parseTilestatsLayers(tilestats: any, options: TileJSONOptions): TileJSONLayer[] {\n if (isObject(tilestats) && Array.isArray(tilestats.layers)) {\n // we are in luck!\n return tilestats.layers.map((layer) => parseTilestatsForLayer(layer, options));\n }\n return [];\n}\n\nfunction parseTilestatsForLayer(layer: TilestatsLayer, options: TileJSONOptions): TileJSONLayer {\n const fields: TileJSONField[] = [];\n const indexedAttributes: {[key: string]: TilestatsLayerAttribute[]} = {};\n\n const attributes = layer.attributes || [];\n for (const attribute of attributes) {\n const name = attribute.attribute;\n if (typeof name === 'string') {\n // TODO - code copied from kepler.gl, need sample tilestats files to test\n if (name.split('|').length > 1) {\n // indexed field\n const fname = name.split('|')[0];\n indexedAttributes[fname] = indexedAttributes[fname] || [];\n indexedAttributes[fname].push(attribute);\n // eslint-disable-next-line no-console\n console.warn('ignoring tilestats indexed field', fname);\n } else if (!fields[name]) {\n fields.push(attributeToField(attribute, options));\n } else {\n // return (fields[name], attribute);\n }\n }\n }\n return {\n name: layer.layer || '',\n dominantGeometry: layer.geometry,\n fields\n };\n}\n\nfunction mergeLayers(layers: TileJSONLayer[], tilestatsLayers: TileJSONLayer[]): TileJSONLayer[] {\n return layers.map((layer) => {\n const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);\n // For aesthetics in JSON dumps, we preserve field order (make sure layers is last)\n const fields = tilestatsLayer?.fields || [];\n const layer2: Partial<TileJSONLayer> = {...layer};\n delete layer2.fields;\n return {\n ...layer2,\n ...tilestatsLayer,\n fields\n } as TileJSONLayer;\n });\n}\n\n/**\n * bounds should be [minLng, minLat, maxLng, maxLat]\n *`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.\n */\nfunction parseBounds(\n bounds: string | number[]\n): [[east: number, south: number], [west: number, north: number]] | undefined {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]\n const result = fromArrayOrString(bounds);\n // validate bounds\n if (\n Array.isArray(result) &&\n result.length === 4 &&\n [result[0], result[2]].every(isLng) &&\n [result[1], result[3]].every(isLat)\n ) {\n return [\n [result[0], result[1]],\n [result[2], result[3]]\n ];\n }\n return undefined;\n}\n\nfunction parseCenter(center: string | number[]): number[] | null {\n // supported formats\n // string: \"-96.657715,40.126127,-90.140061,43.516689\",\n // array: [-91.505127,41.615442,14]\n const result = fromArrayOrString(center);\n if (\n Array.isArray(result) &&\n result.length === 3 &&\n isLng(result[0]) &&\n isLat(result[1]) &&\n isZoom(result[2])\n ) {\n return result;\n }\n return null;\n}\n\nfunction safeParseFloat(input: unknown): number | null {\n const result =\n typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;\n return result === null || isNaN(result) ? null : result;\n}\n\n// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0\nfunction isLat(num: any): boolean {\n return Number.isFinite(num) && num <= 90 && num >= -90;\n}\nfunction isLng(num: any): boolean {\n return Number.isFinite(num) && num <= 180 && num >= -180;\n}\nfunction isZoom(num: any): boolean {\n return Number.isFinite(num) && num >= 0 && num <= 22;\n}\nfunction fromArrayOrString(data: string | number[]): number[] | null {\n if (typeof data === 'string') {\n return data.split(',').map(parseFloat);\n } else if (Array.isArray(data)) {\n return data;\n }\n return null;\n}\n\n// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes\nconst attrTypeMap = {\n number: {\n type: 'float32'\n },\n numeric: {\n type: 'float32'\n },\n string: {\n type: 'utf8'\n },\n vachar: {\n type: 'utf8'\n },\n float: {\n type: 'float32'\n },\n int: {\n type: 'int32'\n },\n int4: {\n type: 'int32'\n },\n boolean: {\n type: 'boolean'\n },\n bool: {\n type: 'boolean'\n }\n};\n\nfunction attributeToField(\n attribute: TilestatsLayerAttribute = {},\n options: TileJSONOptions\n): TileJSONField {\n const fieldTypes = attributeTypeToFieldType(attribute.type!);\n const field: TileJSONField = {\n name: attribute.attribute as string,\n // what happens if attribute type is string...\n // filterProps: getFilterProps(fieldTypes.type, attribute),\n ...fieldTypes\n };\n\n // attribute: \"_season_peaks_color\"\n // count: 1000\n // max: 0.95\n // min: 0.24375\n // type: \"number\"\n\n if (typeof attribute.min === 'number') {\n field.min = attribute.min;\n }\n if (typeof attribute.max === 'number') {\n field.max = attribute.max;\n }\n if (typeof attribute.count === 'number') {\n field.uniqueValueCount = attribute.count;\n }\n if (options.maxValues !== false && attribute.values) {\n // Too much data? Add option?\n field.values = attribute.values?.slice(0, options.maxValues);\n }\n return field;\n}\n\nfunction attributeTypeToFieldType(aType: string): {type: string} {\n const type = aType.toLowerCase();\n if (!type || !attrTypeMap[type]) {\n // console.warn(\n // `cannot convert attribute type ${type} to loaders.gl data type, use string by default`\n // );\n }\n return attrTypeMap[type] || {type: 'string'};\n}\n"],"mappings":"AA4HA,MAAMA,QAAiC,GAAIC,CAAC,IAAKA,CAAC,KAAK,IAAI,IAAI,OAAOA,CAAC,KAAK,QAAQ;AAEpF,OAAO,SAASC,aAAaA,CAACC,YAAiB,EAAEC,OAAwB,EAAmB;EAAA,IAAAC,kBAAA;EAC1F,IAAI,CAACF,YAAY,IAAI,CAACH,QAAQ,CAACG,YAAY,CAAC,EAAE;IAC5C,OAAO,IAAI;EACb;EAEA,IAAIG,QAAkB,GAAG;IACvBC,IAAI,EAAEJ,YAAY,CAACI,IAAI,IAAI,EAAE;IAC7BC,WAAW,EAAEL,YAAY,CAACK,WAAW,IAAI;EAC3C,CAAC;EAID,IAAI,OAAOL,YAAY,CAACM,SAAS,KAAK,QAAQ,EAAE;IAC9CH,QAAQ,CAACG,SAAS,GAAGN,YAAY,CAACM,SAAS;EAC7C;EACA,IAAI,OAAON,YAAY,CAACO,iBAAiB,KAAK,QAAQ,EAAE;IACtDJ,QAAQ,CAACK,gBAAgB,GAAGR,YAAY,CAACO,iBAAiB;EAC5D;EAGAJ,QAAQ,CAACM,WAAW,GAClBC,WAAW,CAACV,YAAY,CAACW,MAAM,CAAC,IAAID,WAAW,CAACV,YAAY,CAACY,4BAA4B,CAAC;EAG5FT,QAAQ,CAACU,MAAM,GAAGC,WAAW,CAACd,YAAY,CAACa,MAAM,CAAC;EAElDV,QAAQ,CAACY,OAAO,GAAGC,cAAc,CAAChB,YAAY,CAACiB,OAAO,CAAC;E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WAAW,CAACE,IAAI,CAAC,IAAI;IAACA,IAAI,EAAE;EAAQ,CAAC;AAC9C"}
|
package/dist/mvt-source.d.ts
CHANGED
|
@@ -14,14 +14,21 @@ export type MVTSourceProps = DataSourceProps & {
|
|
|
14
14
|
export declare class MVTSource extends DataSource implements ImageTileSource, VectorTileSource {
|
|
15
15
|
props: MVTSourceProps;
|
|
16
16
|
url: string;
|
|
17
|
+
data: string;
|
|
17
18
|
schema: 'tms' | 'xyz';
|
|
18
19
|
metadata: Promise<TileJSON | null>;
|
|
20
|
+
extension: string;
|
|
21
|
+
mimeType: string | null;
|
|
19
22
|
constructor(props: MVTSourceProps);
|
|
20
23
|
getMetadata(): Promise<TileJSON | null>;
|
|
24
|
+
getTileMIMEType(): string | null;
|
|
21
25
|
getTile(tileParams: GetTileParameters): Promise<ArrayBuffer | null>;
|
|
22
26
|
getTileData(tileParams: TileLoadParameters): Promise<unknown | null>;
|
|
27
|
+
x: any;
|
|
23
28
|
getImageTile(tileParams: GetTileParameters): Promise<ImageType | null>;
|
|
29
|
+
protected parseImageTile(arrayBuffer: ArrayBuffer): Promise<ImageType>;
|
|
24
30
|
getVectorTile(tileParams: GetTileParameters): Promise<unknown | null>;
|
|
31
|
+
protected parseVectorTile(arrayBuffer: ArrayBuffer, tileParams: GetTileParameters): Promise<unknown | null>;
|
|
25
32
|
getMetadataUrl(): string;
|
|
26
33
|
getTileURL(x: number, y: number, z: number): string;
|
|
27
34
|
}
|
package/dist/mvt-source.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvt-source.d.ts","sourceRoot":"","sources":["../src/mvt-source.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAC,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,EAAC,eAAe,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAC,UAAU,EAAc,MAAM,0BAA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E,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACnC,SAAS,SAAU;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAQ;gBAEnB,KAAK,EAAE,cAAc;IAU3B,WAAW,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAuB7C,eAAe,IAAI,MAAM,GAAG,IAAI;IAI1B,OAAO,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAcnE,WAAW,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAoB1E,CAAC,MAAC;IAII,YAAY,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;cAK5D,cAAc,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC;IAMtE,aAAa,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;cAK3D,eAAe,CAC7B,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAc1B,cAAc,IAAI,MAAM;IAIxB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAS3C"}
|
package/dist/mvt-source.js
CHANGED
|
@@ -1,29 +1,44 @@
|
|
|
1
1
|
import { DataSource, resolvePath } from '@loaders.gl/loader-utils';
|
|
2
|
-
import { ImageLoader } from '@loaders.gl/images';
|
|
2
|
+
import { ImageLoader, getBinaryImageMetadata } from '@loaders.gl/images';
|
|
3
3
|
import { MVTLoader, TileJSONLoader } from '@loaders.gl/mvt';
|
|
4
4
|
export class MVTSource extends DataSource {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
7
|
this.props = void 0;
|
|
8
8
|
this.url = void 0;
|
|
9
|
+
this.data = void 0;
|
|
9
10
|
this.schema = 'tms';
|
|
10
11
|
this.metadata = void 0;
|
|
12
|
+
this.extension = '.png';
|
|
13
|
+
this.mimeType = null;
|
|
14
|
+
this.x = void 0;
|
|
11
15
|
this.props = props;
|
|
12
16
|
this.url = resolvePath(props.url);
|
|
17
|
+
this.data = this.url;
|
|
13
18
|
this.getTileData = this.getTileData.bind(this);
|
|
14
19
|
this.metadata = this.getMetadata();
|
|
15
20
|
}
|
|
16
21
|
async getMetadata() {
|
|
17
22
|
var _TileJSONLoader$parse;
|
|
18
23
|
const metadataUrl = this.getMetadataUrl();
|
|
19
|
-
|
|
24
|
+
let response;
|
|
25
|
+
try {
|
|
26
|
+
response = await this.fetch(metadataUrl);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(error.message);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
20
31
|
if (!response.ok) {
|
|
32
|
+
console.error(response.statusText);
|
|
21
33
|
return null;
|
|
22
34
|
}
|
|
23
35
|
const tileJSON = await response.text();
|
|
24
36
|
const metadata = ((_TileJSONLoader$parse = TileJSONLoader.parseTextSync) === null || _TileJSONLoader$parse === void 0 ? void 0 : _TileJSONLoader$parse.call(TileJSONLoader, JSON.stringify(tileJSON))) || null;
|
|
25
37
|
return metadata;
|
|
26
38
|
}
|
|
39
|
+
getTileMIMEType() {
|
|
40
|
+
return this.mimeType;
|
|
41
|
+
}
|
|
27
42
|
async getTile(tileParams) {
|
|
28
43
|
const {
|
|
29
44
|
x,
|
|
@@ -44,31 +59,42 @@ export class MVTSource extends DataSource {
|
|
|
44
59
|
y,
|
|
45
60
|
z
|
|
46
61
|
} = tileParams.index;
|
|
47
|
-
const
|
|
48
|
-
|
|
62
|
+
const arrayBuffer = await this.getTile({
|
|
63
|
+
x,
|
|
64
|
+
y,
|
|
65
|
+
zoom: z,
|
|
66
|
+
layers: []
|
|
67
|
+
});
|
|
68
|
+
if (arrayBuffer === null) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const imageMetadata = getBinaryImageMetadata(arrayBuffer);
|
|
72
|
+
this.mimeType = this.mimeType || (imageMetadata === null || imageMetadata === void 0 ? void 0 : imageMetadata.mimeType) || 'application/vnd.mapbox-vector-tile';
|
|
73
|
+
switch (this.mimeType) {
|
|
49
74
|
case 'application/vnd.mapbox-vector-tile':
|
|
50
|
-
return await this.
|
|
75
|
+
return await this.parseVectorTile(arrayBuffer, {
|
|
51
76
|
x,
|
|
52
77
|
y,
|
|
53
78
|
zoom: z,
|
|
54
79
|
layers: []
|
|
55
80
|
});
|
|
56
81
|
default:
|
|
57
|
-
return await this.
|
|
58
|
-
x,
|
|
59
|
-
y,
|
|
60
|
-
zoom: z,
|
|
61
|
-
layers: []
|
|
62
|
-
});
|
|
82
|
+
return await this.parseImageTile(arrayBuffer);
|
|
63
83
|
}
|
|
64
84
|
}
|
|
65
85
|
async getImageTile(tileParams) {
|
|
66
86
|
const arrayBuffer = await this.getTile(tileParams);
|
|
67
|
-
return arrayBuffer ?
|
|
87
|
+
return arrayBuffer ? this.parseImageTile(arrayBuffer) : null;
|
|
88
|
+
}
|
|
89
|
+
async parseImageTile(arrayBuffer) {
|
|
90
|
+
return await ImageLoader.parse(arrayBuffer, this.loadOptions);
|
|
68
91
|
}
|
|
69
92
|
async getVectorTile(tileParams) {
|
|
70
|
-
var _this$loadOptions;
|
|
71
93
|
const arrayBuffer = await this.getTile(tileParams);
|
|
94
|
+
return arrayBuffer ? this.parseVectorTile(arrayBuffer, tileParams) : null;
|
|
95
|
+
}
|
|
96
|
+
async parseVectorTile(arrayBuffer, tileParams) {
|
|
97
|
+
var _this$loadOptions;
|
|
72
98
|
const loadOptions = {
|
|
73
99
|
shape: 'geojson-table',
|
|
74
100
|
mvt: {
|
|
@@ -82,7 +108,7 @@ export class MVTSource extends DataSource {
|
|
|
82
108
|
},
|
|
83
109
|
...this.loadOptions
|
|
84
110
|
};
|
|
85
|
-
return
|
|
111
|
+
return await MVTLoader.parse(arrayBuffer, loadOptions);
|
|
86
112
|
}
|
|
87
113
|
getMetadataUrl() {
|
|
88
114
|
return `${this.url}/tilejson.json`;
|
|
@@ -90,10 +116,10 @@ export class MVTSource extends DataSource {
|
|
|
90
116
|
getTileURL(x, y, z) {
|
|
91
117
|
switch (this.schema) {
|
|
92
118
|
case 'xyz':
|
|
93
|
-
return `${this.url}/${x}/${y}/${z}`;
|
|
119
|
+
return `${this.url}/${x}/${y}/${z}${this.extension}`;
|
|
94
120
|
case 'tms':
|
|
95
121
|
default:
|
|
96
|
-
return `${this.url}/${z}/${x}/${y}`;
|
|
122
|
+
return `${this.url}/${z}/${x}/${y}${this.extension}`;
|
|
97
123
|
}
|
|
98
124
|
}
|
|
99
125
|
}
|
package/dist/mvt-source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvt-source.js","names":["DataSource","resolvePath","ImageLoader","MVTLoader","TileJSONLoader","MVTSource","constructor","props","url","schema","metadata","getTileData","bind","getMetadata","_TileJSONLoader$parse","metadataUrl","getMetadataUrl","response","fetch","ok","tileJSON","text","parseTextSync","call","JSON","stringify","
|
|
1
|
+
{"version":3,"file":"mvt-source.js","names":["DataSource","resolvePath","ImageLoader","getBinaryImageMetadata","MVTLoader","TileJSONLoader","MVTSource","constructor","props","url","data","schema","metadata","extension","mimeType","x","getTileData","bind","getMetadata","_TileJSONLoader$parse","metadataUrl","getMetadataUrl","response","fetch","error","console","message","ok","statusText","tileJSON","text","parseTextSync","call","JSON","stringify","getTileMIMEType","getTile","tileParams","y","zoom","z","tileUrl","getTileURL","arrayBuffer","index","layers","imageMetadata","parseVectorTile","parseImageTile","getImageTile","parse","loadOptions","getVectorTile","_this$loadOptions","shape","mvt","coordinates","tileIndex"],"sources":["../src/mvt-source.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {GetTileParameters, ImageType, DataSourceProps} from '@loaders.gl/loader-utils';\nimport type {ImageTileSource, VectorTileSource} from '@loaders.gl/loader-utils';\nimport {DataSource, resolvePath} from '@loaders.gl/loader-utils';\nimport {ImageLoader, getBinaryImageMetadata} from '@loaders.gl/images';\nimport {MVTLoader, MVTLoaderOptions, TileJSONLoader, TileJSON} from '@loaders.gl/mvt';\n\nimport {TileLoadParameters} from '@loaders.gl/loader-utils';\n\nexport type MVTSourceProps = DataSourceProps & {\n url: string;\n attributions?: string[];\n};\n\n/**\n * A PMTiles data source\n * @note Can be either a raster or vector tile source depending on the contents of the PMTiles file.\n */\nexport class MVTSource extends DataSource implements ImageTileSource, VectorTileSource {\n props: MVTSourceProps;\n url: string;\n data: string;\n schema: 'tms' | 'xyz' = 'tms';\n metadata: Promise<TileJSON | null>;\n extension = '.png';\n mimeType: string | null = null;\n\n constructor(props: MVTSourceProps) {\n super(props);\n this.props = props;\n this.url = resolvePath(props.url);\n this.data = this.url;\n this.getTileData = this.getTileData.bind(this);\n this.metadata = this.getMetadata();\n }\n\n // @ts-ignore - Metadata type misalignment\n async getMetadata(): Promise<TileJSON | null> {\n const metadataUrl = this.getMetadataUrl();\n let response: Response;\n try {\n // Annoyingly, fetch throws on CORS errors which is common when requesting an unavailable resource\n response = await this.fetch(metadataUrl);\n } catch (error: unknown) {\n console.error((error as TypeError).message);\n return null;\n }\n if (!response.ok) {\n console.error(response.statusText);\n return null;\n }\n const tileJSON = await response.text();\n const metadata = TileJSONLoader.parseTextSync?.(JSON.stringify(tileJSON)) || null;\n // metadata.attributions = [...this.props.attributions, ...(metadata.attributions || [])];\n // if (metadata?.mimeType) {\n // this.mimeType = metadata?.tileMIMEType;\n // }\n return metadata;\n }\n\n getTileMIMEType(): string | null {\n return this.mimeType;\n }\n\n async getTile(tileParams: GetTileParameters): Promise<ArrayBuffer | null> {\n const {x, y, zoom: z} = tileParams;\n const tileUrl = this.getTileURL(x, y, z);\n const response = await this.fetch(tileUrl);\n if (!response.ok) {\n return null;\n }\n const arrayBuffer = await response.arrayBuffer();\n return arrayBuffer;\n }\n\n // Tile Source interface implementation: deck.gl compatible API\n // TODO - currently only handles image tiles, not vector tiles\n\n async getTileData(tileParams: TileLoadParameters): Promise<unknown | null> {\n const {x, y, z} = tileParams.index;\n // const metadata = await this.metadata;\n // mimeType = metadata?.tileMIMEType || 'application/vnd.mapbox-vector-tile';\n\n const arrayBuffer = await this.getTile({x, y, zoom: z, layers: []});\n if (arrayBuffer === null) {\n return null;\n }\n\n const imageMetadata = getBinaryImageMetadata(arrayBuffer);\n this.mimeType =\n this.mimeType || imageMetadata?.mimeType || 'application/vnd.mapbox-vector-tile';\n switch (this.mimeType) {\n case 'application/vnd.mapbox-vector-tile':\n return await this.parseVectorTile(arrayBuffer, {x, y, zoom: z, layers: []});\n default:\n return await this.parseImageTile(arrayBuffer);\n }\n }\n x;\n\n // ImageTileSource interface implementation\n\n async getImageTile(tileParams: GetTileParameters): Promise<ImageType | null> {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? this.parseImageTile(arrayBuffer) : null;\n }\n\n protected async parseImageTile(arrayBuffer: ArrayBuffer): Promise<ImageType> {\n return await ImageLoader.parse(arrayBuffer, this.loadOptions);\n }\n\n // VectorTileSource interface implementation\n\n async getVectorTile(tileParams: GetTileParameters): Promise<unknown | null> {\n const arrayBuffer = await this.getTile(tileParams);\n return arrayBuffer ? this.parseVectorTile(arrayBuffer, tileParams) : null;\n }\n\n protected async parseVectorTile(\n arrayBuffer: ArrayBuffer,\n tileParams: GetTileParameters\n ): Promise<unknown | null> {\n const loadOptions: MVTLoaderOptions = {\n shape: 'geojson-table',\n mvt: {\n coordinates: 'wgs84',\n tileIndex: {x: tileParams.x, y: tileParams.y, z: tileParams.zoom},\n ...(this.loadOptions as MVTLoaderOptions)?.mvt\n },\n ...this.loadOptions\n };\n\n return await MVTLoader.parse(arrayBuffer, loadOptions);\n }\n\n getMetadataUrl(): string {\n return `${this.url}/tilejson.json`;\n }\n\n getTileURL(x: number, y: number, z: number) {\n switch (this.schema) {\n case 'xyz':\n return `${this.url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EE,CAAC,EAAEH,UAAU,CAACE;QAAI,CAAC;QACjE,KAAAc,iBAAA,GAAI,IAAI,CAACF,WAAW,cAAAE,iBAAA,uBAAjBA,iBAAA,CAAwCE,GAAG;MAChD,CAAC;MACD,GAAG,IAAI,CAACJ;IACV,CAAC;IAED,OAAO,MAAM/C,SAAS,CAAC8C,KAAK,CAACP,WAAW,EAAEQ,WAAW,CAAC;EACxD;EAEA9B,cAAcA,CAAA,EAAW;IACvB,OAAQ,GAAE,IAAI,CAACZ,GAAI,gBAAe;EACpC;EAEAiC,UAAUA,CAAC3B,CAAS,EAAEuB,CAAS,EAAEE,CAAS,EAAE;IAC1C,QAAQ,IAAI,CAAC7B,MAAM;MACjB,KAAK,KAAK;QACR,OAAQ,GAAE,IAAI,CAACF,GAAI,IAAGM,CAAE,IAAGuB,CAAE,IAAGE,CAAE,GAAE,IAAI,CAAC3B,SAAU,EAAC;MACtD,KAAK,KAAK;MACV;QACE,OAAQ,GAAE,IAAI,CAACJ,GAAI,IAAG+B,CAAE,IAAGzB,CAAE,IAAGuB,CAAE,GAAE,IAAI,CAACzB,SAAU,EAAC;IACxD;EACF;AACF"}
|
package/dist/mvt-worker.js
CHANGED
|
@@ -1325,7 +1325,7 @@
|
|
|
1325
1325
|
}
|
|
1326
1326
|
};
|
|
1327
1327
|
|
|
1328
|
-
// ../gis/src/lib/flat-geojson-to-binary.ts
|
|
1328
|
+
// ../gis/src/lib/binary-features/flat-geojson-to-binary.ts
|
|
1329
1329
|
function flatGeojsonToBinary(features, geometryInfo, options) {
|
|
1330
1330
|
const propArrayTypes = extractNumericPropTypes(features);
|
|
1331
1331
|
const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
|
|
@@ -2303,7 +2303,7 @@
|
|
|
2303
2303
|
}
|
|
2304
2304
|
|
|
2305
2305
|
// src/mvt-loader.ts
|
|
2306
|
-
var VERSION = true ? "4.0.
|
|
2306
|
+
var VERSION = true ? "4.0.2" : "latest";
|
|
2307
2307
|
var MVTWorkerLoader = {
|
|
2308
2308
|
name: "Mapbox Vector Tile",
|
|
2309
2309
|
id: "mvt",
|
|
@@ -2372,61 +2372,69 @@
|
|
|
2372
2372
|
}
|
|
2373
2373
|
|
|
2374
2374
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
2375
|
-
function getParentPort() {
|
|
2375
|
+
async function getParentPort() {
|
|
2376
2376
|
let parentPort;
|
|
2377
2377
|
try {
|
|
2378
2378
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
2379
2379
|
parentPort = globalThis.parentPort;
|
|
2380
2380
|
} catch {
|
|
2381
|
+
try {
|
|
2382
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
2383
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
2384
|
+
parentPort = workerThreads.parentPort;
|
|
2385
|
+
} catch (error) {
|
|
2386
|
+
console.error(error.message);
|
|
2387
|
+
}
|
|
2381
2388
|
}
|
|
2382
2389
|
return parentPort;
|
|
2383
2390
|
}
|
|
2384
2391
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
2385
2392
|
var WorkerBody = class {
|
|
2386
2393
|
/** Check that we are actually in a worker thread */
|
|
2387
|
-
static inWorkerThread() {
|
|
2388
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
2394
|
+
static async inWorkerThread() {
|
|
2395
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
2389
2396
|
}
|
|
2390
2397
|
/*
|
|
2391
2398
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
2392
2399
|
*/
|
|
2393
2400
|
static set onmessage(onMessage) {
|
|
2394
|
-
function handleMessage(message) {
|
|
2395
|
-
const
|
|
2396
|
-
const { type, payload } =
|
|
2401
|
+
async function handleMessage(message) {
|
|
2402
|
+
const parentPort2 = await getParentPort();
|
|
2403
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
2397
2404
|
onMessage(type, payload);
|
|
2398
2405
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
+
getParentPort().then((parentPort2) => {
|
|
2407
|
+
if (parentPort2) {
|
|
2408
|
+
parentPort2.on("message", handleMessage);
|
|
2409
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
2410
|
+
} else {
|
|
2411
|
+
globalThis.onmessage = handleMessage;
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2406
2414
|
}
|
|
2407
|
-
static addEventListener(onMessage) {
|
|
2415
|
+
static async addEventListener(onMessage) {
|
|
2408
2416
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
2409
2417
|
if (!onMessageWrapper) {
|
|
2410
|
-
onMessageWrapper = (message) => {
|
|
2418
|
+
onMessageWrapper = async (message) => {
|
|
2411
2419
|
if (!isKnownMessage(message)) {
|
|
2412
2420
|
return;
|
|
2413
2421
|
}
|
|
2414
|
-
const parentPort3 = getParentPort();
|
|
2422
|
+
const parentPort3 = await getParentPort();
|
|
2415
2423
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
2416
2424
|
onMessage(type, payload);
|
|
2417
2425
|
};
|
|
2418
2426
|
}
|
|
2419
|
-
const parentPort2 = getParentPort();
|
|
2427
|
+
const parentPort2 = await getParentPort();
|
|
2420
2428
|
if (parentPort2) {
|
|
2421
2429
|
console.error("not implemented");
|
|
2422
2430
|
} else {
|
|
2423
2431
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
2424
2432
|
}
|
|
2425
2433
|
}
|
|
2426
|
-
static removeEventListener(onMessage) {
|
|
2434
|
+
static async removeEventListener(onMessage) {
|
|
2427
2435
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
2428
2436
|
onMessageWrapperMap.delete(onMessage);
|
|
2429
|
-
const parentPort2 = getParentPort();
|
|
2437
|
+
const parentPort2 = await getParentPort();
|
|
2430
2438
|
if (parentPort2) {
|
|
2431
2439
|
console.error("not implemented");
|
|
2432
2440
|
} else {
|
|
@@ -2438,10 +2446,10 @@
|
|
|
2438
2446
|
* @param type
|
|
2439
2447
|
* @param payload
|
|
2440
2448
|
*/
|
|
2441
|
-
static postMessage(type, payload) {
|
|
2449
|
+
static async postMessage(type, payload) {
|
|
2442
2450
|
const data = { source: "loaders.gl", type, payload };
|
|
2443
2451
|
const transferList = getTransferList(payload);
|
|
2444
|
-
const parentPort2 = getParentPort();
|
|
2452
|
+
const parentPort2 = await getParentPort();
|
|
2445
2453
|
if (parentPort2) {
|
|
2446
2454
|
parentPort2.postMessage(data, transferList);
|
|
2447
2455
|
} else {
|
|
@@ -2456,8 +2464,8 @@
|
|
|
2456
2464
|
|
|
2457
2465
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
2458
2466
|
var requestId = 0;
|
|
2459
|
-
function createLoaderWorker(loader) {
|
|
2460
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
2467
|
+
async function createLoaderWorker(loader) {
|
|
2468
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
2461
2469
|
return;
|
|
2462
2470
|
}
|
|
2463
2471
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { TileJSON } from './lib/parse-tilejson';
|
|
3
3
|
export type TileJSONLoaderOptions = LoaderOptions & {
|
|
4
|
-
tilejson?: {
|
|
4
|
+
tilejson?: {
|
|
5
|
+
maxValues?: number | false;
|
|
6
|
+
};
|
|
5
7
|
};
|
|
6
8
|
/**
|
|
7
9
|
* Loader for TileJSON metadata
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tilejson-loader.d.ts","sourceRoot":"","sources":["../src/tilejson-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAOnD,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAClD,QAAQ,CAAC,EAAE,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"tilejson-loader.d.ts","sourceRoot":"","sources":["../src/tilejson-loader.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAOnD,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG;IAClD,QAAQ,CAAC,EAAE;QACT,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;KAC5B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,CAyBnF,CAAC"}
|