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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/es5/bundle.js +6 -0
  3. package/dist/es5/bundle.js.map +1 -0
  4. package/dist/es5/index.js +59 -0
  5. package/dist/es5/index.js.map +1 -0
  6. package/dist/es5/lib/binary-to-geojson.js +255 -0
  7. package/dist/es5/lib/binary-to-geojson.js.map +1 -0
  8. package/dist/es5/lib/extract-geometry-info.js +167 -0
  9. package/dist/es5/lib/extract-geometry-info.js.map +1 -0
  10. package/dist/es5/lib/flat-geojson-to-binary-types.js +2 -0
  11. package/dist/es5/lib/flat-geojson-to-binary-types.js.map +1 -0
  12. package/dist/es5/lib/flat-geojson-to-binary.js +344 -0
  13. package/dist/es5/lib/flat-geojson-to-binary.js.map +1 -0
  14. package/dist/es5/lib/geojson-to-binary.js +26 -0
  15. package/dist/es5/lib/geojson-to-binary.js.map +1 -0
  16. package/dist/es5/lib/geojson-to-flat-geojson.js +136 -0
  17. package/dist/es5/lib/geojson-to-flat-geojson.js.map +1 -0
  18. package/dist/es5/lib/transform.js +57 -0
  19. package/dist/es5/lib/transform.js.map +1 -0
  20. package/dist/esm/bundle.js +4 -0
  21. package/dist/esm/bundle.js.map +1 -0
  22. package/dist/esm/index.js +6 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/esm/lib/binary-to-geojson.js +223 -0
  25. package/dist/esm/lib/binary-to-geojson.js.map +1 -0
  26. package/dist/esm/lib/extract-geometry-info.js +84 -0
  27. package/dist/esm/lib/extract-geometry-info.js.map +1 -0
  28. package/dist/esm/lib/flat-geojson-to-binary-types.js +2 -0
  29. package/dist/esm/lib/flat-geojson-to-binary-types.js.map +1 -0
  30. package/dist/esm/lib/flat-geojson-to-binary.js +305 -0
  31. package/dist/esm/lib/flat-geojson-to-binary.js.map +1 -0
  32. package/dist/esm/lib/geojson-to-binary.js +22 -0
  33. package/dist/esm/lib/geojson-to-binary.js.map +1 -0
  34. package/dist/esm/lib/geojson-to-flat-geojson.js +97 -0
  35. package/dist/esm/lib/geojson-to-flat-geojson.js.map +1 -0
  36. package/dist/esm/lib/transform.js +40 -0
  37. package/dist/esm/lib/transform.js.map +1 -0
  38. package/dist/index.js +18 -6
  39. package/dist/lib/binary-to-geojson.d.ts +1 -1
  40. package/dist/lib/binary-to-geojson.d.ts.map +1 -1
  41. package/dist/lib/binary-to-geojson.js +201 -242
  42. package/dist/lib/extract-geometry-info.js +93 -102
  43. package/dist/lib/flat-geojson-to-binary-types.d.ts +4 -4
  44. package/dist/lib/flat-geojson-to-binary-types.d.ts.map +1 -1
  45. package/dist/lib/flat-geojson-to-binary-types.js +2 -2
  46. package/dist/lib/flat-geojson-to-binary.d.ts +1 -1
  47. package/dist/lib/flat-geojson-to-binary.d.ts.map +1 -1
  48. package/dist/lib/flat-geojson-to-binary.js +346 -309
  49. package/dist/lib/geojson-to-binary.d.ts +1 -1
  50. package/dist/lib/geojson-to-binary.d.ts.map +1 -1
  51. package/dist/lib/geojson-to-binary.js +23 -20
  52. package/dist/lib/geojson-to-flat-geojson.d.ts +1 -1
  53. package/dist/lib/geojson-to-flat-geojson.d.ts.map +1 -1
  54. package/dist/lib/geojson-to-flat-geojson.js +116 -104
  55. package/dist/lib/transform.d.ts +1 -1
  56. package/dist/lib/transform.d.ts.map +1 -1
  57. package/dist/lib/transform.js +51 -42
  58. package/package.json +6 -6
  59. package/src/lib/flat-geojson-to-binary.ts +1 -0
  60. package/dist/bundle.js.map +0 -1
  61. package/dist/index.js.map +0 -1
  62. package/dist/lib/binary-to-geojson.js.map +0 -1
  63. package/dist/lib/extract-geometry-info.js.map +0 -1
  64. package/dist/lib/flat-geojson-to-binary-types.js.map +0 -1
  65. package/dist/lib/flat-geojson-to-binary.js.map +0 -1
  66. package/dist/lib/geojson-to-binary.js.map +0 -1
  67. package/dist/lib/geojson-to-flat-geojson.js.map +0 -1
  68. package/dist/lib/transform.js.map +0 -1
