@loaders.gl/gis 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 (41) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +2 -2
  4. package/dist/es5/bundle.js +7 -0
  5. package/dist/es5/bundle.js.map +1 -0
  6. package/dist/es5/index.js +48 -0
  7. package/dist/es5/index.js.map +1 -0
  8. package/dist/es5/lib/binary-to-geojson.js +284 -0
  9. package/dist/es5/lib/binary-to-geojson.js.map +1 -0
  10. package/dist/es5/lib/geojson-to-binary.js +417 -0
  11. package/dist/es5/lib/geojson-to-binary.js.map +1 -0
  12. package/dist/es5/lib/transform.js +58 -0
  13. package/dist/es5/lib/transform.js.map +1 -0
  14. package/dist/esm/bundle.js +5 -0
  15. package/dist/esm/bundle.js.map +1 -0
  16. package/dist/esm/index.js +4 -0
  17. package/dist/esm/index.js.map +1 -0
  18. package/dist/esm/lib/binary-to-geojson.js +274 -0
  19. package/dist/esm/lib/binary-to-geojson.js.map +1 -0
  20. package/dist/esm/lib/geojson-to-binary.js +407 -0
  21. package/dist/esm/lib/geojson-to-binary.js.map +1 -0
  22. package/dist/esm/lib/transform.js +50 -0
  23. package/dist/esm/lib/transform.js.map +1 -0
  24. package/dist/index.d.ts +4 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +14 -4
  27. package/dist/lib/binary-to-geojson.d.ts +21 -0
  28. package/dist/lib/binary-to-geojson.d.ts.map +1 -0
  29. package/dist/lib/binary-to-geojson.js +201 -242
  30. package/dist/lib/geojson-to-binary.d.ts +39 -0
  31. package/dist/lib/geojson-to-binary.d.ts.map +1 -0
  32. package/dist/lib/geojson-to-binary.js +324 -369
  33. package/dist/lib/transform.d.ts +19 -0
  34. package/dist/lib/transform.d.ts.map +1 -0
  35. package/dist/lib/transform.js +51 -42
  36. package/package.json +7 -7
  37. package/dist/bundle.js.map +0 -1
  38. package/dist/index.js.map +0 -1
  39. package/dist/lib/binary-to-geojson.js.map +0 -1
  40. package/dist/lib/geojson-to-binary.js.map +0 -1
  41. package/dist/lib/transform.js.map +0 -1
