@loaders.gl/gis 3.1.3 → 4.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/index.js +6 -18
  4. package/dist/index.js.map +1 -0
  5. package/dist/lib/binary-to-geojson.js +242 -201
  6. package/dist/lib/binary-to-geojson.js.map +1 -0
  7. package/dist/lib/extract-geometry-info.js +102 -93
  8. package/dist/lib/extract-geometry-info.js.map +1 -0
  9. package/dist/lib/flat-geojson-to-binary-types.js +2 -2
  10. package/dist/{es5/lib → lib}/flat-geojson-to-binary-types.js.map +0 -0
  11. package/dist/lib/flat-geojson-to-binary.js +309 -345
  12. package/dist/lib/flat-geojson-to-binary.js.map +1 -0
  13. package/dist/lib/geojson-to-binary.js +20 -23
  14. package/dist/lib/geojson-to-binary.js.map +1 -0
  15. package/dist/lib/geojson-to-flat-geojson.js +104 -116
  16. package/dist/lib/geojson-to-flat-geojson.js.map +1 -0
  17. package/dist/lib/transform.js +42 -51
  18. package/dist/lib/transform.js.map +1 -0
  19. package/package.json +6 -6
  20. package/dist/es5/bundle.js +0 -7
  21. package/dist/es5/bundle.js.map +0 -1
  22. package/dist/es5/index.js +0 -64
  23. package/dist/es5/index.js.map +0 -1
  24. package/dist/es5/lib/binary-to-geojson.js +0 -330
  25. package/dist/es5/lib/binary-to-geojson.js.map +0 -1
  26. package/dist/es5/lib/extract-geometry-info.js +0 -204
  27. package/dist/es5/lib/extract-geometry-info.js.map +0 -1
  28. package/dist/es5/lib/flat-geojson-to-binary-types.js +0 -2
  29. package/dist/es5/lib/flat-geojson-to-binary.js +0 -397
  30. package/dist/es5/lib/flat-geojson-to-binary.js.map +0 -1
  31. package/dist/es5/lib/geojson-to-binary.js +0 -30
  32. package/dist/es5/lib/geojson-to-binary.js.map +0 -1
  33. package/dist/es5/lib/geojson-to-flat-geojson.js +0 -169
  34. package/dist/es5/lib/geojson-to-flat-geojson.js.map +0 -1
  35. package/dist/es5/lib/transform.js +0 -73
  36. package/dist/es5/lib/transform.js.map +0 -1
  37. package/dist/esm/bundle.js +0 -5
  38. package/dist/esm/bundle.js.map +0 -1
  39. package/dist/esm/index.js +0 -6
  40. package/dist/esm/index.js.map +0 -1
  41. package/dist/esm/lib/binary-to-geojson.js +0 -274
  42. package/dist/esm/lib/binary-to-geojson.js.map +0 -1
  43. package/dist/esm/lib/extract-geometry-info.js +0 -105
  44. package/dist/esm/lib/extract-geometry-info.js.map +0 -1
  45. package/dist/esm/lib/flat-geojson-to-binary-types.js +0 -2
  46. package/dist/esm/lib/flat-geojson-to-binary-types.js.map +0 -1
  47. package/dist/esm/lib/flat-geojson-to-binary.js +0 -339
  48. package/dist/esm/lib/flat-geojson-to-binary.js.map +0 -1
  49. package/dist/esm/lib/geojson-to-binary.js +0 -21
  50. package/dist/esm/lib/geojson-to-binary.js.map +0 -1
  51. package/dist/esm/lib/geojson-to-flat-geojson.js +0 -116
  52. package/dist/esm/lib/geojson-to-flat-geojson.js.map +0 -1
  53. package/dist/esm/lib/transform.js +0 -50
  54. package/dist/esm/lib/transform.js.map +0 -1
