@loaders.gl/mvt 3.1.0-alpha.3 → 3.1.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/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2276 -4
- package/dist/es5/bundle.js +7 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/helpers/binary-util-functions.js +95 -0
- package/dist/es5/helpers/binary-util-functions.js.map +1 -0
- package/dist/es5/helpers/mapbox-util-functions.js +62 -0
- package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/es5/index.js +20 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
- package/dist/es5/lib/binary-vector-tile/features-to-binary.js +338 -0
- package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +162 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +69 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js +35 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +207 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +69 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +35 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/parse-mvt.js +129 -0
- package/dist/es5/lib/parse-mvt.js.map +1 -0
- package/dist/es5/lib/types.js +2 -0
- package/dist/{lib → es5/lib}/types.js.map +0 -0
- package/dist/es5/mvt-loader.js +38 -0
- package/dist/es5/mvt-loader.js.map +1 -0
- package/dist/es5/workers/mvt-worker.js +8 -0
- package/dist/es5/workers/mvt-worker.js.map +1 -0
- package/dist/esm/bundle.js +5 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/helpers/binary-util-functions.js +81 -0
- package/dist/esm/helpers/binary-util-functions.js.map +1 -0
- package/dist/esm/helpers/mapbox-util-functions.js +49 -0
- package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
- package/dist/esm/lib/binary-vector-tile/features-to-binary.js +327 -0
- package/dist/esm/lib/binary-vector-tile/features-to-binary.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +156 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +64 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js +23 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +202 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +64 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +23 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/parse-mvt.js +116 -0
- package/dist/esm/lib/parse-mvt.js.map +1 -0
- package/dist/esm/lib/types.js +2 -0
- package/dist/esm/lib/types.js.map +1 -0
- package/dist/esm/mvt-loader.js +26 -0
- package/dist/esm/mvt-loader.js.map +1 -0
- package/dist/esm/workers/mvt-worker.js +4 -0
- package/dist/esm/workers/mvt-worker.js.map +1 -0
- package/dist/helpers/binary-util-functions.d.ts +39 -0
- package/dist/helpers/binary-util-functions.d.ts.map +1 -0
- package/dist/helpers/binary-util-functions.js +109 -74
- package/dist/helpers/mapbox-util-functions.d.ts +29 -0
- package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
- package/dist/helpers/mapbox-util-functions.js +78 -45
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -2
- package/dist/lib/binary-vector-tile/features-to-binary.d.ts +185 -0
- package/dist/lib/binary-vector-tile/features-to-binary.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/features-to-binary.js +323 -297
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +36 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +145 -142
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
- package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
- package/dist/lib/parse-mvt.d.ts +85 -0
- package/dist/lib/parse-mvt.d.ts.map +1 -0
- package/dist/lib/parse-mvt.js +126 -100
- package/dist/lib/types.d.ts +92 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +2 -2
- package/dist/mvt-loader.d.ts +10 -0
- package/dist/mvt-loader.d.ts.map +1 -0
- package/dist/mvt-loader.js +42 -23
- package/dist/mvt-worker.js +2286 -3
- package/dist/workers/mvt-worker.d.ts +2 -0
- package/dist/workers/mvt-worker.d.ts.map +1 -0
- package/dist/workers/mvt-worker.js +5 -4
- package/package.json +9 -9
- package/src/lib/parse-mvt.ts +1 -1
- package/dist/bundle.js.map +0 -1
- package/dist/dist.min.js +0 -4
- package/dist/dist.min.js.map +0 -1
- 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/features-to-binary.js.map +0 -1
- 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/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/mvt-loader.js.map +0 -1
- package/dist/mvt-worker.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { MvtBinaryCoordinates, MvtMapboxCoordinates } from '../lib/types';
|
|
2
|
+
import { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
3
|
+
/**
|
|
4
|
+
* Parse MVT arrayBuffer and return GeoJSON.
|
|
5
|
+
*
|
|
6
|
+
* @param arrayBuffer A MVT arrayBuffer
|
|
7
|
+
* @param options
|
|
8
|
+
* @returns A GeoJSON geometry object or a binary representation
|
|
9
|
+
*/
|
|
10
|
+
export default function parseMVT(arrayBuffer: ArrayBuffer, options?: LoaderOptions): {
|
|
11
|
+
points: {
|
|
12
|
+
positions: {
|
|
13
|
+
value: Float32Array;
|
|
14
|
+
size: number;
|
|
15
|
+
};
|
|
16
|
+
globalFeatureIds: {
|
|
17
|
+
value: Uint16Array | Uint32Array;
|
|
18
|
+
size: number;
|
|
19
|
+
};
|
|
20
|
+
featureIds: {
|
|
21
|
+
value: Uint16Array | Uint32Array;
|
|
22
|
+
size: number;
|
|
23
|
+
};
|
|
24
|
+
numericProps: object;
|
|
25
|
+
properties: {}[];
|
|
26
|
+
fields: {
|
|
27
|
+
id?: number | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
lines: {
|
|
31
|
+
pathIndices: {
|
|
32
|
+
value: Uint16Array | Uint32Array;
|
|
33
|
+
size: number;
|
|
34
|
+
};
|
|
35
|
+
positions: {
|
|
36
|
+
value: Float32Array;
|
|
37
|
+
size: number;
|
|
38
|
+
};
|
|
39
|
+
globalFeatureIds: {
|
|
40
|
+
value: Uint16Array | Uint32Array;
|
|
41
|
+
size: number;
|
|
42
|
+
};
|
|
43
|
+
featureIds: {
|
|
44
|
+
value: Uint16Array | Uint32Array;
|
|
45
|
+
size: number;
|
|
46
|
+
};
|
|
47
|
+
numericProps: object;
|
|
48
|
+
properties: {}[];
|
|
49
|
+
fields: {
|
|
50
|
+
id?: number | undefined;
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
polygons: {
|
|
54
|
+
polygonIndices: {
|
|
55
|
+
value: Uint16Array | Uint32Array;
|
|
56
|
+
size: number;
|
|
57
|
+
};
|
|
58
|
+
primitivePolygonIndices: {
|
|
59
|
+
value: Uint16Array | Uint32Array;
|
|
60
|
+
size: number;
|
|
61
|
+
};
|
|
62
|
+
positions: {
|
|
63
|
+
value: Float32Array;
|
|
64
|
+
size: number;
|
|
65
|
+
};
|
|
66
|
+
triangles: {
|
|
67
|
+
value: Uint32Array;
|
|
68
|
+
size: number;
|
|
69
|
+
};
|
|
70
|
+
globalFeatureIds: {
|
|
71
|
+
value: Uint16Array | Uint32Array;
|
|
72
|
+
size: number;
|
|
73
|
+
};
|
|
74
|
+
featureIds: {
|
|
75
|
+
value: Uint16Array | Uint32Array;
|
|
76
|
+
size: number;
|
|
77
|
+
};
|
|
78
|
+
numericProps: object;
|
|
79
|
+
properties: {}[];
|
|
80
|
+
fields: {
|
|
81
|
+
id?: number | undefined;
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
} | (MvtBinaryCoordinates | MvtMapboxCoordinates)[];
|
|
85
|
+
//# sourceMappingURL=parse-mvt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,oBAAoB,EAAE,oBAAoB,EAAa,MAAM,cAAc,CAAC;AAGpF,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAyDjF"}
|
package/dist/lib/parse-mvt.js
CHANGED
|
@@ -1,116 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
+
// import {VectorTile} from '@mapbox/vector-tile';
|
|
7
|
+
const vector_tile_1 = __importDefault(require("./mapbox-vector-tile/vector-tile"));
|
|
8
|
+
const vector_tile_2 = __importDefault(require("./binary-vector-tile/vector-tile"));
|
|
9
|
+
const features_to_binary_1 = require("./binary-vector-tile/features-to-binary");
|
|
10
|
+
const pbf_1 = __importDefault(require("pbf"));
|
|
11
|
+
/**
|
|
12
|
+
* Parse MVT arrayBuffer and return GeoJSON.
|
|
13
|
+
*
|
|
14
|
+
* @param arrayBuffer A MVT arrayBuffer
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns A GeoJSON geometry object or a binary representation
|
|
17
|
+
*/
|
|
18
|
+
function parseMVT(arrayBuffer, options) {
|
|
19
|
+
options = normalizeOptions(options);
|
|
20
|
+
const features = [];
|
|
21
|
+
if (options) {
|
|
22
|
+
const binary = options.gis.format === 'binary';
|
|
23
|
+
const firstPassData = {
|
|
24
|
+
pointPositionsCount: 0,
|
|
25
|
+
pointFeaturesCount: 0,
|
|
26
|
+
linePositionsCount: 0,
|
|
27
|
+
linePathsCount: 0,
|
|
28
|
+
lineFeaturesCount: 0,
|
|
29
|
+
polygonPositionsCount: 0,
|
|
30
|
+
polygonObjectsCount: 0,
|
|
31
|
+
polygonRingsCount: 0,
|
|
32
|
+
polygonFeaturesCount: 0
|
|
31
33
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
if (arrayBuffer.byteLength > 0) {
|
|
35
|
+
const tile = binary
|
|
36
|
+
? new vector_tile_2.default(new pbf_1.default(arrayBuffer))
|
|
37
|
+
: new vector_tile_1.default(new pbf_1.default(arrayBuffer));
|
|
38
|
+
const loaderOptions = options.mvt;
|
|
39
|
+
const selectedLayers = Array.isArray(loaderOptions.layers)
|
|
40
|
+
? loaderOptions.layers
|
|
41
|
+
: Object.keys(tile.layers);
|
|
42
|
+
selectedLayers.forEach((layerName) => {
|
|
43
|
+
const vectorTileLayer = tile.layers[layerName];
|
|
44
|
+
const featureOptions = { ...loaderOptions, layerName };
|
|
45
|
+
if (!vectorTileLayer) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
for (let i = 0; i < vectorTileLayer.length; i++) {
|
|
49
|
+
const vectorTileFeature = vectorTileLayer.feature(i, firstPassData);
|
|
50
|
+
const decodedFeature = binary
|
|
51
|
+
? getDecodedFeatureBinary(vectorTileFeature, featureOptions)
|
|
52
|
+
: getDecodedFeature(vectorTileFeature, featureOptions);
|
|
53
|
+
features.push(decodedFeature);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
35
56
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
57
|
+
if (binary) {
|
|
58
|
+
const data = (0, features_to_binary_1.featuresToBinary)(features, firstPassData);
|
|
59
|
+
// Add the original byteLength (as a reasonable approximation of the size of the binary data)
|
|
60
|
+
// TODO decide where to store extra fields like byteLength (header etc) and document
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
data.byteLength = arrayBuffer.byteLength;
|
|
63
|
+
return data;
|
|
41
64
|
}
|
|
42
|
-
});
|
|
43
65
|
}
|
|
44
|
-
|
|
45
|
-
if (binary) {
|
|
46
|
-
const data = featuresToBinary(features, firstPassData);
|
|
47
|
-
data.byteLength = arrayBuffer.byteLength;
|
|
48
|
-
return data;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return features;
|
|
66
|
+
return features;
|
|
53
67
|
}
|
|
54
|
-
|
|
68
|
+
exports.default = parseMVT;
|
|
69
|
+
/**
|
|
70
|
+
* @param options
|
|
71
|
+
* @returns options
|
|
72
|
+
*/
|
|
55
73
|
function normalizeOptions(options) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
if (options) {
|
|
75
|
+
options = {
|
|
76
|
+
...options,
|
|
77
|
+
mvt: options.mvt || {},
|
|
78
|
+
gis: options.gis || {}
|
|
79
|
+
};
|
|
80
|
+
// Validate
|
|
81
|
+
const wgs84Coordinates = options.coordinates === 'wgs84';
|
|
82
|
+
const { tileIndex } = options;
|
|
83
|
+
const hasTileIndex = tileIndex &&
|
|
84
|
+
Number.isFinite(tileIndex.x) &&
|
|
85
|
+
Number.isFinite(tileIndex.y) &&
|
|
86
|
+
Number.isFinite(tileIndex.z);
|
|
87
|
+
if (wgs84Coordinates && !hasTileIndex) {
|
|
88
|
+
throw new Error('MVT Loader: WGS84 coordinates need tileIndex property. Check documentation.');
|
|
89
|
+
}
|
|
69
90
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return options;
|
|
91
|
+
return options;
|
|
73
92
|
}
|
|
74
|
-
|
|
93
|
+
/**
|
|
94
|
+
* @param feature
|
|
95
|
+
* @param options
|
|
96
|
+
* @returns decoded feature
|
|
97
|
+
*/
|
|
75
98
|
function getDecodedFeature(feature, options) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return decodedFeature;
|
|
99
|
+
const decodedFeature = feature.toGeoJSON(options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinates);
|
|
100
|
+
// Add layer name to GeoJSON properties
|
|
101
|
+
if (options.layerProperty) {
|
|
102
|
+
decodedFeature.properties[options.layerProperty] = options.layerName;
|
|
103
|
+
}
|
|
104
|
+
return decodedFeature;
|
|
83
105
|
}
|
|
84
|
-
|
|
106
|
+
/**
|
|
107
|
+
* @param feature
|
|
108
|
+
* @param options
|
|
109
|
+
* @returns decoded binary feature
|
|
110
|
+
*/
|
|
85
111
|
function getDecodedFeatureBinary(feature, options) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return decodedFeature;
|
|
112
|
+
const decodedFeature = feature.toBinaryCoordinates(options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinatesBinary);
|
|
113
|
+
// Add layer name to GeoJSON properties
|
|
114
|
+
if (options.layerProperty) {
|
|
115
|
+
decodedFeature.properties[options.layerProperty] = options.layerName;
|
|
116
|
+
}
|
|
117
|
+
return decodedFeature;
|
|
93
118
|
}
|
|
94
|
-
|
|
119
|
+
/**
|
|
120
|
+
* @param line
|
|
121
|
+
* @param feature
|
|
122
|
+
*/
|
|
95
123
|
function transformToLocalCoordinates(line, feature) {
|
|
96
|
-
|
|
97
|
-
extent
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
124
|
+
// This function transforms local coordinates in a
|
|
125
|
+
// [0 - bufferSize, this.extent + bufferSize] range to a
|
|
126
|
+
// [0 - (bufferSize / this.extent), 1 + (bufferSize / this.extent)] range.
|
|
127
|
+
// The resulting extent would be 1.
|
|
128
|
+
const { extent } = feature;
|
|
129
|
+
for (let i = 0; i < line.length; i++) {
|
|
130
|
+
const p = line[i];
|
|
131
|
+
p[0] /= extent;
|
|
132
|
+
p[1] /= extent;
|
|
133
|
+
}
|
|
105
134
|
}
|
|
106
|
-
|
|
107
135
|
function transformToLocalCoordinatesBinary(data, feature) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
136
|
+
// For the binary code path, the feature data is just
|
|
137
|
+
// one big flat array, so we just divide each value
|
|
138
|
+
const { extent } = feature;
|
|
139
|
+
for (let i = 0, il = data.length; i < il; ++i) {
|
|
140
|
+
data[i] /= extent;
|
|
141
|
+
}
|
|
115
142
|
}
|
|
116
|
-
//# sourceMappingURL=parse-mvt.js.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export declare type MvtOptions = {
|
|
2
|
+
coordinates: string | number[];
|
|
3
|
+
tileIndex: {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
};
|
|
8
|
+
layerProperty: string | number;
|
|
9
|
+
layerName: string;
|
|
10
|
+
};
|
|
11
|
+
export declare type MvtBinaryGeometry = {
|
|
12
|
+
data: number[];
|
|
13
|
+
lines: any[];
|
|
14
|
+
areas?: number[];
|
|
15
|
+
type?: string;
|
|
16
|
+
id?: number;
|
|
17
|
+
};
|
|
18
|
+
export declare type MvtMapboxGeometry = {
|
|
19
|
+
type?: string;
|
|
20
|
+
id?: number;
|
|
21
|
+
length: number;
|
|
22
|
+
coordinates?: any[];
|
|
23
|
+
};
|
|
24
|
+
export declare type MvtBinaryCoordinates = {
|
|
25
|
+
type: string;
|
|
26
|
+
geometry: MvtBinaryGeometry;
|
|
27
|
+
properties: {
|
|
28
|
+
[x: string]: string | number | boolean | null;
|
|
29
|
+
};
|
|
30
|
+
id?: number;
|
|
31
|
+
};
|
|
32
|
+
export declare type MvtMapboxCoordinates = {
|
|
33
|
+
type: string;
|
|
34
|
+
geometry: {
|
|
35
|
+
type: string;
|
|
36
|
+
coordinates: MvtMapboxGeometry;
|
|
37
|
+
};
|
|
38
|
+
properties: {
|
|
39
|
+
[x: string]: string | number | boolean | null;
|
|
40
|
+
};
|
|
41
|
+
id?: number;
|
|
42
|
+
};
|
|
43
|
+
export declare type MvtBinaryOptions = {
|
|
44
|
+
numericPropKeys: string[];
|
|
45
|
+
PositionDataType: Float32ArrayConstructor;
|
|
46
|
+
};
|
|
47
|
+
export declare type MvtFirstPassedData = {
|
|
48
|
+
pointPositionsCount: number;
|
|
49
|
+
pointFeaturesCount: number;
|
|
50
|
+
linePositionsCount: number;
|
|
51
|
+
linePathsCount: number;
|
|
52
|
+
lineFeaturesCount: number;
|
|
53
|
+
polygonPositionsCount: number;
|
|
54
|
+
polygonObjectsCount: number;
|
|
55
|
+
polygonRingsCount: number;
|
|
56
|
+
polygonFeaturesCount: number;
|
|
57
|
+
};
|
|
58
|
+
export declare type MvtPoints = {
|
|
59
|
+
positions: Float32Array;
|
|
60
|
+
globalFeatureIds: Uint16Array | Uint32Array;
|
|
61
|
+
featureIds: Uint16Array | Uint32Array;
|
|
62
|
+
numericProps: object;
|
|
63
|
+
properties: {}[];
|
|
64
|
+
fields: {
|
|
65
|
+
id?: number;
|
|
66
|
+
}[];
|
|
67
|
+
};
|
|
68
|
+
export declare type MvtLines = {
|
|
69
|
+
pathIndices: Uint16Array | Uint32Array;
|
|
70
|
+
positions: Float32Array;
|
|
71
|
+
globalFeatureIds: Uint16Array | Uint32Array;
|
|
72
|
+
featureIds: Uint16Array | Uint32Array;
|
|
73
|
+
numericProps: object;
|
|
74
|
+
properties: {}[];
|
|
75
|
+
fields: {
|
|
76
|
+
id?: number;
|
|
77
|
+
}[];
|
|
78
|
+
};
|
|
79
|
+
export declare type MvtPolygons = {
|
|
80
|
+
polygonIndices: Uint16Array | Uint32Array;
|
|
81
|
+
primitivePolygonIndices: Uint16Array | Uint32Array;
|
|
82
|
+
positions: Float32Array;
|
|
83
|
+
triangles: number[];
|
|
84
|
+
globalFeatureIds: Uint16Array | Uint32Array;
|
|
85
|
+
featureIds: Uint16Array | Uint32Array;
|
|
86
|
+
numericProps: object;
|
|
87
|
+
properties: {}[];
|
|
88
|
+
fields: {
|
|
89
|
+
id?: number;
|
|
90
|
+
}[];
|
|
91
|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,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,cAAc,EAAE,WAAW,GAAG,WAAW,CAAC;IAC1C,uBAAuB,EAAE,WAAW,GAAG,WAAW,CAAC;IACnD,SAAS,EAAE,YAAY,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,gBAAgB,EAAE,WAAW,GAAG,WAAW,CAAC;IAC5C,UAAU,EAAE,WAAW,GAAG,WAAW,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,CAAC;KACb,EAAE,CAAC;CACL,CAAC"}
|
package/dist/lib/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Loader, LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Worker loader for the Mapbox Vector Tile format
|
|
4
|
+
*/
|
|
5
|
+
export declare const MVTWorkerLoader: Loader;
|
|
6
|
+
/**
|
|
7
|
+
* Loader for the Mapbox Vector Tile format
|
|
8
|
+
*/
|
|
9
|
+
export declare const MVTLoader: LoaderWithParser;
|
|
10
|
+
//# sourceMappingURL=mvt-loader.d.ts.map
|
|
@@ -0,0 +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;AAOvE;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,MAsB7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAKvB,CAAC"}
|
package/dist/mvt-loader.js
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
/**
|
|
12
|
+
* Worker loader for the Mapbox Vector Tile format
|
|
13
|
+
*/
|
|
14
|
+
exports.MVTWorkerLoader = {
|
|
15
|
+
name: 'Mapbox Vector Tile',
|
|
16
|
+
id: 'mvt',
|
|
17
|
+
module: 'mvt',
|
|
18
|
+
version: VERSION,
|
|
19
|
+
// Note: ArcGIS uses '.pbf' extension and 'application/octet-stream'
|
|
20
|
+
extensions: ['mvt', 'pbf'],
|
|
21
|
+
mimeTypes: [
|
|
22
|
+
'application/vnd.mapbox-vector-tile',
|
|
23
|
+
'application/x-protobuf'
|
|
24
|
+
// 'application/octet-stream'
|
|
25
|
+
],
|
|
26
|
+
worker: true,
|
|
27
|
+
category: 'geometry',
|
|
28
|
+
options: {
|
|
29
|
+
mvt: {
|
|
30
|
+
coordinates: 'local',
|
|
31
|
+
layerProperty: 'layerName',
|
|
32
|
+
layers: null,
|
|
33
|
+
tileIndex: null
|
|
34
|
+
}
|
|
18
35
|
}
|
|
19
|
-
}
|
|
20
36
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Loader for the Mapbox Vector Tile format
|
|
39
|
+
*/
|
|
40
|
+
exports.MVTLoader = {
|
|
41
|
+
...exports.MVTWorkerLoader,
|
|
42
|
+
parse: async (arrayBuffer, options) => (0, parse_mvt_1.default)(arrayBuffer, options),
|
|
43
|
+
parseSync: parse_mvt_1.default,
|
|
44
|
+
binary: true
|
|
25
45
|
};
|
|
26
|
-
//# sourceMappingURL=mvt-loader.js.map
|