@@ -0,0 +1,417 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.geojsonToBinary = geojsonToBinary;
7
+ exports.TEST_EXPORTS = void 0;
8
+
9
+ function geojsonToBinary(features, options = {}) {
10
+ const firstPassData = firstPass(features);
11
+ return secondPass(features, firstPassData, {
12
+ coordLength: options.coordLength || firstPassData.coordLength,
13
+ numericPropKeys: options.numericPropKeys || firstPassData.numericPropKeys,
14
+ PositionDataType: options.PositionDataType || Float32Array
15
+ });
16
+ }
17
+
18
+ const TEST_EXPORTS = {
19
+ firstPass,
20
+ secondPass
21
+ };
22
+ exports.TEST_EXPORTS = TEST_EXPORTS;
23
+
24
+ function firstPass(features) {
25
+ let pointPositionsCount = 0;
26
+ let pointFeaturesCount = 0;
27
+ let linePositionsCount = 0;
28
+ let linePathsCount = 0;
29
+ let lineFeaturesCount = 0;
30
+ let polygonPositionsCount = 0;
31
+ let polygonObjectsCount = 0;
32
+ let polygonRingsCount = 0;
33
+ let polygonFeaturesCount = 0;
34
+ const coordLengths = new Set();
35
+ const numericPropKeys = {};
36
+
37
+ for (const feature of features) {
38
+ const geometry = feature.geometry;
39
+
40
+ switch (geometry.type) {
41
+ case 'Point':
42
+ pointFeaturesCount++;
43
+ pointPositionsCount++;
44
+ coordLengths.add(geometry.coordinates.length);
45
+ break;
46
+
47
+ case 'MultiPoint':
48
+ pointFeaturesCount++;
49
+ pointPositionsCount += geometry.coordinates.length;
50
+
51
+ for (const point of geometry.coordinates) {
52
+ coordLengths.add(point.length);
53
+ }
54
+
55
+ break;
56
+
57
+ case 'LineString':
58
+ lineFeaturesCount++;
59
+ linePositionsCount += geometry.coordinates.length;
60
+ linePathsCount++;
61
+
62
+ for (const coord of geometry.coordinates) {
63
+ coordLengths.add(coord.length);
64
+ }
65
+
66
+ break;
67
+
68
+ case 'MultiLineString':
69
+ lineFeaturesCount++;
70
+
71
+ for (const line of geometry.coordinates) {
72
+ linePositionsCount += line.length;
73
+ linePathsCount++;
74
+
75
+ for (const coord of line) {
76
+ coordLengths.add(coord.length);
77
+ }
78
+ }
79
+
80
+ break;
81
+
82
+ case 'Polygon':
83
+ polygonFeaturesCount++;
84
+ polygonObjectsCount++;
85
+ polygonRingsCount += geometry.coordinates.length;
86
+ polygonPositionsCount += flatten(geometry.coordinates).length;
87
+
88
+ for (const coord of flatten(geometry.coordinates)) {
89
+ coordLengths.add(coord.length);
90
+ }
91
+
92
+ break;
93
+
94
+ case 'MultiPolygon':
95
+ polygonFeaturesCount++;
96
+
97
+ for (const polygon of geometry.coordinates) {
98
+ polygonObjectsCount++;
99
+ polygonRingsCount += polygon.length;
100
+ polygonPositionsCount += flatten(polygon).length;
101
+
102
+ for (const coord of flatten(polygon)) {
103
+ coordLengths.add(coord.length);
104
+ }
105
+ }
106
+
107
+ break;
108
+
109
+ default:
110
+ throw new Error("Unsupported geometry type: ".concat(geometry.type));
111
+ }
112
+
113
+ if (feature.properties) {
114
+ for (const key in feature.properties) {
115
+ const val = feature.properties[key];
116
+ numericPropKeys[key] = numericPropKeys[key] || numericPropKeys[key] === undefined ? isNumeric(val) : numericPropKeys[key];
117
+ }
118
+ }
119
+ }
120
+
121
+ return {
122
+ coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,
123
+ pointPositionsCount,
124
+ pointFeaturesCount,
125
+ linePositionsCount,
126
+ linePathsCount,
127
+ lineFeaturesCount,
128
+ polygonPositionsCount,
129
+ polygonObjectsCount,
130
+ polygonRingsCount,
131
+ polygonFeaturesCount,
132
+ numericPropKeys: Object.keys(numericPropKeys).filter(k => numericPropKeys[k])
133
+ };
134
+ }
135
+
136
+ function secondPass(features, firstPassData, options) {
137
+ const {
138
+ pointPositionsCount,
139
+ pointFeaturesCount,
140
+ linePositionsCount,
141
+ linePathsCount,
142
+ lineFeaturesCount,
143
+ polygonPositionsCount,
144
+ polygonObjectsCount,
145
+ polygonRingsCount,
146
+ polygonFeaturesCount
147
+ } = firstPassData;
148
+ const {
149
+ coordLength,
150
+ numericPropKeys,
151
+ PositionDataType = Float32Array
152
+ } = options;
153
+ const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;
154
+ const points = {
155
+ positions: new PositionDataType(pointPositionsCount * coordLength),
156
+ globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),
157
+ featureIds: pointFeaturesCount > 65535 ? new Uint32Array(pointPositionsCount) : new Uint16Array(pointPositionsCount),
158
+ numericProps: {},
159
+ properties: Array(),
160
+ fields: Array()
161
+ };
162
+ const lines = {
163
+ positions: new PositionDataType(linePositionsCount * coordLength),
164
+ pathIndices: linePositionsCount > 65535 ? new Uint32Array(linePathsCount + 1) : new Uint16Array(linePathsCount + 1),
165
+ globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),
166
+ featureIds: lineFeaturesCount > 65535 ? new Uint32Array(linePositionsCount) : new Uint16Array(linePositionsCount),
167
+ numericProps: {},
168
+ properties: Array(),
169
+ fields: Array()
170
+ };
171
+ const polygons = {
172
+ positions: new PositionDataType(polygonPositionsCount * coordLength),
173
+ polygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonObjectsCount + 1) : new Uint16Array(polygonObjectsCount + 1),
174
+ primitivePolygonIndices: polygonPositionsCount > 65535 ? new Uint32Array(polygonRingsCount + 1) : new Uint16Array(polygonRingsCount + 1),
175
+ globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),
176
+ featureIds: polygonFeaturesCount > 65535 ? new Uint32Array(polygonPositionsCount) : new Uint16Array(polygonPositionsCount),
177
+ numericProps: {},
178
+ properties: Array(),
179
+ fields: Array()
180
+ };
181
+
182
+ for (const object of [points, lines, polygons]) {
183
+ for (const propName of numericPropKeys || []) {
184
+ object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);
185
+ }
186
+ }
187
+
188
+ lines.pathIndices[linePathsCount] = linePositionsCount;
189
+ polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;
190
+ polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;
191
+ const indexMap = {
192
+ pointPosition: 0,
193
+ pointFeature: 0,
194
+ linePosition: 0,
195
+ linePath: 0,
196
+ lineFeature: 0,
197
+ polygonPosition: 0,
198
+ polygonObject: 0,
199
+ polygonRing: 0,
200
+ polygonFeature: 0,
201
+ feature: 0
202
+ };
203
+
204
+ for (const feature of features) {
205
+ const geometry = feature.geometry;
206
+ const properties = feature.properties || {};
207
+
208
+ switch (geometry.type) {
209
+ case 'Point':
210
+ handlePoint(geometry.coordinates, points, indexMap, coordLength, properties);
211
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
212
+ indexMap.pointFeature++;
213
+ break;
214
+
215
+ case 'MultiPoint':
216
+ handleMultiPoint(geometry.coordinates, points, indexMap, coordLength, properties);
217
+ points.properties.push(keepStringProperties(properties, numericPropKeys));
218
+ indexMap.pointFeature++;
219
+ break;
220
+
221
+ case 'LineString':
222
+ handleLineString(geometry.coordinates, lines, indexMap, coordLength, properties);
223
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
224
+ indexMap.lineFeature++;
225
+ break;
226
+
227
+ case 'MultiLineString':
228
+ handleMultiLineString(geometry.coordinates, lines, indexMap, coordLength, properties);
229
+ lines.properties.push(keepStringProperties(properties, numericPropKeys));
230
+ indexMap.lineFeature++;
231
+ break;
232
+
233
+ case 'Polygon':
234
+ handlePolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);
235
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
236
+ indexMap.polygonFeature++;
237
+ break;
238
+
239
+ case 'MultiPolygon':
240
+ handleMultiPolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);
241
+ polygons.properties.push(keepStringProperties(properties, numericPropKeys));
242
+ indexMap.polygonFeature++;
243
+ break;
244
+
245
+ default:
246
+ throw new Error('Invalid geometry type');
247
+ }
248
+
249
+ indexMap.feature++;
250
+ }
251
+
252
+ return makeAccessorObjects(points, lines, polygons, coordLength);
253
+ }
254
+
255
+ function handlePoint(coords, points, indexMap, coordLength, properties) {
256
+ points.positions.set(coords, indexMap.pointPosition * coordLength);
257
+ points.globalFeatureIds[indexMap.pointPosition] = indexMap.feature;
258
+ points.featureIds[indexMap.pointPosition] = indexMap.pointFeature;
259
+ fillNumericProperties(points, properties, indexMap.pointPosition, 1);
260
+ indexMap.pointPosition++;
261
+ }
262
+
263
+ function handleMultiPoint(coords, points, indexMap, coordLength, properties) {
264
+ for (const point of coords) {
265
+ handlePoint(point, points, indexMap, coordLength, properties);
266
+ }
267
+ }
268
+
269
+ function handleLineString(coords, lines, indexMap, coordLength, properties) {
270
+ lines.pathIndices[indexMap.linePath] = indexMap.linePosition;
271
+ indexMap.linePath++;
272
+ fillCoords(lines.positions, coords, indexMap.linePosition, coordLength);
273
+ const nPositions = coords.length;
274
+ fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
275
+ lines.globalFeatureIds.set(new Uint32Array(nPositions).fill(indexMap.feature), indexMap.linePosition);
276
+ lines.featureIds.set(new Uint32Array(nPositions).fill(indexMap.lineFeature), indexMap.linePosition);
277
+ indexMap.linePosition += nPositions;
278
+ }
279
+
280
+ function handleMultiLineString(coords, lines, indexMap, coordLength, properties) {
281
+ for (const line of coords) {
282
+ handleLineString(line, lines, indexMap, coordLength, properties);
283
+ }
284
+ }
285
+
286
+ function handlePolygon(coords, polygons, indexMap, coordLength, properties) {
287
+ polygons.polygonIndices[indexMap.polygonObject] = indexMap.polygonPosition;
288
+ indexMap.polygonObject++;
289
+
290
+ for (const ring of coords) {
291
+ polygons.primitivePolygonIndices[indexMap.polygonRing] = indexMap.polygonPosition;
292
+ indexMap.polygonRing++;
293
+ fillCoords(polygons.positions, ring, indexMap.polygonPosition, coordLength);
294
+ const nPositions = ring.length;
295
+ fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
296
+ polygons.globalFeatureIds.set(new Uint32Array(nPositions).fill(indexMap.feature), indexMap.polygonPosition);
297
+ polygons.featureIds.set(new Uint32Array(nPositions).fill(indexMap.polygonFeature), indexMap.polygonPosition);
298
+ indexMap.polygonPosition += nPositions;
299
+ }
300
+ }
301
+
302
+ function handleMultiPolygon(coords, polygons, indexMap, coordLength, properties) {
303
+ for (const polygon of coords) {
304
+ handlePolygon(polygon, polygons, indexMap, coordLength, properties);
305
+ }
306
+ }
307
+
308
+ function makeAccessorObjects(points, lines, polygons, coordLength) {
309
+ const returnObj = {
310
+ points: { ...points,
311
+ positions: {
312
+ value: points.positions,
313
+ size: coordLength
314
+ },
315
+ globalFeatureIds: {
316
+ value: points.globalFeatureIds,
317
+ size: 1
318
+ },
319
+ featureIds: {
320
+ value: points.featureIds,
321
+ size: 1
322
+ },
323
+ type: 'Point'
324
+ },
325
+ lines: { ...lines,
326
+ pathIndices: {
327
+ value: lines.pathIndices,
328
+ size: 1
329
+ },
330
+ positions: {
331
+ value: lines.positions,
332
+ size: coordLength
333
+ },
334
+ globalFeatureIds: {
335
+ value: lines.globalFeatureIds,
336
+ size: 1
337
+ },
338
+ featureIds: {
339
+ value: lines.featureIds,
340
+ size: 1
341
+ },
342
+ type: 'LineString'
343
+ },
344
+ polygons: { ...polygons,
345
+ polygonIndices: {
346
+ value: polygons.polygonIndices,
347
+ size: 1
348
+ },
349
+ primitivePolygonIndices: {
350
+ value: polygons.primitivePolygonIndices,
351
+ size: 1
352
+ },
353
+ positions: {
354
+ value: polygons.positions,
355
+ size: coordLength
356
+ },
357
+ globalFeatureIds: {
358
+ value: polygons.globalFeatureIds,
359
+ size: 1
360
+ },
361
+ featureIds: {
362
+ value: polygons.featureIds,
363
+ size: 1
364
+ },
365
+ type: 'Polygon'
366
+ }
367
+ };
368
+
369
+ for (const geomType in returnObj) {
370
+ for (const numericProp in returnObj[geomType].numericProps) {
371
+ returnObj[geomType].numericProps[numericProp] = {
372
+ value: returnObj[geomType].numericProps[numericProp],
373
+ size: 1
374
+ };
375
+ }
376
+ }
377
+
378
+ return returnObj;
379
+ }
380
+
381
+ function fillNumericProperties(object, properties, index, length) {
382
+ for (const numericPropName in object.numericProps) {
383
+ if (numericPropName in properties) {
384
+ object.numericProps[numericPropName].set(new Array(length).fill(properties[numericPropName]), index);
385
+ }
386
+ }
387
+ }
388
+
389
+ function keepStringProperties(properties, numericKeys) {
390
+ const props = {};
391
+
392
+ for (const key in properties) {
393
+ if (!numericKeys.includes(key)) {
394
+ props[key] = properties[key];
395
+ }
396
+ }
397
+
398
+ return props;
399
+ }
400
+
401
+ function fillCoords(array, coords, startVertex, coordLength) {
402
+ let index = startVertex * coordLength;
403
+
404
+ for (const coord of coords) {
405
+ array.set(coord, index);
406
+ index += coordLength;
407
+ }
408
+ }
409
+
410
+ function flatten(arrays) {
411
+ return [].concat(...arrays);
412
+ }
413
+
414
+ function isNumeric(x) {
415
+ return Number.isFinite(x);
416
+ }
417
+ //# sourceMappingURL=geojson-to-binary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/geojson-to-binary.ts"],"names":["geojsonToBinary","features","options","firstPassData","firstPass","secondPass","coordLength","numericPropKeys","PositionDataType","Float32Array","TEST_EXPORTS","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLengths","Set","feature","geometry","type","add","coordinates","length","point","coord","line","flatten","polygon","Error","properties","key","val","undefined","isNumeric","size","Math","max","Object","keys","filter","k","GlobalFeatureIdsDataType","Uint32Array","Uint16Array","points","positions","globalFeatureIds","featureIds","numericProps","Array","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","object","propName","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","handlePoint","push","keepStringProperties","handleMultiPoint","handleLineString","handleMultiLineString","handlePolygon","handleMultiPolygon","makeAccessorObjects","coords","set","fillNumericProperties","fillCoords","nPositions","fill","ring","returnObj","value","geomType","numericProp","index","numericPropName","numericKeys","props","includes","array","startVertex","arrays","concat","x","Number","isFinite"],"mappings":";;;;;;;;AAUO,SAASA,eAAT,CACLC,QADK,EAELC,OAA+B,GAAG,EAF7B,EAGW;AAChB,QAAMC,aAAa,GAAGC,SAAS,CAACH,QAAD,CAA/B;AACA,SAAOI,UAAU,CAACJ,QAAD,EAAWE,aAAX,EAA0B;AACzCG,IAAAA,WAAW,EAAEJ,OAAO,CAACI,WAAR,IAAuBH,aAAa,CAACG,WADT;AAEzCC,IAAAA,eAAe,EAAEL,OAAO,CAACK,eAAR,IAA2BJ,aAAa,CAACI,eAFjB;AAGzCC,IAAAA,gBAAgB,EAAEN,OAAO,CAACM,gBAAR,IAA4BC;AAHL,GAA1B,CAAjB;AAKD;;AAEM,MAAMC,YAAY,GAAG;AAC1BN,EAAAA,SAD0B;AAE1BC,EAAAA;AAF0B,CAArB;;;AA0BP,SAASD,SAAT,CAAmBH,QAAnB,EAAuD;AAErD,MAAIU,mBAAmB,GAAG,CAA1B;AACA,MAAIC,kBAAkB,GAAG,CAAzB;AACA,MAAIC,kBAAkB,GAAG,CAAzB;AACA,MAAIC,cAAc,GAAG,CAArB;AACA,MAAIC,iBAAiB,GAAG,CAAxB;AACA,MAAIC,qBAAqB,GAAG,CAA5B;AACA,MAAIC,mBAAmB,GAAG,CAA1B;AACA,MAAIC,iBAAiB,GAAG,CAAxB;AACA,MAAIC,oBAAoB,GAAG,CAA3B;AACA,QAAMC,YAAY,GAAG,IAAIC,GAAJ,EAArB;AACA,QAAMd,eAAe,GAAG,EAAxB;;AAEA,OAAK,MAAMe,OAAX,IAAsBrB,QAAtB,EAAgC;AAC9B,UAAMsB,QAAQ,GAAGD,OAAO,CAACC,QAAzB;;AACA,YAAQA,QAAQ,CAACC,IAAjB;AACE,WAAK,OAAL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C,eAApB,EAAqCX,GAArC,CACE,IAAI7B,KAAJ,CAAU3B,MAAV,EAAkB4D,IAAlB,CAAuBrD,UAAU,CAAC4D,eAAD,CAAjC,CADF,EAEED,KAFF;AAID;AACF;AACF;;AAGD,SAASlB,oBAAT,CAA8BzC,UAA9B,EAA0C6D,WAA1C,EAAoF;AAClF,QAAMC,KAAK,GAAG,EAAd;;AACA,OAAK,MAAM7D,GAAX,IAAkBD,UAAlB,EAA8B;AAC5B,QAAI,CAAC6D,WAAW,CAACE,QAAZ,CAAqB9D,GAArB,CAAL,EAAgC;AAC9B6D,MAAAA,KAAK,CAAC7D,GAAD,CAAL,GAAaD,UAAU,CAACC,GAAD,CAAvB;AACD;AACF;;AACD,SAAO6D,KAAP;AACD;;AAGD,SAASX,UAAT,CAAoBa,KAApB,EAA2BhB,MAA3B,EAAmCiB,WAAnC,EAAgD7F,WAAhD,EAAmE;AACjE,MAAIuF,KAAK,GAAGM,WAAW,GAAG7F,WAA1B;;AACA,OAAK,MAAMuB,KAAX,IAAoBqD,MAApB,EAA4B;AAC1BgB,IAAAA,KAAK,CAACf,GAAN,CAAUtD,KAAV,EAAiBgE,KAAjB;AACAA,IAAAA,KAAK,IAAIvF,WAAT;AACD;AACF;;AAGD,SAASyB,OAAT,CAAiBqE,MAAjB,EAAqC;AACnC,SAAO,GAAGC,MAAH,CAAU,GAAGD,MAAb,CAAP;AACD;;AAED,SAAS9D,SAAT,CAAmBgE,CAAnB,EAAoC;AAClC,SAAOC,MAAM,CAACC,QAAP,CAAgBF,CAAhB,CAAP;AACD","sourcesContent":["import {Feature, GeoJsonProperties} from '@loaders.gl/schema';\nimport type {BinaryFeatures} from '@loaders.gl/schema';\n\nexport type GeojsonToBinaryOptions = {\n coordLength?: number;\n numericPropKeys?: string[];\n PositionDataType?: Function;\n};\n\n/** Convert GeoJSON features to flat binary arrays */\nexport function geojsonToBinary(\n features: Feature[],\n options: GeojsonToBinaryOptions = {}\n): BinaryFeatures {\n const firstPassData = firstPass(features);\n return secondPass(features, firstPassData, {\n coordLength: options.coordLength || firstPassData.coordLength,\n numericPropKeys: options.numericPropKeys || firstPassData.numericPropKeys,\n PositionDataType: options.PositionDataType || Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n firstPass,\n secondPass\n};\n\ntype FirstPassData = {\n coordLength: number;\n numericPropKeys: string[];\n\n pointPositionsCount: number;\n pointFeaturesCount: number;\n linePositionsCount: number;\n linePathsCount: number;\n lineFeaturesCount: number;\n polygonPositionsCount: number;\n polygonObjectsCount: number;\n polygonRingsCount: number;\n polygonFeaturesCount: number;\n};\n\n/**\n * Initial scan over GeoJSON features\n * Counts number of coordinates of each geometry type and\n * keeps track of the max coordinate dimensions\n */\n// eslint-disable-next-line complexity, max-statements\nfunction firstPass(features: Feature[]): FirstPassData {\n // Counts the number of _positions_, so [x, y, z] counts as one\n let pointPositionsCount = 0;\n let pointFeaturesCount = 0;\n let linePositionsCount = 0;\n let linePathsCount = 0;\n let lineFeaturesCount = 0;\n let polygonPositionsCount = 0;\n let polygonObjectsCount = 0;\n let polygonRingsCount = 0;\n let polygonFeaturesCount = 0;\n const coordLengths = new Set<number>();\n const numericPropKeys = {};\n\n for (const feature of features) {\n const geometry = feature.geometry;\n switch (geometry.type) {\n case 'Point':\n pointFeaturesCount++;\n pointPositionsCount++;\n coordLengths.add(geometry.coordinates.length);\n break;\n case 'MultiPoint':\n pointFeaturesCount++;\n pointPositionsCount += geometry.coordinates.length;\n for (const point of geometry.coordinates) {\n coordLengths.add(point.length);\n }\n break;\n case 'LineString':\n lineFeaturesCount++;\n linePositionsCount += geometry.coordinates.length;\n linePathsCount++;\n\n for (const coord of geometry.coordinates) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiLineString':\n lineFeaturesCount++;\n for (const line of geometry.coordinates) {\n linePositionsCount += line.length;\n linePathsCount++;\n\n // eslint-disable-next-line max-depth\n for (const coord of line) {\n coordLengths.add(coord.length);\n }\n }\n break;\n case 'Polygon':\n polygonFeaturesCount++;\n polygonObjectsCount++;\n polygonRingsCount += geometry.coordinates.length;\n polygonPositionsCount += flatten(geometry.coordinates).length;\n\n for (const coord of flatten(geometry.coordinates)) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiPolygon':\n polygonFeaturesCount++;\n for (const polygon of geometry.coordinates) {\n polygonObjectsCount++;\n polygonRingsCount += polygon.length;\n polygonPositionsCount += flatten(polygon).length;\n\n // eslint-disable-next-line max-depth\n for (const coord of flatten(polygon)) {\n coordLengths.add(coord.length);\n }\n }\n break;\n default:\n throw new Error(`Unsupported geometry type: ${geometry.type}`);\n }\n\n if (feature.properties) {\n for (const key in feature.properties) {\n const val = feature.properties[key];\n\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 numericPropKeys[key] =\n numericPropKeys[key] || numericPropKeys[key] === undefined\n ? isNumeric(val)\n : numericPropKeys[key];\n }\n }\n }\n\n return {\n coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,\n\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount,\n\n // Array of keys whose values are always numeric\n numericPropKeys: Object.keys(numericPropKeys).filter((k) => numericPropKeys[k])\n };\n}\n\n/**\n * Second scan over GeoJSON features\n * Fills coordinates into pre-allocated typed arrays\n */\n// eslint-disable-next-line complexity\nfunction secondPass(\n features,\n firstPassData: FirstPassData,\n options: Required<GeojsonToBinaryOptions>\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 {coordLength, numericPropKeys, PositionDataType = Float32Array} = options;\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points = {\n // @ts-ignore Typescript doesn't like dynamic constructors\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: Array<any>(),\n fields: Array<any>()\n };\n const lines = {\n // @ts-ignore Typescript doesn't like dynamic constructors\n positions: new PositionDataType(linePositionsCount * coordLength),\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: Array<any>(),\n fields: Array<any>()\n };\n const polygons = {\n // @ts-ignore Typescript doesn't like dynamic constructors\n positions: new PositionDataType(polygonPositionsCount * coordLength),\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 globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: Array<any>(),\n fields: Array<any>()\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: GeoJsonProperties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n handlePoint(geometry.coordinates, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.pointFeature++;\n break;\n case 'MultiPoint':\n handleMultiPoint(geometry.coordinates, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.pointFeature++;\n break;\n case 'LineString':\n handleLineString(geometry.coordinates, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.lineFeature++;\n break;\n case 'MultiLineString':\n handleMultiLineString(geometry.coordinates, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n handlePolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.polygonFeature++;\n break;\n case 'MultiPolygon':\n handleMultiPolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\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/** Fills Point coordinates into points object of arrays */\nfunction handlePoint(coords, points, indexMap, coordLength, properties) {\n points.positions.set(coords, indexMap.pointPosition * coordLength);\n points.globalFeatureIds[indexMap.pointPosition] = indexMap.feature;\n points.featureIds[indexMap.pointPosition] = indexMap.pointFeature;\n\n fillNumericProperties(points, properties, indexMap.pointPosition, 1);\n indexMap.pointPosition++;\n}\n\n/** Fills MultiPoint coordinates into points object of arrays */\nfunction handleMultiPoint(coords, points, indexMap, coordLength, properties) {\n for (const point of coords) {\n handlePoint(point, points, indexMap, coordLength, properties);\n }\n}\n\n/** Fills LineString coordinates into lines object of arrays */\nfunction handleLineString(coords, lines, indexMap, coordLength, properties) {\n lines.pathIndices[indexMap.linePath] = indexMap.linePosition;\n indexMap.linePath++;\n\n fillCoords(lines.positions, coords, indexMap.linePosition, coordLength);\n\n const nPositions = coords.length;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.set(\n new Uint32Array(nPositions).fill(indexMap.feature),\n indexMap.linePosition\n );\n lines.featureIds.set(\n new Uint32Array(nPositions).fill(indexMap.lineFeature),\n indexMap.linePosition\n );\n indexMap.linePosition += nPositions;\n}\n\n/** Fills MultiLineString coordinates into lines object of arrays */\nfunction handleMultiLineString(coords, lines, indexMap, coordLength, properties) {\n for (const line of coords) {\n handleLineString(line, lines, indexMap, coordLength, properties);\n }\n}\n\n/** Fills Polygon coordinates into polygons object of arrays */\nfunction handlePolygon(coords, polygons, indexMap, coordLength, properties) {\n polygons.polygonIndices[indexMap.polygonObject] = indexMap.polygonPosition;\n indexMap.polygonObject++;\n\n for (const ring of coords) {\n polygons.primitivePolygonIndices[indexMap.polygonRing] = indexMap.polygonPosition;\n indexMap.polygonRing++;\n\n fillCoords(polygons.positions, ring, indexMap.polygonPosition, coordLength);\n\n const nPositions = ring.length;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n\n polygons.globalFeatureIds.set(\n new Uint32Array(nPositions).fill(indexMap.feature),\n indexMap.polygonPosition\n );\n polygons.featureIds.set(\n new Uint32Array(nPositions).fill(indexMap.polygonFeature),\n indexMap.polygonPosition\n );\n indexMap.polygonPosition += nPositions;\n }\n}\n\n/** Fills MultiPolygon coordinates into polygons object of arrays */\nfunction handleMultiPolygon(coords, polygons, indexMap, coordLength, properties) {\n for (const polygon of coords) {\n handlePolygon(polygon, polygons, indexMap, coordLength, properties);\n }\n}\n\n/** Wrap each array in an accessor object with value and size keys */\nfunction makeAccessorObjects(points, lines, polygons, coordLength): BinaryFeatures {\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 type: 'Point'\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 type: 'LineString'\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 globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1},\n type: 'Polygon'\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\n return returnObj as unknown as BinaryFeatures;\n}\n\n/** Add numeric properties to object */\nfunction fillNumericProperties(object, properties, index, length) {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n object.numericProps[numericPropName].set(\n new Array(length).fill(properties[numericPropName]),\n index\n );\n }\n }\n}\n\n/** Keep string properties in object */\nfunction keepStringProperties(properties, numericKeys: string[]): GeoJsonProperties {\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\n/** @param coords is expected to be a list of arrays, each with length 2-3 */\nfunction fillCoords(array, coords, startVertex, coordLength): void {\n let index = startVertex * coordLength;\n for (const coord of coords) {\n array.set(coord, index);\n index += coordLength;\n }\n}\n\n// TODO - how does this work? Different `coordinates` have different nesting\nfunction flatten(arrays): number[][] {\n return [].concat(...arrays);\n}\n\nfunction isNumeric(x: any): boolean {\n return Number.isFinite(x);\n}\n"],"file":"geojson-to-binary.js"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.transformBinaryCoords = transformBinaryCoords;
7
+ exports.transformGeoJsonCoords = transformGeoJsonCoords;
8
+
9
+ function transformBinaryCoords(binaryFeatures, transformCoordinate) {
10
+ if (binaryFeatures.points) {
11
+ transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);
12
+ }
13
+
14
+ if (binaryFeatures.lines) {
15
+ transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);
16
+ }
17
+
18
+ if (binaryFeatures.polygons) {
19
+ transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);
20
+ }
21
+
22
+ return binaryFeatures;
23
+ }
24
+
25
+ function transformBinaryGeometryPositions(binaryGeometry, fn) {
26
+ const {
27
+ positions
28
+ } = binaryGeometry;
29
+
30
+ for (let i = 0; i < positions.value.length; i += positions.size) {
31
+ const coord = Array.from(positions.value.subarray(i, i + positions.size));
32
+ const transformedCoord = fn(coord);
33
+ positions.value.set(transformedCoord, i);
34
+ }
35
+ }
36
+
37
+ function transformGeoJsonCoords(features, fn) {
38
+ for (const feature of features) {
39
+ feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);
40
+ }
41
+
42
+ return features;
43
+ }
44
+
45
+ function coordMap(array, fn) {
46
+ if (isCoord(array)) {
47
+ return fn(array);
48
+ }
49
+
50
+ return array.map(item => {
51
+ return coordMap(item, fn);
52
+ });
53
+ }
54
+
55
+ function isCoord(array) {
56
+ return Number.isFinite(array[0]) && Number.isFinite(array[1]);
57
+ }
58
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/transform.ts"],"names":["transformBinaryCoords","binaryFeatures","transformCoordinate","points","transformBinaryGeometryPositions","lines","polygons","binaryGeometry","fn","positions","i","value","length","size","coord","Array","from","subarray","transformedCoord","set","transformGeoJsonCoords","features","feature","geometry","coordinates","coordMap","array","isCoord","map","item","Number","isFinite"],"mappings":";;;;;;;;AAUO,SAASA,qBAAT,CACLC,cADK,EAELC,mBAFK,EAGW;AAChB,MAAID,cAAc,CAACE,MAAnB,EAA2B;AACzBC,IAAAA,gCAAgC,CAACH,cAAc,CAACE,MAAhB,EAAwBD,mBAAxB,CAAhC;AACD;;AACD,MAAID,cAAc,CAACI,KAAnB,EAA0B;AACxBD,IAAAA,gCAAgC,CAACH,cAAc,CAACI,KAAhB,EAAuBH,mBAAvB,CAAhC;AACD;;AACD,MAAID,cAAc,CAACK,QAAnB,EAA6B;AAC3BF,IAAAA,gCAAgC,CAACH,cAAc,CAACK,QAAhB,EAA0BJ,mBAA1B,CAAhC;AACD;;AACD,SAAOD,cAAP;AACD;;AAGD,SAASG,gCAAT,CAA0CG,cAA1C,EAA0EC,EAA1E,EAAmG;AACjG,QAAM;AAACC,IAAAA;AAAD,MAAcF,cAApB;;AACA,OAAK,IAAIG,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,SAAS,CAACE,KAAV,CAAgBC,MAApC,EAA4CF,CAAC,IAAID,SAAS,CAACI,IAA3D,EAAiE;AAE/D,UAAMC,KAAoB,GAAGC,KAAK,CAACC,IAAN,CAAWP,SAAS,CAACE,KAAV,CAAgBM,QAAhB,CAAyBP,CAAzB,EAA4BA,CAAC,GAAGD,SAAS,CAACI,IAA1C,CAAX,CAA7B;AACA,UAAMK,gBAAgB,GAAGV,EAAE,CAACM,KAAD,CAA3B;AAEAL,IAAAA,SAAS,CAACE,KAAV,CAAgBQ,GAAhB,CAAoBD,gBAApB,EAAsCR,CAAtC;AACD;AACF;;AASM,SAASU,sBAAT,CACLC,QADK,EAELb,EAFK,EAGK;AACV,OAAK,MAAMc,OAAX,IAAsBD,QAAtB,EAAgC;AAE9BC,IAAAA,OAAO,CAACC,QAAR,CAAiBC,WAAjB,GAA+BC,QAAQ,CAACH,OAAO,CAACC,QAAR,CAAiBC,WAAlB,EAA+BhB,EAA/B,CAAvC;AACD;;AACD,SAAOa,QAAP;AACD;;AAED,SAASI,QAAT,CAAkBC,KAAlB,EAAyBlB,EAAzB,EAA6B;AAC3B,MAAImB,OAAO,CAACD,KAAD,CAAX,EAAoB;AAClB,WAAOlB,EAAE,CAACkB,KAAD,CAAT;AACD;;AAED,SAAOA,KAAK,CAACE,GAAN,CAAWC,IAAD,IAAU;AACzB,WAAOJ,QAAQ,CAACI,IAAD,EAAOrB,EAAP,CAAf;AACD,GAFM,CAAP;AAGD;;AAED,SAASmB,OAAT,CAAiBD,KAAjB,EAAwB;AACtB,SAAOI,MAAM,CAACC,QAAP,CAAgBL,KAAK,CAAC,CAAD,CAArB,KAA6BI,MAAM,CAACC,QAAP,CAAgBL,KAAK,CAAC,CAAD,CAArB,CAApC;AACD","sourcesContent":["import type {BinaryFeatures, BinaryGeometry} from '@loaders.gl/schema';\n\ntype TransformCoordinate = (coord: number[]) => number[];\n\n/**\n * Apply transformation to every coordinate of binary features\n * @param binaryFeatures binary features\n * @param transformCoordinate Function to call on each coordinate\n * @return Transformed binary features\n */\nexport function transformBinaryCoords(\n binaryFeatures: BinaryFeatures,\n transformCoordinate: TransformCoordinate\n): BinaryFeatures {\n if (binaryFeatures.points) {\n transformBinaryGeometryPositions(binaryFeatures.points, transformCoordinate);\n }\n if (binaryFeatures.lines) {\n transformBinaryGeometryPositions(binaryFeatures.lines, transformCoordinate);\n }\n if (binaryFeatures.polygons) {\n transformBinaryGeometryPositions(binaryFeatures.polygons, transformCoordinate);\n }\n return binaryFeatures;\n}\n\n/** Transform one binary geometry */\nfunction transformBinaryGeometryPositions(binaryGeometry: BinaryGeometry, fn: TransformCoordinate) {\n const {positions} = binaryGeometry;\n for (let i = 0; i < positions.value.length; i += positions.size) {\n // @ts-ignore inclusion of bigint causes problems\n const coord: Array<number> = Array.from(positions.value.subarray(i, i + positions.size));\n const transformedCoord = fn(coord);\n // @ts-ignore typescript typing for .set seems to require bigint?\n positions.value.set(transformedCoord, i);\n }\n}\n\n/**\n * Apply transformation to every coordinate of GeoJSON features\n *\n * @param features Array of GeoJSON features\n * @param fn Function to call on each coordinate\n * @return Transformed GeoJSON features\n */\nexport function transformGeoJsonCoords(\n features: object[],\n fn: (coord: number[]) => number[]\n): object[] {\n for (const feature of features) {\n // @ts-ignore\n feature.geometry.coordinates = coordMap(feature.geometry.coordinates, fn);\n }\n return features;\n}\n\nfunction coordMap(array, fn) {\n if (isCoord(array)) {\n return fn(array);\n }\n\n return array.map((item) => {\n return coordMap(item, fn);\n });\n}\n\nfunction isCoord(array) {\n return Number.isFinite(array[0]) && Number.isFinite(array[1]);\n}\n"],"file":"transform.js"}
@@ -0,0 +1,5 @@
1
+ const moduleExports = require('./index');
2
+
3
+ globalThis.loaders = globalThis.loaders || {};
4
+ module.exports = Object.assign(globalThis.loaders, moduleExports);
5
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -0,0 +1,4 @@
1
+ export { geojsonToBinary } from './lib/geojson-to-binary';
2
+ export { binaryToGeojson, binaryToGeoJson, binaryToGeometry } from './lib/binary-to-geojson';
3
+ export { transformBinaryCoords, transformGeoJsonCoords } from './lib/transform';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":["geojsonToBinary","binaryToGeojson","binaryToGeoJson","binaryToGeometry","transformBinaryCoords","transformGeoJsonCoords"],"mappings":"AAGA,SAAQA,eAAR,QAA8B,yBAA9B;AACA,SAAQC,eAAR,EAAyBC,eAAzB,EAA0CC,gBAA1C,QAAiE,yBAAjE;AACA,SAAQC,qBAAR,EAA+BC,sBAA/B,QAA4D,iBAA5D","sourcesContent":["// Types from `@loaders.gl/schema`\n\n// Functions\nexport {geojsonToBinary} from './lib/geojson-to-binary';\nexport {binaryToGeojson, binaryToGeoJson, binaryToGeometry} from './lib/binary-to-geojson';\nexport {transformBinaryCoords, transformGeoJsonCoords} from './lib/transform';\n"],"file":"index.js"}