@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.
Files changed (129) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2276 -4
  4. package/dist/es5/bundle.js +7 -0
  5. package/dist/es5/bundle.js.map +1 -0
  6. package/dist/es5/helpers/binary-util-functions.js +95 -0
  7. package/dist/es5/helpers/binary-util-functions.js.map +1 -0
  8. package/dist/es5/helpers/mapbox-util-functions.js +62 -0
  9. package/dist/es5/helpers/mapbox-util-functions.js.map +1 -0
  10. package/dist/es5/index.js +20 -0
  11. package/dist/es5/index.js.map +1 -0
  12. package/dist/{lib → es5/lib}/binary-vector-tile/LICENSE.txt +0 -0
  13. package/dist/es5/lib/binary-vector-tile/features-to-binary.js +338 -0
  14. package/dist/es5/lib/binary-vector-tile/features-to-binary.js.map +1 -0
  15. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js +162 -0
  16. package/dist/es5/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  17. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js +69 -0
  18. package/dist/es5/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  19. package/dist/es5/lib/binary-vector-tile/vector-tile.js +35 -0
  20. package/dist/es5/lib/binary-vector-tile/vector-tile.js.map +1 -0
  21. package/dist/{lib → es5/lib}/mapbox-vector-tile/LICENSE.txt +0 -0
  22. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js +207 -0
  23. package/dist/es5/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  24. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js +69 -0
  25. package/dist/es5/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  26. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js +35 -0
  27. package/dist/es5/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  28. package/dist/es5/lib/parse-mvt.js +129 -0
  29. package/dist/es5/lib/parse-mvt.js.map +1 -0
  30. package/dist/es5/lib/types.js +2 -0
  31. package/dist/{lib → es5/lib}/types.js.map +0 -0
  32. package/dist/es5/mvt-loader.js +38 -0
  33. package/dist/es5/mvt-loader.js.map +1 -0
  34. package/dist/es5/workers/mvt-worker.js +8 -0
  35. package/dist/es5/workers/mvt-worker.js.map +1 -0
  36. package/dist/esm/bundle.js +5 -0
  37. package/dist/esm/bundle.js.map +1 -0
  38. package/dist/esm/helpers/binary-util-functions.js +81 -0
  39. package/dist/esm/helpers/binary-util-functions.js.map +1 -0
  40. package/dist/esm/helpers/mapbox-util-functions.js +49 -0
  41. package/dist/esm/helpers/mapbox-util-functions.js.map +1 -0
  42. package/dist/esm/index.js +2 -0
  43. package/dist/esm/index.js.map +1 -0
  44. package/dist/esm/lib/binary-vector-tile/LICENSE.txt +31 -0
  45. package/dist/esm/lib/binary-vector-tile/features-to-binary.js +327 -0
  46. package/dist/esm/lib/binary-vector-tile/features-to-binary.js.map +1 -0
  47. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js +156 -0
  48. package/dist/esm/lib/binary-vector-tile/vector-tile-feature.js.map +1 -0
  49. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js +64 -0
  50. package/dist/esm/lib/binary-vector-tile/vector-tile-layer.js.map +1 -0
  51. package/dist/esm/lib/binary-vector-tile/vector-tile.js +23 -0
  52. package/dist/esm/lib/binary-vector-tile/vector-tile.js.map +1 -0
  53. package/dist/esm/lib/mapbox-vector-tile/LICENSE.txt +31 -0
  54. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js +202 -0
  55. package/dist/esm/lib/mapbox-vector-tile/vector-tile-feature.js.map +1 -0
  56. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js +64 -0
  57. package/dist/esm/lib/mapbox-vector-tile/vector-tile-layer.js.map +1 -0
  58. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js +23 -0
  59. package/dist/esm/lib/mapbox-vector-tile/vector-tile.js.map +1 -0
  60. package/dist/esm/lib/parse-mvt.js +116 -0
  61. package/dist/esm/lib/parse-mvt.js.map +1 -0
  62. package/dist/esm/lib/types.js +2 -0
  63. package/dist/esm/lib/types.js.map +1 -0
  64. package/dist/esm/mvt-loader.js +26 -0
  65. package/dist/esm/mvt-loader.js.map +1 -0
  66. package/dist/esm/workers/mvt-worker.js +4 -0
  67. package/dist/esm/workers/mvt-worker.js.map +1 -0
  68. package/dist/helpers/binary-util-functions.d.ts +39 -0
  69. package/dist/helpers/binary-util-functions.d.ts.map +1 -0
  70. package/dist/helpers/binary-util-functions.js +109 -74
  71. package/dist/helpers/mapbox-util-functions.d.ts +29 -0
  72. package/dist/helpers/mapbox-util-functions.d.ts.map +1 -0
  73. package/dist/helpers/mapbox-util-functions.js +78 -45
  74. package/dist/index.d.ts +2 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +6 -2
  77. package/dist/lib/binary-vector-tile/features-to-binary.d.ts +185 -0
  78. package/dist/lib/binary-vector-tile/features-to-binary.d.ts.map +1 -0
  79. package/dist/lib/binary-vector-tile/features-to-binary.js +323 -297
  80. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts +36 -0
  81. package/dist/lib/binary-vector-tile/vector-tile-feature.d.ts.map +1 -0
  82. package/dist/lib/binary-vector-tile/vector-tile-feature.js +145 -142
  83. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts +23 -0
  84. package/dist/lib/binary-vector-tile/vector-tile-layer.d.ts.map +1 -0
  85. package/dist/lib/binary-vector-tile/vector-tile-layer.js +85 -58
  86. package/dist/lib/binary-vector-tile/vector-tile.d.ts +9 -0
  87. package/dist/lib/binary-vector-tile/vector-tile.d.ts.map +1 -0
  88. package/dist/lib/binary-vector-tile/vector-tile.js +25 -19
  89. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts +27 -0
  90. package/dist/lib/mapbox-vector-tile/vector-tile-feature.d.ts.map +1 -0
  91. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js +161 -193
  92. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts +20 -0
  93. package/dist/lib/mapbox-vector-tile/vector-tile-layer.d.ts.map +1 -0
  94. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js +83 -58
  95. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts +9 -0
  96. package/dist/lib/mapbox-vector-tile/vector-tile.d.ts.map +1 -0
  97. package/dist/lib/mapbox-vector-tile/vector-tile.js +25 -19
  98. package/dist/lib/parse-mvt.d.ts +85 -0
  99. package/dist/lib/parse-mvt.d.ts.map +1 -0
  100. package/dist/lib/parse-mvt.js +126 -100
  101. package/dist/lib/types.d.ts +92 -0
  102. package/dist/lib/types.d.ts.map +1 -0
  103. package/dist/lib/types.js +2 -2
  104. package/dist/mvt-loader.d.ts +10 -0
  105. package/dist/mvt-loader.d.ts.map +1 -0
  106. package/dist/mvt-loader.js +42 -23
  107. package/dist/mvt-worker.js +2286 -3
  108. package/dist/workers/mvt-worker.d.ts +2 -0
  109. package/dist/workers/mvt-worker.d.ts.map +1 -0
  110. package/dist/workers/mvt-worker.js +5 -4
  111. package/package.json +9 -9
  112. package/src/lib/parse-mvt.ts +1 -1
  113. package/dist/bundle.js.map +0 -1
  114. package/dist/dist.min.js +0 -4
  115. package/dist/dist.min.js.map +0 -1
  116. package/dist/helpers/binary-util-functions.js.map +0 -1
  117. package/dist/helpers/mapbox-util-functions.js.map +0 -1
  118. package/dist/index.js.map +0 -1
  119. package/dist/lib/binary-vector-tile/features-to-binary.js.map +0 -1
  120. package/dist/lib/binary-vector-tile/vector-tile-feature.js.map +0 -1
  121. package/dist/lib/binary-vector-tile/vector-tile-layer.js.map +0 -1
  122. package/dist/lib/binary-vector-tile/vector-tile.js.map +0 -1
  123. package/dist/lib/mapbox-vector-tile/vector-tile-feature.js.map +0 -1
  124. package/dist/lib/mapbox-vector-tile/vector-tile-layer.js.map +0 -1
  125. package/dist/lib/mapbox-vector-tile/vector-tile.js.map +0 -1
  126. package/dist/lib/parse-mvt.js.map +0 -1
  127. package/dist/mvt-loader.js.map +0 -1
  128. package/dist/mvt-worker.js.map +0 -1
  129. package/dist/workers/mvt-worker.js.map +0 -1
