@loaders.gl/mvt 4.0.0-alpha.5 → 4.0.0-alpha.7
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 +2 -2
- package/dist/dist.min.js +1748 -913
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/helpers/binary-util-functions.js +82 -0
- package/dist/es5/helpers/binary-util-functions.js.map +1 -0
- package/dist/es5/helpers/mapbox-util-functions.js +50 -0
- package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/es5/index.js +26 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +168 -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 +62 -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 +28 -0
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/LICENSE +19 -0
- package/dist/es5/lib/geojson-tiler/clip.js +237 -0
- package/dist/es5/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/convert.js +161 -0
- package/dist/es5/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/feature.js +62 -0
- package/dist/es5/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js +186 -0
- package/dist/es5/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/simplify.js +52 -0
- package/dist/es5/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/tile.js +121 -0
- package/dist/es5/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/transform.js +50 -0
- package/dist/es5/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/es5/lib/geojson-tiler/wrap.js +122 -0
- package/dist/es5/lib/geojson-tiler/wrap.js.map +1 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +184 -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 +62 -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 +28 -0
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/es5/lib/parse-mvt.js +143 -0
- package/dist/es5/lib/parse-mvt.js.map +1 -0
- package/dist/es5/lib/types.js +2 -0
- package/dist/es5/lib/types.js.map +1 -0
- package/dist/es5/mvt-loader.js +58 -0
- package/dist/es5/mvt-loader.js.map +1 -0
- package/dist/es5/workers/mvt-worker.js +6 -0
- package/dist/es5/workers/mvt-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/helpers/binary-util-functions.js +73 -0
- package/dist/esm/helpers/binary-util-functions.js.map +1 -0
- package/dist/esm/helpers/mapbox-util-functions.js +41 -0
- package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/esm/index.js +3 -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/vector-tile-feature.js +136 -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 +47 -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 +19 -0
- package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/LICENSE +19 -0
- package/dist/esm/lib/geojson-tiler/clip.js +173 -0
- package/dist/esm/lib/geojson-tiler/clip.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/convert.js +116 -0
- package/dist/esm/lib/geojson-tiler/convert.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/feature.js +35 -0
- package/dist/esm/lib/geojson-tiler/feature.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js +171 -0
- package/dist/esm/lib/geojson-tiler/geojson-tiler.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/simplify.js +46 -0
- package/dist/esm/lib/geojson-tiler/simplify.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/tile.js +103 -0
- package/dist/esm/lib/geojson-tiler/tile.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/transform.js +32 -0
- package/dist/esm/lib/geojson-tiler/transform.js.map +1 -0
- package/dist/esm/lib/geojson-tiler/wrap.js +67 -0
- package/dist/esm/lib/geojson-tiler/wrap.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 +163 -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 +47 -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 +19 -0
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/esm/lib/parse-mvt.js +138 -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 +29 -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.js +111 -77
- package/dist/helpers/mapbox-util-functions.d.ts +2 -2
- package/dist/helpers/mapbox-util-functions.js +78 -45
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -1
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +142 -143
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
- package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
- package/dist/lib/geojson-tiler/clip.d.ts +16 -0
- package/dist/lib/geojson-tiler/clip.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/clip.js +209 -0
- package/dist/lib/geojson-tiler/convert.d.ts +10 -0
- package/dist/lib/geojson-tiler/convert.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/convert.js +134 -0
- package/dist/lib/geojson-tiler/feature.d.ts +3 -0
- package/dist/lib/geojson-tiler/feature.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/feature.js +46 -0
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts +44 -0
- package/dist/lib/geojson-tiler/geojson-tiler.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/geojson-tiler.js +210 -0
- package/dist/lib/geojson-tiler/simplify.d.ts +10 -0
- package/dist/lib/geojson-tiler/simplify.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/simplify.js +68 -0
- package/dist/lib/geojson-tiler/tile.d.ts +38 -0
- package/dist/lib/geojson-tiler/tile.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/tile.js +125 -0
- package/dist/lib/geojson-tiler/transform.d.ts +7 -0
- package/dist/lib/geojson-tiler/transform.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/transform.js +43 -0
- package/dist/lib/geojson-tiler/wrap.d.ts +17 -0
- package/dist/lib/geojson-tiler/wrap.d.ts.map +1 -0
- package/dist/lib/geojson-tiler/wrap.js +86 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +4 -4
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
- package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
- package/dist/lib/parse-mvt.d.ts +6 -9
- package/dist/lib/parse-mvt.d.ts.map +1 -1
- package/dist/lib/parse-mvt.js +148 -98
- package/dist/lib/types.d.ts +48 -7
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/types.js +2 -2
- package/dist/mvt-loader.d.ts.map +1 -1
- package/dist/mvt-loader.js +43 -22
- package/dist/mvt-worker.js +903 -829
- package/dist/workers/mvt-worker.js +5 -4
- package/package.json +7 -7
- package/src/helpers/mapbox-util-functions.ts +2 -2
- package/src/index.ts +7 -0
- package/src/lib/binary-vector-tile/vector-tile-feature.ts +6 -1
- package/src/lib/geojson-tiler/LICENSE +19 -0
- package/src/lib/geojson-tiler/clip.ts +248 -0
- package/src/lib/geojson-tiler/convert.ts +158 -0
- package/src/lib/geojson-tiler/feature.ts +45 -0
- package/src/lib/geojson-tiler/geojson-tiler.ts +281 -0
- package/src/lib/geojson-tiler/simplify.ts +77 -0
- package/src/lib/geojson-tiler/tile.ts +185 -0
- package/src/lib/geojson-tiler/transform.ts +55 -0
- package/src/lib/geojson-tiler/wrap.ts +108 -0
- package/src/lib/mapbox-vector-tile/vector-tile-feature.ts +4 -4
- package/src/lib/parse-mvt.ts +136 -93
- package/src/lib/types.ts +53 -7
- package/src/mvt-loader.ts +13 -9
- package/dist/bundle.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/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/lib/types.js.map +0 -1
- package/dist/mvt-loader.js.map +0 -1
- package/dist/workers/mvt-worker.js.map +0 -1
- /package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
- /package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.TEST_EXPORTS = void 0;
|
|
5
|
+
const binary_util_functions_1 = require("../../helpers/binary-util-functions");
|
|
6
|
+
// Reduce GC by reusing variables
|
|
3
7
|
let endPos;
|
|
4
8
|
let cmd;
|
|
5
9
|
let cmdLen;
|
|
@@ -7,151 +11,146 @@ let length;
|
|
|
7
11
|
let x;
|
|
8
12
|
let y;
|
|
9
13
|
let i;
|
|
10
|
-
|
|
11
|
-
|
|
14
|
+
exports.TEST_EXPORTS = {
|
|
15
|
+
classifyRings: binary_util_functions_1.classifyRings
|
|
12
16
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
_defineProperty(this, "_values", void 0);
|
|
30
|
-
|
|
31
|
-
_defineProperty(this, "_geometryInfo", void 0);
|
|
32
|
-
|
|
33
|
-
this.properties = {};
|
|
34
|
-
this.extent = extent;
|
|
35
|
-
this.type = 0;
|
|
36
|
-
this.id = null;
|
|
37
|
-
this._pbf = pbf;
|
|
38
|
-
this._geometry = -1;
|
|
39
|
-
this._keys = keys;
|
|
40
|
-
this._values = values;
|
|
41
|
-
this._geometryInfo = geometryInfo;
|
|
42
|
-
pbf.readFields(readFeature, this, end);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
loadGeometry() {
|
|
46
|
-
const pbf = this._pbf;
|
|
47
|
-
pbf.pos = this._geometry;
|
|
48
|
-
endPos = pbf.readVarint() + pbf.pos;
|
|
49
|
-
cmd = 1;
|
|
50
|
-
length = 0;
|
|
51
|
-
x = 0;
|
|
52
|
-
y = 0;
|
|
53
|
-
i = 0;
|
|
54
|
-
const indices = [];
|
|
55
|
-
const data = [];
|
|
56
|
-
|
|
57
|
-
while (pbf.pos < endPos) {
|
|
58
|
-
if (length <= 0) {
|
|
59
|
-
cmdLen = pbf.readVarint();
|
|
60
|
-
cmd = cmdLen & 0x7;
|
|
61
|
-
length = cmdLen >> 3;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
length--;
|
|
65
|
-
|
|
66
|
-
if (cmd === 1 || cmd === 2) {
|
|
67
|
-
x += pbf.readSVarint();
|
|
68
|
-
y += pbf.readSVarint();
|
|
69
|
-
|
|
70
|
-
if (cmd === 1) {
|
|
71
|
-
indices.push(i);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
data.push(x, y);
|
|
75
|
-
i += 2;
|
|
76
|
-
} else if (cmd === 7) {
|
|
77
|
-
if (i > 0) {
|
|
78
|
-
const start = indices[indices.length - 1];
|
|
79
|
-
data.push(data[start], data[start + 1]);
|
|
80
|
-
i += 2;
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
throw new Error("unknown command ".concat(cmd));
|
|
84
|
-
}
|
|
17
|
+
class VectorTileFeature {
|
|
18
|
+
// eslint-disable-next-line max-params
|
|
19
|
+
constructor(pbf, end, extent, keys, values, geometryInfo) {
|
|
20
|
+
// Public
|
|
21
|
+
this.properties = {};
|
|
22
|
+
this.extent = extent;
|
|
23
|
+
this.type = 0;
|
|
24
|
+
this.id = null;
|
|
25
|
+
// Private
|
|
26
|
+
this._pbf = pbf;
|
|
27
|
+
this._geometry = -1;
|
|
28
|
+
this._keys = keys;
|
|
29
|
+
this._values = values;
|
|
30
|
+
this._geometryInfo = geometryInfo;
|
|
31
|
+
pbf.readFields(binary_util_functions_1.readFeature, this, end);
|
|
85
32
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
33
|
+
// eslint-disable-next-line complexity, max-statements
|
|
34
|
+
loadGeometry() {
|
|
35
|
+
const pbf = this._pbf;
|
|
36
|
+
pbf.pos = this._geometry;
|
|
37
|
+
endPos = pbf.readVarint() + pbf.pos;
|
|
38
|
+
cmd = 1;
|
|
39
|
+
length = 0;
|
|
40
|
+
x = 0;
|
|
41
|
+
y = 0;
|
|
42
|
+
i = 0;
|
|
43
|
+
// Note: I attempted to replace the `data` array with a
|
|
44
|
+
// Float32Array, but performance was worse, both using
|
|
45
|
+
// `set()` and direct index access. Also, we cannot
|
|
46
|
+
// know how large the buffer should be, so it would
|
|
47
|
+
// increase memory usage
|
|
48
|
+
const indices = []; // Indices where geometries start
|
|
49
|
+
const data = []; // Flat array of coordinate data
|
|
50
|
+
while (pbf.pos < endPos) {
|
|
51
|
+
if (length <= 0) {
|
|
52
|
+
cmdLen = pbf.readVarint();
|
|
53
|
+
cmd = cmdLen & 0x7;
|
|
54
|
+
length = cmdLen >> 3;
|
|
55
|
+
}
|
|
56
|
+
length--;
|
|
57
|
+
if (cmd === 1 || cmd === 2) {
|
|
58
|
+
x += pbf.readSVarint();
|
|
59
|
+
y += pbf.readSVarint();
|
|
60
|
+
if (cmd === 1) {
|
|
61
|
+
// New line
|
|
62
|
+
indices.push(i);
|
|
63
|
+
}
|
|
64
|
+
data.push(x, y);
|
|
65
|
+
i += 2;
|
|
66
|
+
}
|
|
67
|
+
else if (cmd === 7) {
|
|
68
|
+
// Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
|
|
69
|
+
if (i > 0) {
|
|
70
|
+
const start = indices[indices.length - 1]; // start index of polygon
|
|
71
|
+
data.push(data[start], data[start + 1]); // closePolygon
|
|
72
|
+
i += 2;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw new Error(`unknown command ${cmd}`);
|
|
77
|
+
}
|
|
126
78
|
}
|
|
127
|
-
|
|
128
|
-
this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
|
|
129
|
-
break;
|
|
130
|
-
|
|
131
|
-
default:
|
|
132
|
-
throw new Error("Invalid geometry type: ".concat(this.type));
|
|
79
|
+
return { data, indices };
|
|
133
80
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param transform
|
|
84
|
+
* @returns result
|
|
85
|
+
*/
|
|
86
|
+
_toBinaryCoordinates(transform) {
|
|
87
|
+
// Expands the protobuf data to an intermediate Flat GeoJSON
|
|
88
|
+
// data format, which maps closely to the binary data buffers.
|
|
89
|
+
// It is similar to GeoJSON, but rather than storing the coordinates
|
|
90
|
+
// in multidimensional arrays, we have a 1D `data` with all the
|
|
91
|
+
// coordinates, and then index into this using the `indices`
|
|
92
|
+
// parameter, e.g.
|
|
93
|
+
//
|
|
94
|
+
// geometry: {
|
|
95
|
+
// type: 'Point', data: [1,2], indices: [0]
|
|
96
|
+
// }
|
|
97
|
+
// geometry: {
|
|
98
|
+
// type: 'LineString', data: [1,2,3,4,...], indices: [0]
|
|
99
|
+
// }
|
|
100
|
+
// geometry: {
|
|
101
|
+
// type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]
|
|
102
|
+
// }
|
|
103
|
+
// Thus the indices member lets us look up the relevant range
|
|
104
|
+
// from the data array.
|
|
105
|
+
// The Multi* versions of the above types share the same data
|
|
106
|
+
// structure, just with multiple elements in the indices array
|
|
107
|
+
const geom = this.loadGeometry();
|
|
108
|
+
let geometry;
|
|
109
|
+
// Apply the supplied transformation to data
|
|
110
|
+
transform(geom.data, this);
|
|
111
|
+
const coordLength = 2;
|
|
112
|
+
// eslint-disable-next-line default-case
|
|
113
|
+
switch (this.type) {
|
|
114
|
+
case 1: // Point
|
|
115
|
+
this._geometryInfo.pointFeaturesCount++;
|
|
116
|
+
this._geometryInfo.pointPositionsCount += geom.indices.length;
|
|
117
|
+
geometry = { type: 'Point', ...geom };
|
|
118
|
+
break;
|
|
119
|
+
case 2: // LineString
|
|
120
|
+
this._geometryInfo.lineFeaturesCount++;
|
|
121
|
+
this._geometryInfo.linePathsCount += geom.indices.length;
|
|
122
|
+
this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
|
|
123
|
+
geometry = { type: 'LineString', ...geom };
|
|
124
|
+
break;
|
|
125
|
+
case 3: // Polygon
|
|
126
|
+
geometry = (0, binary_util_functions_1.classifyRings)(geom);
|
|
127
|
+
// Unlike Point & LineString geom.indices is a 2D array, thanks
|
|
128
|
+
// to the classifyRings method
|
|
129
|
+
this._geometryInfo.polygonFeaturesCount++;
|
|
130
|
+
this._geometryInfo.polygonObjectsCount += geometry.indices.length;
|
|
131
|
+
for (const indices of geometry.indices) {
|
|
132
|
+
this._geometryInfo.polygonRingsCount += indices.length;
|
|
133
|
+
}
|
|
134
|
+
this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
|
|
135
|
+
break;
|
|
136
|
+
default:
|
|
137
|
+
throw new Error(`Invalid geometry type: ${this.type}`);
|
|
138
|
+
}
|
|
139
|
+
const result = { type: 'Feature', geometry, properties: this.properties };
|
|
140
|
+
if (this.id !== null) {
|
|
141
|
+
result.id = this.id;
|
|
142
|
+
}
|
|
143
|
+
return result;
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
145
|
+
toBinaryCoordinates(options) {
|
|
146
|
+
if (typeof options === 'function') {
|
|
147
|
+
return this._toBinaryCoordinates(options);
|
|
148
|
+
}
|
|
149
|
+
const { x, y, z } = options;
|
|
150
|
+
const size = this.extent * Math.pow(2, z);
|
|
151
|
+
const x0 = this.extent * x;
|
|
152
|
+
const y0 = this.extent * y;
|
|
153
|
+
return this._toBinaryCoordinates((data) => (0, binary_util_functions_1.project)(data, x0, y0, size));
|
|
151
154
|
}
|
|
152
|
-
|
|
153
|
-
return this._toBinaryCoordinates(project);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
155
|
}
|
|
157
|
-
|
|
156
|
+
exports.default = VectorTileFeature;
|
|
@@ -1,64 +1,91 @@
|
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
*
|
|
27
|
+
* @param index
|
|
28
|
+
* @param geometryInfo
|
|
29
|
+
* @returns {VectorTileFeature}
|
|
30
|
+
*/
|
|
31
|
+
feature(i, geometryInfo) {
|
|
32
|
+
if (i < 0 || i >= this._features.length) {
|
|
33
|
+
throw new Error('feature index out of bounds');
|
|
34
|
+
}
|
|
35
|
+
this._pbf.pos = this._features[i];
|
|
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, geometryInfo);
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
this._pbf.pos = this._features[i];
|
|
39
|
-
|
|
40
|
-
const end = this._pbf.readVarint() + this._pbf.pos;
|
|
41
|
-
|
|
42
|
-
return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values, geometryInfo);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
}
|
|
46
|
-
|
|
40
|
+
exports.default = VectorTileLayer;
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param tag
|
|
44
|
+
* @param layer
|
|
45
|
+
* @param pbf
|
|
46
|
+
*/
|
|
47
47
|
function readLayer(tag, layer, pbf) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (layer && pbf) {
|
|
49
|
+
if (tag === 15)
|
|
50
|
+
layer.version = pbf.readVarint();
|
|
51
|
+
else if (tag === 1)
|
|
52
|
+
layer.name = pbf.readString();
|
|
53
|
+
else if (tag === 5)
|
|
54
|
+
layer.extent = pbf.readVarint();
|
|
55
|
+
else if (tag === 2)
|
|
56
|
+
layer._features.push(pbf.pos);
|
|
57
|
+
else if (tag === 3)
|
|
58
|
+
layer._keys.push(pbf.readString());
|
|
59
|
+
else if (tag === 4)
|
|
60
|
+
layer._values.push(readValueMessage(pbf));
|
|
61
|
+
}
|
|
51
62
|
}
|
|
52
|
-
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param pbf
|
|
66
|
+
* @returns value
|
|
67
|
+
*/
|
|
53
68
|
function readValueMessage(pbf) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
let value = null;
|
|
70
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
71
|
+
while (pbf.pos < end) {
|
|
72
|
+
const tag = pbf.readVarint() >> 3;
|
|
73
|
+
value =
|
|
74
|
+
tag === 1
|
|
75
|
+
? pbf.readString()
|
|
76
|
+
: tag === 2
|
|
77
|
+
? pbf.readFloat()
|
|
78
|
+
: tag === 3
|
|
79
|
+
? pbf.readDouble()
|
|
80
|
+
: tag === 4
|
|
81
|
+
? pbf.readVarint64()
|
|
82
|
+
: tag === 5
|
|
83
|
+
? pbf.readVarint()
|
|
84
|
+
: tag === 6
|
|
85
|
+
? pbf.readSVarint()
|
|
86
|
+
: tag === 7
|
|
87
|
+
? pbf.readBoolean()
|
|
88
|
+
: null;
|
|
89
|
+
}
|
|
90
|
+
return value;
|
|
63
91
|
}
|
|
64
|
-
//# sourceMappingURL=vector-tile-layer.js.map
|
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
}
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
exports.default = VectorTile;
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param tag
|
|
17
|
+
* @param layers
|
|
18
|
+
* @param pbf
|
|
19
|
+
*/
|
|
12
20
|
function readTile(tag, layers, pbf) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
}
|
|
20
28
|
}
|
|
21
|
-
}
|
|
22
29
|
}
|
|
23
|
-
//# sourceMappingURL=vector-tile.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GeoJSONTileFeature } from './tile';
|
|
2
|
+
/**
|
|
3
|
+
* Clip features between two vertical or horizontal axis-parallel lines:
|
|
4
|
+
* | |
|
|
5
|
+
* ___|___ | /
|
|
6
|
+
* / | \____|____/
|
|
7
|
+
* | |
|
|
8
|
+
*
|
|
9
|
+
* @param k1 and k2 are the line coordinates
|
|
10
|
+
* @param axis: 0 for x, 1 for y
|
|
11
|
+
* @param minAll and maxAll: minimum and maximum coordinate value for all features
|
|
12
|
+
*/
|
|
13
|
+
export declare function clip(features: GeoJSONTileFeature[], scale: number, k1: number, k2: number, axis: any, minAll: number, maxAll: number, options: {
|
|
14
|
+
lineMetrics: boolean;
|
|
15
|
+
}): GeoJSONTileFeature[] | null;
|
|
16
|
+
//# sourceMappingURL=clip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clip.d.ts","sourceRoot":"","sources":["../../../src/lib/geojson-tiler/clip.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,QAAQ,CAAC;AAK/C;;;;;;;;;;GAUG;AAEH,wBAAgB,IAAI,CAClB,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,KAAK,EAAE,MAAM,EACb,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,IAAI,KAAA,EACJ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAC,WAAW,EAAE,OAAO,CAAA;CAAC,GAC9B,kBAAkB,EAAE,GAAG,IAAI,CA4E7B"}
|