@@ -1,96 +1,105 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extractGeometryInfo = void 0;
4
- /**
5
- * Initial scan over GeoJSON features
6
- * Counts number of coordinates of each geometry type and
7
- * keeps track of the max coordinate dimensions
8
- */
9
- // eslint-disable-next-line complexity, max-statements
10
- function extractGeometryInfo(features) {
11
- // Counts the number of _positions_, so [x, y, z] counts as one
12
- let pointPositionsCount = 0;
13
- let pointFeaturesCount = 0;
14
- let linePositionsCount = 0;
15
- let linePathsCount = 0;
16
- let lineFeaturesCount = 0;
17
- let polygonPositionsCount = 0;
18
- let polygonObjectsCount = 0;
19
- let polygonRingsCount = 0;
20
- let polygonFeaturesCount = 0;
21
- const coordLengths = new Set();
22
- for (const feature of features) {
23
- const geometry = feature.geometry;
24
- switch (geometry.type) {
25
- case 'Point':
26
- pointFeaturesCount++;
27
- pointPositionsCount++;
28
- coordLengths.add(geometry.coordinates.length);
29
- break;
30
- case 'MultiPoint':
31
- pointFeaturesCount++;
32
- pointPositionsCount += geometry.coordinates.length;
33
- for (const point of geometry.coordinates) {
34
- coordLengths.add(point.length);
35
- }
36
- break;
37
- case 'LineString':
38
- lineFeaturesCount++;
39
- linePositionsCount += geometry.coordinates.length;
40
- linePathsCount++;
41
- for (const coord of geometry.coordinates) {
42
- coordLengths.add(coord.length);
43
- }
44
- break;
45
- case 'MultiLineString':
46
- lineFeaturesCount++;
47
- for (const line of geometry.coordinates) {
48
- linePositionsCount += line.length;
49
- linePathsCount++;
50
- // eslint-disable-next-line max-depth
51
- for (const coord of line) {
52
- coordLengths.add(coord.length);
53
- }
54
- }
55
- break;
56
- case 'Polygon':
57
- polygonFeaturesCount++;
58
- polygonObjectsCount++;
59
- polygonRingsCount += geometry.coordinates.length;
60
- const flattened = geometry.coordinates.flat();
61
- polygonPositionsCount += flattened.length;
62
- for (const coord of flattened) {
63
- coordLengths.add(coord.length);
64
- }
65
- break;
66
- case 'MultiPolygon':
67
- polygonFeaturesCount++;
68
- for (const polygon of geometry.coordinates) {
69
- polygonObjectsCount++;
70
- polygonRingsCount += polygon.length;
71
- const flattened = polygon.flat();
72
- polygonPositionsCount += flattened.length;
73
- // eslint-disable-next-line max-depth
74
- for (const coord of flattened) {
75
- coordLengths.add(coord.length);
76
- }
77
- }
78
- break;
79
- default:
80
- throw new Error(`Unsupported geometry type: ${geometry.type}`);
1
+ export function extractGeometryInfo(features) {
2
+ let pointPositionsCount = 0;
3
+ let pointFeaturesCount = 0;
4
+ let linePositionsCount = 0;
5
+ let linePathsCount = 0;
6
+ let lineFeaturesCount = 0;
7
+ let polygonPositionsCount = 0;
8
+ let polygonObjectsCount = 0;
9
+ let polygonRingsCount = 0;
10
+ let polygonFeaturesCount = 0;
11
+ const coordLengths = new Set();
12
+
13
+ for (const feature of features) {
14
+ const geometry = feature.geometry;
15
+
16
+ switch (geometry.type) {
17
+ case 'Point':
18
+ pointFeaturesCount++;
19
+ pointPositionsCount++;
20
+ coordLengths.add(geometry.coordinates.length);
21
+ break;
22
+
23
+ case 'MultiPoint':
24
+ pointFeaturesCount++;
25
+ pointPositionsCount += geometry.coordinates.length;
26
+
27
+ for (const point of geometry.coordinates) {
28
+ coordLengths.add(point.length);
81
29
  }
30
+
31
+ break;
32
+
33
+ case 'LineString':
34
+ lineFeaturesCount++;
35
+ linePositionsCount += geometry.coordinates.length;
36
+ linePathsCount++;
37
+
38
+ for (const coord of geometry.coordinates) {
39
+ coordLengths.add(coord.length);
40
+ }
41
+
42
+ break;
43
+
44
+ case 'MultiLineString':
45
+ lineFeaturesCount++;
46
+
47
+ for (const line of geometry.coordinates) {
48
+ linePositionsCount += line.length;
49
+ linePathsCount++;
50
+
51
+ for (const coord of line) {
52
+ coordLengths.add(coord.length);
53
+ }
54
+ }
55
+
56
+ break;
57
+
58
+ case 'Polygon':
59
+ polygonFeaturesCount++;
60
+ polygonObjectsCount++;
61
+ polygonRingsCount += geometry.coordinates.length;
62
+ const flattened = geometry.coordinates.flat();
63
+ polygonPositionsCount += flattened.length;
64
+
65
+ for (const coord of flattened) {
66
+ coordLengths.add(coord.length);
67
+ }
68
+
69
+ break;
70
+
71
+ case 'MultiPolygon':
72
+ polygonFeaturesCount++;
73
+
74
+ for (const polygon of geometry.coordinates) {
75
+ polygonObjectsCount++;
76
+ polygonRingsCount += polygon.length;
77
+ const flattened = polygon.flat();
78
+ polygonPositionsCount += flattened.length;
79
+
80
+ for (const coord of flattened) {
81
+ coordLengths.add(coord.length);
82
+ }
83
+ }
84
+
85
+ break;
86
+
87
+ default:
88
+ throw new Error("Unsupported geometry type: ".concat(geometry.type));
82
89
  }
83
- return {
84
- coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,
85
- pointPositionsCount,
86
- pointFeaturesCount,
87
- linePositionsCount,
88
- linePathsCount,
89
- lineFeaturesCount,
90
- polygonPositionsCount,
91
- polygonObjectsCount,
92
- polygonRingsCount,
93
- polygonFeaturesCount
94
- };
90
+ }
91
+
92
+ return {
93
+ coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,
94
+ pointPositionsCount,
95
+ pointFeaturesCount,
96
+ linePositionsCount,
97
+ linePathsCount,
98
+ lineFeaturesCount,
99
+ polygonPositionsCount,
100
+ polygonObjectsCount,
101
+ polygonRingsCount,
102
+ polygonFeaturesCount
103
+ };
95
104
  }
96
- exports.extractGeometryInfo = extractGeometryInfo;
105
+ //# sourceMappingURL=extract-geometry-info.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/extract-geometry-info.ts"],"names":["extractGeometryInfo","features","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLengths","Set","feature","geometry","type","add","coordinates","length","point","coord","line","flattened","flat","polygon","Error","coordLength","size","Math","max"],"mappings":"AAQA,OAAO,SAASA,mBAAT,CAA6BC,QAA7B,EAAuE;AAE5E,MAAIC,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;;AAEA,OAAK,MAAMC,OAAX,IAAsBZ,QAAtB,EAAgC;AAC9B,UAAMa,QAAQ,GAAGD,OAAO,CAACC,QAAzB;;AACA,YAAQA,QAAQ,CAACC,IAAjB;AACE,WAAK,OAAL;AACEZ,QAAAA,kBAAkB;AAClB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AACF,MAAvB;AACD;;AACD;;AACF,WAAK,cAAL;AACER,QAAAA,oBAAoB;;AACpB,aAAK,MAAMc,OAAX,IAAsBV,QAAQ,CAACG,WAA/B,EAA4C;AAC1CT,UAAAA,mBAAmB;AACnBC,UAAAA,iBAAiB,IAAIe,OAAO,CAACN,MAA7B;AACA,gBAAMI,SAAS,GAAGE,OAAO,CAACD,IAAR,EAAlB;AACAhB,UAAAA,qBAAqB,IAAIe,SAAS,CAACJ,MAAnC;;AAGA,eAAK,MAAME,KAAX,IAAoBE,SAApB,EAA+B;AAC7BX,YAAAA,YAAY,CAACK,GAAb,CAAiBI,KAAK,CAACF,MAAvB;AACD;AACF;;AACD;;AACF;AACE,cAAM,IAAIO,KAAJ,sCAAwCX,QAAQ,CAACC,IAAjD,EAAN;AA5DJ;AA8DD;;AAED,SAAO;AACLW,IAAAA,WAAW,EAAEf,YAAY,CAACgB,IAAb,GAAoB,CAApB,GAAwBC,IAAI,CAACC,GAAL,CAAS,GAAGlB,YAAZ,CAAxB,GAAoD,CAD5D;AAGLT,IAAAA,mBAHK;AAILC,IAAAA,kBAJK;AAKLC,IAAAA,kBALK;AAMLC,IAAAA,cANK;AAOLC,IAAAA,iBAPK;AAQLC,IAAAA,qBARK;AASLC,IAAAA,mBATK;AAULC,IAAAA,iBAVK;AAWLC,IAAAA;AAXK,GAAP;AAaD","sourcesContent":["import {Feature, GeojsonGeometryInfo} from '@loaders.gl/schema';\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\nexport function extractGeometryInfo(features: Feature[]): GeojsonGeometryInfo {\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\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 const flattened = geometry.coordinates.flat();\n polygonPositionsCount += flattened.length;\n\n for (const coord of flattened) {\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 const flattened = polygon.flat();\n polygonPositionsCount += flattened.length;\n\n // eslint-disable-next-line max-depth\n for (const coord of flattened) {\n coordLengths.add(coord.length);\n }\n }\n break;\n default:\n throw new Error(`Unsupported geometry type: ${geometry.type}`);\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}\n"],"file":"extract-geometry-info.js"}
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
2
+ //# sourceMappingURL=flat-geojson-to-binary-types.js.map