@loaders.gl/mvt 3.1.3 → 4.0.0-alpha.5
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/bundle.js.map +1 -0
- package/dist/helpers/binary-util-functions.js +77 -111
- package/dist/helpers/binary-util-functions.js.map +1 -0
- package/dist/helpers/mapbox-util-functions.js +45 -78
- package/dist/helpers/mapbox-util-functions.js.map +1 -0
- package/dist/index.js +2 -6
- package/dist/index.js.map +1 -0
- package/dist/{es5/lib → lib}/binary-vector-tile/LICENSE.txt +0 -0
- package/dist/lib/binary-vector-tile/vector-tile-feature.js +143 -138
- package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile-layer.js +58 -85
- package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/lib/binary-vector-tile/vector-tile.js +19 -25
- package/dist/lib/binary-vector-tile/vector-tile.js.map +1 -0
- package/dist/{es5/lib → lib}/mapbox-vector-tile/LICENSE.txt +0 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +193 -161
- package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +58 -83
- package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
- package/dist/lib/mapbox-vector-tile/vector-tile.js +19 -25
- package/dist/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
- package/dist/lib/parse-mvt.js +101 -127
- package/dist/lib/parse-mvt.js.map +1 -0
- package/dist/lib/types.js +2 -2
- package/dist/{es5/lib → lib}/types.js.map +0 -0
- package/dist/mvt-loader.js +23 -42
- package/dist/mvt-loader.js.map +1 -0
- package/dist/mvt-worker.js +1 -1
- package/dist/workers/mvt-worker.js +4 -5
- package/dist/workers/mvt-worker.js.map +1 -0
- package/package.json +8 -8
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/helpers/binary-util-functions.js +0 -98
- package/dist/es5/helpers/binary-util-functions.js.map +0 -1
- package/dist/es5/helpers/mapbox-util-functions.js +0 -62
- package/dist/es5/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/es5/index.js +0 -20
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +0 -191
- package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +0 -77
- package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/es5/lib/binary-vector-tile/vector-tile.js +0 -35
- package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +0 -217
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +0 -77
- package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +0 -35
- package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/es5/lib/parse-mvt.js +0 -132
- package/dist/es5/lib/parse-mvt.js.map +0 -1
- package/dist/es5/lib/types.js +0 -2
- package/dist/es5/mvt-loader.js +0 -71
- package/dist/es5/mvt-loader.js.map +0 -1
- package/dist/es5/workers/mvt-worker.js +0 -8
- package/dist/es5/workers/mvt-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/helpers/binary-util-functions.js +0 -84
- package/dist/esm/helpers/binary-util-functions.js.map +0 -1
- package/dist/esm/helpers/mapbox-util-functions.js +0 -49
- package/dist/esm/helpers/mapbox-util-functions.js.map +0 -1
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/LICENSE.txt +0 -31
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +0 -157
- package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +0 -64
- package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/esm/lib/binary-vector-tile/vector-tile.js +0 -23
- package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +0 -1
- package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +0 -31
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +0 -202
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +0 -64
- package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +0 -23
- package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
- package/dist/esm/lib/parse-mvt.js +0 -117
- package/dist/esm/lib/parse-mvt.js.map +0 -1
- package/dist/esm/lib/types.js +0 -2
- package/dist/esm/lib/types.js.map +0 -1
- package/dist/esm/mvt-loader.js +0 -26
- package/dist/esm/mvt-loader.js.map +0 -1
- package/dist/esm/workers/mvt-worker.js +0 -4
- package/dist/esm/workers/mvt-worker.js.map +0 -1
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { classifyRings, project, readFeature } from '../../helpers/binary-util-functions';
|
|
7
3
|
let endPos;
|
|
8
4
|
let cmd;
|
|
9
5
|
let cmdLen;
|
|
@@ -11,142 +7,151 @@ let length;
|
|
|
11
7
|
let x;
|
|
12
8
|
let y;
|
|
13
9
|
let i;
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
export const TEST_EXPORTS = {
|
|
11
|
+
classifyRings
|
|
16
12
|
};
|
|
17
|
-
class VectorTileFeature {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
throw new Error(`unknown command ${cmd}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return { data, indices };
|
|
80
|
-
}
|
|
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}`);
|
|
13
|
+
export default class VectorTileFeature {
|
|
14
|
+
constructor(pbf, end, extent, keys, values, geometryInfo) {
|
|
15
|
+
_defineProperty(this, "properties", void 0);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "extent", void 0);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "type", void 0);
|
|
20
|
+
|
|
21
|
+
_defineProperty(this, "id", void 0);
|
|
22
|
+
|
|
23
|
+
_defineProperty(this, "_pbf", void 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "_geometry", void 0);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "_keys", void 0);
|
|
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);
|
|
138
72
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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;
|
|
142
81
|
}
|
|
143
|
-
|
|
82
|
+
} else {
|
|
83
|
+
throw new Error("unknown command ".concat(cmd));
|
|
84
|
+
}
|
|
144
85
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
data,
|
|
89
|
+
indices
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
_toBinaryCoordinates(transform) {
|
|
94
|
+
const geom = this.loadGeometry();
|
|
95
|
+
let geometry;
|
|
96
|
+
transform(geom.data, this);
|
|
97
|
+
const coordLength = 2;
|
|
98
|
+
|
|
99
|
+
switch (this.type) {
|
|
100
|
+
case 1:
|
|
101
|
+
this._geometryInfo.pointFeaturesCount++;
|
|
102
|
+
this._geometryInfo.pointPositionsCount += geom.indices.length;
|
|
103
|
+
geometry = {
|
|
104
|
+
type: 'Point',
|
|
105
|
+
...geom
|
|
106
|
+
};
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
case 2:
|
|
110
|
+
this._geometryInfo.lineFeaturesCount++;
|
|
111
|
+
this._geometryInfo.linePathsCount += geom.indices.length;
|
|
112
|
+
this._geometryInfo.linePositionsCount += geom.data.length / coordLength;
|
|
113
|
+
geometry = {
|
|
114
|
+
type: 'LineString',
|
|
115
|
+
...geom
|
|
116
|
+
};
|
|
117
|
+
break;
|
|
118
|
+
|
|
119
|
+
case 3:
|
|
120
|
+
geometry = classifyRings(geom);
|
|
121
|
+
this._geometryInfo.polygonFeaturesCount++;
|
|
122
|
+
this._geometryInfo.polygonObjectsCount += geometry.indices.length;
|
|
123
|
+
|
|
124
|
+
for (const indices of geometry.indices) {
|
|
125
|
+
this._geometryInfo.polygonRingsCount += indices.length;
|
|
148
126
|
}
|
|
149
|
-
|
|
127
|
+
|
|
128
|
+
this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;
|
|
129
|
+
break;
|
|
130
|
+
|
|
131
|
+
default:
|
|
132
|
+
throw new Error("Invalid geometry type: ".concat(this.type));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const result = {
|
|
136
|
+
type: 'Feature',
|
|
137
|
+
geometry,
|
|
138
|
+
properties: this.properties
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
if (this.id !== null) {
|
|
142
|
+
result.id = this.id;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
toBinaryCoordinates(options) {
|
|
149
|
+
if (typeof options === 'function') {
|
|
150
|
+
return this._toBinaryCoordinates(options);
|
|
150
151
|
}
|
|
152
|
+
|
|
153
|
+
return this._toBinaryCoordinates(project);
|
|
154
|
+
}
|
|
155
|
+
|
|
151
156
|
}
|
|
152
|
-
|
|
157
|
+
//# sourceMappingURL=vector-tile-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/binary-vector-tile/vector-tile-feature.ts"],"names":["classifyRings","project","readFeature","endPos","cmd","cmdLen","length","x","y","i","TEST_EXPORTS","VectorTileFeature","constructor","pbf","end","extent","keys","values","geometryInfo","properties","type","id","_pbf","_geometry","_keys","_values","_geometryInfo","readFields","loadGeometry","pos","readVarint","indices","data","readSVarint","push","start","Error","_toBinaryCoordinates","transform","geom","geometry","coordLength","pointFeaturesCount","pointPositionsCount","lineFeaturesCount","linePathsCount","linePositionsCount","polygonFeaturesCount","polygonObjectsCount","polygonRingsCount","polygonPositionsCount","result","toBinaryCoordinates","options"],"mappings":";AAIA,SAAQA,aAAR,EAAuBC,OAAvB,EAAgCC,WAAhC,QAAkD,qCAAlD;AAGA,IAAIC,MAAJ;AACA,IAAIC,GAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,MAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AACA,IAAIC,CAAJ;AAEA,OAAO,MAAMC,YAAY,GAAG;AAC1BV,EAAAA;AAD0B,CAArB;AAIP,eAAe,MAAMW,iBAAN,CAAwB;AAYrCC,EAAAA,WAAW,CACTC,GADS,EAETC,GAFS,EAGTC,MAHS,EAITC,IAJS,EAKTC,MALS,EAMTC,YANS,EAOT;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEA,SAAKC,UAAL,GAAkB,EAAlB;AACA,SAAKJ,MAAL,GAAcA,MAAd;AACA,SAAKK,IAAL,GAAY,CAAZ;AACA,SAAKC,EAAL,GAAU,IAAV;AAGA,SAAKC,IAAL,GAAYT,GAAZ;AACA,SAAKU,SAAL,GAAiB,CAAC,CAAlB;AACA,SAAKC,KAAL,GAAaR,IAAb;AACA,SAAKS,OAAL,GAAeR,MAAf;AACA,SAAKS,aAAL,GAAqBR,YAArB;AAEAL,IAAAA,GAAG,CAACc,UAAJ,CAAezB,WAAf,EAA4B,IAA5B,EAAkCY,GAAlC;AACD;;AAGDc,EAAAA,YAAY,GAAwB;AAClC,UAAMf,GAAG,GAAG,KAAKS,IAAjB;AACAT,IAAAA,GAAG,CAACgB,GAAJ,GAAU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AmBuB,iBAAnB,IAAwClB,OAAO,CAACzB,MAAhD;AACD;;AACD,aAAKoB,aAAL,CAAmBwB,qBAAnB,IAA4CV,QAAQ,CAACR,IAAT,CAAc1B,MAAd,GAAuBmC,WAAnE;AAEA;;AACF;AACE,cAAM,IAAIL,KAAJ,kCAAoC,KAAKhB,IAAzC,EAAN;AA7BJ;;AAgCA,UAAM+B,MAAmB,GAAG;AAAC/B,MAAAA,IAAI,EAAE,SAAP;AAAkBoB,MAAAA,QAAlB;AAA4BrB,MAAAA,UAAU,EAAE,KAAKA;AAA7C,KAA5B;;AAEA,QAAI,KAAKE,EAAL,KAAY,IAAhB,EAAsB;AACpB8B,MAAAA,MAAM,CAAC9B,EAAP,GAAY,KAAKA,EAAjB;AACD;;AAED,WAAO8B,MAAP;AACD;;AAEDC,EAAAA,mBAAmB,CACjBC,OADiB,EAEJ;AACb,QAAI,OAAOA,OAAP,KAAmB,UAAvB,EAAmC;AACjC,aAAO,KAAKhB,oBAAL,CAA0BgB,OAA1B,CAAP;AACD;;AACD,WAAO,KAAKhB,oBAAL,CAA0BpC,OAA1B,CAAP;AACD;;AA7KoC","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport {FlatFeature, FlatIndexedGeometry, GeojsonGeometryInfo} from '@loaders.gl/schema';\nimport {classifyRings, project, readFeature} from '../../helpers/binary-util-functions';\n\n// Reduce GC by reusing variables\nlet endPos: number;\nlet cmd: number;\nlet cmdLen: number;\nlet length: number;\nlet x: number;\nlet y: number;\nlet i: number;\n\nexport const TEST_EXPORTS = {\n classifyRings\n};\n\nexport default class VectorTileFeature {\n properties: {[x: string]: string | number | boolean | null};\n extent: any;\n type: number;\n id: number | null;\n _pbf: Protobuf;\n _geometry: number;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _geometryInfo: GeojsonGeometryInfo;\n\n // eslint-disable-next-line max-params\n constructor(\n pbf: Protobuf,\n end: number,\n extent: any,\n keys: string[],\n values: (string | number | boolean | null)[],\n geometryInfo: GeojsonGeometryInfo\n ) {\n // Public\n this.properties = {};\n this.extent = extent;\n this.type = 0;\n this.id = null;\n\n // Private\n this._pbf = pbf;\n this._geometry = -1;\n this._keys = keys;\n this._values = values;\n this._geometryInfo = geometryInfo;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): FlatIndexedGeometry {\n const pbf = this._pbf;\n pbf.pos = this._geometry;\n\n endPos = pbf.readVarint() + pbf.pos;\n cmd = 1;\n length = 0;\n x = 0;\n y = 0;\n i = 0;\n\n // Note: I attempted to replace the `data` array with a\n // Float32Array, but performance was worse, both using\n // `set()` and direct index access. Also, we cannot\n // know how large the buffer should be, so it would\n // increase memory usage\n const indices: number[] = []; // Indices where geometries start\n const data: number[] = []; // Flat array of coordinate data\n\n while (pbf.pos < endPos) {\n if (length <= 0) {\n cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // New line\n indices.push(i);\n }\n data.push(x, y);\n i += 2;\n } else if (cmd === 7) {\n // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90\n if (i > 0) {\n const start = indices[indices.length - 1]; // start index of polygon\n data.push(data[start], data[start + 1]); // closePolygon\n i += 2;\n }\n } else {\n throw new Error(`unknown command ${cmd}`);\n }\n }\n\n return {data, indices};\n }\n\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate Flat GeoJSON\n // data format, which maps closely to the binary data buffers.\n // It is similar to GeoJSON, but rather than storing the coordinates\n // in multidimensional arrays, we have a 1D `data` with all the\n // coordinates, and then index into this using the `indices`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], indices: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], indices: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], indices: [[0, 2]]\n // }\n // Thus the indices member lets us look up the relevant range\n // from the data array.\n // The Multi* versions of the above types share the same data\n // structure, just with multiple elements in the indices array\n const geom = this.loadGeometry();\n let geometry;\n\n // Apply the supplied transformation to data\n transform(geom.data, this);\n\n const coordLength = 2;\n\n // eslint-disable-next-line default-case\n switch (this.type) {\n case 1: // Point\n this._geometryInfo.pointFeaturesCount++;\n this._geometryInfo.pointPositionsCount += geom.indices.length;\n geometry = {type: 'Point', ...geom};\n break;\n\n case 2: // LineString\n this._geometryInfo.lineFeaturesCount++;\n this._geometryInfo.linePathsCount += geom.indices.length;\n this._geometryInfo.linePositionsCount += geom.data.length / coordLength;\n geometry = {type: 'LineString', ...geom};\n break;\n\n case 3: // Polygon\n geometry = classifyRings(geom);\n\n // Unlike Point & LineString geom.indices is a 2D array, thanks\n // to the classifyRings method\n this._geometryInfo.polygonFeaturesCount++;\n this._geometryInfo.polygonObjectsCount += geometry.indices.length;\n\n for (const indices of geometry.indices) {\n this._geometryInfo.polygonRingsCount += indices.length;\n }\n this._geometryInfo.polygonPositionsCount += geometry.data.length / coordLength;\n\n break;\n default:\n throw new Error(`Invalid geometry type: ${this.type}`);\n }\n\n const result: FlatFeature = {type: 'Feature', geometry, properties: this.properties};\n\n if (this.id !== null) {\n result.id = this.id;\n }\n\n return result;\n }\n\n toBinaryCoordinates(\n options: {x: number; y: number; z: number} | ((data: number[], feature: {extent: any}) => void)\n ): FlatFeature {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n return this._toBinaryCoordinates(project);\n }\n}\n"],"file":"vector-tile-feature.js"}
|
|
@@ -1,91 +1,64 @@
|
|
|
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
|
-
|
|
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);
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import VectorTileFeature from './vector-tile-feature';
|
|
3
|
+
export default class VectorTileLayer {
|
|
4
|
+
constructor(pbf, end) {
|
|
5
|
+
_defineProperty(this, "version", void 0);
|
|
6
|
+
|
|
7
|
+
_defineProperty(this, "name", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "extent", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "length", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "_pbf", void 0);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "_keys", void 0);
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "_values", void 0);
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "_features", void 0);
|
|
20
|
+
|
|
21
|
+
this.version = 1;
|
|
22
|
+
this.name = '';
|
|
23
|
+
this.extent = 4096;
|
|
24
|
+
this.length = 0;
|
|
25
|
+
this._pbf = pbf;
|
|
26
|
+
this._keys = [];
|
|
27
|
+
this._values = [];
|
|
28
|
+
this._features = [];
|
|
29
|
+
pbf.readFields(readLayer, this, end);
|
|
30
|
+
this.length = this._features.length;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
feature(i, geometryInfo) {
|
|
34
|
+
if (i < 0 || i >= this._features.length) {
|
|
35
|
+
throw new Error('feature index out of bounds');
|
|
38
36
|
}
|
|
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
|
+
|
|
39
45
|
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
* @param tag
|
|
44
|
-
* @param layer
|
|
45
|
-
* @param pbf
|
|
46
|
-
*/
|
|
46
|
+
|
|
47
47
|
function readLayer(tag, layer, pbf) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
}
|
|
48
|
+
if (layer && pbf) {
|
|
49
|
+
if (tag === 15) layer.version = pbf.readVarint();else if (tag === 1) layer.name = pbf.readString();else if (tag === 5) layer.extent = pbf.readVarint();else if (tag === 2) layer._features.push(pbf.pos);else if (tag === 3) layer._keys.push(pbf.readString());else if (tag === 4) layer._values.push(readValueMessage(pbf));
|
|
50
|
+
}
|
|
62
51
|
}
|
|
63
|
-
|
|
64
|
-
*
|
|
65
|
-
* @param pbf
|
|
66
|
-
* @returns value
|
|
67
|
-
*/
|
|
52
|
+
|
|
68
53
|
function readValueMessage(pbf) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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;
|
|
54
|
+
let value = null;
|
|
55
|
+
const end = pbf.readVarint() + pbf.pos;
|
|
56
|
+
|
|
57
|
+
while (pbf.pos < end) {
|
|
58
|
+
const tag = pbf.readVarint() >> 3;
|
|
59
|
+
value = tag === 1 ? pbf.readString() : tag === 2 ? pbf.readFloat() : tag === 3 ? pbf.readDouble() : tag === 4 ? pbf.readVarint64() : tag === 5 ? pbf.readVarint() : tag === 6 ? pbf.readSVarint() : tag === 7 ? pbf.readBoolean() : null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return value;
|
|
91
63
|
}
|
|
64
|
+
//# sourceMappingURL=vector-tile-layer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/binary-vector-tile/vector-tile-layer.ts"],"names":["VectorTileFeature","VectorTileLayer","constructor","pbf","end","version","name","extent","length","_pbf","_keys","_values","_features","readFields","readLayer","feature","i","geometryInfo","Error","pos","readVarint","tag","layer","readString","push","readValueMessage","value","readFloat","readDouble","readVarint64","readSVarint","readBoolean"],"mappings":";AAGA,OAAOA,iBAAP,MAA8B,uBAA9B;AAIA,eAAe,MAAMC,eAAN,CAAsB;AASnCC,EAAAA,WAAW,CAACC,GAAD,EAAgBC,GAAhB,EAA6B;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAEtC,SAAKC,OAAL,GAAe,CAAf;AACA,SAAKC,IAAL,GAAY,EAAZ;AACA,SAAKC,MAAL,GAAc,IAAd;AACA,SAAKC,MAAL,GAAc,CAAd;AAGA,SAAKC,IAAL,GAAYN,G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B,GAAG,CAACgB,GAAzB,EAAf,KACA,IAAIE,GAAG,KAAK,CAAZ,EAAeC,KAAK,CAACZ,KAAN,CAAYc,IAAZ,CAAiBrB,GAAG,CAACoB,UAAJ,EAAjB,EAAf,KACA,IAAIF,GAAG,KAAK,CAAZ,EAAeC,KAAK,CAACX,OAAN,CAAca,IAAd,CAAmBC,gBAAgB,CAACtB,GAAD,CAAnC;AACrB;AACF;;AAOD,SAASsB,gBAAT,CAA0BtB,GAA1B,EAAyC;AACvC,MAAIuB,KAAuC,GAAG,IAA9C;AACA,QAAMtB,GAAG,GAAGD,GAAG,CAACiB,UAAJ,KAAmBjB,GAAG,CAACgB,GAAnC;;AAEA,SAAOhB,GAAG,CAACgB,GAAJ,GAAUf,GAAjB,EAAsB;AACpB,UAAMiB,GAAG,GAAGlB,GAAG,CAACiB,UAAJ,MAAoB,CAAhC;AAEAM,IAAAA,KAAK,GACHL,GAAG,KAAK,CAAR,GACIlB,GAAG,CAACoB,UAAJ,EADJ,GAEIF,GAAG,KAAK,CAAR,GACAlB,GAAG,CAACwB,SAAJ,EADA,GAEAN,GAAG,KAAK,CAAR,GACAlB,GAAG,CAACyB,UAAJ,EADA,GAEAP,GAAG,KAAK,CAAR,GACAlB,GAAG,CAAC0B,YAAJ,EADA,GAEAR,GAAG,KAAK,CAAR,GACAlB,GAAG,CAACiB,UAAJ,EADA,GAEAC,GAAG,KAAK,CAAR,GACAlB,GAAG,CAAC2B,WAAJ,EADA,GAEAT,GAAG,KAAK,CAAR,GACAlB,GAAG,CAAC4B,WAAJ,EADA,GAEA,IAfN;AAgBD;;AAED,SAAOL,KAAP;AACD","sourcesContent":["/* eslint-disable indent */\n// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport VectorTileFeature from './vector-tile-feature';\nimport Protobuf from 'pbf';\nimport {GeojsonGeometryInfo} from '@loaders.gl/schema';\n\nexport default class VectorTileLayer {\n version: number;\n name: string;\n extent: number;\n length: number;\n _pbf: Protobuf;\n _keys: string[];\n _values: (string | number | boolean | null)[];\n _features: number[];\n constructor(pbf: Protobuf, end: number) {\n // Public\n this.version = 1;\n this.name = '';\n this.extent = 4096;\n this.length = 0;\n\n // Private\n this._pbf = pbf;\n this._keys = [];\n this._values = [];\n this._features = [];\n\n pbf.readFields(readLayer, this, end);\n\n this.length = this._features.length;\n }\n\n /**\n * return feature `i` from this layer as a `VectorTileFeature`\n *\n * @param index\n * @param geometryInfo\n * @returns {VectorTileFeature}\n */\n feature(i: number, geometryInfo: GeojsonGeometryInfo): VectorTileFeature {\n if (i < 0 || i >= this._features.length) {\n throw new Error('feature index out of bounds');\n }\n\n this._pbf.pos = this._features[i];\n\n const end = this._pbf.readVarint() + this._pbf.pos;\n return new VectorTileFeature(\n this._pbf,\n end,\n this.extent,\n this._keys,\n this._values,\n geometryInfo\n );\n }\n}\n\n/**\n *\n * @param tag\n * @param layer\n * @param pbf\n */\nfunction readLayer(tag: number, layer?: VectorTileLayer, pbf?: Protobuf): void {\n if (layer && pbf) {\n if (tag === 15) layer.version = pbf.readVarint();\n else if (tag === 1) layer.name = pbf.readString();\n else if (tag === 5) layer.extent = pbf.readVarint();\n else if (tag === 2) layer._features.push(pbf.pos);\n else if (tag === 3) layer._keys.push(pbf.readString());\n else if (tag === 4) layer._values.push(readValueMessage(pbf));\n }\n}\n\n/**\n *\n * @param pbf\n * @returns value\n */\nfunction readValueMessage(pbf: Protobuf) {\n let value: string | number | boolean | null = null;\n const end = pbf.readVarint() + pbf.pos;\n\n while (pbf.pos < end) {\n const tag = pbf.readVarint() >> 3;\n\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n\n return value;\n}\n"],"file":"vector-tile-layer.js"}
|
|
@@ -1,29 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.layers = pbf.readFields(readTile, {}, end);
|
|
11
|
-
}
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import VectorTileLayer from './vector-tile-layer';
|
|
3
|
+
export default class VectorTile {
|
|
4
|
+
constructor(pbf, end) {
|
|
5
|
+
_defineProperty(this, "layers", void 0);
|
|
6
|
+
|
|
7
|
+
this.layers = pbf.readFields(readTile, {}, end);
|
|
8
|
+
}
|
|
9
|
+
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param tag
|
|
17
|
-
* @param layers
|
|
18
|
-
* @param pbf
|
|
19
|
-
*/
|
|
11
|
+
|
|
20
12
|
function readTile(tag, layers, pbf) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
13
|
+
if (tag === 3) {
|
|
14
|
+
if (pbf) {
|
|
15
|
+
const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
|
|
16
|
+
|
|
17
|
+
if (layer.length && layers) {
|
|
18
|
+
layers[layer.name] = layer;
|
|
19
|
+
}
|
|
28
20
|
}
|
|
21
|
+
}
|
|
29
22
|
}
|
|
23
|
+
//# sourceMappingURL=vector-tile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/binary-vector-tile/vector-tile.ts"],"names":["VectorTileLayer","VectorTile","constructor","pbf","end","layers","readFields","readTile","tag","layer","readVarint","pos","length","name"],"mappings":";AAEA,OAAOA,eAAP,MAA4B,qBAA5B;AAGA,eAAe,MAAMC,UAAN,CAAiB;AAE9BC,EAAAA,WAAW,CAACC,GAAD,EAAgBC,GAAhB,EAA8B;AAAA;;AACvC,SAAKC,MAAL,GAAcF,GAAG,CAACG,UAAJ,CAAeC,QAAf,EAAyB,EAAzB,EAA6BH,GAA7B,CAAd;AACD;;AAJ6B;;AAahC,SAASG,QAAT,CAAkBC,GAAlB,EAA+BH,MAA/B,EAAwEF,GAAxE,EAA8F;AAC5F,MAAIK,GAAG,KAAK,CAAZ,EAAe;AACb,QAAIL,GAAJ,EAAS;AACP,YAAMM,KAAK,GAAG,IAAIT,eAAJ,CAAoBG,GAApB,EAAyBA,GAAG,CAACO,UAAJ,KAAmBP,GAAG,CAACQ,GAAhD,CAAd;;AACA,UAAIF,KAAK,CAACG,MAAN,IAAgBP,MAApB,EAA4B;AAC1BA,QAAAA,MAAM,CAACI,KAAK,CAACI,IAAP,CAAN,GAAqBJ,KAArB;AACD;AACF;AACF;AACF","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport VectorTileLayer from './vector-tile-layer';\nimport Protobuf from 'pbf';\n\nexport default class VectorTile {\n layers: {[x: string]: VectorTileLayer};\n constructor(pbf: Protobuf, end?: number) {\n this.layers = pbf.readFields(readTile, {}, end);\n }\n}\n\n/**\n *\n * @param tag\n * @param layers\n * @param pbf\n */\nfunction readTile(tag: number, layers?: {[x: string]: VectorTileLayer}, pbf?: Protobuf): void {\n if (tag === 3) {\n if (pbf) {\n const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);\n if (layer.length && layers) {\n layers[layer.name] = layer;\n }\n }\n }\n}\n"],"file":"vector-tile.js"}
|
|
File without changes
|