@loaders.gl/mvt 4.2.0-alpha.3 → 4.2.0-alpha.5
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 +274 -252
- package/dist/dist.min.js +14 -0
- package/dist/helpers/binary-util-functions.d.ts +1 -1
- package/dist/helpers/binary-util-functions.d.ts.map +1 -1
- package/dist/helpers/binary-util-functions.js +99 -61
- package/dist/helpers/mapbox-util-functions.d.ts +2 -2
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -1
- package/dist/helpers/mapbox-util-functions.js +67 -33
- package/dist/index.cjs +37 -61
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +135 -118
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +77 -38
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile.js +17 -12
- package/dist/lib/geojson-tiler/clip.d.ts +1 -1
- package/dist/lib/geojson-tiler/clip.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/clip.js +177 -142
- package/dist/lib/geojson-tiler/convert.d.ts +1 -1
- package/dist/lib/geojson-tiler/convert.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/convert.js +116 -100
- package/dist/lib/geojson-tiler/feature.d.ts +1 -1
- package/dist/lib/geojson-tiler/feature.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/feature.js +38 -29
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +1 -1
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js +197 -159
- package/dist/lib/geojson-tiler/simplify.js +60 -40
- package/dist/lib/geojson-tiler/tile.js +108 -88
- package/dist/lib/geojson-tiler/transform.d.ts +1 -1
- package/dist/lib/geojson-tiler/transform.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/transform.js +35 -26
- package/dist/lib/geojson-tiler/wrap.d.ts +1 -1
- package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -1
- package/dist/lib/geojson-tiler/wrap.js +71 -53
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +156 -151
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +75 -38
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.js +17 -12
- package/dist/lib/parse-mvt.d.ts +1 -1
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +142 -115
- package/dist/lib/parse-tilejson.js +234 -176
- package/dist/lib/types.js +0 -1
- package/dist/mvt-loader.d.ts +1 -1
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-loader.js +42 -22
- package/dist/mvt-source.js +148 -139
- package/dist/mvt-worker.js +1 -1
- package/dist/tilejson-loader.d.ts +1 -1
- package/dist/tilejson-loader.d.ts.map +1 -1
- package/dist/tilejson-loader.js +32 -31
- package/dist/workers/mvt-worker.js +0 -1
- package/package.json +12 -8
- package/dist/helpers/binary-util-functions.js.map +0 -1
- package/dist/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/binary-vector-tile/LICENSE.txt +0 -31
- package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/lib/geojson-tiler/LICENSE +0 -19
- package/dist/lib/geojson-tiler/clip.js.map +0 -1
- package/dist/lib/geojson-tiler/convert.js.map +0 -1
- package/dist/lib/geojson-tiler/feature.js.map +0 -1
- package/dist/lib/geojson-tiler/geojson-tiler.js.map +0 -1
- package/dist/lib/geojson-tiler/simplify.js.map +0 -1
- package/dist/lib/geojson-tiler/tile.js.map +0 -1
- package/dist/lib/geojson-tiler/transform.js.map +0 -1
- package/dist/lib/geojson-tiler/wrap.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/LICENSE.txt +0 -31
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/lib/parse-mvt.js.map +0 -1
- package/dist/lib/parse-tilejson.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/mvt-loader.js.map +0 -1
- package/dist/mvt-source.js.map +0 -1
- package/dist/tilejson-loader.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
|
@@ -1,209 +1,267 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
const isObject = (x) => x !== null && typeof x === 'object';
|
|
5
|
+
/**
|
|
6
|
+
* Parse TileJSON from metadata
|
|
7
|
+
* @param jsonMetadata - metadata object
|
|
8
|
+
* @param options - options
|
|
9
|
+
* @returns - parsed TileJSON
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line complexity
|
|
2
12
|
export function parseTileJSON(jsonMetadata, options) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
if (!jsonMetadata || !isObject(jsonMetadata)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
let tileJSON = {
|
|
17
|
+
name: jsonMetadata.name || '',
|
|
18
|
+
description: jsonMetadata.description || ''
|
|
19
|
+
};
|
|
20
|
+
// tippecanoe
|
|
21
|
+
if (typeof jsonMetadata.generator === 'string') {
|
|
22
|
+
tileJSON.generator = jsonMetadata.generator;
|
|
23
|
+
}
|
|
24
|
+
if (typeof jsonMetadata.generator_options === 'string') {
|
|
25
|
+
tileJSON.generatorOptions = jsonMetadata.generator_options;
|
|
26
|
+
}
|
|
27
|
+
// Tippecanoe emits `antimeridian_adjusted_bounds` instead of `bounds`
|
|
28
|
+
tileJSON.boundingBox =
|
|
29
|
+
parseBounds(jsonMetadata.bounds) || parseBounds(jsonMetadata.antimeridian_adjusted_bounds);
|
|
30
|
+
// TODO - can be undefined - we could set to center of bounds...
|
|
31
|
+
tileJSON.center = parseCenter(jsonMetadata.center);
|
|
32
|
+
// TODO - can be undefined, we could extract from layers...
|
|
33
|
+
tileJSON.maxZoom = safeParseFloat(jsonMetadata.maxzoom);
|
|
34
|
+
// TODO - can be undefined, we could extract from layers...
|
|
35
|
+
tileJSON.minZoom = safeParseFloat(jsonMetadata.minzoom);
|
|
36
|
+
// Look for nested metadata embedded in .json field
|
|
37
|
+
// TODO - document what source this applies to, when is this needed?
|
|
38
|
+
if (typeof jsonMetadata?.json === 'string') {
|
|
39
|
+
// try to parse json
|
|
40
|
+
try {
|
|
41
|
+
tileJSON.metaJson = JSON.parse(jsonMetadata.json);
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.warn('Failed to parse tilejson.json field', error);
|
|
46
|
+
// do nothing
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Look for fields in tilestats
|
|
50
|
+
const tilestats = jsonMetadata.tilestats || tileJSON.metaJson?.tilestats;
|
|
51
|
+
const tileStatsLayers = parseTilestatsLayers(tilestats, options);
|
|
52
|
+
const tileJSONlayers = parseTileJSONLayers(jsonMetadata.vector_layers); // eslint-disable-line camelcase
|
|
53
|
+
// TODO - merge in description from tilejson
|
|
54
|
+
const layers = mergeLayers(tileJSONlayers, tileStatsLayers);
|
|
55
|
+
tileJSON = {
|
|
56
|
+
...tileJSON,
|
|
57
|
+
layers
|
|
58
|
+
};
|
|
59
|
+
if (tileJSON.maxZoom === null && layers.length > 0) {
|
|
60
|
+
tileJSON.maxZoom = layers[0].maxZoom || null;
|
|
61
|
+
}
|
|
62
|
+
if (tileJSON.minZoom === null && layers.length > 0) {
|
|
63
|
+
tileJSON.minZoom = layers[0].minZoom || null;
|
|
64
|
+
}
|
|
65
|
+
return tileJSON;
|
|
43
66
|
}
|
|
44
67
|
function parseTileJSONLayers(layers) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
// Look for fields in vector_layers
|
|
69
|
+
if (!Array.isArray(layers)) {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
return layers.map((layer) => parseTileJSONLayer(layer));
|
|
49
73
|
}
|
|
50
74
|
function parseTileJSONLayer(layer) {
|
|
51
|
-
|
|
52
|
-
|
|
75
|
+
const fields = Object.entries(layer.fields || []).map(([key, datatype]) => ({
|
|
76
|
+
name: key,
|
|
77
|
+
...attributeTypeToFieldType(String(datatype))
|
|
78
|
+
}));
|
|
79
|
+
const layer2 = { ...layer };
|
|
80
|
+
delete layer2.fields;
|
|
53
81
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
82
|
+
name: layer.id || '',
|
|
83
|
+
...layer2,
|
|
84
|
+
fields
|
|
56
85
|
};
|
|
57
|
-
});
|
|
58
|
-
const layer2 = {
|
|
59
|
-
...layer
|
|
60
|
-
};
|
|
61
|
-
delete layer2.fields;
|
|
62
|
-
return {
|
|
63
|
-
name: layer.id || '',
|
|
64
|
-
...layer2,
|
|
65
|
-
fields
|
|
66
|
-
};
|
|
67
86
|
}
|
|
87
|
+
/** parse Layers array from tilestats */
|
|
68
88
|
function parseTilestatsLayers(tilestats, options) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
89
|
+
if (isObject(tilestats) && Array.isArray(tilestats.layers)) {
|
|
90
|
+
// we are in luck!
|
|
91
|
+
return tilestats.layers.map((layer) => parseTilestatsForLayer(layer, options));
|
|
92
|
+
}
|
|
93
|
+
return [];
|
|
73
94
|
}
|
|
74
95
|
function parseTilestatsForLayer(layer, options) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
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;
|
|
96
|
+
const fields = [];
|
|
97
|
+
const indexedAttributes = {};
|
|
98
|
+
const attributes = layer.attributes || [];
|
|
99
|
+
for (const attribute of attributes) {
|
|
100
|
+
const name = attribute.attribute;
|
|
101
|
+
if (typeof name === 'string') {
|
|
102
|
+
// TODO - code copied from kepler.gl, need sample tilestats files to test
|
|
103
|
+
if (name.split('|').length > 1) {
|
|
104
|
+
// indexed field
|
|
105
|
+
const fname = name.split('|')[0];
|
|
106
|
+
indexedAttributes[fname] = indexedAttributes[fname] || [];
|
|
107
|
+
indexedAttributes[fname].push(attribute);
|
|
108
|
+
// eslint-disable-next-line no-console
|
|
109
|
+
console.warn('ignoring tilestats indexed field', fname);
|
|
110
|
+
}
|
|
111
|
+
else if (!fields[name]) {
|
|
112
|
+
fields.push(attributeToField(attribute, options));
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
// return (fields[name], attribute);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
105
119
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
name: layer.layer || '',
|
|
121
|
+
dominantGeometry: layer.geometry,
|
|
122
|
+
fields
|
|
109
123
|
};
|
|
110
|
-
});
|
|
111
124
|
}
|
|
125
|
+
function mergeLayers(layers, tilestatsLayers) {
|
|
126
|
+
return layers.map((layer) => {
|
|
127
|
+
const tilestatsLayer = tilestatsLayers.find((tsLayer) => tsLayer.name === layer.name);
|
|
128
|
+
// For aesthetics in JSON dumps, we preserve field order (make sure layers is last)
|
|
129
|
+
const fields = tilestatsLayer?.fields || [];
|
|
130
|
+
const layer2 = { ...layer };
|
|
131
|
+
delete layer2.fields;
|
|
132
|
+
return {
|
|
133
|
+
...layer2,
|
|
134
|
+
...tilestatsLayer,
|
|
135
|
+
fields
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* bounds should be [minLng, minLat, maxLng, maxLat]
|
|
141
|
+
*`[[w, s], [e, n]]`, indicates the limits of the bounding box using the axis units and order of the specified CRS.
|
|
142
|
+
*/
|
|
112
143
|
function parseBounds(bounds) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
144
|
+
// supported formats
|
|
145
|
+
// string: "-96.657715,40.126127,-90.140061,43.516689",
|
|
146
|
+
// array: [ -180, -85.05112877980659, 180, 85.0511287798066 ]
|
|
147
|
+
const result = fromArrayOrString(bounds);
|
|
148
|
+
// validate bounds
|
|
149
|
+
if (Array.isArray(result) &&
|
|
150
|
+
result.length === 4 &&
|
|
151
|
+
[result[0], result[2]].every(isLng) &&
|
|
152
|
+
[result[1], result[3]].every(isLat)) {
|
|
153
|
+
return [
|
|
154
|
+
[result[0], result[1]],
|
|
155
|
+
[result[2], result[3]]
|
|
156
|
+
];
|
|
157
|
+
}
|
|
158
|
+
return undefined;
|
|
118
159
|
}
|
|
119
160
|
function parseCenter(center) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
161
|
+
// supported formats
|
|
162
|
+
// string: "-96.657715,40.126127,-90.140061,43.516689",
|
|
163
|
+
// array: [-91.505127,41.615442,14]
|
|
164
|
+
const result = fromArrayOrString(center);
|
|
165
|
+
if (Array.isArray(result) &&
|
|
166
|
+
result.length === 3 &&
|
|
167
|
+
isLng(result[0]) &&
|
|
168
|
+
isLat(result[1]) &&
|
|
169
|
+
isZoom(result[2])) {
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
return null;
|
|
125
173
|
}
|
|
126
174
|
function safeParseFloat(input) {
|
|
127
|
-
|
|
128
|
-
|
|
175
|
+
const result = typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;
|
|
176
|
+
return result === null || isNaN(result) ? null : result;
|
|
129
177
|
}
|
|
178
|
+
// https://github.com/mapbox/tilejson-spec/tree/master/2.2.0
|
|
130
179
|
function isLat(num) {
|
|
131
|
-
|
|
180
|
+
return Number.isFinite(num) && num <= 90 && num >= -90;
|
|
132
181
|
}
|
|
133
182
|
function isLng(num) {
|
|
134
|
-
|
|
183
|
+
return Number.isFinite(num) && num <= 180 && num >= -180;
|
|
135
184
|
}
|
|
136
185
|
function isZoom(num) {
|
|
137
|
-
|
|
186
|
+
return Number.isFinite(num) && num >= 0 && num <= 22;
|
|
138
187
|
}
|
|
139
188
|
function fromArrayOrString(data) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
189
|
+
if (typeof data === 'string') {
|
|
190
|
+
return data.split(',').map(parseFloat);
|
|
191
|
+
}
|
|
192
|
+
else if (Array.isArray(data)) {
|
|
193
|
+
return data;
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
146
196
|
}
|
|
197
|
+
// possible types https://github.com/mapbox/tippecanoe#modifying-feature-attributes
|
|
147
198
|
const attrTypeMap = {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
199
|
+
number: {
|
|
200
|
+
type: 'float32'
|
|
201
|
+
},
|
|
202
|
+
numeric: {
|
|
203
|
+
type: 'float32'
|
|
204
|
+
},
|
|
205
|
+
string: {
|
|
206
|
+
type: 'utf8'
|
|
207
|
+
},
|
|
208
|
+
vachar: {
|
|
209
|
+
type: 'utf8'
|
|
210
|
+
},
|
|
211
|
+
float: {
|
|
212
|
+
type: 'float32'
|
|
213
|
+
},
|
|
214
|
+
int: {
|
|
215
|
+
type: 'int32'
|
|
216
|
+
},
|
|
217
|
+
int4: {
|
|
218
|
+
type: 'int32'
|
|
219
|
+
},
|
|
220
|
+
boolean: {
|
|
221
|
+
type: 'boolean'
|
|
222
|
+
},
|
|
223
|
+
bool: {
|
|
224
|
+
type: 'boolean'
|
|
225
|
+
}
|
|
175
226
|
};
|
|
176
|
-
function attributeToField() {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
227
|
+
function attributeToField(attribute = {}, options) {
|
|
228
|
+
const fieldTypes = attributeTypeToFieldType(attribute.type);
|
|
229
|
+
const field = {
|
|
230
|
+
name: attribute.attribute,
|
|
231
|
+
// what happens if attribute type is string...
|
|
232
|
+
// filterProps: getFilterProps(fieldTypes.type, attribute),
|
|
233
|
+
...fieldTypes
|
|
234
|
+
};
|
|
235
|
+
// attribute: "_season_peaks_color"
|
|
236
|
+
// count: 1000
|
|
237
|
+
// max: 0.95
|
|
238
|
+
// min: 0.24375
|
|
239
|
+
// type: "number"
|
|
240
|
+
if (typeof attribute.min === 'number') {
|
|
241
|
+
field.min = attribute.min;
|
|
242
|
+
}
|
|
243
|
+
if (typeof attribute.max === 'number') {
|
|
244
|
+
field.max = attribute.max;
|
|
245
|
+
}
|
|
246
|
+
if (typeof attribute.count === 'number') {
|
|
247
|
+
field.uniqueValueCount = attribute.count;
|
|
248
|
+
}
|
|
249
|
+
if (attribute.values) {
|
|
250
|
+
// Too much data? Add option?
|
|
251
|
+
field.values = attribute.values;
|
|
252
|
+
}
|
|
253
|
+
if (field.values && typeof options.maxValues === 'number') {
|
|
254
|
+
// Too much data? Add option?
|
|
255
|
+
field.values = field.values?.slice(0, options.maxValues);
|
|
256
|
+
}
|
|
257
|
+
return field;
|
|
201
258
|
}
|
|
202
259
|
function attributeTypeToFieldType(aType) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
260
|
+
const type = aType.toLowerCase();
|
|
261
|
+
if (!type || !attrTypeMap[type]) {
|
|
262
|
+
// console.warn(
|
|
263
|
+
// `cannot convert attribute type ${type} to loaders.gl data type, use string by default`
|
|
264
|
+
// );
|
|
265
|
+
}
|
|
266
|
+
return attrTypeMap[type] || { type: 'string' };
|
|
208
267
|
}
|
|
209
|
-
//# sourceMappingURL=parse-tilejson.js.map
|
package/dist/lib/types.js
CHANGED
package/dist/mvt-loader.d.ts
CHANGED
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;AACvE,OAAO,KAAK,EAAC,gBAAgB,EAAC,
|
|
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,uBAAoB;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-loader.js
CHANGED
|
@@ -1,28 +1,48 @@
|
|
|
1
|
+
// import type {
|
|
2
|
+
// Feature,
|
|
3
|
+
// BinaryFeatureCollection,
|
|
4
|
+
// GeoJSONTable,
|
|
5
|
+
// Geometry,
|
|
6
|
+
// GeoJsonProperties
|
|
7
|
+
// } from '@loaders.gl/schema';
|
|
1
8
|
import parseMVT from "./lib/parse-mvt.js";
|
|
2
|
-
|
|
9
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
10
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
11
|
+
const VERSION = typeof "4.2.0-alpha.4" !== 'undefined' ? "4.2.0-alpha.4" : 'latest';
|
|
12
|
+
/**
|
|
13
|
+
* Worker loader for the Mapbox Vector Tile format
|
|
14
|
+
*/
|
|
3
15
|
export const MVTWorkerLoader = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
name: 'Mapbox Vector Tile',
|
|
17
|
+
id: 'mvt',
|
|
18
|
+
module: 'mvt',
|
|
19
|
+
version: VERSION,
|
|
20
|
+
// Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
|
|
21
|
+
extensions: ['mvt', 'pbf'],
|
|
22
|
+
mimeTypes: [
|
|
23
|
+
// https://www.iana.org/assignments/media-types/application/vnd.mapbox-vector-tile
|
|
24
|
+
'application/vnd.mapbox-vector-tile',
|
|
25
|
+
'application/x-protobuf'
|
|
26
|
+
// 'application/octet-stream'
|
|
27
|
+
],
|
|
28
|
+
worker: true,
|
|
29
|
+
category: 'geometry',
|
|
30
|
+
options: {
|
|
31
|
+
mvt: {
|
|
32
|
+
shape: 'geojson',
|
|
33
|
+
coordinates: 'local',
|
|
34
|
+
layerProperty: 'layerName',
|
|
35
|
+
layers: undefined,
|
|
36
|
+
tileIndex: null
|
|
37
|
+
}
|
|
19
38
|
}
|
|
20
|
-
}
|
|
21
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* Loader for the Mapbox Vector Tile format
|
|
42
|
+
*/
|
|
22
43
|
export const MVTLoader = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
...MVTWorkerLoader,
|
|
45
|
+
parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),
|
|
46
|
+
parseSync: parseMVT,
|
|
47
|
+
binary: true
|
|
27
48
|
};
|
|
28
|
-
//# sourceMappingURL=mvt-loader.js.map
|