@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.
Files changed (93) hide show
  1. package/dist/dist.dev.js +274 -252
  2. package/dist/dist.min.js +14 -0
  3. package/dist/helpers/binary-util-functions.d.ts +1 -1
  4. package/dist/helpers/binary-util-functions.d.ts.map +1 -1
  5. package/dist/helpers/binary-util-functions.js +99 -61
  6. package/dist/helpers/mapbox-util-functions.d.ts +2 -2
  7. package/dist/helpers/mapbox-util-functions.d.ts.map +1 -1
  8. package/dist/helpers/mapbox-util-functions.js +67 -33
  9. package/dist/index.cjs +37 -61
  10. package/dist/index.cjs.map +7 -0
  11. package/dist/index.d.ts +8 -8
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -1
  14. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +1 -1
  15. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
  16. package/dist/lib/binary-vector-tile/vector-tile-feature.js +135 -118
  17. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +1 -1
  18. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -1
  19. package/dist/lib/binary-vector-tile/vector-tile-layer.js +77 -38
  20. package/dist/lib/binary-vector-tile/vector-tile.d.ts +1 -1
  21. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -1
  22. package/dist/lib/binary-vector-tile/vector-tile.js +17 -12
  23. package/dist/lib/geojson-tiler/clip.d.ts +1 -1
  24. package/dist/lib/geojson-tiler/clip.d.ts.map +1 -1
  25. package/dist/lib/geojson-tiler/clip.js +177 -142
  26. package/dist/lib/geojson-tiler/convert.d.ts +1 -1
  27. package/dist/lib/geojson-tiler/convert.d.ts.map +1 -1
  28. package/dist/lib/geojson-tiler/convert.js +116 -100
  29. package/dist/lib/geojson-tiler/feature.d.ts +1 -1
  30. package/dist/lib/geojson-tiler/feature.d.ts.map +1 -1
  31. package/dist/lib/geojson-tiler/feature.js +38 -29
  32. package/dist/lib/geojson-tiler/geojson-tiler.d.ts +1 -1
  33. package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -1
  34. package/dist/lib/geojson-tiler/geojson-tiler.js +197 -159
  35. package/dist/lib/geojson-tiler/simplify.js +60 -40
  36. package/dist/lib/geojson-tiler/tile.js +108 -88
  37. package/dist/lib/geojson-tiler/transform.d.ts +1 -1
  38. package/dist/lib/geojson-tiler/transform.d.ts.map +1 -1
  39. package/dist/lib/geojson-tiler/transform.js +35 -26
  40. package/dist/lib/geojson-tiler/wrap.d.ts +1 -1
  41. package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -1
  42. package/dist/lib/geojson-tiler/wrap.js +71 -53
  43. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +1 -1
  44. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -1
  45. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +156 -151
  46. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +1 -1
  47. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -1
  48. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +75 -38
  49. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +1 -1
  50. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -1
  51. package/dist/lib/mapbox-vector-tile/vector-tile.js +17 -12
  52. package/dist/lib/parse-mvt.d.ts +1 -1
  53. package/dist/lib/parse-mvt.d.ts.map +1 -1
  54. package/dist/lib/parse-mvt.js +142 -115
  55. package/dist/lib/parse-tilejson.js +234 -176
  56. package/dist/lib/types.js +0 -1
  57. package/dist/mvt-loader.d.ts +1 -1
  58. package/dist/mvt-loader.d.ts.map +1 -1
  59. package/dist/mvt-loader.js +42 -22
  60. package/dist/mvt-source.js +148 -139
  61. package/dist/mvt-worker.js +1 -1
  62. package/dist/tilejson-loader.d.ts +1 -1
  63. package/dist/tilejson-loader.d.ts.map +1 -1
  64. package/dist/tilejson-loader.js +32 -31
  65. package/dist/workers/mvt-worker.js +0 -1
  66. package/package.json +12 -8
  67. package/dist/helpers/binary-util-functions.js.map +0 -1
  68. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  69. package/dist/index.js.map +0 -1
  70. package/dist/lib/binary-vector-tile/LICENSE.txt +0 -31
  71. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  72. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  73. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  74. package/dist/lib/geojson-tiler/LICENSE +0 -19
  75. package/dist/lib/geojson-tiler/clip.js.map +0 -1
  76. package/dist/lib/geojson-tiler/convert.js.map +0 -1
  77. package/dist/lib/geojson-tiler/feature.js.map +0 -1
  78. package/dist/lib/geojson-tiler/geojson-tiler.js.map +0 -1
  79. package/dist/lib/geojson-tiler/simplify.js.map +0 -1
  80. package/dist/lib/geojson-tiler/tile.js.map +0 -1
  81. package/dist/lib/geojson-tiler/transform.js.map +0 -1
  82. package/dist/lib/geojson-tiler/wrap.js.map +0 -1
  83. package/dist/lib/mapbox-vector-tile/LICENSE.txt +0 -31
  84. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  85. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  86. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  87. package/dist/lib/parse-mvt.js.map +0 -1
  88. package/dist/lib/parse-tilejson.js.map +0 -1
  89. package/dist/lib/types.js.map +0 -1
  90. package/dist/mvt-loader.js.map +0 -1
  91. package/dist/mvt-source.js.map +0 -1
  92. package/dist/tilejson-loader.js.map +0 -1
  93. package/dist/workers/mvt-worker.js.map +0 -1
