@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.
Files changed (65) hide show
  1. package/dist/dist.min.js +228 -24
  2. package/dist/es5/index.js +7 -0
  3. package/dist/es5/index.js.map +1 -1
  4. package/dist/es5/lib/parse-mvt.js +8 -7
  5. package/dist/es5/lib/parse-mvt.js.map +1 -1
  6. package/dist/es5/lib/parse-tilejson.js +186 -0
  7. package/dist/es5/lib/parse-tilejson.js.map +1 -0
  8. package/dist/es5/lib/types.js.map +1 -1
  9. package/dist/es5/mvt-loader.js +10 -11
  10. package/dist/es5/mvt-loader.js.map +1 -1
  11. package/dist/es5/tilejson-loader.js +50 -0
  12. package/dist/es5/tilejson-loader.js.map +1 -0
  13. package/dist/esm/index.js +1 -0
  14. package/dist/esm/index.js.map +1 -1
  15. package/dist/esm/lib/parse-mvt.js +8 -7
  16. package/dist/esm/lib/parse-mvt.js.map +1 -1
  17. package/dist/esm/lib/parse-tilejson.js +157 -0
  18. package/dist/esm/lib/parse-tilejson.js.map +1 -0
  19. package/dist/esm/lib/types.js.map +1 -1
  20. package/dist/esm/mvt-loader.js +10 -11
  21. package/dist/esm/mvt-loader.js.map +1 -1
  22. package/dist/esm/tilejson-loader.js +25 -0
  23. package/dist/esm/tilejson-loader.js.map +1 -0
  24. package/dist/index.d.ts +4 -0
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/lib/parse-mvt.d.ts +3 -3
  27. package/dist/lib/parse-mvt.d.ts.map +1 -1
  28. package/dist/lib/parse-tilejson.d.ts +46 -0
  29. package/dist/lib/parse-tilejson.d.ts.map +1 -0
  30. package/dist/lib/types.d.ts +4 -4
  31. package/dist/lib/types.d.ts.map +1 -1
  32. package/dist/mvt-loader.d.ts +5 -2
  33. package/dist/mvt-loader.d.ts.map +1 -1
  34. package/dist/mvt-worker.js +40 -26
  35. package/dist/tilejson-loader.d.ts +10 -0
  36. package/dist/tilejson-loader.d.ts.map +1 -0
  37. package/package.json +5 -5
  38. package/src/index.ts +5 -0
  39. package/src/lib/parse-mvt.ts +15 -11
  40. package/src/lib/parse-tilejson.ts +314 -0
  41. package/src/lib/types.ts +4 -4
  42. package/src/mvt-loader.ts +27 -13
  43. package/src/tilejson-loader.ts +39 -0
  44. package/dist/bundle.js +0 -5
  45. package/dist/helpers/binary-util-functions.js +0 -118
  46. package/dist/helpers/mapbox-util-functions.js +0 -82
  47. package/dist/index.js +0 -9
  48. package/dist/lib/binary-vector-tile/vector-tile-feature.js +0 -156
  49. package/dist/lib/binary-vector-tile/vector-tile-layer.js +0 -91
  50. package/dist/lib/binary-vector-tile/vector-tile.js +0 -29
  51. package/dist/lib/geojson-tiler/clip.js +0 -209
  52. package/dist/lib/geojson-tiler/convert.js +0 -134
  53. package/dist/lib/geojson-tiler/feature.js +0 -46
  54. package/dist/lib/geojson-tiler/geojson-tiler.js +0 -210
  55. package/dist/lib/geojson-tiler/simplify.js +0 -68
  56. package/dist/lib/geojson-tiler/tile.js +0 -125
  57. package/dist/lib/geojson-tiler/transform.js +0 -43
  58. package/dist/lib/geojson-tiler/wrap.js +0 -86
  59. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +0 -170
  60. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +0 -89
  61. package/dist/lib/mapbox-vector-tile/vector-tile.js +0 -29
  62. package/dist/lib/parse-mvt.js +0 -167
  63. package/dist/lib/types.js +0 -2
  64. package/dist/mvt-loader.js +0 -47
  65. package/dist/workers/mvt-worker.js +0 -5
