@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
|
@@ -1,81 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const shape = geom.data.slice(startIndex, endIndex);
|
|
24
|
-
const area = getPolygonSignedArea(shape);
|
|
25
|
-
|
|
26
|
-
if (area === 0) {
|
|
27
|
-
const before = geom.data.slice(0, startIndex);
|
|
28
|
-
const after = geom.data.slice(endIndex);
|
|
29
|
-
geom.data = before.concat(after);
|
|
30
|
-
offset += endIndex - startIndex;
|
|
31
|
-
continue;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTag = exports.readFeature = exports.project = exports.classifyRings = void 0;
|
|
4
|
+
const polygon_1 = require("@math.gl/polygon");
|
|
5
|
+
/**
|
|
6
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
7
|
+
* The function also detects holes which have zero area and
|
|
8
|
+
* removes them. In doing so it modifies the input
|
|
9
|
+
* `geom.data` array to remove the unneeded data
|
|
10
|
+
*
|
|
11
|
+
* @param geometry
|
|
12
|
+
* @returns object
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line max-statements
|
|
15
|
+
function classifyRings(geom) {
|
|
16
|
+
const len = geom.lines.length;
|
|
17
|
+
if (len <= 1) {
|
|
18
|
+
return {
|
|
19
|
+
data: geom.data,
|
|
20
|
+
areas: [[(0, polygon_1.getPolygonSignedArea)(geom.data)]],
|
|
21
|
+
lines: [geom.lines]
|
|
22
|
+
};
|
|
32
23
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
const areas = [];
|
|
25
|
+
const polygons = [];
|
|
26
|
+
let ringAreas = [];
|
|
27
|
+
let polygon = [];
|
|
28
|
+
let ccw;
|
|
29
|
+
let offset = 0;
|
|
30
|
+
for (let endIndex, i = 0, startIndex; i < len; i++) {
|
|
31
|
+
startIndex = geom.lines[i] - offset;
|
|
32
|
+
endIndex = geom.lines[i + 1] - offset || geom.data.length;
|
|
33
|
+
const shape = geom.data.slice(startIndex, endIndex);
|
|
34
|
+
const area = (0, polygon_1.getPolygonSignedArea)(shape);
|
|
35
|
+
if (area === 0) {
|
|
36
|
+
// This polygon has no area, so remove it from the shape
|
|
37
|
+
// Remove the section from the data array
|
|
38
|
+
const before = geom.data.slice(0, startIndex);
|
|
39
|
+
const after = geom.data.slice(endIndex);
|
|
40
|
+
geom.data = before.concat(after);
|
|
41
|
+
// Need to offset any remaining indices as we have
|
|
42
|
+
// modified the data buffer
|
|
43
|
+
offset += endIndex - startIndex;
|
|
44
|
+
// Do not add this index to the output and process next shape
|
|
45
|
+
continue; // eslint-disable-line no-continue
|
|
46
|
+
}
|
|
47
|
+
if (ccw === undefined)
|
|
48
|
+
ccw = area < 0;
|
|
49
|
+
if (ccw === area < 0) {
|
|
50
|
+
if (polygon.length) {
|
|
51
|
+
areas.push(ringAreas);
|
|
52
|
+
polygons.push(polygon);
|
|
53
|
+
}
|
|
54
|
+
polygon = [startIndex];
|
|
55
|
+
ringAreas = [area];
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
ringAreas.push(area);
|
|
59
|
+
polygon.push(startIndex);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (ringAreas)
|
|
38
63
|
areas.push(ringAreas);
|
|
64
|
+
if (polygon.length)
|
|
39
65
|
polygons.push(polygon);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
polygon = [startIndex];
|
|
43
|
-
ringAreas = [area];
|
|
44
|
-
} else {
|
|
45
|
-
ringAreas.push(area);
|
|
46
|
-
polygon.push(startIndex);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (ringAreas) areas.push(ringAreas);
|
|
51
|
-
if (polygon.length) polygons.push(polygon);
|
|
52
|
-
return {
|
|
53
|
-
areas,
|
|
54
|
-
lines: polygons,
|
|
55
|
-
data: geom.data
|
|
56
|
-
};
|
|
66
|
+
return { areas, lines: polygons, data: geom.data };
|
|
57
67
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
exports.classifyRings = classifyRings;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param data
|
|
72
|
+
* @param x0
|
|
73
|
+
* @param y0
|
|
74
|
+
* @param size
|
|
75
|
+
*/
|
|
76
|
+
function project(data, x0, y0, size) {
|
|
77
|
+
for (let j = 0, jl = data.length; j < jl; j += 2) {
|
|
78
|
+
data[j] = ((data[j] + x0) * 360) / size - 180;
|
|
79
|
+
const y2 = 180 - ((data[j + 1] + y0) * 360) / size;
|
|
80
|
+
data[j + 1] = (360 / Math.PI) * Math.atan(Math.exp((y2 * Math.PI) / 180)) - 90;
|
|
81
|
+
}
|
|
64
82
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
exports.project = project;
|
|
84
|
+
/**
|
|
85
|
+
* All code below is unchanged from the original Mapbox implemenation
|
|
86
|
+
*
|
|
87
|
+
* @param tag
|
|
88
|
+
* @param feature
|
|
89
|
+
* @param pbf
|
|
90
|
+
*/
|
|
91
|
+
function readFeature(tag, feature, pbf) {
|
|
92
|
+
if (feature && pbf) {
|
|
93
|
+
if (tag === 1)
|
|
94
|
+
feature.id = pbf.readVarint();
|
|
95
|
+
else if (tag === 2)
|
|
96
|
+
readTag(pbf, feature);
|
|
97
|
+
else if (tag === 3)
|
|
98
|
+
feature.type = pbf.readVarint();
|
|
99
|
+
else if (tag === 4)
|
|
100
|
+
feature._geometry = pbf.pos;
|
|
101
|
+
}
|
|
69
102
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
103
|
+
exports.readFeature = readFeature;
|
|
104
|
+
/**
|
|
105
|
+
* @param pbf
|
|
106
|
+
* @param feature
|
|
107
|
+
*/
|
|
108
|
+
function readTag(pbf, feature) {
|
|
109
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
110
|
+
while (pbf.pos < end) {
|
|
111
|
+
const key = feature._keys[pbf.readVarint()];
|
|
112
|
+
const value = feature._values[pbf.readVarint()];
|
|
113
|
+
feature.properties[key] = value;
|
|
114
|
+
}
|
|
80
115
|
}
|
|
81
|
-
|
|
116
|
+
exports.readTag = readTag;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Protobuf from 'pbf';
|
|
2
|
+
import { MvtMapboxGeometry } from '../lib/types';
|
|
3
|
+
import VectorTileFeature from '../lib/mapbox-vector-tile/vector-tile-feature';
|
|
4
|
+
/**
|
|
5
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
6
|
+
* @param rings
|
|
7
|
+
* @returns polygons
|
|
8
|
+
*/
|
|
9
|
+
export declare function classifyRings(rings: MvtMapboxGeometry): MvtMapboxGeometry[] | number[][][];
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param ring
|
|
13
|
+
* @returns sum
|
|
14
|
+
*/
|
|
15
|
+
export declare function signedArea(ring: number[][]): number;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param tag
|
|
19
|
+
* @param feature
|
|
20
|
+
* @param pbf
|
|
21
|
+
*/
|
|
22
|
+
export declare function readFeature(tag: number, feature?: VectorTileFeature, pbf?: Protobuf): void;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param pbf
|
|
26
|
+
* @param feature
|
|
27
|
+
*/
|
|
28
|
+
export declare function readTag(pbf: Protobuf, feature: VectorTileFeature): void;
|
|
29
|
+
//# sourceMappingURL=mapbox-util-functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapbox-util-functions.d.ts","sourceRoot":"","sources":["../../src/helpers/mapbox-util-functions.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,KAAK,CAAC;AAC3B,OAAO,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC/C,OAAO,iBAAiB,MAAM,+CAA+C,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,iBAAiB,sCAuBrD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAQ1C;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,EAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAO1F;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAQvE"}
|
|
@@ -1,49 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readTag = exports.readFeature = exports.signedArea = exports.classifyRings = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Classifies an array of rings into polygons with outer rings and holes
|
|
6
|
+
* @param rings
|
|
7
|
+
* @returns polygons
|
|
8
|
+
*/
|
|
9
|
+
function classifyRings(rings) {
|
|
10
|
+
const len = rings.length;
|
|
11
|
+
if (len <= 1)
|
|
12
|
+
return [rings];
|
|
13
|
+
const polygons = [];
|
|
14
|
+
let polygon;
|
|
15
|
+
let ccw;
|
|
16
|
+
for (let i = 0; i < len; i++) {
|
|
17
|
+
const area = signedArea(rings[i]);
|
|
18
|
+
if (area === 0)
|
|
19
|
+
continue; // eslint-disable-line no-continue
|
|
20
|
+
if (ccw === undefined)
|
|
21
|
+
ccw = area < 0;
|
|
22
|
+
if (ccw === area < 0) {
|
|
23
|
+
if (polygon)
|
|
24
|
+
polygons.push(polygon);
|
|
25
|
+
polygon = [rings[i]];
|
|
26
|
+
}
|
|
27
|
+
else if (polygon)
|
|
28
|
+
polygon.push(rings[i]);
|
|
29
|
+
}
|
|
30
|
+
if (polygon)
|
|
31
|
+
polygons.push(polygon);
|
|
32
|
+
return polygons;
|
|
21
33
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
exports.classifyRings = classifyRings;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param ring
|
|
38
|
+
* @returns sum
|
|
39
|
+
*/
|
|
40
|
+
function signedArea(ring) {
|
|
41
|
+
let sum = 0;
|
|
42
|
+
for (let i = 0, j = ring.length - 1, p1, p2; i < ring.length; j = i++) {
|
|
43
|
+
p1 = ring[i];
|
|
44
|
+
p2 = ring[j];
|
|
45
|
+
sum += (p2[0] - p1[0]) * (p1[1] + p2[1]);
|
|
46
|
+
}
|
|
47
|
+
return sum;
|
|
32
48
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
exports.signedArea = signedArea;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param tag
|
|
53
|
+
* @param feature
|
|
54
|
+
* @param pbf
|
|
55
|
+
*/
|
|
56
|
+
function readFeature(tag, feature, pbf) {
|
|
57
|
+
if (feature && pbf) {
|
|
58
|
+
if (tag === 1)
|
|
59
|
+
feature.id = pbf.readVarint();
|
|
60
|
+
else if (tag === 2)
|
|
61
|
+
readTag(pbf, feature);
|
|
62
|
+
else if (tag === 3)
|
|
63
|
+
feature.type = pbf.readVarint();
|
|
64
|
+
else if (tag === 4)
|
|
65
|
+
feature._geometry = pbf.pos;
|
|
66
|
+
}
|
|
37
67
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
68
|
+
exports.readFeature = readFeature;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param pbf
|
|
72
|
+
* @param feature
|
|
73
|
+
*/
|
|
74
|
+
function readTag(pbf, feature) {
|
|
75
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
76
|
+
while (pbf.pos < end) {
|
|
77
|
+
const key = feature._keys[pbf.readVarint()];
|
|
78
|
+
const value = feature._values[pbf.readVarint()];
|
|
79
|
+
feature.properties[key] = value;
|
|
80
|
+
}
|
|
48
81
|
}
|
|
49
|
-
|
|
82
|
+
exports.readTag = readTag;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MVTWorkerLoader = exports.MVTLoader = void 0;
|
|
4
|
+
var mvt_loader_1 = require("./mvt-loader");
|
|
5
|
+
Object.defineProperty(exports, "MVTLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTLoader; } });
|
|
6
|
+
Object.defineProperty(exports, "MVTWorkerLoader", { enumerable: true, get: function () { return mvt_loader_1.MVTWorkerLoader; } });
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { MvtBinaryCoordinates, MvtBinaryOptions, MvtFirstPassedData } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert binary features to flat binary arrays. Similar to
|
|
4
|
+
* `geojsonToBinary` helper function, except that it expects
|
|
5
|
+
* a binary representation of the feature data, which enables
|
|
6
|
+
* 2X-3X speed increase in parse speed, compared to using
|
|
7
|
+
* geoJSON. See `binary-vector-tile/VectorTileFeature` for
|
|
8
|
+
* data format detais
|
|
9
|
+
*
|
|
10
|
+
* @param features
|
|
11
|
+
* @param firstPassData
|
|
12
|
+
* @param options
|
|
13
|
+
* @returns filled arrays
|
|
14
|
+
*/
|
|
15
|
+
export declare function featuresToBinary(features: MvtBinaryCoordinates[], firstPassData: MvtFirstPassedData, options?: MvtBinaryOptions): {
|
|
16
|
+
points: {
|
|
17
|
+
positions: {
|
|
18
|
+
value: Float32Array;
|
|
19
|
+
size: number;
|
|
20
|
+
};
|
|
21
|
+
globalFeatureIds: {
|
|
22
|
+
value: Uint16Array | Uint32Array;
|
|
23
|
+
size: number;
|
|
24
|
+
};
|
|
25
|
+
featureIds: {
|
|
26
|
+
value: Uint16Array | Uint32Array;
|
|
27
|
+
size: number;
|
|
28
|
+
};
|
|
29
|
+
numericProps: object;
|
|
30
|
+
properties: {}[];
|
|
31
|
+
fields: {
|
|
32
|
+
id?: number | undefined;
|
|
33
|
+
}[];
|
|
34
|
+
};
|
|
35
|
+
lines: {
|
|
36
|
+
pathIndices: {
|
|
37
|
+
value: Uint16Array | Uint32Array;
|
|
38
|
+
size: number;
|
|
39
|
+
};
|
|
40
|
+
positions: {
|
|
41
|
+
value: Float32Array;
|
|
42
|
+
size: number;
|
|
43
|
+
};
|
|
44
|
+
globalFeatureIds: {
|
|
45
|
+
value: Uint16Array | Uint32Array;
|
|
46
|
+
size: number;
|
|
47
|
+
};
|
|
48
|
+
featureIds: {
|
|
49
|
+
value: Uint16Array | Uint32Array;
|
|
50
|
+
size: number;
|
|
51
|
+
};
|
|
52
|
+
numericProps: object;
|
|
53
|
+
properties: {}[];
|
|
54
|
+
fields: {
|
|
55
|
+
id?: number | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
};
|
|
58
|
+
polygons: {
|
|
59
|
+
polygonIndices: {
|
|
60
|
+
value: Uint16Array | Uint32Array;
|
|
61
|
+
size: number;
|
|
62
|
+
};
|
|
63
|
+
primitivePolygonIndices: {
|
|
64
|
+
value: Uint16Array | Uint32Array;
|
|
65
|
+
size: number;
|
|
66
|
+
};
|
|
67
|
+
positions: {
|
|
68
|
+
value: Float32Array;
|
|
69
|
+
size: number;
|
|
70
|
+
};
|
|
71
|
+
triangles: {
|
|
72
|
+
value: Uint32Array;
|
|
73
|
+
size: number;
|
|
74
|
+
};
|
|
75
|
+
globalFeatureIds: {
|
|
76
|
+
value: Uint16Array | Uint32Array;
|
|
77
|
+
size: number;
|
|
78
|
+
};
|
|
79
|
+
featureIds: {
|
|
80
|
+
value: Uint16Array | Uint32Array;
|
|
81
|
+
size: number;
|
|
82
|
+
};
|
|
83
|
+
numericProps: object;
|
|
84
|
+
properties: {}[];
|
|
85
|
+
fields: {
|
|
86
|
+
id?: number | undefined;
|
|
87
|
+
}[];
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export declare const TEST_EXPORTS: {
|
|
91
|
+
extractNumericPropKeys: typeof extractNumericPropKeys;
|
|
92
|
+
fillArrays: typeof fillArrays;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Extracts properties that are always numeric
|
|
96
|
+
*
|
|
97
|
+
* @param features
|
|
98
|
+
* @returns object with numeric keys
|
|
99
|
+
*/
|
|
100
|
+
declare function extractNumericPropKeys(features: MvtBinaryCoordinates[]): string[];
|
|
101
|
+
/**
|
|
102
|
+
* Fills coordinates into pre-allocated typed arrays
|
|
103
|
+
*
|
|
104
|
+
* @param features
|
|
105
|
+
* @param firstPassData
|
|
106
|
+
* @param options
|
|
107
|
+
* @returns an accessor object with value and size keys
|
|
108
|
+
*/
|
|
109
|
+
declare function fillArrays(features: MvtBinaryCoordinates[], firstPassData: MvtFirstPassedData, options: MvtBinaryOptions): {
|
|
110
|
+
points: {
|
|
111
|
+
positions: {
|
|
112
|
+
value: Float32Array;
|
|
113
|
+
size: number;
|
|
114
|
+
};
|
|
115
|
+
globalFeatureIds: {
|
|
116
|
+
value: Uint16Array | Uint32Array;
|
|
117
|
+
size: number;
|
|
118
|
+
};
|
|
119
|
+
featureIds: {
|
|
120
|
+
value: Uint16Array | Uint32Array;
|
|
121
|
+
size: number;
|
|
122
|
+
};
|
|
123
|
+
numericProps: object;
|
|
124
|
+
properties: {}[];
|
|
125
|
+
fields: {
|
|
126
|
+
id?: number | undefined;
|
|
127
|
+
}[];
|
|
128
|
+
};
|
|
129
|
+
lines: {
|
|
130
|
+
pathIndices: {
|
|
131
|
+
value: Uint16Array | Uint32Array;
|
|
132
|
+
size: number;
|
|
133
|
+
};
|
|
134
|
+
positions: {
|
|
135
|
+
value: Float32Array;
|
|
136
|
+
size: number;
|
|
137
|
+
};
|
|
138
|
+
globalFeatureIds: {
|
|
139
|
+
value: Uint16Array | Uint32Array;
|
|
140
|
+
size: number;
|
|
141
|
+
};
|
|
142
|
+
featureIds: {
|
|
143
|
+
value: Uint16Array | Uint32Array;
|
|
144
|
+
size: number;
|
|
145
|
+
};
|
|
146
|
+
numericProps: object;
|
|
147
|
+
properties: {}[];
|
|
148
|
+
fields: {
|
|
149
|
+
id?: number | undefined;
|
|
150
|
+
}[];
|
|
151
|
+
};
|
|
152
|
+
polygons: {
|
|
153
|
+
polygonIndices: {
|
|
154
|
+
value: Uint16Array | Uint32Array;
|
|
155
|
+
size: number;
|
|
156
|
+
};
|
|
157
|
+
primitivePolygonIndices: {
|
|
158
|
+
value: Uint16Array | Uint32Array;
|
|
159
|
+
size: number;
|
|
160
|
+
};
|
|
161
|
+
positions: {
|
|
162
|
+
value: Float32Array;
|
|
163
|
+
size: number;
|
|
164
|
+
};
|
|
165
|
+
triangles: {
|
|
166
|
+
value: Uint32Array;
|
|
167
|
+
size: number;
|
|
168
|
+
};
|
|
169
|
+
globalFeatureIds: {
|
|
170
|
+
value: Uint16Array | Uint32Array;
|
|
171
|
+
size: number;
|
|
172
|
+
};
|
|
173
|
+
featureIds: {
|
|
174
|
+
value: Uint16Array | Uint32Array;
|
|
175
|
+
size: number;
|
|
176
|
+
};
|
|
177
|
+
numericProps: object;
|
|
178
|
+
properties: {}[];
|
|
179
|
+
fields: {
|
|
180
|
+
id?: number | undefined;
|
|
181
|
+
}[];
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
export {};
|
|
185
|
+
//# sourceMappingURL=features-to-binary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features-to-binary.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-vector-tile/features-to-binary.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EAEpB,gBAAgB,EAChB,kBAAkB,EAInB,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,oBAAoB,EAAE,EAChC,aAAa,EAAE,kBAAkB,EACjC,OAAO,CAAC,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAM3B;AAED,eAAO,MAAM,YAAY;;;CAGxB,CAAC;AAEF;;;;;GAKG;AACH,iBAAS,sBAAsB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,CAkB1E;AAED;;;;;;;GAOG;AAEH,iBAAS,UAAU,CACjB,QAAQ,EAAE,oBAAoB,EAAE,EAChC,aAAa,EAAE,kBAAkB,EACjC,OAAO,EAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoI1B"}
|