@@ -1,209 +1,267 @@
1
- const isObject = x => x !== null && typeof x === 'object';
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
- var _tileJSON$metaJson;
4
- if (!jsonMetadata || !isObject(jsonMetadata)) {
5
- return null;
6
- }
7
- let tileJSON = {
8
- name: jsonMetadata.name || '',
9
- description: jsonMetadata.description || ''
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);
21
- if (typeof (jsonMetadata === null || jsonMetadata === void 0 ? void 0 : jsonMetadata.json) === 'string') {
22
- try {
23
- tileJSON.metaJson = JSON.parse(jsonMetadata.json);
24
- } catch (error) {
25
- console.warn('Failed to parse tilejson.json field', error);
26
- }
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);
32
- tileJSON = {
33
- ...tileJSON,
34
- layers
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
- }
42
- return tileJSON;
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
- if (!Array.isArray(layers)) {
46
- return [];
47
- }
48
- return layers.map(layer => parseTileJSONLayer(layer));
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
- const fields = Object.entries(layer.fields || []).map(_ref => {
52
- let [key, datatype] = _ref;
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
- name: key,
55
- ...attributeTypeToFieldType(String(datatype))
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
- if (isObject(tilestats) && Array.isArray(tilestats.layers)) {
70
- return tilestats.layers.map(layer => parseTilestatsForLayer(layer, options));
71
- }
72
- return [];
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
- const fields = [];
76
- const indexedAttributes = {};
77
- const attributes = layer.attributes || [];
78
- for (const attribute of attributes) {
79
- const name = attribute.attribute;
80
- if (typeof name === 'string') {
81
- if (name.split('|').length > 1) {
82
- const fname = name.split('|')[0];
83
- indexedAttributes[fname] = indexedAttributes[fname] || [];
84
- indexedAttributes[fname].push(attribute);
85
- console.warn('ignoring tilestats indexed field', fname);
86
- } else if (!fields[name]) {
87
- fields.push(attributeToField(attribute, options));
88
- } else {}
89
- }
90
- }
91
- return {
92
- name: layer.layer || '',
93
- dominantGeometry: layer.geometry,
94
- fields
95
- };
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;
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
- ...layer2,
107
- ...tilestatsLayer,
108
- fields
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
- const result = fromArrayOrString(bounds);
114
- if (Array.isArray(result) && result.length === 4 && [result[0], result[2]].every(isLng) && [result[1], result[3]].every(isLat)) {
115
- return [[result[0], result[1]], [result[2], result[3]]];
116
- }
117
- return undefined;
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
- const result = fromArrayOrString(center);
121
- if (Array.isArray(result) && result.length === 3 && isLng(result[0]) && isLat(result[1]) && isZoom(result[2])) {
122
- return result;
123
- }
124
- return null;
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
- const result = typeof input === 'string' ? parseFloat(input) : typeof input === 'number' ? input : null;
128
- return result === null || isNaN(result) ? null : result;
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
- return Number.isFinite(num) && num <= 90 && num >= -90;
180
+ return Number.isFinite(num) && num <= 90 && num >= -90;
132
181
  }
133
182
  function isLng(num) {
134
- return Number.isFinite(num) && num <= 180 && num >= -180;
183
+ return Number.isFinite(num) && num <= 180 && num >= -180;
135
184
  }
136
185
  function isZoom(num) {
137
- return Number.isFinite(num) && num >= 0 && num <= 22;
186
+ return Number.isFinite(num) && num >= 0 && num <= 22;
138
187
  }
139
188
  function fromArrayOrString(data) {
140
- if (typeof data === 'string') {
141
- return data.split(',').map(parseFloat);
142
- } else if (Array.isArray(data)) {
143
- return data;
144
- }
145
- return null;
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
- number: {
149
- type: 'float32'
150
- },
151
- numeric: {
152
- type: 'float32'
153
- },
154
- string: {
155
- type: 'utf8'
156
- },
157
- vachar: {
158
- type: 'utf8'
159
- },
160
- float: {
161
- type: 'float32'
162
- },
163
- int: {
164
- type: 'int32'
165
- },
166
- int4: {
167
- type: 'int32'
168
- },
169
- boolean: {
170
- type: 'boolean'
171
- },
172
- bool: {
173
- type: 'boolean'
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
- let attribute = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
178
- let options = arguments.length > 1 ? arguments[1] : undefined;
179
- const fieldTypes = attributeTypeToFieldType(attribute.type);
180
- const field = {
181
- name: attribute.attribute,
182
- ...fieldTypes
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 (attribute.values) {
194
- field.values = attribute.values;
195
- }
196
- if (field.values && typeof options.maxValues === 'number') {
197
- var _field$values;
198
- field.values = (_field$values = field.values) === null || _field$values === void 0 ? void 0 : _field$values.slice(0, options.maxValues);
199
- }
200
- return field;
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
- const type = aType.toLowerCase();
204
- if (!type || !attrTypeMap[type]) {}
205
- return attrTypeMap[type] || {
206
- type: 'string'
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
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -1,5 +1,5 @@
1
1
  import type { Loader, LoaderWithParser } from '@loaders.gl/loader-utils';
2
- import type { MVTLoaderOptions } from './lib/types';
2
+ import type { MVTLoaderOptions } from "./lib/types.js";
3
3
  /**
4
4
  * Worker loader for the Mapbox Vector Tile format
5
5
  */
@@ -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,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"}
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"}
@@ -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
- const VERSION = typeof "4.2.0-alpha.3" !== 'undefined' ? "4.2.0-alpha.3" : 'latest';
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
- name: 'Mapbox Vector Tile',
5
- id: 'mvt',
6
- module: 'mvt',
7
- version: VERSION,
8
- extensions: ['mvt', 'pbf'],
9
- mimeTypes: ['application/vnd.mapbox-vector-tile', 'application/x-protobuf'],
10
- worker: true,
11
- category: 'geometry',
12
- options: {
13
- mvt: {
14
- shape: 'geojson',
15
- coordinates: 'local',
16
- layerProperty: 'layerName',
17
- layers: undefined,
18
- tileIndex: null
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
- ...MVTWorkerLoader,
24
- parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),
25
- parseSync: parseMVT,
26
- binary: true
44
+ ...MVTWorkerLoader,
45
+ parse: async (arrayBuffer, options) => parseMVT(arrayBuffer, options),
46
+ parseSync: parseMVT,
47
+ binary: true
27
48
  };
28
- //# sourceMappingURL=mvt-loader.js.map