@loaders.gl/mvt 4.0.0-alpha.9 → 4.0.0-beta.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.min.js +228 -24
- package/dist/es5/index.js +7 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parse-mvt.js +8 -7
- package/dist/es5/lib/parse-mvt.js.map +1 -1
- package/dist/es5/lib/parse-tilejson.js +186 -0
- package/dist/es5/lib/parse-tilejson.js.map +1 -0
- package/dist/es5/lib/types.js.map +1 -1
- package/dist/es5/mvt-loader.js +10 -11
- package/dist/es5/mvt-loader.js.map +1 -1
- package/dist/es5/tilejson-loader.js +50 -0
- package/dist/es5/tilejson-loader.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/parse-mvt.js +8 -7
- package/dist/esm/lib/parse-mvt.js.map +1 -1
- package/dist/esm/lib/parse-tilejson.js +157 -0
- package/dist/esm/lib/parse-tilejson.js.map +1 -0
- package/dist/esm/lib/types.js.map +1 -1
- package/dist/esm/mvt-loader.js +10 -11
- package/dist/esm/mvt-loader.js.map +1 -1
- package/dist/esm/tilejson-loader.js +25 -0
- package/dist/esm/tilejson-loader.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parse-mvt.d.ts +3 -3
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-tilejson.d.ts +46 -0
- package/dist/lib/parse-tilejson.d.ts.map +1 -0
- package/dist/lib/types.d.ts +4 -4
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/mvt-loader.d.ts +5 -2
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-worker.js +40 -26
- package/dist/tilejson-loader.d.ts +10 -0
- package/dist/tilejson-loader.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/index.ts +5 -0
- package/src/lib/parse-mvt.ts +15 -11
- package/src/lib/parse-tilejson.ts +314 -0
- package/src/lib/types.ts +4 -4
- package/src/mvt-loader.ts +27 -13
- package/src/tilejson-loader.ts +39 -0
- package/dist/bundle.js +0 -5
- package/dist/helpers/binary-util-functions.js +0 -118
- package/dist/helpers/mapbox-util-functions.js +0 -82
- package/dist/index.js +0 -9
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +0 -156
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +0 -91
- package/dist/lib/binary-vector-tile/vector-tile.js +0 -29
- package/dist/lib/geojson-tiler/clip.js +0 -209
- package/dist/lib/geojson-tiler/convert.js +0 -134
- package/dist/lib/geojson-tiler/feature.js +0 -46
- package/dist/lib/geojson-tiler/geojson-tiler.js +0 -210
- package/dist/lib/geojson-tiler/simplify.js +0 -68
- package/dist/lib/geojson-tiler/tile.js +0 -125
- package/dist/lib/geojson-tiler/transform.js +0 -43
- package/dist/lib/geojson-tiler/wrap.js +0 -86
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +0 -170
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +0 -89
- package/dist/lib/mapbox-vector-tile/vector-tile.js +0 -29
- package/dist/lib/parse-mvt.js +0 -167
- package/dist/lib/types.js +0 -2
- package/dist/mvt-loader.js +0 -47
- package/dist/workers/mvt-worker.js +0 -5
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const isObject = x => x !== null && typeof x === 'object';
|
|
2
|
+
export function parseTileJSON(jsonMetadata) {
|
|
3
|
+
var _tileJSON$metaJson;
|
|
4
|
+
if (!jsonMetadata || !isObject(jsonMetadata)) {
|
|
5
|
+
return null;
|
|
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
|
+
let tileJSON = {
|
|
12
|
+
name: jsonMetadata.name || '',
|
|
13
|
+
description: jsonMetadata.description || '',
|
|
14
|
+
boundingBox,
|
|
15
|
+
center,
|
|
16
|
+
maxZoom,
|
|
17
|
+
minZoom,
|
|
18
|
+
layers: []
|
|
19
|
+
};
|
|
20
|
+
if (typeof (jsonMetadata === null || jsonMetadata === void 0 ? void 0 : jsonMetadata.json) === 'string') {
|
|
21
|
+
try {
|
|
22
|
+
tileJSON.metaJson = JSON.parse(jsonMetadata.json);
|
|
23
|
+
} catch (err) {}
|
|
24
|
+
}
|
|
25
|
+
let layers = parseTilestatsLayers((_tileJSON$metaJson = tileJSON.metaJson) === null || _tileJSON$metaJson === void 0 ? void 0 : _tileJSON$metaJson.tilestats);
|
|
26
|
+
if (layers.length === 0) {
|
|
27
|
+
layers = parseTileJSONLayers(jsonMetadata.vector_layers);
|
|
28
|
+
}
|
|
29
|
+
tileJSON = {
|
|
30
|
+
...tileJSON,
|
|
31
|
+
layers
|
|
32
|
+
};
|
|
33
|
+
return tileJSON;
|
|
34
|
+
}
|
|
35
|
+
function parseTileJSONLayers(layers) {
|
|
36
|
+
if (!Array.isArray(layers)) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
return layers.map(layer => ({
|
|
40
|
+
name: layer.id || '',
|
|
41
|
+
fields: Object.entries(layer.fields || []).map(_ref => {
|
|
42
|
+
let [key, datatype] = _ref;
|
|
43
|
+
return {
|
|
44
|
+
name: key,
|
|
45
|
+
...attributeTypeToFieldType(String(datatype))
|
|
46
|
+
};
|
|
47
|
+
})
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
function parseTilestatsLayers(tilestats) {
|
|
51
|
+
if (isObject(tilestats) && Array.isArray(tilestats.layers)) {
|
|
52
|
+
return tilestats.layers.map(layer => parseTilestatsForLayer(layer));
|
|
53
|
+
}
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
function parseTilestatsForLayer(layer) {
|
|
57
|
+
const fields = [];
|
|
58
|
+
const indexedAttributes = {};
|
|
59
|
+
const attributes = layer.attributes || [];
|
|
60
|
+
for (const attr of attributes) {
|
|
61
|
+
const name = attr.attribute;
|
|
62
|
+
if (typeof name === 'string') {
|
|
63
|
+
if (name.split('|').length > 1) {
|
|
64
|
+
const fname = name.split('|')[0];
|
|
65
|
+
indexedAttributes[fname] = indexedAttributes[fname] || [];
|
|
66
|
+
indexedAttributes[fname].push(attr);
|
|
67
|
+
} else if (!fields[name]) {
|
|
68
|
+
fields[name] = attributeToField(attr);
|
|
69
|
+
} else {}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
name: layer.layer || '',
|
|
74
|
+
dominantGeometry: layer.geometry,
|
|
75
|
+
fields
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function parseBounds(bounds) {
|
|
79
|
+
const result = fromArrayOrString(bounds);
|
|
80
|
+
if (Array.isArray(result) && result.length === 4 && [result[0], result[2]].every(isLng) && [result[1], result[3]].every(isLat)) {
|
|
81
|
+
return [[result[0], result[1]], [result[2], result[3]]];
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
function parseCenter(center) {
|
|
86
|
+
const result = fromArrayOrString(center);
|
|
87
|
+
if (Array.isArray(result) && result.length === 3 && isLng(result[0]) && isLat(result[1]) && isZoom(result[2])) {
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function safeParseFloat(input) {
|
|
93
|
+
const result = typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;
|
|
94
|
+
return result === null || isNaN(result) ? null : result;
|
|
95
|
+
}
|
|
96
|
+
function isLat(num) {
|
|
97
|
+
return Number.isFinite(num) && num <= 90 && num >= -90;
|
|
98
|
+
}
|
|
99
|
+
function isLng(num) {
|
|
100
|
+
return Number.isFinite(num) && num <= 180 && num >= -180;
|
|
101
|
+
}
|
|
102
|
+
function isZoom(num) {
|
|
103
|
+
return Number.isFinite(num) && num >= 0 && num <= 22;
|
|
104
|
+
}
|
|
105
|
+
function fromArrayOrString(data) {
|
|
106
|
+
if (typeof data === 'string') {
|
|
107
|
+
return data.split(',').map(parseFloat);
|
|
108
|
+
} else if (Array.isArray(data)) {
|
|
109
|
+
return data;
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const attrTypeMap = {
|
|
114
|
+
number: {
|
|
115
|
+
type: 'float32'
|
|
116
|
+
},
|
|
117
|
+
numeric: {
|
|
118
|
+
type: 'float32'
|
|
119
|
+
},
|
|
120
|
+
string: {
|
|
121
|
+
type: 'utf8'
|
|
122
|
+
},
|
|
123
|
+
vachar: {
|
|
124
|
+
type: 'utf8'
|
|
125
|
+
},
|
|
126
|
+
float: {
|
|
127
|
+
type: 'float32'
|
|
128
|
+
},
|
|
129
|
+
int: {
|
|
130
|
+
type: 'int32'
|
|
131
|
+
},
|
|
132
|
+
int4: {
|
|
133
|
+
type: 'int32'
|
|
134
|
+
},
|
|
135
|
+
boolean: {
|
|
136
|
+
type: 'boolean'
|
|
137
|
+
},
|
|
138
|
+
bool: {
|
|
139
|
+
type: 'boolean'
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
function attributeToField() {
|
|
143
|
+
let attribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
144
|
+
const fieldTypes = attributeTypeToFieldType(attribute.type);
|
|
145
|
+
return {
|
|
146
|
+
name: attribute.attribute,
|
|
147
|
+
...fieldTypes
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function attributeTypeToFieldType(aType) {
|
|
151
|
+
const type = aType.toLowerCase();
|
|
152
|
+
if (!type || !attrTypeMap[type]) {}
|
|
153
|
+
return attrTypeMap[type] || {
|
|
154
|
+
type: 'string'
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=parse-tilejson.js.map
|
|
@@ -0,0 +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\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":"AAgGA,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,MAAME,OAAO,GAAGC,cAAc,CAACR,YAAY,CAACS,OAAO,CAAC;EACpD,MAAMC,OAAO,GAAGF,cAAc,CAACR,YAAY,CAACW,OAAO,CAAC;EAEpD,IAAIC,QAAkB,GAAG;IACvBC,IAAI,EAAEb,YAAY,CAACa,IAAI,IAAI,EAAE;IAC7BC,WAAW,EAAEd,YAAY,CAACc,WAAW,IAAI,EAAE;IAC3CZ,WAAW;IACXG,MAAM;IACNE,OAAO;IACPG,OAAO;IACPK,MAAM,EAAE;EACV,CAAC;EAGD,IAAI,QAAOf,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAEgB,IAAI,MAAK,QAAQ,EAAE;IAC1C,IAAI;MACFJ,QAAQ,CAACK,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACnB,YAAY,CAACgB,IAAI,CAAC;IACnD,CAAC,CAAC,OAAOI,GAAG,EAAE,CAEd;EACF;EAEA,IAAIL,MAAM,GAAGM,oBAAoB,EAAApB,kBAAA,GAACW,QAAQ,CAACK,QAAQ,cAAAhB,kBAAA,uBAAjBA,kBAAA,CAAmBqB,SAAS,CAAC;EAE/D,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;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/lib/types.ts"],"sourcesContent":["import type {LoaderOptions} from '@loaders.gl/loader-utils';\n\n/** For local coordinates, the tileIndex is not required */\ntype MVTLocalCoordinatesOptions = {\n /**\n * When set to `local`, the parser will return a flat array of GeoJSON objects with local coordinates decoded from tile origin.\n */\n coordinates: 'local';\n tileIndex: null;\n};\n\n/** In WGS84 coordinates, the tileIndex is required */\ntype MVTWgs84CoordinatesOptions = {\n /**\n * When set to `wgs84`, the parser will return a flat array of GeoJSON objects with coordinates in longitude, latitude decoded from the provided tile index.\n */\n coordinates
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/lib/types.ts"],"sourcesContent":["import type {LoaderOptions} from '@loaders.gl/loader-utils';\n\n/** For local coordinates, the tileIndex is not required */\ntype MVTLocalCoordinatesOptions = {\n /**\n * When set to `local`, the parser will return a flat array of GeoJSON objects with local coordinates decoded from tile origin.\n */\n coordinates: 'local';\n tileIndex: null;\n};\n\n/** In WGS84 coordinates, the tileIndex is required */\ntype MVTWgs84CoordinatesOptions = {\n /**\n * When set to `wgs84`, the parser will return a flat array of GeoJSON objects with coordinates in longitude, latitude decoded from the provided tile index.\n */\n coordinates?: 'wgs84';\n\n /**\n * Mandatory with `wgs84` coordinates option. An object containing tile index values (`x`, `y`,\n * `z`) to reproject features' coordinates into WGS84.\n */\n tileIndex?: {x: number; y: number; z: number};\n};\n\nexport type MVTOptions = (MVTLocalCoordinatesOptions | MVTWgs84CoordinatesOptions) & {\n /**\n * When non-`null`, the layer name of each feature is added to\n * `feature.properties[layerProperty]`. (A `feature.properties` object is created if the feature\n * has no existing properties). If set to `null`, a layer name property will not be added.\n */\n layerProperty?: string | number;\n\n /**\n * Optional list of layer names. If not `null`, only features belonging to the named layers will\n * be included in the output. If `null`, features from all layers are returned.\n */\n layers?: string[];\n shape?: 'geojson-table' | 'columnar-table' | 'geojson' | 'binary' | 'binary-geometry';\n};\n\nexport type MVTMapboxGeometry = {\n type?: string;\n id?: number;\n length: number;\n coordinates?: any[];\n};\n\nexport type MVTMapboxCoordinates = {\n type: string;\n geometry: {\n type: string;\n coordinates: MVTMapboxGeometry;\n };\n properties: {[x: string]: string | number | boolean | null};\n id?: number;\n};\n\nexport type MVTLoaderOptions = LoaderOptions & {\n mvt?: MVTOptions;\n gis?: {\n /**\n * When set to `true`, the parser will output the data in binary format. This is equivalent to loading the data as GeoJSON and then applying [geojsonToBinary](https://loaders.gl/modules/gis/docs/api-reference/geojson-to-binary).\n */\n binary?: boolean;\n /** @deprecated. Use options.mvt.shape */\n format?: 'geojson-table' | 'columnar-table' | 'geojson' | 'binary' | 'binary-geometry';\n };\n};\n"],"mappings":""}
|
package/dist/esm/mvt-loader.js
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import parseMVT from './lib/parse-mvt';
|
|
2
|
-
const VERSION = typeof "4.0.0-
|
|
3
|
-
const DEFAULT_MVT_LOADER_OPTIONS = {
|
|
4
|
-
mvt: {
|
|
5
|
-
shape: 'geojson',
|
|
6
|
-
coordinates: 'local',
|
|
7
|
-
layerProperty: 'layerName',
|
|
8
|
-
layers: undefined,
|
|
9
|
-
tileIndex: null
|
|
10
|
-
}
|
|
11
|
-
};
|
|
2
|
+
const VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
|
|
12
3
|
export const MVTWorkerLoader = {
|
|
13
4
|
name: 'Mapbox Vector Tile',
|
|
14
5
|
id: 'mvt',
|
|
@@ -18,7 +9,15 @@ export const MVTWorkerLoader = {
|
|
|
18
9
|
mimeTypes: ['application/vnd.mapbox-vector-tile', 'application/x-protobuf'],
|
|
19
10
|
worker: true,
|
|
20
11
|
category: 'geometry',
|
|
21
|
-
options:
|
|
12
|
+
options: {
|
|
13
|
+
mvt: {
|
|
14
|
+
shape: 'geojson',
|
|
15
|
+
coordinates: 'local',
|
|
16
|
+
layerProperty: 'layerName',
|
|
17
|
+
layers: undefined,
|
|
18
|
+
tileIndex: null
|
|
19
|
+
}
|
|
20
|
+
}
|
|
22
21
|
};
|
|
23
22
|
export const MVTLoader = {
|
|
24
23
|
...MVTWorkerLoader,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvt-loader.js","names":["parseMVT","VERSION","
|
|
1
|
+
{"version":3,"file":"mvt-loader.js","names":["parseMVT","VERSION","MVTWorkerLoader","name","id","module","version","extensions","mimeTypes","worker","category","options","mvt","shape","coordinates","layerProperty","layers","undefined","tileIndex","MVTLoader","parse","arrayBuffer","parseSync","binary"],"sources":["../../src/mvt-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {MVTLoaderOptions} from './lib/types';\n// import type {\n// Feature,\n// BinaryFeatureCollection,\n// GeoJSONTable,\n// Geometry,\n// GeoJsonProperties\n// } from '@loaders.gl/schema';\nimport parseMVT from './lib/parse-mvt';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Worker loader for the Mapbox Vector Tile format\n */\nexport const MVTWorkerLoader: Loader<\n any, // BinaryFeatureCollection | GeoJSONTable | Feature<Geometry, GeoJsonProperties>,\n never,\n MVTLoaderOptions\n> = {\n name: 'Mapbox Vector Tile',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'\n extensions: ['mvt', 'pbf'],\n mimeTypes: [\n // https://www.iana.org/assignments/media-types/application/vnd.mapbox-vector-tile\n 'application/vnd.mapbox-vector-tile',\n 'application/x-protobuf'\n // 'application/octet-stream'\n ],\n worker: true,\n category: 'geometry',\n options: {\n mvt: {\n shape: 'geojson',\n coordinates: 'local',\n layerProperty: 'layerName',\n layers: undefined,\n tileIndex: null\n }\n }\n};\n\n/**\n * Loader for the Mapbox Vector Tile format\n */\nexport const MVTLoader: LoaderWithParser<\n any, // BinaryFeatureCollection | GeoJSONTable | Feature<Geometry, GeoJsonProperties>,\n never,\n MVTLoaderOptions\n> = {\n ...MVTWorkerLoader,\n parse: async (arrayBuffer, options?: MVTLoaderOptions) => parseMVT(arrayBuffer, options),\n parseSync: parseMVT,\n binary: true\n};\n"],"mappings":"AASA,OAAOA,QAAQ,MAAM,iBAAiB;AAItC,MAAMC,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAK3E,OAAO,MAAMC,eAIZ,GAAG;EACFC,IAAI,EAAE,oBAAoB;EAC1BC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAEhBM,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;EAC1BC,SAAS,EAAE,CAET,oCAAoC,EACpC,wBAAwB,CAEzB;EACDC,MAAM,EAAE,IAAI;EACZC,QAAQ,EAAE,UAAU;EACpBC,OAAO,EAAE;IACPC,GAAG,EAAE;MACHC,KAAK,EAAE,SAAS;MAChBC,WAAW,EAAE,OAAO;MACpBC,aAAa,EAAE,WAAW;MAC1BC,MAAM,EAAEC,SAAS;MACjBC,SAAS,EAAE;IACb;EACF;AACF,CAAC;AAKD,OAAO,MAAMC,SAIZ,GAAG;EACF,GAAGjB,eAAe;EAClBkB,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEV,OAA0B,KAAKX,QAAQ,CAACqB,WAAW,EAAEV,OAAO,CAAC;EACxFW,SAAS,EAAEtB,QAAQ;EACnBuB,MAAM,EAAE;AACV,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { parseTileJSON } from './lib/parse-tilejson';
|
|
2
|
+
const VERSION = typeof "4.0.0-beta.2" !== 'undefined' ? "4.0.0-beta.2" : 'latest';
|
|
3
|
+
export const TileJSONLoader = {
|
|
4
|
+
name: 'TileJSON',
|
|
5
|
+
id: 'tilejson',
|
|
6
|
+
module: 'pmtiles',
|
|
7
|
+
version: VERSION,
|
|
8
|
+
worker: true,
|
|
9
|
+
extensions: ['json'],
|
|
10
|
+
mimeTypes: ['application/json'],
|
|
11
|
+
text: true,
|
|
12
|
+
options: {
|
|
13
|
+
tilejson: {}
|
|
14
|
+
},
|
|
15
|
+
parse: async (arrayBuffer, options) => {
|
|
16
|
+
const jsonString = new TextDecoder().decode(arrayBuffer);
|
|
17
|
+
const json = JSON.parse(jsonString);
|
|
18
|
+
return parseTileJSON(json);
|
|
19
|
+
},
|
|
20
|
+
parseTextSync: (text, options) => {
|
|
21
|
+
const json = JSON.parse(text);
|
|
22
|
+
return parseTileJSON(json);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=tilejson-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tilejson-loader.js","names":["parseTileJSON","VERSION","TileJSONLoader","name","id","module","version","worker","extensions","mimeTypes","text","options","tilejson","parse","arrayBuffer","jsonString","TextDecoder","decode","json","JSON","parseTextSync"],"sources":["../../src/tilejson-loader.ts"],"sourcesContent":["// loaders.gl, MIT license\n\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {TileJSON} from './lib/parse-tilejson';\nimport {parseTileJSON} from './lib/parse-tilejson';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type TileJSONLoaderOptions = LoaderOptions & {\n tilejson?: {};\n};\n\n/**\n * Loader for TileJSON metadata\n */\nexport const TileJSONLoader: LoaderWithParser<TileJSON, never, TileJSONLoaderOptions> = {\n name: 'TileJSON',\n id: 'tilejson',\n module: 'pmtiles',\n version: VERSION,\n worker: true,\n extensions: ['json'],\n mimeTypes: ['application/json'],\n text: true,\n options: {\n tilejson: {}\n },\n parse: async (arrayBuffer, options) => {\n const jsonString = new TextDecoder().decode(arrayBuffer);\n const json = JSON.parse(jsonString);\n return parseTileJSON(json) as TileJSON;\n },\n parseTextSync: (text, options) => {\n const json = JSON.parse(text);\n return parseTileJSON(json) as TileJSON;\n }\n};\n"],"mappings":"AAIA,SAAQA,aAAa,QAAO,sBAAsB;AAIlD,MAAMC,OAAO,GAAG,qBAAkB,KAAK,WAAW,oBAAiB,QAAQ;AAS3E,OAAO,MAAMC,cAAwE,GAAG;EACtFC,IAAI,EAAE,UAAU;EAChBC,EAAE,EAAE,UAAU;EACdC,MAAM,EAAE,SAAS;EACjBC,OAAO,EAAEL,OAAO;EAChBM,MAAM,EAAE,IAAI;EACZC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,IAAI,EAAE,IAAI;EACVC,OAAO,EAAE;IACPC,QAAQ,EAAE,CAAC;EACb,CAAC;EACDC,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEH,OAAO,KAAK;IACrC,MAAMI,UAAU,GAAG,IAAIC,WAAW,CAAC,CAAC,CAACC,MAAM,CAACH,WAAW,CAAC;IACxD,MAAMI,IAAI,GAAGC,IAAI,CAACN,KAAK,CAACE,UAAU,CAAC;IACnC,OAAOf,aAAa,CAACkB,IAAI,CAAC;EAC5B,CAAC;EACDE,aAAa,EAAEA,CAACV,IAAI,EAAEC,OAAO,KAAK;IAChC,MAAMO,IAAI,GAAGC,IAAI,CAACN,KAAK,CAACH,IAAI,CAAC;IAC7B,OAAOV,aAAa,CAACkB,IAAI,CAAC;EAC5B;AACF,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
export type { MVTLoaderOptions } from './lib/types';
|
|
1
2
|
export { MVTLoader, MVTWorkerLoader } from './mvt-loader';
|
|
3
|
+
export type { TileJSON } from './lib/parse-tilejson';
|
|
4
|
+
export type { TileJSONLoaderOptions } from './tilejson-loader';
|
|
5
|
+
export { TileJSONLoader } from './tilejson-loader';
|
|
2
6
|
export type { GeoJSONTilerOptions } from './lib/geojson-tiler/geojson-tiler';
|
|
3
7
|
export { GeoJSONTiler } from './lib/geojson-tiler/geojson-tiler';
|
|
4
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAClD,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAExD,YAAY,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AACnD,YAAY,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAIjD,YAAY,EAAC,mBAAmB,EAAC,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC"}
|
package/dist/lib/parse-mvt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Feature,
|
|
1
|
+
import type { Feature, BinaryFeatureCollection, GeoJSONTable } from '@loaders.gl/schema';
|
|
2
2
|
import type { MVTLoaderOptions } from '../lib/types';
|
|
3
3
|
/**
|
|
4
4
|
* Parse MVT arrayBuffer and return GeoJSON.
|
|
@@ -7,8 +7,8 @@ import type { MVTLoaderOptions } from '../lib/types';
|
|
|
7
7
|
* @param options
|
|
8
8
|
* @returns A GeoJSON geometry object or a binary representation
|
|
9
9
|
*/
|
|
10
|
-
export default function parseMVT(arrayBuffer: ArrayBuffer, options?: MVTLoaderOptions):
|
|
10
|
+
export default function parseMVT(arrayBuffer: ArrayBuffer, options?: MVTLoaderOptions): BinaryFeatureCollection | GeoJSONTable | Feature<import("geojson").Geometry, import("geojson").GeoJsonProperties>[] | {
|
|
11
11
|
shape: string;
|
|
12
|
-
data:
|
|
12
|
+
data: BinaryFeatureCollection;
|
|
13
13
|
};
|
|
14
14
|
//# sourceMappingURL=parse-mvt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EAEP,
|
|
1
|
+
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,OAAO,EAEP,uBAAuB,EACvB,YAAY,EACb,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAmC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAOrF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB;;;EAyBpF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Parsed and typed TileJSON, merges Tilestats information if present */
|
|
2
|
+
export type TileJSON = {
|
|
3
|
+
name?: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
scheme?: 'xyz' | 'tms';
|
|
7
|
+
tiles?: string[];
|
|
8
|
+
/** `[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS. */
|
|
9
|
+
boundingBox?: [min: [w: number, s: number], max: [e: number, n: number]];
|
|
10
|
+
center: number[] | null;
|
|
11
|
+
maxZoom: number | null;
|
|
12
|
+
minZoom: number | null;
|
|
13
|
+
htmlAttribution?: string;
|
|
14
|
+
htmlLegend?: string;
|
|
15
|
+
layers?: TileJSONLayer[];
|
|
16
|
+
metaJson?: any | null;
|
|
17
|
+
};
|
|
18
|
+
export type TileJSONLayer = {
|
|
19
|
+
/** The name (id) of this layer (tilejson.vector_layers[].id / tilestats.layers[].layer) */
|
|
20
|
+
name: string;
|
|
21
|
+
/** The description of this layer (tilejson.layer.description) */
|
|
22
|
+
description?: string;
|
|
23
|
+
/** The number of features in this layer (tilestats.layer.count) */
|
|
24
|
+
featureCount?: number;
|
|
25
|
+
/** The dominant geometry type in this layer (tilestats.layer.geometry) */
|
|
26
|
+
dominantGeometry?: string;
|
|
27
|
+
/** An array of details about the first 100 attributes in this layer */
|
|
28
|
+
/** */
|
|
29
|
+
minZoom?: number;
|
|
30
|
+
maxZoom?: number;
|
|
31
|
+
fields: TileJSONField[];
|
|
32
|
+
};
|
|
33
|
+
export type TileJSONField = {
|
|
34
|
+
/** The name of this attribute */
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
type: string;
|
|
38
|
+
/** min value (if there are *any* numbers in the values) */
|
|
39
|
+
min?: number;
|
|
40
|
+
/** max value (if there are *any* numbers in the values) */
|
|
41
|
+
max?: number;
|
|
42
|
+
/** An array of this attribute's first 100 unique values */
|
|
43
|
+
values?: unknown[];
|
|
44
|
+
};
|
|
45
|
+
export declare function parseTileJSON(jsonMetadata: any): TileJSON | null;
|
|
46
|
+
//# sourceMappingURL=parse-tilejson.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-tilejson.d.ts","sourceRoot":"","sources":["../../src/lib/parse-tilejson.ts"],"names":[],"mappings":"AAEA,yEAAyE;AACzE,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,wHAAwH;IACxH,W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,GAAG,IAAI,CAyChE"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -12,12 +12,12 @@ type MVTWgs84CoordinatesOptions = {
|
|
|
12
12
|
/**
|
|
13
13
|
* When set to `wgs84`, the parser will return a flat array of GeoJSON objects with coordinates in longitude, latitude decoded from the provided tile index.
|
|
14
14
|
*/
|
|
15
|
-
coordinates
|
|
15
|
+
coordinates?: 'wgs84';
|
|
16
16
|
/**
|
|
17
17
|
* Mandatory with `wgs84` coordinates option. An object containing tile index values (`x`, `y`,
|
|
18
18
|
* `z`) to reproject features' coordinates into WGS84.
|
|
19
19
|
*/
|
|
20
|
-
tileIndex
|
|
20
|
+
tileIndex?: {
|
|
21
21
|
x: number;
|
|
22
22
|
y: number;
|
|
23
23
|
z: number;
|
|
@@ -35,7 +35,7 @@ export type MVTOptions = (MVTLocalCoordinatesOptions | MVTWgs84CoordinatesOption
|
|
|
35
35
|
* be included in the output. If `null`, features from all layers are returned.
|
|
36
36
|
*/
|
|
37
37
|
layers?: string[];
|
|
38
|
-
shape?: 'geojson-
|
|
38
|
+
shape?: 'geojson-table' | 'columnar-table' | 'geojson' | 'binary' | 'binary-geometry';
|
|
39
39
|
};
|
|
40
40
|
export type MVTMapboxGeometry = {
|
|
41
41
|
type?: string;
|
|
@@ -62,7 +62,7 @@ export type MVTLoaderOptions = LoaderOptions & {
|
|
|
62
62
|
*/
|
|
63
63
|
binary?: boolean;
|
|
64
64
|
/** @deprecated. Use options.mvt.shape */
|
|
65
|
-
format?: 'geojson-
|
|
65
|
+
format?: 'geojson-table' | 'columnar-table' | 'geojson' | 'binary' | 'binary-geometry';
|
|
66
66
|
};
|
|
67
67
|
};
|
|
68
68
|
export {};
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;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C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,iBAAiB,CAAC;KAChC,CAAC;IACF,UAAU,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;KAAC,CAAC;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB,GAAG,CAAC,EAAE;QACJ;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,yCAAyC;QACzC,MAAM,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,SAAS,GAAG,QAAQ,GAAG,iBAAiB,CAAC;KACxF,CAAC;CACH,CAAC"}
|
package/dist/mvt-loader.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Loader, LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { MVTLoaderOptions } from './lib/types';
|
|
2
3
|
/**
|
|
3
4
|
* Worker loader for the Mapbox Vector Tile format
|
|
4
5
|
*/
|
|
5
|
-
export declare const MVTWorkerLoader: Loader
|
|
6
|
+
export declare const MVTWorkerLoader: Loader<any, // BinaryFeatureCollection | GeoJSONTable | Feature<Geometry, GeoJsonProperties>,
|
|
7
|
+
never, MVTLoaderOptions>;
|
|
6
8
|
/**
|
|
7
9
|
* Loader for the Mapbox Vector Tile format
|
|
8
10
|
*/
|
|
9
|
-
export declare const MVTLoader: LoaderWithParser
|
|
11
|
+
export declare const MVTLoader: LoaderWithParser<any, // BinaryFeatureCollection | GeoJSONTable | Feature<Geometry, GeoJsonProperties>,
|
|
12
|
+
never, MVTLoaderOptions>;
|
|
10
13
|
//# sourceMappingURL=mvt-loader.d.ts.map
|
package/dist/mvt-loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mvt-loader.d.ts","sourceRoot":"","sources":["../src/mvt-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"mvt-loader.d.ts","sourceRoot":"","sources":["../src/mvt-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAclD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,GAAG,EAAE,iFAAiF;AACtF,KAAK,EACL,gBAAgB,CAyBjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAAgB,CACtC,GAAG,EAAE,iFAAiF;AACtF,KAAK,EACL,gBAAgB,CAMjB,CAAC"}
|
package/dist/mvt-worker.js
CHANGED
|
@@ -1253,7 +1253,8 @@
|
|
|
1253
1253
|
...geometryInfo
|
|
1254
1254
|
}, {
|
|
1255
1255
|
numericPropKeys: options && options.numericPropKeys || numericPropKeys,
|
|
1256
|
-
PositionDataType: options ? options.PositionDataType : Float32Array
|
|
1256
|
+
PositionDataType: options ? options.PositionDataType : Float32Array,
|
|
1257
|
+
triangulate: options ? options.triangulate : true
|
|
1257
1258
|
});
|
|
1258
1259
|
}
|
|
1259
1260
|
function extractNumericPropTypes(features) {
|
|
@@ -1282,7 +1283,7 @@
|
|
|
1282
1283
|
propArrayTypes,
|
|
1283
1284
|
coordLength
|
|
1284
1285
|
} = geometryInfo;
|
|
1285
|
-
const { numericPropKeys = [], PositionDataType = Float32Array } = options;
|
|
1286
|
+
const { numericPropKeys = [], PositionDataType = Float32Array, triangulate = true } = options;
|
|
1286
1287
|
const hasGlobalId = features[0] && "id" in features[0];
|
|
1287
1288
|
const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
|
|
1288
1289
|
const points = {
|
|
@@ -1309,13 +1310,15 @@
|
|
|
1309
1310
|
polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
|
|
1310
1311
|
primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
|
|
1311
1312
|
positions: new PositionDataType(polygonPositionsCount * coordLength),
|
|
1312
|
-
triangles: [],
|
|
1313
1313
|
globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
|
|
1314
1314
|
featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
|
|
1315
1315
|
numericProps: {},
|
|
1316
1316
|
properties: [],
|
|
1317
1317
|
fields: []
|
|
1318
1318
|
};
|
|
1319
|
+
if (triangulate) {
|
|
1320
|
+
polygons.triangles = [];
|
|
1321
|
+
}
|
|
1319
1322
|
for (const object of [points, lines, polygons]) {
|
|
1320
1323
|
for (const propName of numericPropKeys) {
|
|
1321
1324
|
const T = propArrayTypes[propName];
|
|
@@ -1420,6 +1423,9 @@
|
|
|
1420
1423
|
endPosition,
|
|
1421
1424
|
coordLength
|
|
1422
1425
|
}) {
|
|
1426
|
+
if (!polygons.triangles) {
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1423
1429
|
const start = startPosition * coordLength;
|
|
1424
1430
|
const end = endPosition * coordLength;
|
|
1425
1431
|
const polygonPositions = polygons.positions.subarray(start, end);
|
|
@@ -1438,7 +1444,7 @@
|
|
|
1438
1444
|
return returnObj;
|
|
1439
1445
|
}
|
|
1440
1446
|
function makeAccessorObjects(points, lines, polygons, coordLength) {
|
|
1441
|
-
|
|
1447
|
+
const binaryFeatures = {
|
|
1442
1448
|
points: {
|
|
1443
1449
|
...points,
|
|
1444
1450
|
positions: { value: points.positions, size: coordLength },
|
|
@@ -1459,12 +1465,15 @@
|
|
|
1459
1465
|
positions: { value: polygons.positions, size: coordLength },
|
|
1460
1466
|
polygonIndices: { value: polygons.polygonIndices, size: 1 },
|
|
1461
1467
|
primitivePolygonIndices: { value: polygons.primitivePolygonIndices, size: 1 },
|
|
1462
|
-
triangles: { value: new Uint32Array(polygons.triangles), size: 1 },
|
|
1463
1468
|
globalFeatureIds: { value: polygons.globalFeatureIds, size: 1 },
|
|
1464
1469
|
featureIds: { value: polygons.featureIds, size: 1 },
|
|
1465
1470
|
numericProps: wrapProps(polygons.numericProps, 1)
|
|
1466
1471
|
}
|
|
1467
1472
|
};
|
|
1473
|
+
if (binaryFeatures.polygons && polygons.triangles) {
|
|
1474
|
+
binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
|
|
1475
|
+
}
|
|
1476
|
+
return binaryFeatures;
|
|
1468
1477
|
}
|
|
1469
1478
|
function fillNumericProperties(object, properties, index, length2) {
|
|
1470
1479
|
for (const numericPropName in object.numericProps) {
|
|
@@ -2024,25 +2033,26 @@
|
|
|
2024
2033
|
// src/lib/parse-mvt.ts
|
|
2025
2034
|
function parseMVT(arrayBuffer, options) {
|
|
2026
2035
|
const mvtOptions = normalizeOptions(options);
|
|
2027
|
-
const shape = options?.gis?.format || options?.mvt?.shape;
|
|
2036
|
+
const shape = options?.gis?.format || options?.mvt?.shape || options?.shape;
|
|
2028
2037
|
switch (shape) {
|
|
2029
2038
|
case "columnar-table":
|
|
2030
2039
|
return { shape: "columnar-table", data: parseToBinary(arrayBuffer, mvtOptions) };
|
|
2031
|
-
case "geojson-
|
|
2040
|
+
case "geojson-table": {
|
|
2032
2041
|
const table = {
|
|
2033
|
-
shape: "geojson-
|
|
2034
|
-
|
|
2042
|
+
shape: "geojson-table",
|
|
2043
|
+
type: "FeatureCollection",
|
|
2044
|
+
features: parseToGeojsonFeatures(arrayBuffer, mvtOptions)
|
|
2035
2045
|
};
|
|
2036
2046
|
return table;
|
|
2037
2047
|
}
|
|
2038
2048
|
case "geojson":
|
|
2039
|
-
return
|
|
2049
|
+
return parseToGeojsonFeatures(arrayBuffer, mvtOptions);
|
|
2040
2050
|
case "binary-geometry":
|
|
2041
2051
|
return parseToBinary(arrayBuffer, mvtOptions);
|
|
2042
2052
|
case "binary":
|
|
2043
2053
|
return parseToBinary(arrayBuffer, mvtOptions);
|
|
2044
2054
|
default:
|
|
2045
|
-
throw new Error(shape);
|
|
2055
|
+
throw new Error(shape || "undefined shape");
|
|
2046
2056
|
}
|
|
2047
2057
|
}
|
|
2048
2058
|
function parseToBinary(arrayBuffer, options) {
|
|
@@ -2083,7 +2093,7 @@
|
|
|
2083
2093
|
});
|
|
2084
2094
|
return [features, geometryInfo];
|
|
2085
2095
|
}
|
|
2086
|
-
function
|
|
2096
|
+
function parseToGeojsonFeatures(arrayBuffer, options) {
|
|
2087
2097
|
if (arrayBuffer.byteLength <= 0) {
|
|
2088
2098
|
return [];
|
|
2089
2099
|
}
|
|
@@ -2145,16 +2155,7 @@
|
|
|
2145
2155
|
}
|
|
2146
2156
|
|
|
2147
2157
|
// src/mvt-loader.ts
|
|
2148
|
-
var VERSION = true ? "4.0.0-
|
|
2149
|
-
var DEFAULT_MVT_LOADER_OPTIONS = {
|
|
2150
|
-
mvt: {
|
|
2151
|
-
shape: "geojson",
|
|
2152
|
-
coordinates: "local",
|
|
2153
|
-
layerProperty: "layerName",
|
|
2154
|
-
layers: void 0,
|
|
2155
|
-
tileIndex: null
|
|
2156
|
-
}
|
|
2157
|
-
};
|
|
2158
|
+
var VERSION = true ? "4.0.0-beta.2" : "latest";
|
|
2158
2159
|
var MVTWorkerLoader = {
|
|
2159
2160
|
name: "Mapbox Vector Tile",
|
|
2160
2161
|
id: "mvt",
|
|
@@ -2167,7 +2168,15 @@
|
|
|
2167
2168
|
],
|
|
2168
2169
|
worker: true,
|
|
2169
2170
|
category: "geometry",
|
|
2170
|
-
options:
|
|
2171
|
+
options: {
|
|
2172
|
+
mvt: {
|
|
2173
|
+
shape: "geojson",
|
|
2174
|
+
coordinates: "local",
|
|
2175
|
+
layerProperty: "layerName",
|
|
2176
|
+
layers: void 0,
|
|
2177
|
+
tileIndex: null
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2171
2180
|
};
|
|
2172
2181
|
var MVTLoader = {
|
|
2173
2182
|
...MVTWorkerLoader,
|
|
@@ -2302,7 +2311,7 @@
|
|
|
2302
2311
|
options,
|
|
2303
2312
|
context: {
|
|
2304
2313
|
...context,
|
|
2305
|
-
|
|
2314
|
+
_parse: parseOnMainThread
|
|
2306
2315
|
}
|
|
2307
2316
|
});
|
|
2308
2317
|
WorkerBody.postMessage("done", { result });
|
|
@@ -2315,7 +2324,7 @@
|
|
|
2315
2324
|
}
|
|
2316
2325
|
};
|
|
2317
2326
|
}
|
|
2318
|
-
function parseOnMainThread(arrayBuffer, options) {
|
|
2327
|
+
function parseOnMainThread(arrayBuffer, loader, options, context) {
|
|
2319
2328
|
return new Promise((resolve, reject) => {
|
|
2320
2329
|
const id = requestId++;
|
|
2321
2330
|
const onMessage = (type, payload2) => {
|
|
@@ -2339,7 +2348,12 @@
|
|
|
2339
2348
|
WorkerBody.postMessage("process", payload);
|
|
2340
2349
|
});
|
|
2341
2350
|
}
|
|
2342
|
-
async function parseData({
|
|
2351
|
+
async function parseData({
|
|
2352
|
+
loader,
|
|
2353
|
+
arrayBuffer,
|
|
2354
|
+
options,
|
|
2355
|
+
context
|
|
2356
|
+
}) {
|
|
2343
2357
|
let data;
|
|
2344
2358
|
let parser;
|
|
2345
2359
|
if (loader.parseSync || loader.parse) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
|
|
2
|
+
import type { TileJSON } from './lib/parse-tilejson';
|
|
3
|
+
export type TileJSONLoaderOptions = LoaderOptions & {
|
|
4
|
+
tilejson?: {};
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Loader for TileJSON metadata
|
|
8
|
+
*/
|
|
9
|
+
export declare const TileJSONLoader: LoaderWithParser<TileJSON, never, TileJSONLoaderOptions>;
|
|
10
|
+
//# sourceMappingURL=tilejson-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tilejson-loader.d.ts","sourceRoot":"","sources":["../src/tilejson-loader.ts"],"names":[],"mappings":"AAEA,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;CACf,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAAE,qBAAqB,CAqBnF,CAAC"}
|