@@ -1,105 +1,96 @@
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);
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}`);
29
81
  }
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));
89
82
  }
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
- };
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
+ };
104
95
  }
105
- //# sourceMappingURL=extract-geometry-info.js.map
96
+ exports.extractGeometryInfo = extractGeometryInfo;
@@ -2,11 +2,11 @@ import type { TypedArray } from '@loaders.gl/schema';
2
2
  /**
3
3
  * Permissable constructor for numeric props
4
4
  */
5
- export declare type PropArrayConstructor = Float32ArrayConstructor | Float64ArrayConstructor | ArrayConstructor;
5
+ export type PropArrayConstructor = Float32ArrayConstructor | Float64ArrayConstructor | ArrayConstructor;
6
6
  /**
7
7
  * Collection type for holding intermediate binary data before conversion to `BinaryPointGeometry`
8
8
  */
9
- export declare type Points = {
9
+ export type Points = {
10
10
  type: 'Point';
11
11
  positions: Float32Array | Float64Array;
12
12
  globalFeatureIds: Uint16Array | Uint32Array;
@@ -22,7 +22,7 @@ export declare type Points = {
22
22
  /**
23
23
  * Collection type for holding intermediate binary data before conversion to `BinaryLineStringGeometry`
24
24
  */
25
- export declare type Lines = {
25
+ export type Lines = {
26
26
  type: 'LineString';
27
27
  positions: Float32Array | Float64Array;
28
28
  pathIndices: Uint16Array | Uint32Array;
@@ -39,7 +39,7 @@ export declare type Lines = {
39
39
  /**
40
40
  * Collection type for holding intermediate binary data before conversion to `BinaryPolygonGeometry`
41
41
  */
42
- export declare type Polygons = {
42
+ export type Polygons = {
43
43
  type: 'Polygon';
44
44
  positions: Float32Array | Float64Array;
45
45
  polygonIndices: Uint16Array | Uint32Array;
@@ -1 +1 @@
1
- {"version":3,"file":"flat-geojson-to-binary-types.d.ts","sourceRoot":"","sources":["../../src/lib/flat-geojson-to-binary-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,oBAAY,oBAAoB,GAC5B,uBAAuB,GACvB,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;GAEG;AACH,oBAAY,MAAM,GAAG;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IACvC,gBAAgB,EAAE,WAAW,GAAG,WAAW,CAAC;IAC5C,UAAU,EAAE,WAAW,GAAG,WAAW,CAAC;IACtC,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAA;KAAC,CAAC;IAC1C,UAAU,EAAE,EAAE,EAAE,CAAC;IACjB,MAAM,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB,EAAE,CAAC;CACL,CAAC;AAEF;;GAEG;AACH,oBAAY,KAAK,GAAG;IAClB,IAAI,EAAE,YAAY,CAAC;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AC;IACjB,MAAM,EAAE;QACN,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KACtB,EAAE,CAAC;CACL,CAAC"}
@@ -1,2 +1,2 @@
1
- export {};
2
- //# sourceMappingURL=flat-geojson-to-binary-types.js.map
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -17,7 +17,7 @@ export declare function flatGeojsonToBinary(features: FlatFeature[], geometryInf
17
17
  /**
18
18
  * Options for `flatGeojsonToBinary`
19
19
  */
20
- export declare type FlatGeojsonToBinaryOptions = {
20
+ export type FlatGeojsonToBinaryOptions = {
21
21
  numericPropKeys?: string[];
22
22
  PositionDataType?: Float32ArrayConstructor | Float64ArrayConstructor;
23
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"flat-geojson-to-binary.d.ts","sourceRoot":"","sources":["../../src/lib/flat-geojson-to-binary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,cAAc,EACd,WAAW,EAIX,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,oBAAoB,EAA0B,MAAM,gCAAgC,CAAC;AAE7F;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,0BAA0B,kBAerC;AAED;;GAEG;AACH,oBAAY,0BAA0B,GAAG;IACvC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,CAAC;CACtE,CAAC;AAEF,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF;;;;;GAKG;AACH,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG;IACzD,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACrC,CAgBA"}
1
+ {"version":3,"file":"flat-geojson-to-binary.d.ts","sourceRoot":"","sources":["../../src/lib/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