@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.
- package/dist/bundle.js +2 -2
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/index.js +59 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/binary-to-geojson.js +255 -0
- package/dist/es5/lib/binary-to-geojson.js.map +1 -0
- package/dist/es5/lib/extract-geometry-info.js +167 -0
- package/dist/es5/lib/extract-geometry-info.js.map +1 -0
- package/dist/es5/lib/flat-geojson-to-binary-types.js +2 -0
- package/dist/es5/lib/flat-geojson-to-binary-types.js.map +1 -0
- package/dist/es5/lib/flat-geojson-to-binary.js +344 -0
- package/dist/es5/lib/flat-geojson-to-binary.js.map +1 -0
- package/dist/es5/lib/geojson-to-binary.js +26 -0
- package/dist/es5/lib/geojson-to-binary.js.map +1 -0
- package/dist/es5/lib/geojson-to-flat-geojson.js +136 -0
- package/dist/es5/lib/geojson-to-flat-geojson.js.map +1 -0
- package/dist/es5/lib/transform.js +57 -0
- package/dist/es5/lib/transform.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/binary-to-geojson.js +223 -0
- package/dist/esm/lib/binary-to-geojson.js.map +1 -0
- package/dist/esm/lib/extract-geometry-info.js +84 -0
- package/dist/esm/lib/extract-geometry-info.js.map +1 -0
- package/dist/esm/lib/flat-geojson-to-binary-types.js +2 -0
- package/dist/esm/lib/flat-geojson-to-binary-types.js.map +1 -0
- package/dist/esm/lib/flat-geojson-to-binary.js +305 -0
- package/dist/esm/lib/flat-geojson-to-binary.js.map +1 -0
- package/dist/esm/lib/geojson-to-binary.js +22 -0
- package/dist/esm/lib/geojson-to-binary.js.map +1 -0
- package/dist/esm/lib/geojson-to-flat-geojson.js +97 -0
- package/dist/esm/lib/geojson-to-flat-geojson.js.map +1 -0
- package/dist/esm/lib/transform.js +40 -0
- package/dist/esm/lib/transform.js.map +1 -0
- package/dist/index.js +18 -6
- package/dist/lib/binary-to-geojson.d.ts +1 -1
- package/dist/lib/binary-to-geojson.d.ts.map +1 -1
- package/dist/lib/binary-to-geojson.js +201 -242
- package/dist/lib/extract-geometry-info.js +93 -102
- package/dist/lib/flat-geojson-to-binary-types.d.ts +4 -4
- package/dist/lib/flat-geojson-to-binary-types.d.ts.map +1 -1
- package/dist/lib/flat-geojson-to-binary-types.js +2 -2
- package/dist/lib/flat-geojson-to-binary.d.ts +1 -1
- package/dist/lib/flat-geojson-to-binary.d.ts.map +1 -1
- package/dist/lib/flat-geojson-to-binary.js +346 -309
- package/dist/lib/geojson-to-binary.d.ts +1 -1
- package/dist/lib/geojson-to-binary.d.ts.map +1 -1
- package/dist/lib/geojson-to-binary.js +23 -20
- package/dist/lib/geojson-to-flat-geojson.d.ts +1 -1
- package/dist/lib/geojson-to-flat-geojson.d.ts.map +1 -1
- package/dist/lib/geojson-to-flat-geojson.js +116 -104
- package/dist/lib/transform.d.ts +1 -1
- package/dist/lib/transform.d.ts.map +1 -1
- package/dist/lib/transform.js +51 -42
- package/package.json +6 -6
- package/src/lib/flat-geojson-to-binary.ts +1 -0
- package/dist/bundle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/binary-to-geojson.js.map +0 -1
- package/dist/lib/extract-geometry-info.js.map +0 -1
- package/dist/lib/flat-geojson-to-binary-types.js.map +0 -1
- package/dist/lib/flat-geojson-to-binary.js.map +0 -1
- package/dist/lib/geojson-to-binary.js.map +0 -1
- package/dist/lib/geojson-to-flat-geojson.js.map +0 -1
- package/dist/lib/transform.js.map +0 -1
|
@@ -1,105 +1,96 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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,MAAM,MAAM,oBAAoB,GAC5B,uBAAuB,GACvB,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,MAAM,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,MAAM,MAAM,KAAK,GAAG;IAClB,IAAI,EAAE,YAAY,CAAC;IACnB,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IACvC,WAAW,EAAE,WAAW,GAAG,WAAW,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,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC;IACvC,cAAc,EAAE,WAAW,GAAG,WAAW,CAAC;IAC1C,uBAAuB,EAAE,WAAW,GAAG,WAAW,CAAC;IACnD,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
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,
|
|
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,MAAM,MAAM,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"}
|