@loaders.gl/mvt 3.1.0 → 3.1.4
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.js +5 -2281
- package/dist/dist.min.js +2289 -0
- package/dist/es5/helpers/binary-util-functions.js +8 -5
- package/dist/es5/helpers/binary-util-functions.js.map +1 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +33 -31
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +2 -2
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -1
- package/dist/es5/lib/parse-mvt.js +6 -5
- package/dist/es5/lib/parse-mvt.js.map +1 -1
- package/dist/es5/mvt-loader.js +1 -1
- package/dist/esm/helpers/binary-util-functions.js +8 -5
- package/dist/esm/helpers/binary-util-functions.js.map +1 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +31 -30
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +2 -2
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -1
- package/dist/esm/lib/parse-mvt.js +6 -5
- package/dist/esm/lib/parse-mvt.js.map +1 -1
- package/dist/esm/mvt-loader.js +1 -1
- package/dist/helpers/binary-util-functions.d.ts +2 -6
- package/dist/helpers/binary-util-functions.d.ts.map +1 -1
- package/dist/helpers/binary-util-functions.js +7 -5
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +12 -7
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +32 -39
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +3 -3
- package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +3 -3
- package/dist/lib/parse-mvt.d.ts +8 -76
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +6 -5
- package/dist/lib/types.d.ts +0 -68
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/mvt-worker.js +90 -89
- package/package.json +7 -6
- package/src/helpers/binary-util-functions.ts +9 -7
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +36 -44
- package/src/lib/binary-vector-tile/vector-tile-layer.ts +4 -4
- package/src/lib/parse-mvt.ts +10 -8
- package/src/lib/types.ts +0 -75
- package/dist/es5/lib/binary-vector-tile/features-to-binary.js +0 -389
- package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/features-to-binary.js +0 -331
- package/dist/esm/lib/binary-vector-tile/features-to-binary.js.map +0 -1
- package/dist/lib/binary-vector-tile/features-to-binary.d.ts +0 -177
- package/dist/lib/binary-vector-tile/features-to-binary.d.ts.map +0 -1
- package/dist/lib/binary-vector-tile/features-to-binary.js +0 -358
- package/src/lib/binary-vector-tile/features-to-binary.ts +0 -527
|
@@ -25,16 +25,16 @@ class VectorTileLayer {
|
|
|
25
25
|
* return feature `i` from this layer as a `VectorTileFeature`
|
|
26
26
|
*
|
|
27
27
|
* @param index
|
|
28
|
-
* @param
|
|
28
|
+
* @param geometryInfo
|
|
29
29
|
* @returns {VectorTileFeature}
|
|
30
30
|
*/
|
|
31
|
-
feature(i,
|
|
31
|
+
feature(i, geometryInfo) {
|
|
32
32
|
if (i < 0 || i >= this._features.length) {
|
|
33
33
|
throw new Error('feature index out of bounds');
|
|
34
34
|
}
|
|
35
35
|
this._pbf.pos = this._features[i];
|
|
36
36
|
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
37
|
-
return new vector_tile_feature_1.default(this._pbf, end, this.extent, this._keys, this._values,
|
|
37
|
+
return new vector_tile_feature_1.default(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
exports.default = VectorTileLayer;
|
package/dist/lib/parse-mvt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MvtMapboxCoordinates } from '../lib/types';
|
|
2
2
|
import { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
3
3
|
/**
|
|
4
4
|
* Parse MVT arrayBuffer and return GeoJSON.
|
|
@@ -7,79 +7,11 @@ import { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
|
7
7
|
* @param options
|
|
8
8
|
* @returns A GeoJSON geometry object or a binary representation
|
|
9
9
|
*/
|
|
10
|
-
export default function parseMVT(arrayBuffer: ArrayBuffer, options?: LoaderOptions): {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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)[];
|
|
10
|
+
export default function parseMVT(arrayBuffer: ArrayBuffer, options?: LoaderOptions): (MvtMapboxCoordinates | {
|
|
11
|
+
type: "Feature";
|
|
12
|
+
geometry: import("@loaders.gl/schema").FlatGeometry;
|
|
13
|
+
id?: string | number | undefined;
|
|
14
|
+
properties: import("geojson").GeoJsonProperties;
|
|
15
|
+
bbox?: import("geojson").BBox | undefined;
|
|
16
|
+
})[] | import("@loaders.gl/schema").BinaryFeatures;
|
|
85
17
|
//# sourceMappingURL=parse-mvt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-mvt.d.ts","sourceRoot":"","sources":["../../src/lib/parse-mvt.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,oBAAoB,EAAa,MAAM,cAAc,CAAC;AAGnE,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEvD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,aAAa;;;;;;mDA0DjF"}
|
package/dist/lib/parse-mvt.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
// import {VectorTile} from '@mapbox/vector-tile';
|
|
7
7
|
const vector_tile_1 = __importDefault(require("./mapbox-vector-tile/vector-tile"));
|
|
8
8
|
const vector_tile_2 = __importDefault(require("./binary-vector-tile/vector-tile"));
|
|
9
|
-
const
|
|
9
|
+
const gis_1 = require("@loaders.gl/gis");
|
|
10
10
|
const pbf_1 = __importDefault(require("pbf"));
|
|
11
11
|
/**
|
|
12
12
|
* Parse MVT arrayBuffer and return GeoJSON.
|
|
@@ -20,7 +20,8 @@ function parseMVT(arrayBuffer, options) {
|
|
|
20
20
|
const features = [];
|
|
21
21
|
if (options) {
|
|
22
22
|
const binary = options.gis.format === 'binary';
|
|
23
|
-
const
|
|
23
|
+
const geometryInfo = {
|
|
24
|
+
coordLength: 2,
|
|
24
25
|
pointPositionsCount: 0,
|
|
25
26
|
pointFeaturesCount: 0,
|
|
26
27
|
linePositionsCount: 0,
|
|
@@ -46,7 +47,7 @@ function parseMVT(arrayBuffer, options) {
|
|
|
46
47
|
return;
|
|
47
48
|
}
|
|
48
49
|
for (let i = 0; i < vectorTileLayer.length; i++) {
|
|
49
|
-
const vectorTileFeature = vectorTileLayer.feature(i,
|
|
50
|
+
const vectorTileFeature = vectorTileLayer.feature(i, geometryInfo);
|
|
50
51
|
const decodedFeature = binary
|
|
51
52
|
? getDecodedFeatureBinary(vectorTileFeature, featureOptions)
|
|
52
53
|
: getDecodedFeature(vectorTileFeature, featureOptions);
|
|
@@ -55,7 +56,7 @@ function parseMVT(arrayBuffer, options) {
|
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
if (binary) {
|
|
58
|
-
const data = (0,
|
|
59
|
+
const data = (0, gis_1.flatGeojsonToBinary)(features, geometryInfo);
|
|
59
60
|
// Add the original byteLength (as a reasonable approximation of the size of the binary data)
|
|
60
61
|
// TODO decide where to store extra fields like byteLength (header etc) and document
|
|
61
62
|
// @ts-ignore
|
|
@@ -111,7 +112,7 @@ function getDecodedFeature(feature, options) {
|
|
|
111
112
|
function getDecodedFeatureBinary(feature, options) {
|
|
112
113
|
const decodedFeature = feature.toBinaryCoordinates(options.coordinates === 'wgs84' ? options.tileIndex : transformToLocalCoordinatesBinary);
|
|
113
114
|
// Add layer name to GeoJSON properties
|
|
114
|
-
if (options.layerProperty) {
|
|
115
|
+
if (options.layerProperty && decodedFeature.properties) {
|
|
115
116
|
decodedFeature.properties[options.layerProperty] = options.layerName;
|
|
116
117
|
}
|
|
117
118
|
return decodedFeature;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -8,27 +8,12 @@ export declare type MvtOptions = {
|
|
|
8
8
|
layerProperty: string | number;
|
|
9
9
|
layerName: string;
|
|
10
10
|
};
|
|
11
|
-
export declare type MvtBinaryGeometry = {
|
|
12
|
-
data: number[];
|
|
13
|
-
lines: any[];
|
|
14
|
-
areas?: number[];
|
|
15
|
-
type?: string;
|
|
16
|
-
id?: number;
|
|
17
|
-
};
|
|
18
11
|
export declare type MvtMapboxGeometry = {
|
|
19
12
|
type?: string;
|
|
20
13
|
id?: number;
|
|
21
14
|
length: number;
|
|
22
15
|
coordinates?: any[];
|
|
23
16
|
};
|
|
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
17
|
export declare type MvtMapboxCoordinates = {
|
|
33
18
|
type: string;
|
|
34
19
|
geometry: {
|
|
@@ -40,57 +25,4 @@ export declare type MvtMapboxCoordinates = {
|
|
|
40
25
|
};
|
|
41
26
|
id?: number;
|
|
42
27
|
};
|
|
43
|
-
export declare type MvtPropArrayConstructor = Float32ArrayConstructor | Float64ArrayConstructor | ArrayConstructor;
|
|
44
|
-
export declare type MvtBinaryOptions = {
|
|
45
|
-
numericPropKeys: string[];
|
|
46
|
-
propArrayTypes: {
|
|
47
|
-
[key: string]: MvtPropArrayConstructor;
|
|
48
|
-
};
|
|
49
|
-
PositionDataType: Float32ArrayConstructor;
|
|
50
|
-
};
|
|
51
|
-
export declare type MvtFirstPassedData = {
|
|
52
|
-
pointPositionsCount: number;
|
|
53
|
-
pointFeaturesCount: number;
|
|
54
|
-
linePositionsCount: number;
|
|
55
|
-
linePathsCount: number;
|
|
56
|
-
lineFeaturesCount: number;
|
|
57
|
-
polygonPositionsCount: number;
|
|
58
|
-
polygonObjectsCount: number;
|
|
59
|
-
polygonRingsCount: number;
|
|
60
|
-
polygonFeaturesCount: number;
|
|
61
|
-
};
|
|
62
|
-
export declare type MvtPoints = {
|
|
63
|
-
positions: Float32Array;
|
|
64
|
-
globalFeatureIds: Uint16Array | Uint32Array;
|
|
65
|
-
featureIds: Uint16Array | Uint32Array;
|
|
66
|
-
numericProps: object;
|
|
67
|
-
properties: {}[];
|
|
68
|
-
fields: {
|
|
69
|
-
id?: number;
|
|
70
|
-
}[];
|
|
71
|
-
};
|
|
72
|
-
export declare type MvtLines = {
|
|
73
|
-
pathIndices: Uint16Array | Uint32Array;
|
|
74
|
-
positions: Float32Array;
|
|
75
|
-
globalFeatureIds: Uint16Array | Uint32Array;
|
|
76
|
-
featureIds: Uint16Array | Uint32Array;
|
|
77
|
-
numericProps: object;
|
|
78
|
-
properties: {}[];
|
|
79
|
-
fields: {
|
|
80
|
-
id?: number;
|
|
81
|
-
}[];
|
|
82
|
-
};
|
|
83
|
-
export declare type MvtPolygons = {
|
|
84
|
-
polygonIndices: Uint16Array | Uint32Array;
|
|
85
|
-
primitivePolygonIndices: Uint16Array | Uint32Array;
|
|
86
|
-
positions: Float32Array;
|
|
87
|
-
triangles: number[];
|
|
88
|
-
globalFeatureIds: Uint16Array | Uint32Array;
|
|
89
|
-
featureIds: Uint16Array | Uint32Array;
|
|
90
|
-
numericProps: object;
|
|
91
|
-
properties: {}[];
|
|
92
|
-
fields: {
|
|
93
|
-
id?: number;
|
|
94
|
-
}[];
|
|
95
|
-
};
|
|
96
28
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IAC7C,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG;IACvB,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC;IAC7C,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,GAAG,EAAE,CAAC;CACrB,CAAC;AAEF,oBAAY,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,iBAAiB,CAAC;KAChC,CAAC;IACF,UAAU,EAAE;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAA;KAAC,CAAC;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC"}
|