@@ -0,0 +1,327 @@
1
+ import { earcut } from '@math.gl/polygon';
2
+ export function featuresToBinary(features, firstPassData, options) {
3
+ return fillArrays(features, firstPassData, {
4
+ numericPropKeys: options ? options.numericPropKeys : extractNumericPropKeys(features),
5
+ PositionDataType: options ? options.PositionDataType : Float32Array
6
+ });
7
+ }
8
+ export const TEST_EXPORTS = {
9
+ extractNumericPropKeys,
10
+ fillArrays
11
+ };
12
+
13
+ function extractNumericPropKeys(features) {
14
+ const numericPropKeys = {};
15
+
16
+ for (const feature of features) {
17
+ if (feature.properties) {
18
+ for (const key in feature.properties) {
19
+ const numericSoFar = numericPropKeys[key];
20
+
21
+ if (numericSoFar || numericSoFar === undefined) {
22
+ const val = feature.properties[key];
23
+ numericPropKeys[key] = isNumeric(val);
24
+ }
25
+ }
26
+ }
27
+ }
28
+
29
+ return Object.keys(numericPropKeys).filter(k => numericPropKeys[k]);
30
+ }
31
+
32
+ function fillArrays(features, firstPassData, options) {
33
+ const {
34
+ pointPositionsCount,
35
+ pointFeaturesCount,
36
+ linePositionsCount,
37
+ linePathsCount,
38
+ lineFeaturesCount,
39
+ polygonPositionsCount,
40
+ polygonObjectsCount,
41
+ polygonRingsCount,
42
+ polygonFeaturesCount
43
+ } = firstPassData;
44
+ const {
45
+ numericPropKeys,
46
+ PositionDataType = Float32Array
47
+ } = options;
48
+ const hasGlobalId = features[0] && 'id' in features[0];
49
+ const coordLength = 2;
50
+ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
51
+ const points = {
52
+ positions: new PositionDataType(pointPositionsCount * coordLength),
53
+ globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
54
+ featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
55
+ numericProps: {},
56
+ properties: [],
57
+ fields: []
58
+ };
59
+ const lines = {
60
+ pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
61
+ positions: new PositionDataType(linePositionsCount * coordLength),
62
+ globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
63
+ featureIds: lineFeaturesCount > 65535 ? new Uint32Array(linePositionsCount) : new Uint16Array(linePositionsCount),
64
+ numericProps: {},
65
+ properties: [],
66
+ fields: []
67
+ };
68
+ const polygons = {
69
+ polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
70
+ primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
71
+ positions: new PositionDataType(polygonPositionsCount * coordLength),
72
+ triangles: [],
73
+ globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
74
+ featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
75
+ numericProps: {},
76
+ properties: [],
77
+ fields: []
78
+ };
79
+
80
+ for (const object of [points, lines, polygons]) {
81
+ for (const propName of numericPropKeys) {
82
+ object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
83
+ }
84
+ }
85
+
86
+ lines.pathIndices[linePathsCount] = linePositionsCount;
87
+ polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
88
+ polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
89
+ const indexMap = {
90
+ pointPosition: 0,
91
+ pointFeature: 0,
92
+ linePosition: 0,
93
+ linePath: 0,
94
+ lineFeature: 0,
95
+ polygonPosition: 0,
96
+ polygonObject: 0,
97
+ polygonRing: 0,
98
+ polygonFeature: 0,
99
+ feature: 0
100
+ };
101
+
102
+ for (const feature of features) {
103
+ const geometry = feature.geometry;
104
+ const properties = feature.properties || {};
105
+
106
+ switch (geometry.type) {
107
+ case 'Point':
108
+ case 'MultiPoint':
109
+ handlePoint(geometry, points, indexMap, coordLength, properties);
110
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
111
+
112
+ if (hasGlobalId) {
113
+ points.fields.push({
114
+ id: feature.id
115
+ });
116
+ }
117
+
118
+ indexMap.pointFeature++;
119
+ break;
120
+
121
+ case 'LineString':
122
+ case 'MultiLineString':
123
+ handleLineString(geometry, lines, indexMap, coordLength, properties);
124
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
125
+
126
+ if (hasGlobalId) {
127
+ lines.fields.push({
128
+ id: feature.id
129
+ });
130
+ }
131
+
132
+ indexMap.lineFeature++;
133
+ break;
134
+
135
+ case 'Polygon':
136
+ case 'MultiPolygon':
137
+ handlePolygon(geometry, polygons, indexMap, coordLength, properties);
138
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
139
+
140
+ if (hasGlobalId) {
141
+ polygons.fields.push({
142
+ id: feature.id
143
+ });
144
+ }
145
+
146
+ indexMap.polygonFeature++;
147
+ break;
148
+
149
+ default:
150
+ throw new Error('Invalid geometry type');
151
+ }
152
+
153
+ indexMap.feature++;
154
+ }
155
+
156
+ return makeAccessorObjects(points, lines, polygons, coordLength);
157
+ }
158
+
159
+ function handlePoint(geometry, points, indexMap, coordLength, properties) {
160
+ points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
161
+ const nPositions = geometry.data.length / coordLength;
162
+ fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
163
+ points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
164
+ points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
165
+ indexMap.pointPosition += nPositions;
166
+ }
167
+
168
+ function handleLineString(geometry, lines, indexMap, coordLength, properties) {
169
+ lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
170
+ const nPositions = geometry.data.length / coordLength;
171
+ fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
172
+ lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
173
+ lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
174
+
175
+ for (let i = 0, il = geometry.lines.length; i < il; ++i) {
176
+ const start = geometry.lines[i];
177
+ const end = i === il - 1 ? geometry.data.length : geometry.lines[i + 1];
178
+ lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;
179
+ indexMap.linePosition += (end - start) / coordLength;
180
+ }
181
+ }
182
+
183
+ function handlePolygon(geometry, polygons, indexMap, coordLength, properties) {
184
+ polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
185
+ const nPositions = geometry.data.length / coordLength;
186
+ fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
187
+ polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
188
+ polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
189
+
190
+ for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {
191
+ const startPosition = indexMap.polygonPosition;
192
+ polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
193
+ const areas = geometry.areas[l];
194
+ const lines = geometry.lines[l];
195
+ const nextLines = geometry.lines[l + 1];
196
+
197
+ for (let i = 0, il = lines.length; i < il; ++i) {
198
+ const start = lines[i];
199
+ const end = i === il - 1 ? nextLines === undefined ? geometry.data.length : nextLines[0] : lines[i + 1];
200
+ polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
201
+ indexMap.polygonPosition += (end - start) / coordLength;
202
+ }
203
+
204
+ const endPosition = indexMap.polygonPosition;
205
+ triangulatePolygon(polygons, areas, lines, {
206
+ startPosition,
207
+ endPosition,
208
+ coordLength
209
+ });
210
+ }
211
+ }
212
+
213
+ function triangulatePolygon(polygons, areas, lines, {
214
+ startPosition,
215
+ endPosition,
216
+ coordLength
217
+ }) {
218
+ const start = startPosition * coordLength;
219
+ const end = endPosition * coordLength;
220
+ const polygonPositions = polygons.positions.subarray(start, end);
221
+ const offset = lines[0];
222
+ const holes = lines.slice(1).map(n => (n - offset) / coordLength);
223
+ const indices = earcut(polygonPositions, holes, coordLength, areas);
224
+
225
+ for (let t = 0, tl = indices.length; t < tl; ++t) {
226
+ polygons.triangles.push(startPosition + indices[t]);
227
+ }
228
+ }
229
+
230
+ function makeAccessorObjects(points, lines, polygons, coordLength) {
231
+ const returnObj = {
232
+ points: { ...points,
233
+ positions: {
234
+ value: points.positions,
235
+ size: coordLength
236
+ },
237
+ globalFeatureIds: {
238
+ value: points.globalFeatureIds,
239
+ size: 1
240
+ },
241
+ featureIds: {
242
+ value: points.featureIds,
243
+ size: 1
244
+ }
245
+ },
246
+ lines: { ...lines,
247
+ pathIndices: {
248
+ value: lines.pathIndices,
249
+ size: 1
250
+ },
251
+ positions: {
252
+ value: lines.positions,
253
+ size: coordLength
254
+ },
255
+ globalFeatureIds: {
256
+ value: lines.globalFeatureIds,
257
+ size: 1
258
+ },
259
+ featureIds: {
260
+ value: lines.featureIds,
261
+ size: 1
262
+ }
263
+ },
264
+ polygons: { ...polygons,
265
+ polygonIndices: {
266
+ value: polygons.polygonIndices,
267
+ size: 1
268
+ },
269
+ primitivePolygonIndices: {
270
+ value: polygons.primitivePolygonIndices,
271
+ size: 1
272
+ },
273
+ positions: {
274
+ value: polygons.positions,
275
+ size: coordLength
276
+ },
277
+ triangles: {
278
+ value: new Uint32Array(polygons.triangles),
279
+ size: 1
280
+ },
281
+ globalFeatureIds: {
282
+ value: polygons.globalFeatureIds,
283
+ size: 1
284
+ },
285
+ featureIds: {
286
+ value: polygons.featureIds,
287
+ size: 1
288
+ }
289
+ }
290
+ };
291
+
292
+ for (const geomType in returnObj) {
293
+ for (const numericProp in returnObj[geomType].numericProps) {
294
+ returnObj[geomType].numericProps[numericProp] = {
295
+ value: returnObj[geomType].numericProps[numericProp],
296
+ size: 1
297
+ };
298
+ }
299
+ }
300
+
301
+ return returnObj;
302
+ }
303
+
304
+ function fillNumericProperties(object, properties, index, length) {
305
+ for (const numericPropName in object.numericProps) {
306
+ if (numericPropName in properties) {
307
+ object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);
308
+ }
309
+ }
310
+ }
311
+
312
+ function keepStringProperties(properties, numericKeys) {
313
+ const props = {};
314
+
315
+ for (const key in properties) {
316
+ if (!numericKeys.includes(key)) {
317
+ props[key] = properties[key];
318
+ }
319
+ }
320
+
321
+ return props;
322
+ }
323
+
324
+ function isNumeric(x) {
325
+ return Number.isFinite(x);
326
+ }
327
+ //# sourceMappingURL=features-to-binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/lib/binary-vector-tile/features-to-binary.ts"],"names":["earcut","featuresToBinary","features","firstPassData","options","fillArrays","numericPropKeys","extractNumericPropKeys","PositionDataType","Float32Array","TEST_EXPORTS","feature","properties","key","numericSoFar","undefined","val","isNumeric","Object","keys","filter","k","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","hasGlobalId","coordLength","GlobalFeatureIdsDataType","length","Uint32Array","Uint16Array","points","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","triangles","object","propName","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","geometry","type","handlePoint","push","keepStringProperties","id","handleLineString","handlePolygon","Error","makeAccessorObjects","set","data","nPositions","fillNumericProperties","fill","i","il","start","end","l","ll","startPosition","areas","nextLines","endPosition","triangulatePolygon","polygonPositions","subarray","offset","holes","slice","map","n","indices","t","tl","returnObj","value","size","geomType","numericProp","index","numericPropName","numericKeys","props","includes","x","Number","isFinite"],"mappings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F,GAArB,CAAL,EAAgC;AAC9B4F,MAAAA,KAAK,CAAC5F,GAAD,CAAL,GAAaD,UAAU,CAACC,GAAD,CAAvB;AACD;AACF;;AACD,SAAO4F,KAAP;AACD;;AAED,SAASxF,SAAT,CAAmB0F,CAAnB,EAA+B;AAC7B,SAAOC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAAP;AACD","sourcesContent":["/* eslint-disable indent */\nimport {earcut} from '@math.gl/polygon';\nimport {\n MvtBinaryCoordinates,\n MvtBinaryGeometry,\n MvtBinaryOptions,\n MvtFirstPassedData,\n MvtLines,\n MvtPoints,\n MvtPolygons\n} from '../types';\n\n/**\n * Convert binary features to flat binary arrays. Similar to\n * `geojsonToBinary` helper function, except that it expects\n * a binary representation of the feature data, which enables\n * 2X-3X speed increase in parse speed, compared to using\n * geoJSON. See `binary-vector-tile/VectorTileFeature` for\n * data format detais\n *\n * @param features\n * @param firstPassData\n * @param options\n * @returns filled arrays\n */\nexport function featuresToBinary(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options?: MvtBinaryOptions\n) {\n return fillArrays(features, firstPassData, {\n numericPropKeys: options ? options.numericPropKeys : extractNumericPropKeys(features),\n PositionDataType: options ? options.PositionDataType : Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n extractNumericPropKeys,\n fillArrays\n};\n\n/**\n * Extracts properties that are always numeric\n *\n * @param features\n * @returns object with numeric keys\n */\nfunction extractNumericPropKeys(features: MvtBinaryCoordinates[]): string[] {\n const numericPropKeys = {};\n for (const feature of features) {\n if (feature.properties) {\n for (const key in feature.properties) {\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, false is stored to prevent rechecking in the future\n const numericSoFar = numericPropKeys[key];\n if (numericSoFar || numericSoFar === undefined) {\n const val = feature.properties[key];\n numericPropKeys[key] = isNumeric(val);\n }\n }\n }\n }\n\n return Object.keys(numericPropKeys).filter((k) => numericPropKeys[k]);\n}\n\n/**\n * Fills coordinates into pre-allocated typed arrays\n *\n * @param features\n * @param firstPassData\n * @param options\n * @returns an accessor object with value and size keys\n */\n// eslint-disable-next-line complexity\nfunction fillArrays(\n features: MvtBinaryCoordinates[],\n firstPassData: MvtFirstPassedData,\n options: MvtBinaryOptions\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n } = firstPassData;\n const {numericPropKeys, PositionDataType = Float32Array} = options;\n const hasGlobalId = features[0] && 'id' in features[0];\n const coordLength = 2;\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points: MvtPoints = {\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const lines: MvtLines = {\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n positions: new PositionDataType(linePositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n const polygons: MvtPolygons = {\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n triangles: [],\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: [],\n fields: []\n };\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n case 'MultiPoint':\n handlePoint(geometry, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n points.fields.push({id: feature.id});\n }\n indexMap.pointFeature++;\n break;\n case 'LineString':\n case 'MultiLineString':\n handleLineString(geometry, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n lines.fields.push({id: feature.id});\n }\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n case 'MultiPolygon':\n handlePolygon(geometry, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n if (hasGlobalId) {\n polygons.fields.push({id: feature.id});\n }\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n/**\n * Fills (Multi)Point coordinates into points object of arrays\n *\n * @param geometry\n * @param points\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePoint(\n geometry: MvtBinaryGeometry,\n points: MvtPoints,\n indexMap: {\n pointPosition: number;\n pointFeature: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n points.positions.set(geometry.data, indexMap.pointPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);\n points.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n points.featureIds.fill(\n indexMap.pointFeature,\n indexMap.pointPosition,\n indexMap.pointPosition + nPositions\n );\n\n indexMap.pointPosition += nPositions;\n}\n\n/**\n * Fills (Multi)LineString coordinates into lines object of arrays\n *\n * @param geometry\n * @param lines\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handleLineString(\n geometry: MvtBinaryGeometry,\n lines: MvtLines,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition: number;\n linePath: number;\n lineFeature: number;\n polygonPosition?: number;\n polygonObject?: number;\n polygonRing?: number;\n polygonFeature?: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n lines.positions.set(geometry.data, indexMap.linePosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n lines.featureIds.fill(\n indexMap.lineFeature,\n indexMap.linePosition,\n indexMap.linePosition + nPositions\n );\n\n for (let i = 0, il = geometry.lines.length; i < il; ++i) {\n // Extract range of data we are working with, defined by start\n // and end indices (these index into the geometry.data array)\n const start = geometry.lines[i];\n const end =\n i === il - 1\n ? geometry.data.length // last line, so read to end of data\n : geometry.lines[i + 1]; // start index for next line\n\n lines.pathIndices[indexMap.linePath++] = indexMap.linePosition;\n indexMap.linePosition += (end - start) / coordLength;\n }\n}\n\n/**\n * Fills (Multi)Polygon coordinates into polygons object of arrays\n *\n * @param geometry\n * @param polygons\n * @param indexMap\n * @param coordLength\n * @param properties\n */\nfunction handlePolygon(\n geometry: MvtBinaryGeometry,\n polygons: MvtPolygons,\n indexMap: {\n pointPosition?: number;\n pointFeature?: number;\n linePosition?: number;\n linePath?: number;\n lineFeature?: number;\n polygonPosition: number;\n polygonObject: number;\n polygonRing: number;\n polygonFeature: number;\n feature: number;\n },\n coordLength: number,\n properties: {[x: string]: string | number | boolean | null}\n): void {\n polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);\n\n const nPositions = geometry.data.length / coordLength;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n polygons.globalFeatureIds.fill(\n indexMap.feature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n polygons.featureIds.fill(\n indexMap.polygonFeature,\n indexMap.polygonPosition,\n indexMap.polygonPosition + nPositions\n );\n\n // Unlike Point & LineString geometry.lines is a 2D array\n for (let l = 0, ll = geometry.lines.length; l < ll; ++l) {\n const startPosition = indexMap.polygonPosition;\n polygons.polygonIndices[indexMap.polygonObject++] = startPosition;\n\n const areas = geometry.areas![l];\n const lines = geometry.lines[l];\n const nextLines = geometry.lines[l + 1];\n\n for (let i = 0, il = lines.length; i < il; ++i) {\n const start = lines[i];\n const end =\n i === il - 1\n ? // last line, so either read to:\n nextLines === undefined\n ? geometry.data.length // end of data (no next lines)\n : nextLines[0] // start of first line in nextLines\n : lines[i + 1]; // start index for next line\n\n polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;\n indexMap.polygonPosition += (end - start) / coordLength;\n }\n\n const endPosition = indexMap.polygonPosition;\n triangulatePolygon(polygons, areas, lines, {startPosition, endPosition, coordLength});\n }\n}\n\n/**\n * Triangulate polygon using earcut\n *\n * @param polygons\n * @param areas\n * @param lines\n * @param param3\n */\nfunction triangulatePolygon(\n polygons: MvtPolygons,\n areas: number,\n lines: number[],\n {\n startPosition,\n endPosition,\n coordLength\n }: {startPosition: number; endPosition: number; coordLength: number}\n): void {\n const start = startPosition * coordLength;\n const end = endPosition * coordLength;\n\n // Extract positions and holes for just this polygon\n const polygonPositions = polygons.positions.subarray(start, end);\n\n // Holes are referenced relative to outer polygon\n const offset = lines[0];\n const holes = lines.slice(1).map((n: number) => (n - offset) / coordLength);\n\n // Compute triangulation\n const indices = earcut(polygonPositions, holes, coordLength, areas);\n\n // Indices returned by triangulation are relative to start\n // of polygon, so we need to offset\n for (let t = 0, tl = indices.length; t < tl; ++t) {\n polygons.triangles.push(startPosition + indices[t]);\n }\n}\n\n/**\n * Wrap each array in an accessor object with value and size keys\n *\n * @param points\n * @param lines\n * @param polygons\n * @param coordLength\n * @returns object\n */\nfunction makeAccessorObjects(\n points: MvtPoints,\n lines: MvtLines,\n polygons: MvtPolygons,\n coordLength: number\n) {\n const returnObj = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1}\n },\n lines: {\n ...lines,\n pathIndices: {value: lines.pathIndices, size: 1},\n positions: {value: lines.positions, size: coordLength},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1}\n },\n polygons: {\n ...polygons,\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n positions: {value: polygons.positions, size: coordLength},\n triangles: {value: new Uint32Array(polygons.triangles), size: 1},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1}\n }\n };\n\n for (const geomType in returnObj) {\n for (const numericProp in returnObj[geomType].numericProps) {\n returnObj[geomType].numericProps[numericProp] = {\n value: returnObj[geomType].numericProps[numericProp],\n size: 1\n };\n }\n }\n return returnObj;\n}\n\n/**\n * Add numeric properties to object\n *\n * @param object\n * @param properties\n * @param index\n * @param length\n */\nfunction fillNumericProperties(\n object: MvtPoints,\n properties: {[x: string]: string | number | boolean | null},\n index: number,\n length: number\n): void {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n object.numericProps[numericPropName].fill(properties[numericPropName], index, index + length);\n }\n }\n}\n\n/**\n * Keep string properties in object\n *\n * @param properties\n * @param numericKeys\n * @returns object\n */\nfunction keepStringProperties(\n properties: {[x: string]: string | number | boolean | null},\n numericKeys: string[]\n) {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\nfunction isNumeric(x: unknown) {\n return Number.isFinite(x);\n}\n"],"file":"features-to-binary.js"}
@@ -0,0 +1,156 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import { classifyRings, project, readFeature } from '../../helpers/binary-util-functions';
3
+ let endPos;
4
+ let cmd;
5
+ let cmdLen;
6
+ let length;
7
+ let x;
8
+ let y;
9
+ let i;
10
+ export const TEST_EXPORTS = {
11
+ classifyRings
12
+ };
13
+ export default class VectorTileFeature {
14
+ static get types() {
15
+ return ['Unknown', 'Point', 'LineString', 'Polygon'];
16
+ }
17
+
18
+ constructor(pbf, end, extent, keys, values, firstPassData) {
19
+ _defineProperty(this, "properties", void 0);
20
+
21
+ _defineProperty(this, "extent", void 0);
22
+
23
+ _defineProperty(this, "type", void 0);
24
+
25
+ _defineProperty(this, "id", void 0);
26
+
27
+ _defineProperty(this, "_pbf", void 0);
28
+
29
+ _defineProperty(this, "_geometry", void 0);
30
+
31
+ _defineProperty(this, "_keys", void 0);
32
+
33
+ _defineProperty(this, "_values", void 0);
34
+
35
+ _defineProperty(this, "_firstPassData", void 0);
36
+
37
+ this.properties = {};
38
+ this.extent = extent;
39
+ this.type = 0;
40
+ this.id = null;
41
+ this._pbf = pbf;
42
+ this._geometry = -1;
43
+ this._keys = keys;
44
+ this._values = values;
45
+ this._firstPassData = firstPassData;
46
+ pbf.readFields(readFeature, this, end);
47
+ }
48
+
49
+ loadGeometry() {
50
+ const pbf = this._pbf;
51
+ pbf.pos = this._geometry;
52
+ endPos = pbf.readVarint() + pbf.pos;
53
+ cmd = 1;
54
+ length = 0;
55
+ x = 0;
56
+ y = 0;
57
+ i = 0;
58
+ const lines = [];
59
+ const data = [];
60
+
61
+ while (pbf.pos < endPos) {
62
+ if (length <= 0) {
63
+ cmdLen = pbf.readVarint();
64
+ cmd = cmdLen & 0x7;
65
+ length = cmdLen >> 3;
66
+ }
67
+
68
+ length--;
69
+
70
+ if (cmd === 1 || cmd === 2) {
71
+ x += pbf.readSVarint();
72
+ y += pbf.readSVarint();
73
+
74
+ if (cmd === 1) {
75
+ lines.push(i);
76
+ }
77
+
78
+ data.push(x, y);
79
+ i += 2;
80
+ } else if (cmd === 7) {
81
+ if (i > 0) {
82
+ const start = lines[lines.length - 1];
83
+ data.push(data[start], data[start + 1]);
84
+ i += 2;
85
+ }
86
+ } else {
87
+ throw new Error("unknown command ".concat(cmd));
88
+ }
89
+ }
90
+
91
+ return {
92
+ data,
93
+ lines
94
+ };
95
+ }
96
+
97
+ _toBinaryCoordinates(transform) {
98
+ let geom = this.loadGeometry();
99
+ transform(geom.data, this);
100
+ const coordLength = 2;
101
+
102
+ switch (this.type) {
103
+ case 1:
104
+ this._firstPassData.pointFeaturesCount++;
105
+ this._firstPassData.pointPositionsCount += geom.lines.length;
106
+ break;
107
+
108
+ case 2:
109
+ this._firstPassData.lineFeaturesCount++;
110
+ this._firstPassData.linePathsCount += geom.lines.length;
111
+ this._firstPassData.linePositionsCount += geom.data.length / coordLength;
112
+ break;
113
+
114
+ case 3:
115
+ const classified = classifyRings(geom);
116
+ this._firstPassData.polygonFeaturesCount++;
117
+ this._firstPassData.polygonObjectsCount += classified.lines.length;
118
+
119
+ for (const lines of classified.lines) {
120
+ this._firstPassData.polygonRingsCount += lines.length;
121
+ }
122
+
123
+ this._firstPassData.polygonPositionsCount += classified.data.length / coordLength;
124
+ geom = classified;
125
+ break;
126
+ }
127
+
128
+ geom.type = VectorTileFeature.types[this.type];
129
+
130
+ if (geom.lines.length > 1) {
131
+ geom.type = "Multi".concat(geom.type);
132
+ }
133
+
134
+ const result = {
135
+ type: 'Feature',
136
+ geometry: geom,
137
+ properties: this.properties
138
+ };
139
+
140
+ if (this.id !== null) {
141
+ result.id = this.id;
142
+ }
143
+
144
+ return result;
145
+ }
146
+
147
+ toBinaryCoordinates(options) {
148
+ if (typeof options === 'function') {
149
+ return this._toBinaryCoordinates(options);
150
+ }
151
+
152
+ return this._toBinaryCoordinates(project);
153
+ }
154
+
155
+ }
156
+ //# 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","types","constructor","pbf","end","extent","keys","values","firstPassData","properties","type","id","_pbf","_geometry","_keys","_values","_firstPassData","readFields","loadGeometry","pos","readVarint","lines","data","readSVarint","push","start","Error","_toBinaryCoordinates","transform","geom","coordLength","pointFeaturesCount","pointPositionsCount","lineFeaturesCount","linePathsCount","linePositionsCount","classified","polygonFeaturesCount","polygonObjectsCount","polygonRingsCount","polygonPositionsCount","result","geometry","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;AAUrB,aAALC,KAAK,GAAG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AAEDE,EAAAA,mBAAmB,CACjBC,OADiB,EAEK;AACtB,QAAI,OAAOA,OAAP,KAAmB,UAAvB,EAAmC;AACjC,aAAO,KAAKjB,oBAAL,CAA0BiB,OAA1B,CAAP;AACD;;AACD,WAAO,KAAKjB,oBAAL,CAA0BrC,OAA1B,CAAP;AACD;;AArLoC","sourcesContent":["// This code is forked from https://github.com/mapbox/vector-tile-js under BSD 3-clause license.\n\nimport Protobuf from 'pbf';\nimport {MvtBinaryCoordinates, MvtBinaryGeometry, MvtFirstPassedData} from '../types';\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 _firstPassData: MvtFirstPassedData;\n static get types() {\n return ['Unknown', 'Point', 'LineString', 'Polygon'];\n }\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 firstPassData: MvtFirstPassedData\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._firstPassData = firstPassData;\n\n pbf.readFields(readFeature, this, end);\n }\n\n // eslint-disable-next-line complexity, max-statements\n loadGeometry(): MvtBinaryGeometry {\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 lines: number[] = []; // Indices where lines 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 lines.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 = lines[lines.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, lines};\n }\n\n /**\n *\n * @param transform\n * @returns result\n */\n _toBinaryCoordinates(transform) {\n // Expands the protobuf data to an intermediate `lines`\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 `lines`\n // parameter, e.g.\n //\n // geometry: {\n // type: 'Point', data: [1,2], lines: [0]\n // }\n // geometry: {\n // type: 'LineString', data: [1,2,3,4,...], lines: [0]\n // }\n // geometry: {\n // type: 'Polygon', data: [1,2,3,4,...], lines: [[0, 2]]\n // }\n // Thus the lines 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 lines array\n let geom = this.loadGeometry();\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._firstPassData.pointFeaturesCount++;\n this._firstPassData.pointPositionsCount += geom.lines.length;\n break;\n\n case 2: // LineString\n this._firstPassData.lineFeaturesCount++;\n this._firstPassData.linePathsCount += geom.lines.length;\n this._firstPassData.linePositionsCount += geom.data.length / coordLength;\n break;\n\n case 3: // Polygon\n const classified = classifyRings(geom);\n\n // Unlike Point & LineString geom.lines is a 2D array, thanks\n // to the classifyRings method\n this._firstPassData.polygonFeaturesCount++;\n this._firstPassData.polygonObjectsCount += classified.lines.length;\n\n for (const lines of classified.lines) {\n this._firstPassData.polygonRingsCount += lines.length;\n }\n this._firstPassData.polygonPositionsCount += classified.data.length / coordLength;\n\n geom = classified;\n break;\n }\n\n geom.type = VectorTileFeature.types[this.type];\n if (geom.lines.length > 1) {\n geom.type = `Multi${geom.type}`;\n }\n\n const result: MvtBinaryCoordinates = {\n type: 'Feature',\n geometry: geom,\n properties: this.properties\n };\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 ): MvtBinaryCoordinates {\n if (typeof options === 'function') {\n return this._toBinaryCoordinates(options);\n }\n return this._toBinaryCoordinates(project);\n }\n}\n"],"file":"vector-tile-feature.js"}
@@ -0,0 +1,64 @@
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, firstPassData) {
34
+ if (i < 0 || i >= this._features.length) {
35
+ throw new Error('feature index out of bounds');
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, firstPassData);
43
+ }
44
+
45
+ }
46
+
47
+ function readLayer(tag, layer, pbf) {
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
+ }
51
+ }
52
+
53
+ function readValueMessage(pbf) {
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;
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","firstPassData","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,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C,GAAG,KAAK,CAAZ,EAAeC,KAAK,CAACV,SAAN,CAAgBY,IAAhB,CAAqBrB,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 {MvtFirstPassedData} from '../types';\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 firstPassData\n * @returns {VectorTileFeature}\n */\n feature(i: number, firstPassData: MvtFirstPassedData): 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 firstPassData\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"}
@@ -0,0 +1,23 @@
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
+
10
+ }
11
+
12
+ function readTile(tag, layers, pbf) {
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
+ }
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=vector-tile.js.map