@loaders.gl/gis 4.3.4 → 4.4.0-alpha.10
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/index.cjs +2411 -469
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +31 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -15
- package/dist/index.js.map +1 -0
- package/dist/lib/binary-geometry-api/binary-geometry-info.d.ts +21 -0
- package/dist/lib/binary-geometry-api/binary-geometry-info.d.ts.map +1 -0
- package/dist/lib/binary-geometry-api/binary-geometry-info.js +49 -0
- package/dist/lib/binary-geometry-api/binary-geometry-info.js.map +1 -0
- package/dist/lib/binary-geometry-api/concat-binary-geometry.d.ts +5 -0
- package/dist/lib/binary-geometry-api/concat-binary-geometry.d.ts.map +1 -0
- package/dist/lib/binary-geometry-api/concat-binary-geometry.js +51 -0
- package/dist/lib/binary-geometry-api/concat-binary-geometry.js.map +1 -0
- package/dist/lib/{binary-features/transform.d.ts → binary-geometry-api/transform-coordinates.d.ts} +1 -2
- package/dist/lib/binary-geometry-api/transform-coordinates.d.ts.map +1 -0
- package/dist/lib/{binary-features/transform.js → binary-geometry-api/transform-coordinates.js} +1 -1
- package/dist/lib/binary-geometry-api/transform-coordinates.js.map +1 -0
- package/dist/lib/feature-collection-converters/convert-binary-features-to-geojson.d.ts +16 -0
- package/dist/lib/feature-collection-converters/convert-binary-features-to-geojson.d.ts.map +1 -0
- package/dist/lib/{binary-features/binary-to-geojson.js → feature-collection-converters/convert-binary-features-to-geojson.js} +4 -90
- package/dist/lib/feature-collection-converters/convert-binary-features-to-geojson.js.map +1 -0
- package/dist/lib/{binary-features/flat-geojson-to-binary.d.ts → feature-collection-converters/convert-flat-geojson-to-binary-features.d.ts} +6 -9
- package/dist/lib/feature-collection-converters/convert-flat-geojson-to-binary-features.d.ts.map +1 -0
- package/dist/lib/{binary-features/flat-geojson-to-binary.js → feature-collection-converters/convert-flat-geojson-to-binary-features.js} +6 -5
- package/dist/lib/feature-collection-converters/convert-flat-geojson-to-binary-features.js.map +1 -0
- package/dist/lib/feature-collection-converters/convert-geoarrow-to-binary-features.d.ts +74 -0
- package/dist/lib/feature-collection-converters/convert-geoarrow-to-binary-features.d.ts.map +1 -0
- package/dist/lib/feature-collection-converters/convert-geoarrow-to-binary-features.js +378 -0
- package/dist/lib/feature-collection-converters/convert-geoarrow-to-binary-features.js.map +1 -0
- package/dist/lib/{binary-features/geojson-to-binary.d.ts → feature-collection-converters/convert-geojson-to-binary-features.d.ts} +2 -2
- package/dist/lib/feature-collection-converters/convert-geojson-to-binary-features.d.ts.map +1 -0
- package/dist/lib/feature-collection-converters/convert-geojson-to-binary-features.js +25 -0
- package/dist/lib/feature-collection-converters/convert-geojson-to-binary-features.js.map +1 -0
- package/dist/lib/{binary-features/geojson-to-flat-geojson.d.ts → feature-collection-converters/convert-geojson-to-flat-geojson.d.ts} +2 -2
- package/dist/lib/feature-collection-converters/convert-geojson-to-flat-geojson.d.ts.map +1 -0
- package/dist/lib/{binary-features/geojson-to-flat-geojson.js → feature-collection-converters/convert-geojson-to-flat-geojson.js} +5 -1
- package/dist/lib/feature-collection-converters/convert-geojson-to-flat-geojson.js.map +1 -0
- package/dist/lib/feature-collection-converters/helpers/flat-geojson-to-binary-types.d.ts.map +1 -0
- package/dist/lib/feature-collection-converters/helpers/flat-geojson-to-binary-types.js +5 -0
- package/dist/lib/feature-collection-converters/helpers/flat-geojson-to-binary-types.js.map +1 -0
- package/dist/lib/geometry-api/geometry-info.d.ts +21 -0
- package/dist/lib/geometry-api/geometry-info.d.ts.map +1 -0
- package/dist/lib/{binary-features/extract-geometry-info.js → geometry-api/geometry-info.js} +5 -1
- package/dist/lib/geometry-api/geometry-info.js.map +1 -0
- package/dist/lib/geometry-converters/convert-binary-geometry-to-geojson.d.ts +4 -0
- package/dist/lib/geometry-converters/convert-binary-geometry-to-geojson.d.ts.map +1 -0
- package/dist/lib/geometry-converters/convert-binary-geometry-to-geojson.js +92 -0
- package/dist/lib/geometry-converters/convert-binary-geometry-to-geojson.js.map +1 -0
- package/dist/lib/geometry-converters/convert-geoarrow-to-geojson.d.ts +13 -0
- package/dist/lib/geometry-converters/convert-geoarrow-to-geojson.d.ts.map +1 -0
- package/dist/lib/geometry-converters/convert-geoarrow-to-geojson.js +165 -0
- package/dist/lib/geometry-converters/convert-geoarrow-to-geojson.js.map +1 -0
- package/dist/lib/geometry-converters/convert-to-geojson.d.ts +6 -0
- package/dist/lib/geometry-converters/convert-to-geojson.d.ts.map +1 -0
- package/dist/lib/geometry-converters/convert-to-geojson.js +40 -0
- package/dist/lib/geometry-converters/convert-to-geojson.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-twkb.d.ts +6 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-twkb.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-twkb.js +196 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-twkb.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkb.d.ts +9 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkb.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkb.js +274 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkb.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkt.d.ts +8 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkt.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkt.js +45 -0
- package/dist/lib/geometry-converters/wkb/convert-geometry-to-wkt.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-twkb-to-geometry.d.ts +10 -0
- package/dist/lib/geometry-converters/wkb/convert-twkb-to-geometry.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-twkb-to-geometry.js +255 -0
- package/dist/lib/geometry-converters/wkb/convert-twkb-to-geometry.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.d.ts +3 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js +165 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-geometry.d.ts +11 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-geometry.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-geometry.js +10 -0
- package/dist/lib/geometry-converters/wkb/convert-wkb-to-geometry.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-wkt-to-geometry.d.ts +16 -0
- package/dist/lib/geometry-converters/wkb/convert-wkt-to-geometry.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/convert-wkt-to-geometry.js +259 -0
- package/dist/lib/geometry-converters/wkb/convert-wkt-to-geometry.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts +43 -0
- package/dist/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +175 -0
- package/dist/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-types.d.ts +64 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-types.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-types.js +47 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-types.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-utils.d.ts +21 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-utils.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-utils.js +65 -0
- package/dist/lib/geometry-converters/wkb/helpers/wkb-utils.js.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/write-wkb-header.d.ts +8 -0
- package/dist/lib/geometry-converters/wkb/helpers/write-wkb-header.d.ts.map +1 -0
- package/dist/lib/geometry-converters/wkb/helpers/write-wkb-header.js +34 -0
- package/dist/lib/geometry-converters/wkb/helpers/write-wkb-header.js.map +1 -0
- package/dist/lib/table-converters/convert-geoarrow-table.d.ts +27 -0
- package/dist/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -0
- package/dist/lib/table-converters/convert-geoarrow-table.js +155 -0
- package/dist/lib/table-converters/convert-geoarrow-table.js.map +1 -0
- package/dist/lib/table-converters/convert-wkb-table-to-geojson.d.ts +4 -0
- package/dist/lib/table-converters/convert-wkb-table-to-geojson.d.ts.map +1 -0
- package/dist/lib/{tables/convert-table-to-geojson.js → table-converters/convert-wkb-table-to-geojson.js} +11 -16
- package/dist/lib/table-converters/convert-wkb-table-to-geojson.js.map +1 -0
- package/dist/lib/table-converters/make-arrow-batch-iterator.d.ts +6 -0
- package/dist/lib/table-converters/make-arrow-batch-iterator.d.ts.map +1 -0
- package/dist/lib/table-converters/make-arrow-batch-iterator.js +36 -0
- package/dist/lib/table-converters/make-arrow-batch-iterator.js.map +1 -0
- package/dist/lib/utils/base64-encoder.d.ts +5 -0
- package/dist/lib/utils/base64-encoder.d.ts.map +1 -0
- package/dist/lib/utils/base64-encoder.js +154 -0
- package/dist/lib/utils/base64-encoder.js.map +1 -0
- package/dist/lib/utils/binary-reader.d.ts +18 -0
- package/dist/lib/utils/binary-reader.d.ts.map +1 -0
- package/dist/lib/utils/binary-reader.js +70 -0
- package/dist/lib/utils/binary-reader.js.map +1 -0
- package/dist/lib/utils/binary-writer.d.ts +30 -0
- package/dist/lib/utils/binary-writer.d.ts.map +1 -0
- package/dist/lib/utils/binary-writer.js +128 -0
- package/dist/lib/utils/binary-writer.js.map +1 -0
- package/dist/lib/utils/concat-typed-arrays.d.ts +3 -0
- package/dist/lib/utils/concat-typed-arrays.d.ts.map +1 -0
- package/dist/lib/utils/concat-typed-arrays.js +19 -0
- package/dist/lib/utils/concat-typed-arrays.js.map +1 -0
- package/dist/lib/utils/hex-encoder.d.ts +15 -0
- package/dist/lib/utils/hex-encoder.d.ts.map +1 -0
- package/dist/lib/utils/hex-encoder.js +55 -0
- package/dist/lib/utils/hex-encoder.js.map +1 -0
- package/dist/lib/utils/hex-transcoder.d.ts +15 -0
- package/dist/lib/utils/hex-transcoder.d.ts.map +1 -0
- package/dist/lib/utils/hex-transcoder.js +51 -0
- package/dist/lib/utils/hex-transcoder.js.map +1 -0
- package/dist/lib/wkt-crs/encode-wkt-crs.d.ts +10 -0
- package/dist/lib/wkt-crs/encode-wkt-crs.d.ts.map +1 -0
- package/dist/lib/wkt-crs/encode-wkt-crs.js +36 -0
- package/dist/lib/wkt-crs/encode-wkt-crs.js.map +1 -0
- package/dist/lib/wkt-crs/parse-wkt-crs.d.ts +15 -0
- package/dist/lib/wkt-crs/parse-wkt-crs.d.ts.map +1 -0
- package/dist/lib/wkt-crs/parse-wkt-crs.js +121 -0
- package/dist/lib/wkt-crs/parse-wkt-crs.js.map +1 -0
- package/package.json +7 -5
- package/src/index.ts +87 -14
- package/src/lib/binary-geometry-api/binary-geometry-info.ts +75 -0
- package/src/lib/binary-geometry-api/concat-binary-geometry.ts +78 -0
- package/src/lib/{binary-features/transform.ts → binary-geometry-api/transform-coordinates.ts} +0 -1
- package/src/lib/{binary-features/binary-to-geojson.ts → feature-collection-converters/convert-binary-features-to-geojson.ts} +5 -142
- package/src/lib/{binary-features/flat-geojson-to-binary.ts → feature-collection-converters/convert-flat-geojson-to-binary-features.ts} +14 -9
- package/src/lib/feature-collection-converters/convert-geoarrow-to-binary-features.ts +496 -0
- package/src/lib/{binary-features/geojson-to-binary.ts → feature-collection-converters/convert-geojson-to-binary-features.ts} +11 -7
- package/src/lib/{binary-features/geojson-to-flat-geojson.ts → feature-collection-converters/convert-geojson-to-flat-geojson.ts} +5 -1
- package/src/lib/{binary-features → feature-collection-converters/helpers}/flat-geojson-to-binary-types.ts +4 -0
- package/src/lib/{binary-features/extract-geometry-info.ts → geometry-api/geometry-info.ts} +20 -2
- package/src/lib/geometry-converters/convert-binary-geometry-to-geojson.ts +148 -0
- package/src/lib/geometry-converters/convert-geoarrow-to-geojson.ts +193 -0
- package/src/lib/geometry-converters/convert-to-geojson.ts +52 -0
- package/src/lib/geometry-converters/wkb/convert-geometry-to-twkb.ts +308 -0
- package/src/lib/geometry-converters/wkb/convert-geometry-to-wkb.ts +365 -0
- package/src/lib/geometry-converters/wkb/convert-geometry-to-wkt.ts +54 -0
- package/src/lib/geometry-converters/wkb/convert-twkb-to-geometry.ts +366 -0
- package/src/lib/geometry-converters/wkb/convert-wkb-to-binary-geometry.ts +238 -0
- package/src/lib/geometry-converters/wkb/convert-wkb-to-geometry.ts +23 -0
- package/src/lib/geometry-converters/wkb/convert-wkt-to-geometry.ts +294 -0
- package/src/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +213 -0
- package/src/lib/geometry-converters/wkb/helpers/wkb-types.ts +82 -0
- package/src/lib/geometry-converters/wkb/helpers/wkb-utils.ts +85 -0
- package/src/lib/geometry-converters/wkb/helpers/write-wkb-header.ts +41 -0
- package/src/lib/table-converters/convert-geoarrow-table.ts +218 -0
- package/src/lib/{tables/convert-table-to-geojson.ts → table-converters/convert-wkb-table-to-geojson.ts} +10 -23
- package/src/lib/table-converters/make-arrow-batch-iterator.ts +53 -0
- package/src/lib/utils/base64-encoder.ts +157 -0
- package/src/lib/utils/binary-reader.ts +76 -0
- package/src/lib/utils/binary-writer.ts +136 -0
- package/src/lib/utils/concat-typed-arrays.ts +24 -0
- package/src/lib/utils/hex-encoder.ts +60 -0
- package/src/lib/utils/hex-transcoder.ts +54 -0
- package/src/lib/wkt-crs/encode-wkt-crs.ts +41 -0
- package/src/lib/wkt-crs/parse-wkt-crs.ts +149 -0
- package/dist/lib/binary-features/binary-to-geojson.d.ts +0 -18
- package/dist/lib/binary-features/binary-to-geojson.d.ts.map +0 -1
- package/dist/lib/binary-features/extract-geometry-info.d.ts +0 -8
- package/dist/lib/binary-features/extract-geometry-info.d.ts.map +0 -1
- package/dist/lib/binary-features/flat-geojson-to-binary-types.d.ts.map +0 -1
- package/dist/lib/binary-features/flat-geojson-to-binary-types.js +0 -1
- package/dist/lib/binary-features/flat-geojson-to-binary.d.ts.map +0 -1
- package/dist/lib/binary-features/geojson-to-binary.d.ts.map +0 -1
- package/dist/lib/binary-features/geojson-to-binary.js +0 -21
- package/dist/lib/binary-features/geojson-to-flat-geojson.d.ts.map +0 -1
- package/dist/lib/binary-features/transform.d.ts.map +0 -1
- package/dist/lib/geo/geoarrow-metadata.d.ts +0 -27
- package/dist/lib/geo/geoarrow-metadata.d.ts.map +0 -1
- package/dist/lib/geo/geoarrow-metadata.js +0 -70
- package/dist/lib/geo/geoparquet-metadata-schema.d.ts +0 -79
- package/dist/lib/geo/geoparquet-metadata-schema.d.ts.map +0 -1
- package/dist/lib/geo/geoparquet-metadata-schema.js +0 -69
- package/dist/lib/geo/geoparquet-metadata.d.ts +0 -45
- package/dist/lib/geo/geoparquet-metadata.d.ts.map +0 -1
- package/dist/lib/geo/geoparquet-metadata.js +0 -117
- package/dist/lib/tables/convert-table-to-geojson.d.ts +0 -5
- package/dist/lib/tables/convert-table-to-geojson.d.ts.map +0 -1
- package/src/lib/geo/geoarrow-metadata.ts +0 -100
- package/src/lib/geo/geoparquet-metadata-schema.json +0 -60
- package/src/lib/geo/geoparquet-metadata-schema.ts +0 -71
- package/src/lib/geo/geoparquet-metadata.ts +0 -191
- /package/dist/lib/{binary-features → feature-collection-converters/helpers}/flat-geojson-to-binary-types.d.ts +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/**
|
|
5
|
+
* Simple helper to decode and encode "hex encoded" binary buffers
|
|
6
|
+
* without first converting to string.
|
|
7
|
+
*/
|
|
8
|
+
export class HexEncoder {
|
|
9
|
+
/** Get length in bytes required to store encoded data */
|
|
10
|
+
getEncodedLength(array) {
|
|
11
|
+
return array.byteLength * 2;
|
|
12
|
+
}
|
|
13
|
+
/** Get length in bytes required to store decoded data */
|
|
14
|
+
getDecodedLength(array) {
|
|
15
|
+
return Math.ceil(array.byteLength / 2);
|
|
16
|
+
}
|
|
17
|
+
/** Decode hexadecimal */
|
|
18
|
+
decode(array, result) {
|
|
19
|
+
for (let i = 0; i < array.byteLength / 2; ++i) {
|
|
20
|
+
const halfByte1 = hexDecode(array[i]);
|
|
21
|
+
const halfByte2 = hexDecode(array[i + 1]);
|
|
22
|
+
result[i] = halfByte1 * 16 + halfByte2;
|
|
23
|
+
}
|
|
24
|
+
// Check if final half byte (is that legal?)
|
|
25
|
+
// if (array.byteLength % 2) {
|
|
26
|
+
// const halfByte1 = hexDecode(array[i]);
|
|
27
|
+
// }
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/** Encode hexadecimal */
|
|
31
|
+
encode(array, result) {
|
|
32
|
+
for (let i = 0; i < array.byteLength; ++i) {
|
|
33
|
+
const byte = array[i];
|
|
34
|
+
result[i * 2] = hexEncode(byte & 0x0f);
|
|
35
|
+
result[i * 2 + 1] = hexEncode(byte & 0xf0);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function hexEncode(value) {
|
|
41
|
+
if (value < 10) {
|
|
42
|
+
return value + 48; // ASCII of 0
|
|
43
|
+
}
|
|
44
|
+
return value - 10 + 65; // ASCII of capital A
|
|
45
|
+
}
|
|
46
|
+
function hexDecode(value) {
|
|
47
|
+
if (value >= 65) {
|
|
48
|
+
return value - 65 + 10; // ASCII of A
|
|
49
|
+
}
|
|
50
|
+
if (value >= 97) {
|
|
51
|
+
return value - 97 + 10; // ASCII of a
|
|
52
|
+
}
|
|
53
|
+
return value - 48; // ASCII of 0
|
|
54
|
+
}
|
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,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;YACvC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,IAAI,KAAK,GAAG,EAAE,EAAE,CAAC;QACf,OAAO,KAAK,GAAG,EAAE,CAAC,CAAC,aAAa;IAClC,CAAC;IACD,OAAO,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,qBAAqB;AAC/C,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAChB,OAAO,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa;IACvC,CAAC;IACD,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAChB,OAAO,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,aAAa;IACvC,CAAC;IACD,OAAO,KAAK,GAAG,EAAE,CAAC,CAAC,aAAa;AAClC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a Uint8Array to a hex string
|
|
3
|
+
*
|
|
4
|
+
* @param array Bytes to encode to string
|
|
5
|
+
* @return hex string
|
|
6
|
+
*/
|
|
7
|
+
export declare function encodeHex(array: Uint8Array): string;
|
|
8
|
+
/**
|
|
9
|
+
* Decodes a hex string to a Uint8Array
|
|
10
|
+
*
|
|
11
|
+
* @param string hex string to decode to Uint8Array
|
|
12
|
+
* @return Uint8Array
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeHex(string: string): Uint8Array;
|
|
15
|
+
//# sourceMappingURL=hex-transcoder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-transcoder.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/hex-transcoder.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQnD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAUpD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://github.com/jessetane/hex-transcoder under MIT license
|
|
5
|
+
const alphabet = '0123456789abcdef';
|
|
6
|
+
const encodeLookup = [];
|
|
7
|
+
const decodeLookup = [];
|
|
8
|
+
for (let i = 0; i < 256; i++) {
|
|
9
|
+
encodeLookup[i] = alphabet[(i >> 4) & 0xf] + alphabet[i & 0xf];
|
|
10
|
+
if (i < 16) {
|
|
11
|
+
if (i < 10) {
|
|
12
|
+
decodeLookup[0x30 + i] = i;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
decodeLookup[0x61 - 10 + i] = i;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Encode a Uint8Array to a hex string
|
|
21
|
+
*
|
|
22
|
+
* @param array Bytes to encode to string
|
|
23
|
+
* @return hex string
|
|
24
|
+
*/
|
|
25
|
+
export function encodeHex(array) {
|
|
26
|
+
const length = array.length;
|
|
27
|
+
let string = '';
|
|
28
|
+
let i = 0;
|
|
29
|
+
while (i < length) {
|
|
30
|
+
string += encodeLookup[array[i++]];
|
|
31
|
+
}
|
|
32
|
+
return string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Decodes a hex string to a Uint8Array
|
|
36
|
+
*
|
|
37
|
+
* @param string hex string to decode to Uint8Array
|
|
38
|
+
* @return Uint8Array
|
|
39
|
+
*/
|
|
40
|
+
export function decodeHex(string) {
|
|
41
|
+
const sizeof = string.length >> 1;
|
|
42
|
+
const length = sizeof << 1;
|
|
43
|
+
const array = new Uint8Array(sizeof);
|
|
44
|
+
let n = 0;
|
|
45
|
+
let i = 0;
|
|
46
|
+
while (i < length) {
|
|
47
|
+
array[n++] = (decodeLookup[string.charCodeAt(i++)] << 4) | decodeLookup[string.charCodeAt(i++)];
|
|
48
|
+
}
|
|
49
|
+
return array;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=hex-transcoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex-transcoder.js","sourceRoot":"","sources":["../../../src/lib/utils/hex-transcoder.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,4EAA4E;AAE5E,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,YAAY,GAAa,EAAE,CAAC;AAClC,MAAM,YAAY,GAAa,EAAE,CAAC;AAElC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;IAC7B,YAAY,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IAC/D,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACX,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACX,YAAY,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAiB;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC5B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC;QAClB,MAAM,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,MAAM,EAAE,CAAC;QAClB,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { WKTCRS } from "./parse-wkt-crs.js";
|
|
2
|
+
export type EncodeWKTCRSOptions = {
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* convert JSON representation of Well-Known Text
|
|
7
|
+
* back to standard Well-Known Text
|
|
8
|
+
*/
|
|
9
|
+
export declare function encodeWKTCRS(wkt: WKTCRS, options?: EncodeWKTCRSOptions): string;
|
|
10
|
+
//# sourceMappingURL=encode-wkt-crs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-wkt-crs.d.ts","sourceRoot":"","sources":["../../../src/lib/wkt-crs/encode-wkt-crs.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAC,2BAAwB;AAE5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAyB/E"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// parse-wkt-crs was forked from https://github.com/DanielJDufour/wkt-crs under Creative Commons CC0 1.0 license.
|
|
5
|
+
/**
|
|
6
|
+
* convert JSON representation of Well-Known Text
|
|
7
|
+
* back to standard Well-Known Text
|
|
8
|
+
*/
|
|
9
|
+
export function encodeWKTCRS(wkt, options) {
|
|
10
|
+
if (Array.isArray(wkt) && wkt.length === 1 && Array.isArray(wkt[0])) {
|
|
11
|
+
wkt = wkt[0]; // ignore first extra wrapper array
|
|
12
|
+
}
|
|
13
|
+
const [kw, ...attrs] = wkt;
|
|
14
|
+
const str = `${kw}[${attrs
|
|
15
|
+
.map((attr) => {
|
|
16
|
+
if (Array.isArray(attr)) {
|
|
17
|
+
return encodeWKTCRS(attr, options);
|
|
18
|
+
}
|
|
19
|
+
else if (typeof attr === 'number') {
|
|
20
|
+
return attr.toString();
|
|
21
|
+
}
|
|
22
|
+
else if (typeof attr === 'string') {
|
|
23
|
+
// can't automatically convert all caps to varibale
|
|
24
|
+
// because EPSG is string in AUTHORITY["EPSG", ...]
|
|
25
|
+
if (attr.startsWith('raw:')) {
|
|
26
|
+
// convert "raw:NORTH" to NORTH
|
|
27
|
+
return attr.replace('raw:', '');
|
|
28
|
+
}
|
|
29
|
+
return `"${attr}"`;
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`[wktcrs] unexpected attribute "${attr}"`);
|
|
32
|
+
})
|
|
33
|
+
.join(',')}]`;
|
|
34
|
+
return str;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=encode-wkt-crs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode-wkt-crs.js","sourceRoot":"","sources":["../../../src/lib/wkt-crs/encode-wkt-crs.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AACpC,iHAAiH;AAQjH;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,OAA6B;IACrE,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC;IACnD,CAAC;IAED,MAAM,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,CAAC;IAC3B,MAAM,GAAG,GAAG,GAAG,EAAE,IAAI,KAAK;SACvB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,OAAO,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;aAAM,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpC,mDAAmD;YACnD,mDAAmD;YACnD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5B,+BAA+B;gBAC/B,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,IAAI,IAAI,GAAG,CAAC;QACrB,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,GAAG,CAAC,CAAC;IAC7D,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAChB,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type ParseWKTCRSOptions = {
|
|
2
|
+
sort?: boolean;
|
|
3
|
+
keywords?: string[];
|
|
4
|
+
raw?: boolean;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type WKTCRS = any;
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param wkt
|
|
11
|
+
* @param options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseWKTCRS(wkt: string, options?: ParseWKTCRSOptions): WKTCRS;
|
|
15
|
+
//# sourceMappingURL=parse-wkt-crs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-wkt-crs.d.ts","sourceRoot":"","sources":["../../../src/lib/wkt-crs/parse-wkt-crs.ts"],"names":[],"mappings":"AAOA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,GAAG,CAAC;AAEzB;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,MAAM,CA2E7E"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// parse-wkt-crs was forked from https://github.com/DanielJDufour/wkt-crs under Creative Commons CC0 1.0 license.
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param wkt
|
|
8
|
+
* @param options
|
|
9
|
+
* @returns
|
|
10
|
+
*/
|
|
11
|
+
export function parseWKTCRS(wkt, options) {
|
|
12
|
+
if (options?.debug) {
|
|
13
|
+
console.log('[wktcrs] parse starting with\n', wkt);
|
|
14
|
+
}
|
|
15
|
+
// move all keywords into first array item slot
|
|
16
|
+
// from PARAM[12345, 67890] to ["PARAM", 12345, 67890]
|
|
17
|
+
wkt = wkt.replace(/[A-Z][A-Z\d_]+\[/gi, (match) => `["${match.substr(0, match.length - 1)}",`);
|
|
18
|
+
// wrap variables in strings
|
|
19
|
+
// from [...,NORTH] to [...,"NORTH"]
|
|
20
|
+
wkt = wkt.replace(/, ?([A-Z][A-Z\d_]+[,\]])/gi, (match, p1) => {
|
|
21
|
+
const varname = p1.substr(0, p1.length - 1);
|
|
22
|
+
return ',' + `"${options?.raw ? 'raw:' : ''}${varname}"${p1[p1.length - 1]}`;
|
|
23
|
+
});
|
|
24
|
+
if (options?.raw) {
|
|
25
|
+
// replace all numbers with strings
|
|
26
|
+
wkt = wkt.replace(/, {0,2}(-?[\.\d]+)(?=,|\])/g, function (match, p1) {
|
|
27
|
+
return ',' + `"${options?.raw ? 'raw:' : ''}${p1}"`;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// str should now be valid JSON
|
|
31
|
+
if (options?.debug) {
|
|
32
|
+
console.log(`[wktcrs] json'd wkt: '${wkt}'`);
|
|
33
|
+
}
|
|
34
|
+
let data;
|
|
35
|
+
try {
|
|
36
|
+
data = JSON.parse(wkt);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error(`[wktcrs] failed to parse '${wkt}'`);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
if (options?.debug) {
|
|
43
|
+
console.log(`[wktcrs] json parsed: '${wkt}'`);
|
|
44
|
+
}
|
|
45
|
+
function process(data, parent) {
|
|
46
|
+
const kw = data[0];
|
|
47
|
+
// after removing the first element with .shift()
|
|
48
|
+
// data is now just an array of attributes
|
|
49
|
+
data.forEach(function (it) {
|
|
50
|
+
if (Array.isArray(it)) {
|
|
51
|
+
process(it, data);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const kwarr = `MULTIPLE_${kw}`;
|
|
55
|
+
if (kwarr in parent) {
|
|
56
|
+
parent[kwarr].push(data);
|
|
57
|
+
}
|
|
58
|
+
else if (kw in parent) {
|
|
59
|
+
parent[kwarr] = [parent[kw], data];
|
|
60
|
+
delete parent[kw];
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
parent[kw] = data;
|
|
64
|
+
}
|
|
65
|
+
return parent;
|
|
66
|
+
}
|
|
67
|
+
const result = process(data, [data]);
|
|
68
|
+
if (options?.debug) {
|
|
69
|
+
console.log('[wktcrs] parse returning', result);
|
|
70
|
+
}
|
|
71
|
+
if (options?.sort) {
|
|
72
|
+
sort(result, options);
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
function sort(data, options) {
|
|
77
|
+
const keys = Object.keys(data).filter((k) => !/\d+/.test(k));
|
|
78
|
+
const keywords = options?.keywords || [];
|
|
79
|
+
if (!options?.keywords) {
|
|
80
|
+
// try to find multiples
|
|
81
|
+
const counts = {};
|
|
82
|
+
if (Array.isArray(data)) {
|
|
83
|
+
data.forEach((it) => {
|
|
84
|
+
if (Array.isArray(it) && it.length >= 2 && typeof it[1] === 'string') {
|
|
85
|
+
const k = it[0];
|
|
86
|
+
if (!counts[k])
|
|
87
|
+
counts[k] = 0;
|
|
88
|
+
counts[k]++;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
for (const k in counts) {
|
|
92
|
+
if (counts[k] > 0)
|
|
93
|
+
keywords.push(k);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
keys.forEach((key) => {
|
|
98
|
+
data[key] = sort(data[key]);
|
|
99
|
+
});
|
|
100
|
+
keywords.forEach((key) => {
|
|
101
|
+
const indices = [];
|
|
102
|
+
const params = [];
|
|
103
|
+
data.forEach((item, i) => {
|
|
104
|
+
if (Array.isArray(item) && item[0] === key) {
|
|
105
|
+
indices.push(i);
|
|
106
|
+
params.push(item);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
params.sort((a, b) => {
|
|
110
|
+
a = a[1].toString();
|
|
111
|
+
b = b[1].toString();
|
|
112
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
113
|
+
});
|
|
114
|
+
// replace in order
|
|
115
|
+
params.forEach((param, i) => {
|
|
116
|
+
data[indices[i]] = param;
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return data;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=parse-wkt-crs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-wkt-crs.js","sourceRoot":"","sources":["../../../src/lib/wkt-crs/parse-wkt-crs.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AACpC,iHAAiH;AAajH;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAA4B;IACnE,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,+CAA+C;IAC/C,sDAAsD;IACtD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,oBAAoB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;IAE/F,4BAA4B;IAC5B,oCAAoC;IACpC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,4BAA4B,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE;QAC5D,MAAM,OAAO,GAAG,EAAE,CAAC,MA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C;gBAChB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACpB,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACnB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,mBAAmB;QACnB,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE;YAC1B,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;QAC3B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/gis",
|
|
3
3
|
"description": "Helpers for GIS category data",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.0-alpha.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
@@ -32,8 +32,10 @@
|
|
|
32
32
|
"README.md"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@loaders.gl/
|
|
36
|
-
"@loaders.gl/
|
|
35
|
+
"@loaders.gl/geoarrow": "4.4.0-alpha.10",
|
|
36
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.10",
|
|
37
|
+
"@loaders.gl/schema": "4.4.0-alpha.10",
|
|
38
|
+
"@loaders.gl/schema-utils": "4.4.0-alpha.10",
|
|
37
39
|
"@mapbox/vector-tile": "^1.3.1",
|
|
38
40
|
"@math.gl/polygon": "^4.1.0",
|
|
39
41
|
"pbf": "^3.2.1"
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
"@math.gl/proj4": "^4.1.0"
|
|
43
45
|
},
|
|
44
46
|
"peerDependencies": {
|
|
45
|
-
"@loaders.gl/core": "
|
|
47
|
+
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
46
48
|
},
|
|
47
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7b4dc3fdbaed20a2597c70c57efdcda5c404147f"
|
|
48
50
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,21 +3,94 @@
|
|
|
3
3
|
// Geo Metadata
|
|
4
4
|
// import {default as GEOPARQUET_METADATA_SCHEMA} from './lib/geo/geoparquet-metadata-schema.json';
|
|
5
5
|
// export {GEOPARQUET_METADATA_SCHEMA};
|
|
6
|
-
export {GEOPARQUET_METADATA_JSON_SCHEMA} from './lib/
|
|
6
|
+
// export {GEOPARQUET_METADATA_JSON_SCHEMA} from './lib/geoarrow/geoparquet-metadata-schema';
|
|
7
7
|
|
|
8
|
-
export type {GeoMetadata} from './lib/
|
|
9
|
-
export {
|
|
10
|
-
|
|
8
|
+
// export type {GeoMetadata} from './lib/geoarrow/geoparquet-metadata';
|
|
9
|
+
// export {
|
|
10
|
+
// getGeoMetadata,
|
|
11
|
+
// setGeoMetadata,
|
|
12
|
+
// unpackGeoMetadata
|
|
13
|
+
// } from './lib/geoarrow/geoparquet-metadata';
|
|
14
|
+
// export {unpackJSONStringMetadata} from './lib/geoarrow/geoparquet-metadata';
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
export {
|
|
16
|
+
//
|
|
17
|
+
export type {GeojsonGeometryInfo} from './lib/geometry-api/geometry-info';
|
|
18
|
+
export {getGeometryInfo} from './lib/geometry-api/geometry-info';
|
|
14
19
|
|
|
15
|
-
//
|
|
16
|
-
export {
|
|
20
|
+
// Binary Geometry Utilities
|
|
21
|
+
export type {BinaryGeometryInfo} from './lib/binary-geometry-api/binary-geometry-info';
|
|
22
|
+
export {getBinaryGeometryInfo} from './lib/binary-geometry-api/binary-geometry-info';
|
|
23
|
+
export {
|
|
24
|
+
transformBinaryCoords,
|
|
25
|
+
transformGeoJsonCoords
|
|
26
|
+
} from './lib/binary-geometry-api/transform-coordinates';
|
|
17
27
|
|
|
18
|
-
//
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export {
|
|
28
|
+
// TABLE CONVERSION
|
|
29
|
+
export {convertGeoArrowToTable} from './lib/table-converters/convert-geoarrow-table';
|
|
30
|
+
export {convertWKBTableToGeoJSON} from './lib/table-converters/convert-wkb-table-to-geojson';
|
|
31
|
+
|
|
32
|
+
// FEATURE COLLECTION CONVERSION
|
|
33
|
+
export {
|
|
34
|
+
convertFlatGeojsonToBinaryFeatureCollection,
|
|
35
|
+
// deprecated
|
|
36
|
+
convertFlatGeojsonToBinaryFeatureCollection as flatGeojsonToBinary
|
|
37
|
+
} from './lib/feature-collection-converters/convert-flat-geojson-to-binary-features';
|
|
38
|
+
export {
|
|
39
|
+
convertGeojsonToBinaryFeatureCollection,
|
|
40
|
+
// deprecated
|
|
41
|
+
convertGeojsonToBinaryFeatureCollection as geojsonToBinary
|
|
42
|
+
} from './lib/feature-collection-converters/convert-geojson-to-binary-features';
|
|
43
|
+
export {
|
|
44
|
+
convertGeojsonToFlatGeojson,
|
|
45
|
+
// deprecated
|
|
46
|
+
convertGeojsonToFlatGeojson as geojsonToFlatGeojson
|
|
47
|
+
} from './lib/feature-collection-converters/convert-geojson-to-flat-geojson';
|
|
48
|
+
export {
|
|
49
|
+
convertBinaryFeatureCollectionToGeojson,
|
|
50
|
+
convertBinaryFeatureCollectionToGeojson as binaryToGeojson
|
|
51
|
+
} from './lib/feature-collection-converters/convert-binary-features-to-geojson';
|
|
52
|
+
|
|
53
|
+
// GEOMETRY ENCODING DETECTION
|
|
54
|
+
export {isWKB, isTWKB, isWKT} from './lib/geometry-converters/wkb/helpers/parse-wkb-header';
|
|
55
|
+
|
|
56
|
+
export type {WKBHeader} from './lib/geometry-converters/wkb/helpers/wkb-types';
|
|
57
|
+
export {WKT_MAGIC_STRINGS} from './lib/geometry-converters/wkb/helpers/wkb-types';
|
|
58
|
+
|
|
59
|
+
// GEOMETRY CONVERSION
|
|
60
|
+
export {convertBinaryGeometryToGeometry} from './lib/geometry-converters/convert-binary-geometry-to-geojson';
|
|
61
|
+
|
|
62
|
+
export {convertWKTToGeometry} from './lib/geometry-converters/wkb/convert-wkt-to-geometry';
|
|
63
|
+
export {convertWKBToGeometry} from './lib/geometry-converters/wkb/convert-wkb-to-geometry';
|
|
64
|
+
export {convertWKBToBinaryGeometry} from './lib/geometry-converters/wkb/convert-wkb-to-binary-geometry';
|
|
65
|
+
export {convertTWKBToGeometry} from './lib/geometry-converters/wkb/convert-twkb-to-geometry';
|
|
66
|
+
|
|
67
|
+
export {convertGeometryToWKT} from './lib/geometry-converters/wkb/convert-geometry-to-wkt';
|
|
68
|
+
export {convertGeometryToWKB} from './lib/geometry-converters/wkb/convert-geometry-to-wkb';
|
|
69
|
+
export {convertGeometryToTWKB} from './lib/geometry-converters/wkb/convert-geometry-to-twkb';
|
|
70
|
+
|
|
71
|
+
// CRS
|
|
72
|
+
export type {WKTCRS, ParseWKTCRSOptions} from './lib//wkt-crs/parse-wkt-crs';
|
|
73
|
+
export {parseWKTCRS} from './lib//wkt-crs/parse-wkt-crs';
|
|
74
|
+
export type {EncodeWKTCRSOptions} from './lib//wkt-crs/encode-wkt-crs';
|
|
75
|
+
export {encodeWKTCRS} from './lib//wkt-crs/encode-wkt-crs';
|
|
76
|
+
|
|
77
|
+
// GEOARROW
|
|
78
|
+
export type {
|
|
79
|
+
BinaryDataFromGeoArrow,
|
|
80
|
+
BinaryGeometriesFromArrowOptions
|
|
81
|
+
} from './lib/feature-collection-converters/convert-geoarrow-to-binary-features';
|
|
82
|
+
export {
|
|
83
|
+
convertGeoArrowToBinaryFeatureCollection,
|
|
84
|
+
// deprecated
|
|
85
|
+
convertGeoArrowToBinaryFeatureCollection as getBinaryGeometriesFromArrow,
|
|
86
|
+
getBinaryGeometryTemplate,
|
|
87
|
+
getTriangleIndices,
|
|
88
|
+
getMeanCentersFromBinaryGeometries
|
|
89
|
+
} from './lib/feature-collection-converters/convert-geoarrow-to-binary-features';
|
|
90
|
+
|
|
91
|
+
export {convertGeoArrowGeometryToGeoJSON} from './lib/geometry-converters/convert-geoarrow-to-geojson';
|
|
92
|
+
|
|
93
|
+
// EXPERIMENTAL APIs
|
|
94
|
+
|
|
95
|
+
export {encodeHex, decodeHex} from './lib/utils/hex-transcoder';
|
|
96
|
+
export {extractNumericPropTypes as _extractNumericPropTypes} from './lib/feature-collection-converters/convert-flat-geojson-to-binary-features';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {BinaryGeometry} from '@loaders.gl/schema';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Information about a binary geometry
|
|
9
|
+
*/
|
|
10
|
+
export type BinaryGeometryInfo = {
|
|
11
|
+
/** The GeoJSON style geometry type corresponding to this particular binary geometry */
|
|
12
|
+
multiGeometryType:
|
|
13
|
+
| 'Point'
|
|
14
|
+
| 'LineString'
|
|
15
|
+
| 'Polygon'
|
|
16
|
+
| 'MultiPoint'
|
|
17
|
+
| 'MultiLineString'
|
|
18
|
+
| 'MultiPolygon';
|
|
19
|
+
/** Is this a "Multi" version of the binary geometry? */
|
|
20
|
+
isMultiGeometry: boolean;
|
|
21
|
+
/** How many dimensions are the coordinates? */
|
|
22
|
+
dimension: number;
|
|
23
|
+
/** How many points does this geometry have? */
|
|
24
|
+
pointCount: number;
|
|
25
|
+
/** How many coordinates does this geometry have? */
|
|
26
|
+
coordinateCount: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @returns information about a binary geometry
|
|
31
|
+
*/
|
|
32
|
+
export function getBinaryGeometryInfo(geometry: BinaryGeometry): BinaryGeometryInfo {
|
|
33
|
+
return {
|
|
34
|
+
isMultiGeometry: isMultiGeometryType(geometry),
|
|
35
|
+
multiGeometryType: getMultiGeometryType(geometry),
|
|
36
|
+
dimension: geometry.positions.size,
|
|
37
|
+
pointCount: geometry.positions.value.length / geometry.positions.size,
|
|
38
|
+
coordinateCount: geometry.positions.value.length
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** @returns true if a binary geometry corresponds to a MultiPoint, MultiLineString or MultiPolygon */
|
|
43
|
+
function isMultiGeometryType(geometry: BinaryGeometry) {
|
|
44
|
+
switch (geometry.type) {
|
|
45
|
+
case 'Point':
|
|
46
|
+
const {positions} = geometry;
|
|
47
|
+
return positions.value.length / positions.size > 1;
|
|
48
|
+
case 'LineString':
|
|
49
|
+
const {pathIndices} = geometry;
|
|
50
|
+
return pathIndices.value.length > 1;
|
|
51
|
+
case 'Polygon':
|
|
52
|
+
const {polygonIndices} = geometry;
|
|
53
|
+
return polygonIndices.value.length > 1;
|
|
54
|
+
default:
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @returns geometry type of binary geometry, including MultiPoint, MultiLineString or MultiPolygon
|
|
61
|
+
*/
|
|
62
|
+
function getMultiGeometryType(geometry: BinaryGeometry) {
|
|
63
|
+
const isMulti = isMultiGeometryType(geometry);
|
|
64
|
+
switch (geometry.type) {
|
|
65
|
+
case 'Point':
|
|
66
|
+
return isMulti ? 'MultiPoint' : 'Point';
|
|
67
|
+
case 'LineString':
|
|
68
|
+
return isMulti ? 'MultiLineString' : 'LineString';
|
|
69
|
+
case 'Polygon':
|
|
70
|
+
return isMulti ? 'MultiPolygon' : 'Polygon';
|
|
71
|
+
default:
|
|
72
|
+
// @ts-expect-error
|
|
73
|
+
throw new Error(`Illegal geometry type: ${type}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
TypedArray,
|
|
7
|
+
BinaryPointGeometry,
|
|
8
|
+
BinaryLineGeometry,
|
|
9
|
+
BinaryPolygonGeometry
|
|
10
|
+
} from '@loaders.gl/schema';
|
|
11
|
+
import {concatTypedArrays} from '../utils/concat-typed-arrays';
|
|
12
|
+
|
|
13
|
+
export function concatenateBinaryPointGeometries(
|
|
14
|
+
binaryPointGeometries: BinaryPointGeometry[],
|
|
15
|
+
dimension: number
|
|
16
|
+
): BinaryPointGeometry {
|
|
17
|
+
const positions: TypedArray[] = binaryPointGeometries.map((geometry) => geometry.positions.value);
|
|
18
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(positions).buffer);
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
type: 'Point',
|
|
22
|
+
positions: {value: concatenatedPositions, size: dimension}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function concatenateBinaryLineGeometries(
|
|
27
|
+
binaryLineGeometries: BinaryLineGeometry[],
|
|
28
|
+
dimension: number
|
|
29
|
+
): BinaryLineGeometry {
|
|
30
|
+
const lines: TypedArray[] = binaryLineGeometries.map((geometry) => geometry.positions.value);
|
|
31
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(lines).buffer);
|
|
32
|
+
const pathIndices = lines.map((line) => line.length / dimension).map(cumulativeSum(0));
|
|
33
|
+
pathIndices.unshift(0);
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
type: 'LineString',
|
|
37
|
+
positions: {value: concatenatedPositions, size: dimension},
|
|
38
|
+
pathIndices: {value: new Uint32Array(pathIndices), size: 1}
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function concatenateBinaryPolygonGeometries(
|
|
43
|
+
binaryPolygonGeometries: BinaryPolygonGeometry[],
|
|
44
|
+
dimension: number
|
|
45
|
+
): BinaryPolygonGeometry {
|
|
46
|
+
const polygons: TypedArray[] = [];
|
|
47
|
+
const primitivePolygons: TypedArray[] = [];
|
|
48
|
+
|
|
49
|
+
for (const binaryPolygon of binaryPolygonGeometries) {
|
|
50
|
+
const {positions, primitivePolygonIndices} = binaryPolygon;
|
|
51
|
+
polygons.push(positions.value);
|
|
52
|
+
primitivePolygons.push(primitivePolygonIndices.value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(polygons).buffer);
|
|
56
|
+
const polygonIndices = polygons.map((p) => p.length / dimension).map(cumulativeSum(0));
|
|
57
|
+
polygonIndices.unshift(0);
|
|
58
|
+
|
|
59
|
+
// Combine primitivePolygonIndices from each individual polygon
|
|
60
|
+
const primitivePolygonIndices = [0];
|
|
61
|
+
for (const primitivePolygon of primitivePolygons) {
|
|
62
|
+
primitivePolygonIndices.push(
|
|
63
|
+
...primitivePolygon
|
|
64
|
+
.filter((x: number) => x > 0)
|
|
65
|
+
.map((x: number) => x + primitivePolygonIndices[primitivePolygonIndices.length - 1])
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
type: 'Polygon',
|
|
71
|
+
positions: {value: concatenatedPositions, size: dimension},
|
|
72
|
+
polygonIndices: {value: new Uint32Array(polygonIndices), size: 1},
|
|
73
|
+
primitivePolygonIndices: {value: new Uint32Array(primitivePolygonIndices), size: 1}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// https://stackoverflow.com/a/55261098
|
|
78
|
+
const cumulativeSum = (sum: number) => (value: number) => (sum += value);
|
package/src/lib/{binary-features/transform.ts → binary-geometry-api/transform-coordinates.ts}
RENAMED
|
@@ -38,7 +38,6 @@ function transformBinaryGeometryPositions(binaryGeometry: BinaryGeometry, fn: Tr
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Apply transformation to every coordinate of GeoJSON features
|
|
41
|
-
*
|
|
42
41
|
* @param features Array of GeoJSON features
|
|
43
42
|
* @param fn Function to call on each coordinate
|
|
44
43
|
* @return Transformed GeoJSON features
|