@@ -1,86 +0,0 @@
1
- "use strict";
2
- // loaders.gl, MIT license
3
- // Forked from https://github.com/mapbox/geojson-vt under compatible ISC license
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.wrap = void 0;
6
- const clip_1 = require("./clip");
7
- const feature_1 = require("./feature");
8
- /**
9
- * Wrap across antemeridian, by clipping into two tiles, shifting the overflowing x coordinates
10
- * @param features list of features to be wrapped
11
- * @param options buffer and extent
12
- * @returns
13
- */
14
- function wrap(features, options) {
15
- const buffer = options.buffer / options.extent;
16
- let merged = features;
17
- const left = (0, clip_1.clip)(features, 1, -1 - buffer, buffer, 0, -1, 2, options); // left world copy
18
- const right = (0, clip_1.clip)(features, 1, 1 - buffer, 2 + buffer, 0, -1, 2, options); // right world copy
19
- if (left || right) {
20
- merged = (0, clip_1.clip)(features, 1, -buffer, 1 + buffer, 0, -1, 2, options) || []; // center world copy
21
- if (left) {
22
- merged = shiftFeatureCoords(left, 1).concat(merged); // merge left into center
23
- }
24
- if (right) {
25
- merged = merged.concat(shiftFeatureCoords(right, -1)); // merge right into center
26
- }
27
- }
28
- return merged;
29
- }
30
- exports.wrap = wrap;
31
- /**
32
- * Shift the x coordinates of a list of features
33
- * @param features list of features to shift x coordinates for
34
- * @param offset
35
- * @returns
36
- */
37
- function shiftFeatureCoords(features, offset) {
38
- const newFeatures = [];
39
- for (let i = 0; i < features.length; i++) {
40
- const feature = features[i];
41
- const type = feature.type;
42
- let newGeometry;
43
- if (type === 'Point' || type === 'MultiPoint' || type === 'LineString') {
44
- newGeometry = shiftCoords(feature.geometry, offset);
45
- }
46
- else if (type === 'MultiLineString' || type === 'Polygon') {
47
- newGeometry = [];
48
- for (const line of feature.geometry) {
49
- newGeometry.push(shiftCoords(line, offset));
50
- }
51
- }
52
- else if (type === 'MultiPolygon') {
53
- newGeometry = [];
54
- for (const polygon of feature.geometry) {
55
- const newPolygon = [];
56
- for (const line of polygon) {
57
- // @ts-expect-error TODO
58
- newPolygon.push(shiftCoords(line, offset));
59
- }
60
- newGeometry.push(newPolygon);
61
- }
62
- }
63
- newFeatures.push((0, feature_1.createFeature)(feature.id, type, newGeometry, feature.tags));
64
- }
65
- return newFeatures;
66
- }
67
- class Points extends Array {
68
- }
69
- /**
70
- * Shift the x coordinate of every point
71
- * @param points
72
- * @param offset
73
- * @returns
74
- */
75
- function shiftCoords(points, offset) {
76
- const newPoints = [];
77
- newPoints.size = points.size;
78
- if (points.start !== undefined) {
79
- newPoints.start = points.start;
80
- newPoints.end = points.end;
81
- }
82
- for (let i = 0; i < points.length; i += 3) {
83
- newPoints.push(points[i] + offset, points[i + 1], points[i + 2]);
84
- }
85
- return newPoints;
86
- }
@@ -1,170 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mapbox_util_functions_1 = require("../../helpers/mapbox-util-functions");
4
- class VectorTileFeature {
5
- static get types() {
6
- return ['Unknown', 'Point', 'LineString', 'Polygon'];
7
- }
8
- constructor(pbf, end, extent, keys, values) {
9
- // Public
10
- this.properties = {};
11
- this.extent = extent;
12
- this.type = 0;
13
- this.id = null;
14
- // Private
15
- this._pbf = pbf;
16
- this._geometry = -1;
17
- this._keys = keys;
18
- this._values = values;
19
- pbf.readFields(mapbox_util_functions_1.readFeature, this, end);
20
- }
21
- // eslint-disable-next-line complexity, max-statements
22
- loadGeometry() {
23
- const pbf = this._pbf;
24
- pbf.pos = this._geometry;
25
- const end = pbf.readVarint() + pbf.pos;
26
- let cmd = 1;
27
- let length = 0;
28
- let x = 0;
29
- let y = 0;
30
- const lines = [];
31
- let line;
32
- while (pbf.pos < end) {
33
- if (length <= 0) {
34
- const cmdLen = pbf.readVarint();
35
- cmd = cmdLen & 0x7;
36
- length = cmdLen >> 3;
37
- }
38
- length--;
39
- if (cmd === 1 || cmd === 2) {
40
- x += pbf.readSVarint();
41
- y += pbf.readSVarint();
42
- if (cmd === 1) {
43
- // moveTo
44
- if (line)
45
- lines.push(line);
46
- line = [];
47
- }
48
- if (line)
49
- line.push([x, y]);
50
- }
51
- else if (cmd === 7) {
52
- // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
53
- if (line) {
54
- line.push(line[0].slice()); // closePolygon
55
- }
56
- }
57
- else {
58
- throw new Error(`unknown command ${cmd}`);
59
- }
60
- }
61
- if (line)
62
- lines.push(line);
63
- return lines;
64
- }
65
- // eslint-disable-next-line max-statements
66
- bbox() {
67
- const pbf = this._pbf;
68
- pbf.pos = this._geometry;
69
- const end = pbf.readVarint() + pbf.pos;
70
- let cmd = 1;
71
- let length = 0;
72
- let x = 0;
73
- let y = 0;
74
- let x1 = Infinity;
75
- let x2 = -Infinity;
76
- let y1 = Infinity;
77
- let y2 = -Infinity;
78
- while (pbf.pos < end) {
79
- if (length <= 0) {
80
- const cmdLen = pbf.readVarint();
81
- cmd = cmdLen & 0x7;
82
- length = cmdLen >> 3;
83
- }
84
- length--;
85
- if (cmd === 1 || cmd === 2) {
86
- x += pbf.readSVarint();
87
- y += pbf.readSVarint();
88
- if (x < x1)
89
- x1 = x;
90
- if (x > x2)
91
- x2 = x;
92
- if (y < y1)
93
- y1 = y;
94
- if (y > y2)
95
- y2 = y;
96
- }
97
- else if (cmd !== 7) {
98
- throw new Error(`unknown command ${cmd}`);
99
- }
100
- }
101
- return [x1, y1, x2, y2];
102
- }
103
- _toGeoJSON(transform) {
104
- let coords = this.loadGeometry();
105
- let type = VectorTileFeature.types[this.type];
106
- let i;
107
- let j;
108
- // eslint-disable-next-line default-case
109
- switch (this.type) {
110
- case 1:
111
- const points = [];
112
- for (i = 0; i < coords.length; i++) {
113
- points[i] = coords[i][0];
114
- }
115
- coords = points;
116
- transform(coords, this);
117
- break;
118
- case 2:
119
- for (i = 0; i < coords.length; i++) {
120
- transform(coords[i], this);
121
- }
122
- break;
123
- case 3:
124
- coords = (0, mapbox_util_functions_1.classifyRings)(coords);
125
- for (i = 0; i < coords.length; i++) {
126
- for (j = 0; j < coords[i].length; j++) {
127
- transform(coords[i][j], this);
128
- }
129
- }
130
- break;
131
- }
132
- if (coords.length === 1) {
133
- coords = coords[0];
134
- }
135
- else {
136
- type = `Multi${type}`;
137
- }
138
- const result = {
139
- type: 'Feature',
140
- geometry: {
141
- type,
142
- coordinates: coords
143
- },
144
- properties: this.properties
145
- };
146
- if (this.id !== null) {
147
- result.id = this.id;
148
- }
149
- return result;
150
- }
151
- toGeoJSON(options) {
152
- if (typeof options === 'function') {
153
- return this._toGeoJSON(options);
154
- }
155
- const { x, y, z } = options;
156
- const size = this.extent * Math.pow(2, z);
157
- const x0 = this.extent * x;
158
- const y0 = this.extent * y;
159
- function project(line) {
160
- for (let j = 0; j < line.length; j++) {
161
- const p = line[j];
162
- p[0] = ((p[0] + x0) * 360) / size - 180;
163
- const y2 = 180 - ((p[1] + y0) * 360) / size;
164
- p[1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
165
- }
166
- }
167
- return this._toGeoJSON(project);
168
- }
169
- }
170
- exports.default = VectorTileFeature;
@@ -1,89 +0,0 @@
1
- "use strict";
2
- /* eslint-disable indent */
3
- // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
4
- var __importDefault = (this && this.__importDefault) || function (mod) {
5
- return (mod && mod.__esModule) ? mod : { "default": mod };
6
- };
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- const vector_tile_feature_1 = __importDefault(require("./vector-tile-feature"));
9
- class VectorTileLayer {
10
- constructor(pbf, end) {
11
- // Public
12
- this.version = 1;
13
- this.name = '';
14
- this.extent = 4096;
15
- this.length = 0;
16
- // Private
17
- this._pbf = pbf;
18
- this._keys = [];
19
- this._values = [];
20
- this._features = [];
21
- pbf.readFields(readLayer, this, end);
22
- this.length = this._features.length;
23
- }
24
- /**
25
- * return feature `i` from this layer as a `VectorTileFeature`
26
- * @param index
27
- * @returns feature
28
- */
29
- feature(i) {
30
- if (i < 0 || i >= this._features.length) {
31
- throw new Error('feature index out of bounds');
32
- }
33
- this._pbf.pos = this._features[i];
34
- const end = this._pbf.readVarint() + this._pbf.pos;
35
- return new vector_tile_feature_1.default(this._pbf, end, this.extent, this._keys, this._values);
36
- }
37
- }
38
- exports.default = VectorTileLayer;
39
- /**
40
- *
41
- * @param tag
42
- * @param layer
43
- * @param pbf
44
- */
45
- function readLayer(tag, layer, pbf) {
46
- if (layer && pbf) {
47
- if (tag === 15)
48
- layer.version = pbf.readVarint();
49
- else if (tag === 1)
50
- layer.name = pbf.readString();
51
- else if (tag === 5)
52
- layer.extent = pbf.readVarint();
53
- else if (tag === 2)
54
- layer._features.push(pbf.pos);
55
- else if (tag === 3)
56
- layer._keys.push(pbf.readString());
57
- else if (tag === 4)
58
- layer._values.push(readValueMessage(pbf));
59
- }
60
- }
61
- /**
62
- *
63
- * @param pbf
64
- * @returns value
65
- */
66
- function readValueMessage(pbf) {
67
- let value = null;
68
- const end = pbf.readVarint() + pbf.pos;
69
- while (pbf.pos < end) {
70
- const tag = pbf.readVarint() >> 3;
71
- value =
72
- tag === 1
73
- ? pbf.readString()
74
- : tag === 2
75
- ? pbf.readFloat()
76
- : tag === 3
77
- ? pbf.readDouble()
78
- : tag === 4
79
- ? pbf.readVarint64()
80
- : tag === 5
81
- ? pbf.readVarint()
82
- : tag === 6
83
- ? pbf.readSVarint()
84
- : tag === 7
85
- ? pbf.readBoolean()
86
- : null;
87
- }
88
- return value;
89
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- // This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const vector_tile_layer_1 = __importDefault(require("./vector-tile-layer"));
8
- class VectorTile {
9
- constructor(pbf, end) {
10
- this.layers = pbf.readFields(readTile, {}, end);
11
- }
12
- }
13
- exports.default = VectorTile;
14
- /**
15
- *
16
- * @param tag
17
- * @param layers
18
- * @param pbf
19
- */
20
- function readTile(tag, layers, pbf) {
21
- if (tag === 3) {
22
- if (pbf) {
23
- const layer = new vector_tile_layer_1.default(pbf, pbf.readVarint() + pbf.pos);
24
- if (layer.length && layers) {
25
- layers[layer.name] = layer;
26
- }
27
- }
28
- }
29
- }
@@ -1,167 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const gis_1 = require("@loaders.gl/gis");
7
- const pbf_1 = __importDefault(require("pbf"));
8
- const vector_tile_1 = __importDefault(require("./mapbox-vector-tile/vector-tile"));
9
- const vector_tile_2 = __importDefault(require("./binary-vector-tile/vector-tile"));
10
- /**
11
- * Parse MVT arrayBuffer and return GeoJSON.
12
- *
13
- * @param arrayBuffer A MVT arrayBuffer
14
- * @param options
15
- * @returns A GeoJSON geometry object or a binary representation
16
- */
17
- function parseMVT(arrayBuffer, options) {
18
- const mvtOptions = normalizeOptions(options);
19
- const shape = options?.gis?.format || options?.mvt?.shape;
20
- switch (shape) {
21
- case 'columnar-table': // binary + some JS arrays
22
- return { shape: 'columnar-table', data: parseToBinary(arrayBuffer, mvtOptions) };
23
- case 'geojson-row-table': {
24
- const table = {
25
- shape: 'geojson-row-table',
26
- data: parseToGeojson(arrayBuffer, mvtOptions)
27
- };
28
- return table;
29
- }
30
- case 'geojson':
31
- return parseToGeojson(arrayBuffer, mvtOptions);
32
- case 'binary-geometry':
33
- return parseToBinary(arrayBuffer, mvtOptions);
34
- case 'binary':
35
- return parseToBinary(arrayBuffer, mvtOptions);
36
- default:
37
- throw new Error(shape);
38
- }
39
- }
40
- exports.default = parseMVT;
41
- function parseToBinary(arrayBuffer, options) {
42
- const [flatGeoJsonFeatures, geometryInfo] = parseToFlatGeoJson(arrayBuffer, options);
43
- const binaryData = (0, gis_1.flatGeojsonToBinary)(flatGeoJsonFeatures, geometryInfo);
44
- // Add the original byteLength (as a reasonable approximation of the size of the binary data)
45
- // TODO decide where to store extra fields like byteLength (header etc) and document
46
- // @ts-ignore
47
- binaryData.byteLength = arrayBuffer.byteLength;
48
- return binaryData;
49
- }
50
- function parseToFlatGeoJson(arrayBuffer, options) {
51
- const features = [];
52
- const geometryInfo = {
53
- coordLength: 2,
54
- pointPositionsCount: 0,
55
- pointFeaturesCount: 0,
56
- linePositionsCount: 0,
57
- linePathsCount: 0,
58
- lineFeaturesCount: 0,
59
- polygonPositionsCount: 0,
60
- polygonObjectsCount: 0,
61
- polygonRingsCount: 0,
62
- polygonFeaturesCount: 0
63
- };
64
- if (arrayBuffer.byteLength <= 0) {
65
- return [features, geometryInfo];
66
- }
67
- const tile = new vector_tile_2.default(new pbf_1.default(arrayBuffer));
68
- const selectedLayers = options && Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
69
- selectedLayers.forEach((layerName) => {
70
- const vectorTileLayer = tile.layers[layerName];
71
- if (!vectorTileLayer) {
72
- return;
73
- }
74
- for (let i = 0; i < vectorTileLayer.length; i++) {
75
- const vectorTileFeature = vectorTileLayer.feature(i, geometryInfo);
76
- const decodedFeature = getDecodedFeatureBinary(vectorTileFeature, options, layerName);
77
- features.push(decodedFeature);
78
- }
79
- });
80
- return [features, geometryInfo];
81
- }
82
- function parseToGeojson(arrayBuffer, options) {
83
- if (arrayBuffer.byteLength <= 0) {
84
- return [];
85
- }
86
- const features = [];
87
- const tile = new vector_tile_1.default(new pbf_1.default(arrayBuffer));
88
- const selectedLayers = Array.isArray(options.layers) ? options.layers : Object.keys(tile.layers);
89
- selectedLayers.forEach((layerName) => {
90
- const vectorTileLayer = tile.layers[layerName];
91
- if (!vectorTileLayer) {
92
- return;
93
- }
94
- for (let i = 0; i < vectorTileLayer.length; i++) {
95
- const vectorTileFeature = vectorTileLayer.feature(i);
96
- const decodedFeature = getDecodedFeature(vectorTileFeature, options, layerName);
97
- features.push(decodedFeature);
98
- }
99
- });
100
- return features;
101
- }
102
- function normalizeOptions(options) {
103
- if (!options?.mvt) {
104
- throw new Error('mvt options required');
105
- }
106
- // Validate
107
- const wgs84Coordinates = options.mvt?.coordinates === 'wgs84';
108
- const { tileIndex } = options.mvt;
109
- const hasTileIndex = tileIndex &&
110
- Number.isFinite(tileIndex.x) &&
111
- Number.isFinite(tileIndex.y) &&
112
- Number.isFinite(tileIndex.z);
113
- if (wgs84Coordinates && !hasTileIndex) {
114
- throw new Error('MVT Loader: WGS84 coordinates need tileIndex property');
115
- }
116
- return options.mvt;
117
- }
118
- /**
119
- * @param feature
120
- * @param options
121
- * @returns decoded feature
122
- */
123
- function getDecodedFeature(feature, options, layerName) {
124
- const decodedFeature = feature.toGeoJSON(options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinates);
125
- // Add layer name to GeoJSON properties
126
- if (options.layerProperty) {
127
- decodedFeature.properties[options.layerProperty] = layerName;
128
- }
129
- return decodedFeature;
130
- }
131
- /**
132
- * @param feature
133
- * @param options
134
- * @returns decoded binary feature
135
- */
136
- function getDecodedFeatureBinary(feature, options, layerName) {
137
- const decodedFeature = feature.toBinaryCoordinates(options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinatesBinary);
138
- // Add layer name to GeoJSON properties
139
- if (options.layerProperty && decodedFeature.properties) {
140
- decodedFeature.properties[options.layerProperty] = layerName;
141
- }
142
- return decodedFeature;
143
- }
144
- /**
145
- * @param line
146
- * @param feature
147
- */
148
- function transformToLocalCoordinates(line, feature) {
149
- // This function transforms local coordinates in a
150
- // [0 - bufferSize, this.extent + bufferSize] range to a
151
- // [0 - (bufferSize / this.extent), 1 + (bufferSize / this.extent)] range.
152
- // The resulting extent would be 1.
153
- const { extent } = feature;
154
- for (let i = 0; i < line.length; i++) {
155
- const p = line[i];
156
- p[0] /= extent;
157
- p[1] /= extent;
158
- }
159
- }
160
- function transformToLocalCoordinatesBinary(data, feature) {
161
- // For the binary code path, the feature data is just
162
- // one big flat array, so we just divide each value
163
- const { extent } = feature;
164
- for (let i = 0, il = data.length; i < il; ++i) {
165
- data[i] /= extent;
166
- }
167
- }
package/dist/lib/types.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.MVTLoader = exports.MVTWorkerLoader = void 0;
7
- const parse_mvt_1 = __importDefault(require("./lib/parse-mvt"));
8
- // __VERSION__ is injected by babel-plugin-version-inline
9
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
10
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
11
- const DEFAULT_MVT_LOADER_OPTIONS = {
12
- mvt: {
13
- shape: 'geojson',
14
- coordinates: 'local',
15
- layerProperty: 'layerName',
16
- layers: undefined,
17
- tileIndex: null
18
- }
19
- };
20
- /**
21
- * Worker loader for the Mapbox Vector Tile format
22
- */
23
- exports.MVTWorkerLoader = {
24
- name: 'Mapbox Vector Tile',
25
- id: 'mvt',
26
- module: 'mvt',
27
- version: VERSION,
28
- // Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
29
- extensions: ['mvt', 'pbf'],
30
- mimeTypes: [
31
- 'application/vnd.mapbox-vector-tile',
32
- 'application/x-protobuf'
33
- // 'application/octet-stream'
34
- ],
35
- worker: true,
36
- category: 'geometry',
37
- options: DEFAULT_MVT_LOADER_OPTIONS
38
- };
39
- /**
40
- * Loader for the Mapbox Vector Tile format
41
- */
42
- exports.MVTLoader = {
43
- ...exports.MVTWorkerLoader,
44
- parse: async (arrayBuffer, options) => (0, parse_mvt_1.default)(arrayBuffer, options),
45
- parseSync: parse_mvt_1.default,
46
- binary: true
47
- };
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const mvt_loader_1 = require("../mvt-loader");
4
- const loader_utils_1 = require("@loaders.gl/loader-utils");
5
- (0, loader_utils_1.createLoaderWorker)(mvt_loader_1.MVTLoader);