@loaders.gl/gis 4.3.2 → 4.4.0-alpha.1
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 +38 -15
- 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 +48 -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 +50 -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} +0 -1
- 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} +3 -90
- 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} +5 -5
- 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 +377 -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 +24 -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} +4 -1
- 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 +4 -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} +4 -1
- 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 +91 -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 +164 -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 +39 -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 +195 -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 +273 -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 +44 -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 +254 -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 +164 -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 +9 -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 +258 -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 +174 -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 +46 -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 +64 -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 +33 -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 +154 -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} +10 -16
- 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 +35 -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 +153 -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 +69 -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 +127 -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 +18 -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 +54 -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 +50 -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 +35 -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 +120 -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,136 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// Forked from https://github.com/cschwarz/wkx under MIT license, Copyright (c) 2013 Christian Schwarz
|
|
5
|
+
|
|
6
|
+
import {TypedArray} from '@math.gl/types';
|
|
7
|
+
|
|
8
|
+
const LE = true;
|
|
9
|
+
const BE = false;
|
|
10
|
+
|
|
11
|
+
export class BinaryWriter {
|
|
12
|
+
arrayBuffer: ArrayBuffer;
|
|
13
|
+
dataView: DataView;
|
|
14
|
+
byteOffset: number = 0;
|
|
15
|
+
allowResize: boolean = false;
|
|
16
|
+
|
|
17
|
+
constructor(size: number, allowResize?: boolean) {
|
|
18
|
+
this.arrayBuffer = new ArrayBuffer(size);
|
|
19
|
+
this.dataView = new DataView(this.arrayBuffer);
|
|
20
|
+
this.byteOffset = 0;
|
|
21
|
+
this.allowResize = allowResize || false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
writeUInt8(value: number): void {
|
|
25
|
+
this._ensureSize(1);
|
|
26
|
+
this.dataView.setUint8(this.byteOffset, value);
|
|
27
|
+
this.byteOffset += 1;
|
|
28
|
+
}
|
|
29
|
+
writeUInt16LE(value: number): void {
|
|
30
|
+
this._ensureSize(2);
|
|
31
|
+
this.dataView.setUint16(this.byteOffset, value, LE);
|
|
32
|
+
this.byteOffset += 2;
|
|
33
|
+
}
|
|
34
|
+
writeUInt16BE(value: number): void {
|
|
35
|
+
this._ensureSize(2);
|
|
36
|
+
this.dataView.setUint16(this.byteOffset, value, BE);
|
|
37
|
+
this.byteOffset += 2;
|
|
38
|
+
}
|
|
39
|
+
writeUInt32LE(value: number): void {
|
|
40
|
+
this._ensureSize(4);
|
|
41
|
+
this.dataView.setUint32(this.byteOffset, value, LE);
|
|
42
|
+
this.byteOffset += 4;
|
|
43
|
+
}
|
|
44
|
+
writeUInt32BE(value: number): void {
|
|
45
|
+
this._ensureSize(4);
|
|
46
|
+
this.dataView.setUint32(this.byteOffset, value, BE);
|
|
47
|
+
this.byteOffset += 4;
|
|
48
|
+
}
|
|
49
|
+
writeInt8(value: number): void {
|
|
50
|
+
this._ensureSize(1);
|
|
51
|
+
this.dataView.setInt8(this.byteOffset, value);
|
|
52
|
+
this.byteOffset += 1;
|
|
53
|
+
}
|
|
54
|
+
writeInt16LE(value: number): void {
|
|
55
|
+
this._ensureSize(2);
|
|
56
|
+
this.dataView.setInt16(this.byteOffset, value, LE);
|
|
57
|
+
this.byteOffset += 2;
|
|
58
|
+
}
|
|
59
|
+
writeInt16BE(value: number): void {
|
|
60
|
+
this._ensureSize(2);
|
|
61
|
+
this.dataView.setInt16(this.byteOffset, value, BE);
|
|
62
|
+
this.byteOffset += 2;
|
|
63
|
+
}
|
|
64
|
+
writeInt32LE(value: number): void {
|
|
65
|
+
this._ensureSize(4);
|
|
66
|
+
this.dataView.setInt32(this.byteOffset, value, LE);
|
|
67
|
+
this.byteOffset += 4;
|
|
68
|
+
}
|
|
69
|
+
writeInt32BE(value: number): void {
|
|
70
|
+
this._ensureSize(4);
|
|
71
|
+
this.dataView.setInt32(this.byteOffset, value, BE);
|
|
72
|
+
this.byteOffset += 4;
|
|
73
|
+
}
|
|
74
|
+
writeFloatLE(value: number): void {
|
|
75
|
+
this._ensureSize(4);
|
|
76
|
+
this.dataView.setFloat32(this.byteOffset, value, LE);
|
|
77
|
+
this.byteOffset += 4;
|
|
78
|
+
}
|
|
79
|
+
writeFloatBE(value: number): void {
|
|
80
|
+
this._ensureSize(4);
|
|
81
|
+
this.dataView.setFloat32(this.byteOffset, value, BE);
|
|
82
|
+
this.byteOffset += 4;
|
|
83
|
+
}
|
|
84
|
+
writeDoubleLE(value: number): void {
|
|
85
|
+
this._ensureSize(8);
|
|
86
|
+
this.dataView.setFloat64(this.byteOffset, value, LE);
|
|
87
|
+
this.byteOffset += 8;
|
|
88
|
+
}
|
|
89
|
+
writeDoubleBE(value: number): void {
|
|
90
|
+
this._ensureSize(8);
|
|
91
|
+
this.dataView.setFloat64(this.byteOffset, value, BE);
|
|
92
|
+
this.byteOffset += 8;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A varint uses a variable number of bytes */
|
|
96
|
+
writeVarInt(value: number): number {
|
|
97
|
+
// TODO - ensure size?
|
|
98
|
+
let length = 1;
|
|
99
|
+
while ((value & 0xffffff80) !== 0) {
|
|
100
|
+
this.writeUInt8((value & 0x7f) | 0x80);
|
|
101
|
+
value >>>= 7;
|
|
102
|
+
length++;
|
|
103
|
+
}
|
|
104
|
+
this.writeUInt8(value & 0x7f);
|
|
105
|
+
return length;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
writeTypedArray(typedArray: TypedArray) {
|
|
109
|
+
this._ensureSize(typedArray.byteLength);
|
|
110
|
+
const tempArray = new Uint8Array(this.arrayBuffer);
|
|
111
|
+
tempArray.set(typedArray, this.byteOffset);
|
|
112
|
+
this.byteOffset += typedArray.byteLength;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Append another ArrayBuffer to this ArrayBuffer */
|
|
116
|
+
writeBuffer(arrayBuffer: ArrayBuffer): void {
|
|
117
|
+
this._ensureSize(arrayBuffer.byteLength);
|
|
118
|
+
const tempArray = new Uint8Array(this.arrayBuffer);
|
|
119
|
+
tempArray.set(new Uint8Array(arrayBuffer), this.byteOffset);
|
|
120
|
+
this.byteOffset += arrayBuffer.byteLength;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Resizes this.arrayBuffer if not enough space */
|
|
124
|
+
_ensureSize(size: number) {
|
|
125
|
+
if (this.arrayBuffer.byteLength < this.byteOffset + size) {
|
|
126
|
+
if (this.allowResize) {
|
|
127
|
+
const newArrayBuffer = new ArrayBuffer(this.byteOffset + size);
|
|
128
|
+
const tempArray = new Uint8Array(newArrayBuffer);
|
|
129
|
+
tempArray.set(new Uint8Array(this.arrayBuffer));
|
|
130
|
+
this.arrayBuffer = newArrayBuffer;
|
|
131
|
+
} else {
|
|
132
|
+
throw new Error('BinaryWriter overflow');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
import type {TypedArray} from '@loaders.gl/schema';
|
|
5
|
+
|
|
6
|
+
// TODO: remove copy; import from typed-array-utils
|
|
7
|
+
// modules/math/src/geometry/typed-arrays/typed-array-utils.js
|
|
8
|
+
export function concatTypedArrays(arrays: TypedArray[]): TypedArray {
|
|
9
|
+
let byteLength = 0;
|
|
10
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
11
|
+
byteLength += arrays[i].byteLength;
|
|
12
|
+
}
|
|
13
|
+
const buffer = new Uint8Array(byteLength);
|
|
14
|
+
|
|
15
|
+
let byteOffset = 0;
|
|
16
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
17
|
+
const data = new Uint8Array(arrays[i].buffer);
|
|
18
|
+
byteLength = data.length;
|
|
19
|
+
for (let j = 0; j < byteLength; ++j) {
|
|
20
|
+
buffer[byteOffset++] = data[j];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return buffer;
|
|
24
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Simple helper to decode and encode "hex encoded" binary buffers
|
|
7
|
+
* without first converting to string.
|
|
8
|
+
*/
|
|
9
|
+
export class HexEncoder {
|
|
10
|
+
/** Get length in bytes required to store encoded data */
|
|
11
|
+
getEncodedLength(array: Uint8Array): number {
|
|
12
|
+
return array.byteLength * 2;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Get length in bytes required to store decoded data */
|
|
16
|
+
getDecodedLength(array: Uint8Array): number {
|
|
17
|
+
return Math.ceil(array.byteLength / 2);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Decode hexadecimal */
|
|
21
|
+
decode(array: Uint8Array, result: Uint8Array): Uint8Array {
|
|
22
|
+
for (let i = 0; i < array.byteLength / 2; ++i) {
|
|
23
|
+
const halfByte1 = hexDecode(array[i]);
|
|
24
|
+
const halfByte2 = hexDecode(array[i + 1]);
|
|
25
|
+
result[i] = halfByte1 * 16 + halfByte2;
|
|
26
|
+
}
|
|
27
|
+
// Check if final half byte (is that legal?)
|
|
28
|
+
// if (array.byteLength % 2) {
|
|
29
|
+
// const halfByte1 = hexDecode(array[i]);
|
|
30
|
+
// }
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Encode hexadecimal */
|
|
35
|
+
encode(array: Uint8Array, result: Uint8Array): Uint8Array {
|
|
36
|
+
for (let i = 0; i < array.byteLength; ++i) {
|
|
37
|
+
const byte = array[i];
|
|
38
|
+
result[i * 2] = hexEncode(byte & 0x0f);
|
|
39
|
+
result[i * 2 + 1] = hexEncode(byte & 0xf0);
|
|
40
|
+
}
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function hexEncode(value: number): number {
|
|
46
|
+
if (value < 10) {
|
|
47
|
+
return value + 48; // ASCII of 0
|
|
48
|
+
}
|
|
49
|
+
return value - 10 + 65; // ASCII of capital A
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function hexDecode(value: number): number {
|
|
53
|
+
if (value >= 65) {
|
|
54
|
+
return value - 65 + 10; // ASCII of A
|
|
55
|
+
}
|
|
56
|
+
if (value >= 97) {
|
|
57
|
+
return value - 97 + 10; // ASCII of a
|
|
58
|
+
}
|
|
59
|
+
return value - 48; // ASCII of 0
|
|
60
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// Forked from https://github.com/jessetane/hex-transcoder under MIT license
|
|
6
|
+
|
|
7
|
+
const alphabet = '0123456789abcdef';
|
|
8
|
+
const encodeLookup: string[] = [];
|
|
9
|
+
const decodeLookup: number[] = [];
|
|
10
|
+
|
|
11
|
+
for (let i = 0; i < 256; i++) {
|
|
12
|
+
encodeLookup[i] = alphabet[(i >> 4) & 0xf] + alphabet[i & 0xf];
|
|
13
|
+
if (i < 16) {
|
|
14
|
+
if (i < 10) {
|
|
15
|
+
decodeLookup[0x30 + i] = i;
|
|
16
|
+
} else {
|
|
17
|
+
decodeLookup[0x61 - 10 + i] = i;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Encode a Uint8Array to a hex string
|
|
24
|
+
*
|
|
25
|
+
* @param array Bytes to encode to string
|
|
26
|
+
* @return hex string
|
|
27
|
+
*/
|
|
28
|
+
export function encodeHex(array: Uint8Array): string {
|
|
29
|
+
const length = array.length;
|
|
30
|
+
let string = '';
|
|
31
|
+
let i = 0;
|
|
32
|
+
while (i < length) {
|
|
33
|
+
string += encodeLookup[array[i++]];
|
|
34
|
+
}
|
|
35
|
+
return string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Decodes a hex string to a Uint8Array
|
|
40
|
+
*
|
|
41
|
+
* @param string hex string to decode to Uint8Array
|
|
42
|
+
* @return Uint8Array
|
|
43
|
+
*/
|
|
44
|
+
export function decodeHex(string: string): Uint8Array {
|
|
45
|
+
const sizeof = string.length >> 1;
|
|
46
|
+
const length = sizeof << 1;
|
|
47
|
+
const array = new Uint8Array(sizeof);
|
|
48
|
+
let n = 0;
|
|
49
|
+
let i = 0;
|
|
50
|
+
while (i < length) {
|
|
51
|
+
array[n++] = (decodeLookup[string.charCodeAt(i++)] << 4) | decodeLookup[string.charCodeAt(i++)];
|
|
52
|
+
}
|
|
53
|
+
return array;
|
|
54
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
import type {WKTCRS} from './parse-wkt-crs';
|
|
7
|
+
|
|
8
|
+
export type EncodeWKTCRSOptions = {
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* convert JSON representation of Well-Known Text
|
|
14
|
+
* back to standard Well-Known Text
|
|
15
|
+
*/
|
|
16
|
+
export function encodeWKTCRS(wkt: WKTCRS, options?: EncodeWKTCRSOptions): string {
|
|
17
|
+
if (Array.isArray(wkt) && wkt.length === 1 && Array.isArray(wkt[0])) {
|
|
18
|
+
wkt = wkt[0]; // ignore first extra wrapper array
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const [kw, ...attrs] = wkt;
|
|
22
|
+
const str = `${kw}[${attrs
|
|
23
|
+
.map((attr) => {
|
|
24
|
+
if (Array.isArray(attr)) {
|
|
25
|
+
return encodeWKTCRS(attr, options);
|
|
26
|
+
} else if (typeof attr === 'number') {
|
|
27
|
+
return attr.toString();
|
|
28
|
+
} else if (typeof attr === 'string') {
|
|
29
|
+
// can't automatically convert all caps to varibale
|
|
30
|
+
// because EPSG is string in AUTHORITY["EPSG", ...]
|
|
31
|
+
if (attr.startsWith('raw:')) {
|
|
32
|
+
// convert "raw:NORTH" to NORTH
|
|
33
|
+
return attr.replace('raw:', '');
|
|
34
|
+
}
|
|
35
|
+
return `"${attr}"`;
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`[wktcrs] unexpected attribute "${attr}"`);
|
|
38
|
+
})
|
|
39
|
+
.join(',')}]`;
|
|
40
|
+
return str;
|
|
41
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
/* eslint-disable no-console */ // TODO switch to options.log
|
|
7
|
+
|
|
8
|
+
export type ParseWKTCRSOptions = {
|
|
9
|
+
sort?: boolean;
|
|
10
|
+
keywords?: string[];
|
|
11
|
+
raw?: boolean;
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type WKTCRS = any;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param wkt
|
|
20
|
+
* @param options
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function parseWKTCRS(wkt: string, options?: ParseWKTCRSOptions): WKTCRS {
|
|
24
|
+
if (options?.debug) {
|
|
25
|
+
console.log('[wktcrs] parse starting with\n', wkt);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// move all keywords into first array item slot
|
|
29
|
+
// from PARAM[12345, 67890] to ["PARAM", 12345, 67890]
|
|
30
|
+
wkt = wkt.replace(/[A-Z][A-Z\d_]+\[/gi, (match) => `["${match.substr(0, match.length - 1)}",`);
|
|
31
|
+
|
|
32
|
+
// wrap variables in strings
|
|
33
|
+
// from [...,NORTH] to [...,"NORTH"]
|
|
34
|
+
wkt = wkt.replace(/, ?([A-Z][A-Z\d_]+[,\]])/gi, (match, p1) => {
|
|
35
|
+
const varname = p1.substr(0, p1.length - 1);
|
|
36
|
+
return ',' + `"${options?.raw ? 'raw:' : ''}${varname}"${p1[p1.length - 1]}`;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (options?.raw) {
|
|
40
|
+
// replace all numbers with strings
|
|
41
|
+
wkt = wkt.replace(/, {0,2}(-?[\.\d]+)(?=,|\])/g, function (match, p1) {
|
|
42
|
+
return ',' + `"${options?.raw ? 'raw:' : ''}${p1}"`;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// str should now be valid JSON
|
|
47
|
+
if (options?.debug) {
|
|
48
|
+
console.log(`[wktcrs] json'd wkt: '${wkt}'`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let data;
|
|
52
|
+
try {
|
|
53
|
+
data = JSON.parse(wkt);
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error(`[wktcrs] failed to parse '${wkt}'`);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (options?.debug) {
|
|
60
|
+
console.log(`[wktcrs] json parsed: '${wkt}'`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function process(data, parent) {
|
|
64
|
+
const kw = data[0];
|
|
65
|
+
|
|
66
|
+
// after removing the first element with .shift()
|
|
67
|
+
// data is now just an array of attributes
|
|
68
|
+
|
|
69
|
+
data.forEach(function (it) {
|
|
70
|
+
if (Array.isArray(it)) {
|
|
71
|
+
process(it, data);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const kwarr = `MULTIPLE_${kw}`;
|
|
76
|
+
|
|
77
|
+
if (kwarr in parent) {
|
|
78
|
+
parent[kwarr].push(data);
|
|
79
|
+
} else if (kw in parent) {
|
|
80
|
+
parent[kwarr] = [parent[kw], data];
|
|
81
|
+
delete parent[kw];
|
|
82
|
+
} else {
|
|
83
|
+
parent[kw] = data;
|
|
84
|
+
}
|
|
85
|
+
return parent;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const result = process(data, [data]);
|
|
89
|
+
if (options?.debug) {
|
|
90
|
+
console.log('[wktcrs] parse returning', result);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (options?.sort) {
|
|
94
|
+
sort(result, options);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function sort(data: string[], options?: {keywords?: string[]}) {
|
|
101
|
+
const keys = Object.keys(data).filter((k) => !/\d+/.test(k));
|
|
102
|
+
|
|
103
|
+
const keywords: string[] = options?.keywords || [];
|
|
104
|
+
if (!options?.keywords) {
|
|
105
|
+
// try to find multiples
|
|
106
|
+
const counts = {};
|
|
107
|
+
if (Array.isArray(data)) {
|
|
108
|
+
data.forEach((it) => {
|
|
109
|
+
if (Array.isArray(it) && it.length >= 2 && typeof it[1] === 'string') {
|
|
110
|
+
const k = it[0];
|
|
111
|
+
if (!counts[k]) counts[k] = 0;
|
|
112
|
+
counts[k]++;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
for (const k in counts) {
|
|
116
|
+
if (counts[k] > 0) keywords.push(k);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
keys.forEach((key) => {
|
|
122
|
+
data[key] = sort(data[key]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
keywords.forEach((key) => {
|
|
126
|
+
const indices: number[] = [];
|
|
127
|
+
const params: string[] = [];
|
|
128
|
+
|
|
129
|
+
data.forEach((item, i) => {
|
|
130
|
+
if (Array.isArray(item) && item[0] === key) {
|
|
131
|
+
indices.push(i);
|
|
132
|
+
params.push(item);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
params.sort((a, b) => {
|
|
137
|
+
a = a[1].toString();
|
|
138
|
+
b = b[1].toString();
|
|
139
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// replace in order
|
|
143
|
+
params.forEach((param, i) => {
|
|
144
|
+
data[indices[i]] = param;
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { BinaryGeometry, BinaryGeometryType, BinaryFeatureCollection, Feature, Geometry } from '@loaders.gl/schema';
|
|
2
|
-
type BinaryToGeoJsonOptions = {
|
|
3
|
-
type?: BinaryGeometryType;
|
|
4
|
-
globalFeatureId?: number;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Convert binary geometry representation to GeoJSON
|
|
8
|
-
* @param data geometry data in binary representation
|
|
9
|
-
* @param options
|
|
10
|
-
* @param options.type Input data type: Point, LineString, or Polygon
|
|
11
|
-
* @param options.featureId Global feature id. If specified, only a single feature is extracted
|
|
12
|
-
* @return GeoJSON objects
|
|
13
|
-
*/
|
|
14
|
-
export declare function binaryToGeojson(data: BinaryFeatureCollection, options?: BinaryToGeoJsonOptions): Feature[] | Feature;
|
|
15
|
-
/** Parse input binary data and return a valid GeoJSON geometry object */
|
|
16
|
-
export declare function binaryToGeometry(data: BinaryGeometry, startIndex?: number, endIndex?: number): Geometry;
|
|
17
|
-
export {};
|
|
18
|
-
//# sourceMappingURL=binary-to-geojson.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"binary-to-geojson.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/binary-to-geojson.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAIlB,uBAAuB,EAMvB,OAAO,EACP,QAAQ,EAST,MAAM,oBAAoB,CAAC;AAK5B,KAAK,sBAAsB,GAAG;IAC5B,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,uBAAuB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,EAAE,GAAG,OAAO,CAMrB;AAwCD,yEAAyE;AACzE,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,cAAc,EACpB,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,QAAQ,CAYV"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Feature, GeojsonGeometryInfo } from '@loaders.gl/schema';
|
|
2
|
-
/**
|
|
3
|
-
* Initial scan over GeoJSON features
|
|
4
|
-
* Counts number of coordinates of each geometry type and
|
|
5
|
-
* keeps track of the max coordinate dimensions
|
|
6
|
-
*/
|
|
7
|
-
export declare function extractGeometryInfo(features: Feature[]): GeojsonGeometryInfo;
|
|
8
|
-
//# sourceMappingURL=extract-geometry-info.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extract-geometry-info.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/extract-geometry-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAEhE;;;;GAIG;AAEH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,mBAAmB,CA4F5E"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary-types.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/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,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,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 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"flat-geojson-to-binary.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/flat-geojson-to-binary.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,uBAAuB,EAEvB,WAAW,EAIX,mBAAmB,EAEpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,oBAAoB,EAA0B,0CAAuC;AAE7F;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,WAAW,EAAE,EACvB,YAAY,EAAE,mBAAmB,EACjC,OAAO,CAAC,EAAE,0BAA0B,2BAgBrC;AAED;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,CAAC;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-binary.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/geojson-to-binary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAE,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAMzE;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,gBAAgB,CAAC,EAAE,uBAAuB,GAAG,uBAAuB,CAAC;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,sBAAkE,GAC1E,uBAAuB,CAUzB"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { extractGeometryInfo } from "./extract-geometry-info.js";
|
|
2
|
-
import { geojsonToFlatGeojson } from "./geojson-to-flat-geojson.js";
|
|
3
|
-
import { flatGeojsonToBinary } from "./flat-geojson-to-binary.js";
|
|
4
|
-
/**
|
|
5
|
-
* Convert GeoJSON features to flat binary arrays
|
|
6
|
-
*
|
|
7
|
-
* @param features
|
|
8
|
-
* @param options
|
|
9
|
-
* @returns features in binary format, grouped by geometry type
|
|
10
|
-
*/
|
|
11
|
-
export function geojsonToBinary(features, options = { fixRingWinding: true, triangulate: true }) {
|
|
12
|
-
const geometryInfo = extractGeometryInfo(features);
|
|
13
|
-
const coordLength = geometryInfo.coordLength;
|
|
14
|
-
const { fixRingWinding } = options;
|
|
15
|
-
const flatFeatures = geojsonToFlatGeojson(features, { coordLength, fixRingWinding });
|
|
16
|
-
return flatGeojsonToBinary(flatFeatures, geometryInfo, {
|
|
17
|
-
numericPropKeys: options.numericPropKeys,
|
|
18
|
-
PositionDataType: options.PositionDataType || Float32Array,
|
|
19
|
-
triangulate: options.triangulate
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-to-flat-geojson.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/geojson-to-flat-geojson.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAY,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AASF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,2BAAoE,GAC5E,WAAW,EAAE,CAEf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/lib/binary-features/transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,uBAAuB,EAAkB,OAAO,EAAC,MAAM,oBAAoB,CAAC;AAEzF,KAAK,mBAAmB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;AAEzD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,uBAAuB,EACvC,mBAAmB,EAAE,mBAAmB,GACvC,uBAAuB,CAWzB;AAcD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,OAAO,EAAE,EACnB,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,GAChC,OAAO,EAAE,CAMX"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Schema, Field } from '@loaders.gl/schema';
|
|
2
|
-
export type GeoArrowEncoding = 'geoarrow.multipolygon' | 'geoarrow.polygon' | 'geoarrow.multilinestring' | 'geoarrow.linestring' | 'geoarrow.multipoint' | 'geoarrow.point' | 'geoarrow.wkb' | 'geoarrow.wkt';
|
|
3
|
-
/**
|
|
4
|
-
* Geospatial metadata for one column, extracted from Apache Arrow metadata
|
|
5
|
-
* @see https://github.com/geoarrow/geoarrow/blob/main/extension-types.md
|
|
6
|
-
*/
|
|
7
|
-
export type GeoArrowMetadata = {
|
|
8
|
-
/** Encoding of geometry in this column */
|
|
9
|
-
encoding?: GeoArrowEncoding;
|
|
10
|
-
/** CRS in [PROJJSON](https://proj.org/specifications/projjson.html). Omitted if producer has no information about CRS */
|
|
11
|
-
crs?: Record<string, unknown>;
|
|
12
|
-
/** Edges are either spherical or omitted */
|
|
13
|
-
edges?: 'spherical';
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* get geometry columns from arrow table
|
|
18
|
-
*/
|
|
19
|
-
export declare function getGeometryColumnsFromSchema(schema: Schema): Record<string, GeoArrowMetadata>;
|
|
20
|
-
/**
|
|
21
|
-
* Extracts GeoArrow metadata from a field
|
|
22
|
-
* @param field
|
|
23
|
-
* @returns
|
|
24
|
-
* @see https://github.com/geoarrow/geoarrow/blob/d2f56704414d9ae71e8a5170a8671343ed15eefe/extension-types.md
|
|
25
|
-
*/
|
|
26
|
-
export declare function getGeometryMetadataForField(field: Field): GeoArrowMetadata | null;
|
|
27
|
-
//# sourceMappingURL=geoarrow-metadata.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"geoarrow-metadata.d.ts","sourceRoot":"","sources":["../../../src/lib/geo/geoarrow-metadata.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,gBAAgB,GACxB,uBAAuB,GACvB,kBAAkB,GAClB,0BAA0B,GAC1B,qBAAqB,GACrB,qBAAqB,GACrB,gBAAgB,GAChB,cAAc,GACd,cAAc,CAAC;AAiBnB;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,yHAAyH;IACzH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,4CAA4C;IAC5C,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAS7F;AACD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,KAAK,GAAG,gBAAgB,GAAG,IAAI,CAmCjF"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
/** Array containing all encodings */
|
|
5
|
-
const GEOARROW_ENCODINGS = [
|
|
6
|
-
'geoarrow.multipolygon',
|
|
7
|
-
'geoarrow.polygon',
|
|
8
|
-
'geoarrow.multilinestring',
|
|
9
|
-
'geoarrow.linestring',
|
|
10
|
-
'geoarrow.multipoint',
|
|
11
|
-
'geoarrow.point',
|
|
12
|
-
'geoarrow.wkb',
|
|
13
|
-
'geoarrow.wkt'
|
|
14
|
-
];
|
|
15
|
-
const GEOARROW_COLUMN_METADATA_ENCODING = 'ARROW:extension:name';
|
|
16
|
-
const GEOARROW_COLUMN_METADATA_METADATA = 'ARROW:extension:metadata';
|
|
17
|
-
/**
|
|
18
|
-
* get geometry columns from arrow table
|
|
19
|
-
*/
|
|
20
|
-
export function getGeometryColumnsFromSchema(schema) {
|
|
21
|
-
const geometryColumns = {};
|
|
22
|
-
for (const field of schema.fields) {
|
|
23
|
-
const metadata = getGeometryMetadataForField(field);
|
|
24
|
-
if (metadata) {
|
|
25
|
-
geometryColumns[field.name] = metadata;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return geometryColumns;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Extracts GeoArrow metadata from a field
|
|
32
|
-
* @param field
|
|
33
|
-
* @returns
|
|
34
|
-
* @see https://github.com/geoarrow/geoarrow/blob/d2f56704414d9ae71e8a5170a8671343ed15eefe/extension-types.md
|
|
35
|
-
*/
|
|
36
|
-
export function getGeometryMetadataForField(field) {
|
|
37
|
-
let metadata = null;
|
|
38
|
-
// Check for GeoArrow column encoding
|
|
39
|
-
let geoEncoding = field.metadata?.[GEOARROW_COLUMN_METADATA_ENCODING];
|
|
40
|
-
if (geoEncoding) {
|
|
41
|
-
geoEncoding = geoEncoding.toLowerCase();
|
|
42
|
-
// at time of testing, ogr2ogr uses WKB/WKT for encoding.
|
|
43
|
-
if (geoEncoding === 'wkb') {
|
|
44
|
-
geoEncoding = 'geoarrow.wkb';
|
|
45
|
-
}
|
|
46
|
-
if (geoEncoding === 'wkt') {
|
|
47
|
-
geoEncoding = 'geoarrow.wkt';
|
|
48
|
-
}
|
|
49
|
-
if (!GEOARROW_ENCODINGS.includes(geoEncoding)) {
|
|
50
|
-
// eslint-disable-next-line no-console
|
|
51
|
-
console.warn(`Invalid GeoArrow encoding: ${geoEncoding}`);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
metadata = metadata || {};
|
|
55
|
-
metadata.encoding = geoEncoding;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
// Check for GeoArrow metadata
|
|
59
|
-
const columnMetadata = field.metadata?.[GEOARROW_COLUMN_METADATA_METADATA];
|
|
60
|
-
if (columnMetadata) {
|
|
61
|
-
try {
|
|
62
|
-
metadata = JSON.parse(columnMetadata);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
// eslint-disable-next-line no-console
|
|
66
|
-
console.warn('Failed to parse GeoArrow metadata', error);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return metadata || null;
|
|
70
|
-
}
|