@loaders.gl/core 5.0.0-rc.2 → 5.0.0
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/arrow-geometry/geometry-codecs.cjs +51 -50
- package/dist/arrow-geometry/geometry-codecs.cjs.map +3 -3
- package/dist/arrow-geometry/geometry-codecs.d.ts +1 -1
- package/dist/arrow-geometry/geometry-codecs.d.ts.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.js +27 -60
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb.cjs +33 -118
- package/dist/arrow-geometry/triangulate-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/triangulate-wkb.d.ts.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb.js +39 -142
- package/dist/arrow-geometry/triangulate-wkb.js.map +1 -1
- package/dist/cluster-source.cjs +124 -370
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/constants/index.cjs +2 -2
- package/dist/constants/index.d.ts +4 -4
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +2 -2
- package/dist/constants/index.js.map +1 -1
- package/dist/dist.dev.js +2 -2
- package/dist/dist.min.js +2 -2
- package/dist/federated-table-scan-source.cjs +166 -564
- package/dist/federated-table-scan-source.cjs.map +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +15 -0
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +19 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +6 -27
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.d.ts.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js +9 -24
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -5
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts +2 -24
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +6 -28
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs +20 -226
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts +1 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js +23 -264
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/loader-utils/index.cjs +31 -217
- package/dist/loader-utils/index.cjs.map +2 -2
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts +4 -52
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js +16 -236
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts +2 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/relational-query.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +9 -78
- package/dist/scan/arrow-execution/expressions.cjs.map +3 -3
- package/dist/scan/arrow-execution/expressions.d.ts +2 -8
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +2 -55
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +41 -179
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +3 -3
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +1 -5
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +44 -190
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/arrow-execution.cjs +2 -2
- package/dist/scan/arrow-execution.cjs.map +2 -2
- package/dist/scan/arrow-execution.d.ts +1 -1
- package/dist/scan/arrow-execution.d.ts.map +1 -1
- package/dist/scan/arrow-execution.js +1 -1
- package/dist/scan/arrow-execution.js.map +1 -1
- package/dist/scan/arrow-query.cjs +3 -3
- package/dist/scan/arrow-query.cjs.map +2 -2
- package/dist/scan/arrow-query.d.ts +2 -2
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/arrow-query.js +2 -2
- package/dist/scan/arrow-query.js.map +1 -1
- package/dist/scan/federated-table-scan-source.cjs +3 -3
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.js +1 -1
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +9 -49
- package/dist/scan/index.cjs.map +3 -3
- package/dist/scan/index.d.ts +2 -2
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -2
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/plan-arrow-table-query.cjs +271 -0
- package/dist/scan/plan-arrow-table-query.cjs.map +7 -0
- package/dist/scan/plan-arrow-table-query.d.ts +50 -0
- package/dist/scan/plan-arrow-table-query.d.ts.map +1 -0
- package/dist/scan/plan-arrow-table-query.js +257 -0
- package/dist/scan/plan-arrow-table-query.js.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.cjs +2 -39
- package/dist/scan/query-arrow-table-in-batches.cjs.map +2 -2
- package/dist/scan/query-arrow-table-in-batches.d.ts +1 -1
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.js +3 -26
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -1
- package/dist/scan/query-arrow-table.cjs +7 -443
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +6 -54
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +6 -475
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +3 -4
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.js +4 -5
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query.cjs +10 -9
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +14 -5
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/scan-engine.cjs +14 -7
- package/dist/scan/scan-engine.cjs.map +2 -2
- package/dist/scan/scan-engine.d.ts +1 -1
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js +4 -9
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +14 -3
- package/dist/scan/vector-table-scan-source.cjs.map +2 -2
- package/dist/scan/vector-table-scan-source.d.ts +1 -1
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +2 -1
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema-utils/index.cjs +11 -47
- package/dist/schema-utils/index.cjs.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +2 -4
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +2 -43
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +854 -1314
- package/dist/vector-table-scan-source.cjs.map +3 -3
- package/dist/wkt/twkb/index.cjs +68 -5
- package/dist/wkt/twkb/index.cjs.map +3 -3
- package/dist/wkt/twkb/index.d.ts +10 -2
- package/dist/wkt/twkb/index.d.ts.map +1 -1
- package/dist/wkt/twkb/index.js +49 -2
- package/dist/wkt/twkb/index.js.map +1 -1
- package/dist/worker-utils/index.cjs +4 -4
- package/dist/worker-utils/index.cjs.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -1
- package/package.json +7 -7
- package/src/arrow-geometry/geometry-codecs.ts +35 -78
- package/src/arrow-geometry/triangulate-wkb.ts +37 -169
- package/src/constants/index.ts +2 -2
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +22 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +7 -32
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +6 -30
- package/src/geoarrow/lib/kernels/decode-wkt-native.ts +23 -269
- package/src/loader-utils/lib/scan-utils/columnar-predicate.ts +46 -363
- package/src/loader-utils/lib/scan-utils/relational-query.ts +7 -1
- package/src/scan/arrow-execution/expressions.ts +2 -86
- package/src/scan/arrow-execution/filter-arrow-table.ts +54 -238
- package/src/scan/arrow-execution.ts +1 -1
- package/src/scan/arrow-query.ts +2 -2
- package/src/scan/federated-table-scan-source.ts +1 -1
- package/src/scan/index.ts +2 -2
- package/src/scan/plan-arrow-table-query.ts +367 -0
- package/src/scan/query-arrow-table-in-batches.ts +4 -33
- package/src/scan/query-arrow-table.ts +10 -626
- package/src/scan/query-pushdown.ts +3 -4
- package/src/scan/query.ts +16 -10
- package/src/scan/scan-engine.ts +4 -11
- package/src/scan/vector-table-scan-source.ts +2 -1
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +2 -50
- package/src/wkt/twkb/index.ts +63 -2
- package/dist/scan/arrow-execution/portable-predicate-compatibility.cjs +0 -41
- package/dist/scan/arrow-execution/portable-predicate-compatibility.cjs.map +0 -7
- package/dist/scan/arrow-execution/portable-predicate-compatibility.d.ts +0 -5
- package/dist/scan/arrow-execution/portable-predicate-compatibility.d.ts.map +0 -1
- package/dist/scan/arrow-execution/portable-predicate-compatibility.js +0 -23
- package/dist/scan/arrow-execution/portable-predicate-compatibility.js.map +0 -1
- package/dist/scan/arrow-execution/project-arrow-table.cjs +0 -70
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +0 -7
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +0 -8
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +0 -1
- package/dist/scan/arrow-execution/project-arrow-table.js +0 -39
- package/dist/scan/arrow-execution/project-arrow-table.js.map +0 -1
- package/dist/scan/query-arrow-table-math.cjs +0 -41
- package/dist/scan/query-arrow-table-math.cjs.map +0 -7
- package/dist/scan/query-arrow-table-math.d.ts +0 -5
- package/dist/scan/query-arrow-table-math.d.ts.map +0 -1
- package/dist/scan/query-arrow-table-math.js +0 -14
- package/dist/scan/query-arrow-table-math.js.map +0 -1
- package/dist/wkt/twkb/convert-geometry-to-twkb.cjs +0 -211
- package/dist/wkt/twkb/convert-geometry-to-twkb.cjs.map +0 -7
- package/dist/wkt/twkb/convert-geometry-to-twkb.d.ts +0 -6
- package/dist/wkt/twkb/convert-geometry-to-twkb.d.ts.map +0 -1
- package/dist/wkt/twkb/convert-geometry-to-twkb.js +0 -204
- package/dist/wkt/twkb/convert-geometry-to-twkb.js.map +0 -1
- package/dist/wkt/twkb/convert-twkb-to-geometry.cjs +0 -251
- package/dist/wkt/twkb/convert-twkb-to-geometry.cjs.map +0 -7
- package/dist/wkt/twkb/convert-twkb-to-geometry.d.ts +0 -10
- package/dist/wkt/twkb/convert-twkb-to-geometry.d.ts.map +0 -1
- package/dist/wkt/twkb/convert-twkb-to-geometry.js +0 -261
- package/dist/wkt/twkb/convert-twkb-to-geometry.js.map +0 -1
- package/dist/wkt/twkb/twkb-io.cjs +0 -102
- package/dist/wkt/twkb/twkb-io.cjs.map +0 -7
- package/dist/wkt/twkb/twkb-io.d.ts +0 -33
- package/dist/wkt/twkb/twkb-io.d.ts.map +0 -1
- package/dist/wkt/twkb/twkb-io.js +0 -78
- package/dist/wkt/twkb/twkb-io.js.map +0 -1
- package/dist/wkt/twkb/twkb-types.cjs +0 -40
- package/dist/wkt/twkb/twkb-types.cjs.map +0 -7
- package/dist/wkt/twkb/twkb-types.d.ts +0 -11
- package/dist/wkt/twkb/twkb-types.d.ts.map +0 -1
- package/dist/wkt/twkb/twkb-types.js +0 -15
- package/dist/wkt/twkb/twkb-types.js.map +0 -1
- package/src/scan/arrow-execution/portable-predicate-compatibility.ts +0 -27
- package/src/scan/arrow-execution/project-arrow-table.ts +0 -53
- package/src/scan/query-arrow-table-math.ts +0 -23
- package/src/wkt/twkb/convert-geometry-to-twkb.ts +0 -317
- package/src/wkt/twkb/convert-twkb-to-geometry.ts +0 -373
- package/src/wkt/twkb/twkb-io.ts +0 -85
- package/src/wkt/twkb/twkb-types.ts +0 -14
package/dist/cluster-source.cjs
CHANGED
|
@@ -82,6 +82,7 @@ function getLoaderLog(options) {
|
|
|
82
82
|
// src/loader-utils/lib/javascript-utils/is-type.ts
|
|
83
83
|
var isObject = (value) => value !== null && typeof value === "object";
|
|
84
84
|
var isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
85
|
+
var isSharedArrayBuffer = (value) => typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
|
|
85
86
|
|
|
86
87
|
// src/loader-utils/lib/option-utils/merge-options.ts
|
|
87
88
|
function mergeOptions(baseOptions, newOptions) {
|
|
@@ -388,6 +389,27 @@ function resolvePath(filename) {
|
|
|
388
389
|
return filename;
|
|
389
390
|
}
|
|
390
391
|
|
|
392
|
+
// src/loader-utils/lib/binary-utils/memory-conversion-utils.ts
|
|
393
|
+
function ensureArrayBuffer(bufferSource) {
|
|
394
|
+
if (bufferSource instanceof ArrayBuffer) {
|
|
395
|
+
return bufferSource;
|
|
396
|
+
}
|
|
397
|
+
if (isSharedArrayBuffer(bufferSource)) {
|
|
398
|
+
return copyToArrayBuffer(bufferSource);
|
|
399
|
+
}
|
|
400
|
+
const { buffer, byteOffset, byteLength } = bufferSource;
|
|
401
|
+
if (buffer instanceof ArrayBuffer && byteOffset === 0 && byteLength === buffer.byteLength) {
|
|
402
|
+
return buffer;
|
|
403
|
+
}
|
|
404
|
+
return copyToArrayBuffer(buffer, byteOffset, byteLength);
|
|
405
|
+
}
|
|
406
|
+
function copyToArrayBuffer(buffer, byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
|
|
407
|
+
const view = new Uint8Array(buffer, byteOffset, byteLength);
|
|
408
|
+
const copy = new Uint8Array(view.length);
|
|
409
|
+
copy.set(view);
|
|
410
|
+
return copy.buffer;
|
|
411
|
+
}
|
|
412
|
+
|
|
391
413
|
// src/loader-utils/lib/sources/data-source.ts
|
|
392
414
|
var UNAVAILABLE_CORE_API = {
|
|
393
415
|
fetchFile: unavailableCoreApiMethod("fetchFile"),
|
|
@@ -646,61 +668,46 @@ function getDimensionSize(dimension) {
|
|
|
646
668
|
// src/arrow-geometry/geometry-codecs.ts
|
|
647
669
|
function convertWKBToGeometry(input) {
|
|
648
670
|
const bytes = ArrayBuffer.isView(input) ? new Uint8Array(input.buffer, input.byteOffset, input.byteLength) : new Uint8Array(input);
|
|
649
|
-
return
|
|
671
|
+
return (0, import_arrow2.parseWKB)(bytes, { normalizeEmptyPoints: true }).geometry;
|
|
650
672
|
}
|
|
651
673
|
function convertGeometryToWKB(input, options = {}) {
|
|
652
674
|
const geometry = input.type === "Feature" ? input.geometry : input;
|
|
653
675
|
if (!geometry) throw new Error("WKB writer does not support null feature geometry");
|
|
654
676
|
const dimension = options.hasZ ? options.hasM ? "xyzm" : "xyz" : options.hasM ? "xym" : "xy";
|
|
655
|
-
const bytes =
|
|
656
|
-
return bytes
|
|
657
|
-
}
|
|
658
|
-
function
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
headerBuilder.beginGeometry("GeometryCollection", children.length);
|
|
670
|
-
const headerLength = headerBuilder.finishGeometry();
|
|
671
|
-
const bytes = new Uint8Array(
|
|
672
|
-
headerLength + children.reduce((total, child) => total + child.length, 0)
|
|
673
|
-
);
|
|
674
|
-
const writer = new import_arrow2.WKBBuilder({ mode: "write", target: bytes, dimension });
|
|
675
|
-
writer.beginGeometry("GeometryCollection", children.length);
|
|
676
|
-
let byteOffset = writer.finishGeometry();
|
|
677
|
-
for (const child of children) {
|
|
678
|
-
bytes.set(child, byteOffset);
|
|
679
|
-
byteOffset += child.length;
|
|
680
|
-
}
|
|
681
|
-
return bytes;
|
|
677
|
+
const bytes = (0, import_arrow2.writeWKB)(describeGeometry(geometry, dimension));
|
|
678
|
+
return ensureArrayBuffer(bytes);
|
|
679
|
+
}
|
|
680
|
+
function describeGeometry(geometry, dimension) {
|
|
681
|
+
return {
|
|
682
|
+
geometry,
|
|
683
|
+
dimension,
|
|
684
|
+
children: geometry.type === "GeometryCollection" ? geometry.geometries.map(
|
|
685
|
+
(child) => describeGeometry(
|
|
686
|
+
child,
|
|
687
|
+
child.__geoarrowDimension ?? dimension
|
|
688
|
+
)
|
|
689
|
+
) : void 0
|
|
690
|
+
};
|
|
682
691
|
}
|
|
683
692
|
function getWKTDimension2(input) {
|
|
684
|
-
var _a
|
|
685
|
-
|
|
686
|
-
/^(?:POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)(?:\s+(ZM|Z|M))?(?:\s|\()/i
|
|
687
|
-
);
|
|
688
|
-
if (!match) return null;
|
|
689
|
-
return ((_a = match[1]) == null ? void 0 : _a.toUpperCase()) === "Z" ? "xyz" : ((_b = match[1]) == null ? void 0 : _b.toUpperCase()) === "M" ? "xym" : ((_c = match[1]) == null ? void 0 : _c.toUpperCase()) === "ZM" ? "xyzm" : "xy";
|
|
693
|
+
var _a;
|
|
694
|
+
return ((_a = (0, import_arrow2.inspectWKTHeader)(input)) == null ? void 0 : _a.dimension) ?? null;
|
|
690
695
|
}
|
|
691
696
|
function convertWKTToGeometry(input, options) {
|
|
692
697
|
var _a;
|
|
693
|
-
const
|
|
698
|
+
const dimension = getWKTDimension2(input);
|
|
694
699
|
try {
|
|
695
|
-
if (/\(\s*\)\s*$/s.test(
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
const
|
|
699
|
-
|
|
700
|
-
|
|
700
|
+
if (/\(\s*\)\s*$/s.test(input)) return null;
|
|
701
|
+
const collectionHeader = /^(\s*(?:SRID\s*=\s*\d+\s*;\s*)?GEOMETRYCOLLECTION)\s+(?:ZM|Z|M)(?=\s|\()/i;
|
|
702
|
+
const parseText = dimension !== "xym" ? input.replace(collectionHeader, "$1") : input;
|
|
703
|
+
const parsed = (0, import_arrow2.parseWKTWithMetadata)(parseText, {
|
|
704
|
+
inferDimensions: true,
|
|
705
|
+
allowMissingInheritedOrdinates: true
|
|
706
|
+
});
|
|
707
|
+
const { srid } = parsed;
|
|
701
708
|
const geometry = toGeometryWithDimensionMetadata(
|
|
702
709
|
parsed,
|
|
703
|
-
collectionHeader ? dimension : void 0
|
|
710
|
+
collectionHeader.test(input) ? dimension ?? void 0 : void 0
|
|
704
711
|
);
|
|
705
712
|
if (((_a = options == null ? void 0 : options.wkt) == null ? void 0 : _a.crs) && srid !== void 0) {
|
|
706
713
|
Object.defineProperty(geometry, "crs", {
|
|
@@ -734,17 +741,6 @@ function addDimensionMarker(geometry, dimension) {
|
|
|
734
741
|
}
|
|
735
742
|
return geometry;
|
|
736
743
|
}
|
|
737
|
-
function splitWKTHeader(input) {
|
|
738
|
-
var _a;
|
|
739
|
-
const sridMatch = input.match(/^\s*SRID=(\d+)\s*;\s*/i);
|
|
740
|
-
const text = sridMatch ? input.slice(sridMatch[0].length) : input;
|
|
741
|
-
const dimensionMatch = text.match(
|
|
742
|
-
/^\s*(?:POINT|LINESTRING|POLYGON|MULTIPOINT|MULTILINESTRING|MULTIPOLYGON|GEOMETRYCOLLECTION)(?:\s+(ZM|Z|M))?(?:\s|\()/i
|
|
743
|
-
);
|
|
744
|
-
const dimensionToken = (_a = dimensionMatch == null ? void 0 : dimensionMatch[1]) == null ? void 0 : _a.toUpperCase();
|
|
745
|
-
const dimension = dimensionToken === "Z" ? "xyz" : dimensionToken === "M" ? "xym" : dimensionToken === "ZM" ? "xyzm" : void 0;
|
|
746
|
-
return { text, srid: sridMatch == null ? void 0 : sridMatch[1], dimension };
|
|
747
|
-
}
|
|
748
744
|
|
|
749
745
|
// src/schema/metadata.ts
|
|
750
746
|
function getMetadataValue(metadata, key) {
|
|
@@ -1733,9 +1729,7 @@ function deserializeArrowDictionaryKeyType(keyType) {
|
|
|
1733
1729
|
|
|
1734
1730
|
// src/schema-utils/lib/arrow/arrow-metadata.ts
|
|
1735
1731
|
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
1736
|
-
|
|
1737
|
-
return deserializeArrowSchema(serializeArrowSchema(schema));
|
|
1738
|
-
}
|
|
1732
|
+
var import_arrow3 = require("@math.gl/core/arrow");
|
|
1739
1733
|
|
|
1740
1734
|
// src/schema-utils/lib/table/batch-builder/arrow-table-builder.ts
|
|
1741
1735
|
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
@@ -1796,7 +1790,7 @@ var ArrowTableBuilder = class {
|
|
|
1796
1790
|
const structField = new arrow3.Struct(arrowSchema.fields);
|
|
1797
1791
|
const arrowStructData = new arrow3.Data(structField, 0, length, 0, void 0, arrowDatas);
|
|
1798
1792
|
const arrowRecordBatch = new arrow3.RecordBatch(
|
|
1799
|
-
snapshotArrowSchema(arrowSchema),
|
|
1793
|
+
(0, import_arrow3.snapshotArrowSchema)(arrowSchema),
|
|
1800
1794
|
arrowStructData
|
|
1801
1795
|
);
|
|
1802
1796
|
return arrowRecordBatch;
|
|
@@ -1805,7 +1799,7 @@ var ArrowTableBuilder = class {
|
|
|
1805
1799
|
|
|
1806
1800
|
// dist/loader-utils/lib/log-utils/log.js
|
|
1807
1801
|
var import_log3 = require("probe.gl/log");
|
|
1808
|
-
var VERSION2 = true ? "5.0.0
|
|
1802
|
+
var VERSION2 = true ? "5.0.0" : "latest";
|
|
1809
1803
|
var version2 = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
1810
1804
|
function createLog2() {
|
|
1811
1805
|
const log3 = new import_log3.Log({ id: "loaders.gl" });
|
|
@@ -2041,7 +2035,7 @@ function parseGeoArrowMetadata(value) {
|
|
|
2041
2035
|
|
|
2042
2036
|
// dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js
|
|
2043
2037
|
var arrow13 = __toESM(require("apache-arrow"), 1);
|
|
2044
|
-
var
|
|
2038
|
+
var import_arrow9 = require("@math.gl/core/arrow");
|
|
2045
2039
|
|
|
2046
2040
|
// dist/geoarrow/lib/geometry-converters/convert-geoarrow-to-geojson.js
|
|
2047
2041
|
function convertGeoArrowGeometryToGeoJSON(arrowCellValue, encoding) {
|
|
@@ -2174,7 +2168,7 @@ function isEmptyArrowCoordinate(arrowCoordinate) {
|
|
|
2174
2168
|
var arrow5 = __toESM(require("apache-arrow"), 1);
|
|
2175
2169
|
|
|
2176
2170
|
// dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js
|
|
2177
|
-
var
|
|
2171
|
+
var import_arrow4 = require("@math.gl/core/arrow");
|
|
2178
2172
|
|
|
2179
2173
|
// dist/geoarrow/lib/geometry-converters/wkb/helpers/wkb-types.js
|
|
2180
2174
|
var WKBGeometryType;
|
|
@@ -2202,10 +2196,10 @@ var WKT_MAGIC_BYTES = WKT_MAGIC_STRINGS.map((string) => textEncoder.encode(strin
|
|
|
2202
2196
|
// dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js
|
|
2203
2197
|
function getWKTGeometryType(input) {
|
|
2204
2198
|
if (typeof input === "string") {
|
|
2205
|
-
const
|
|
2206
|
-
if (!
|
|
2199
|
+
const header = (0, import_arrow4.inspectWKTHeader)(input);
|
|
2200
|
+
if (!header)
|
|
2207
2201
|
return null;
|
|
2208
|
-
const geometryType = WKT_MAGIC_STRINGS.findIndex((magicString) => magicString.startsWith(
|
|
2202
|
+
const geometryType = WKT_MAGIC_STRINGS.findIndex((magicString) => magicString.startsWith(header.geometryType.toUpperCase()));
|
|
2209
2203
|
return geometryType >= 0 ? geometryType + 1 : null;
|
|
2210
2204
|
}
|
|
2211
2205
|
const inputArray = new Uint8Array(input);
|
|
@@ -2214,7 +2208,7 @@ function getWKTGeometryType(input) {
|
|
|
2214
2208
|
}
|
|
2215
2209
|
|
|
2216
2210
|
// dist/geoarrow/geoarrow-inspection.js
|
|
2217
|
-
var
|
|
2211
|
+
var import_arrow5 = require("@math.gl/core/arrow");
|
|
2218
2212
|
|
|
2219
2213
|
// dist/geoarrow/lib/kernels/geoarrow-union.js
|
|
2220
2214
|
var arrow4 = __toESM(require("apache-arrow"), 1);
|
|
@@ -2363,7 +2357,7 @@ function inspectGeoArrowVector(column, encoding) {
|
|
|
2363
2357
|
if (encoding === "geoarrow.wkb") {
|
|
2364
2358
|
const bytes = value;
|
|
2365
2359
|
try {
|
|
2366
|
-
const header = (0,
|
|
2360
|
+
const header = (0, import_arrow5.inspectWKBHeader)(bytes);
|
|
2367
2361
|
dimensions.add(header.dimension);
|
|
2368
2362
|
geometryTypes.add(getGeometryTypeName(header.geometryType, header.dimension));
|
|
2369
2363
|
} catch {
|
|
@@ -2540,6 +2534,7 @@ function dimensionFromSize(size) {
|
|
|
2540
2534
|
|
|
2541
2535
|
// dist/geoarrow/lib/kernels/decode-wkt-native.js
|
|
2542
2536
|
var arrow7 = __toESM(require("apache-arrow"), 1);
|
|
2537
|
+
var import_arrow6 = require("@math.gl/core/arrow");
|
|
2543
2538
|
|
|
2544
2539
|
// src/arrow-geometry/geoarrow-builder.ts
|
|
2545
2540
|
var arrow6 = __toESM(require("apache-arrow"), 1);
|
|
@@ -3087,15 +3082,6 @@ var UNION_GEOMETRY_KINDS = [
|
|
|
3087
3082
|
"MultiLineString",
|
|
3088
3083
|
"MultiPolygon"
|
|
3089
3084
|
];
|
|
3090
|
-
var GEOMETRY_KINDS = [
|
|
3091
|
-
"Point",
|
|
3092
|
-
"LineString",
|
|
3093
|
-
"Polygon",
|
|
3094
|
-
"MultiPoint",
|
|
3095
|
-
"MultiLineString",
|
|
3096
|
-
"MultiPolygon",
|
|
3097
|
-
"GeometryCollection"
|
|
3098
|
-
];
|
|
3099
3085
|
function decodeWKTNativeVector(column, targetEncoding, dimension, coordinates = "interleaved", offsetType = "int32", maxGeometryCollectionDepth = 64) {
|
|
3100
3086
|
const parsedRows = [];
|
|
3101
3087
|
let inferredDimension;
|
|
@@ -3385,269 +3371,38 @@ function writeMultiPolygon(builder, coordinates) {
|
|
|
3385
3371
|
for (const polygon of coordinates)
|
|
3386
3372
|
writePolygon(builder, polygon);
|
|
3387
3373
|
}
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
index = 0;
|
|
3392
|
-
geometryCollectionDepth = 0;
|
|
3393
|
-
/** Creates a parser for one WKT value. */
|
|
3394
|
-
constructor(input, maxGeometryCollectionDepth) {
|
|
3395
|
-
this.input = input;
|
|
3396
|
-
this.maxGeometryCollectionDepth = maxGeometryCollectionDepth;
|
|
3397
|
-
}
|
|
3398
|
-
/** Parses one WKT value, including an optional SRID prefix. */
|
|
3399
|
-
parse() {
|
|
3400
|
-
this.skipWhitespace();
|
|
3401
|
-
if (this.readLiteral("SRID")) {
|
|
3402
|
-
this.skipWhitespace();
|
|
3403
|
-
if (!this.readCharacter("="))
|
|
3404
|
-
return null;
|
|
3405
|
-
if (this.readNumber() === null)
|
|
3406
|
-
return null;
|
|
3407
|
-
this.skipWhitespace();
|
|
3408
|
-
if (!this.readCharacter(";"))
|
|
3409
|
-
return null;
|
|
3410
|
-
}
|
|
3411
|
-
const geometry = this.parseGeometry();
|
|
3412
|
-
this.skipWhitespace();
|
|
3413
|
-
return geometry && this.index === this.input.length ? geometry : null;
|
|
3414
|
-
}
|
|
3415
|
-
parseGeometry() {
|
|
3416
|
-
this.skipWhitespace();
|
|
3417
|
-
const kind = this.readGeometryKind();
|
|
3418
|
-
if (!kind)
|
|
3419
|
-
return null;
|
|
3420
|
-
this.skipWhitespace();
|
|
3421
|
-
const dimensionToken = this.readDimensionToken();
|
|
3422
|
-
this.skipWhitespace();
|
|
3423
|
-
if (this.readLiteral("EMPTY")) {
|
|
3424
|
-
return { kind, dimension: dimensionToken || "xy", coordinates: getEmptyCoordinates(kind) };
|
|
3425
|
-
}
|
|
3426
|
-
if (!this.readCharacter("("))
|
|
3427
|
-
return null;
|
|
3428
|
-
let coordinates;
|
|
3429
|
-
let geometries;
|
|
3430
|
-
switch (kind) {
|
|
3431
|
-
case "Point":
|
|
3432
|
-
coordinates = this.parseCoordinate();
|
|
3433
|
-
break;
|
|
3434
|
-
case "LineString":
|
|
3435
|
-
coordinates = this.parseCoordinateList();
|
|
3436
|
-
break;
|
|
3437
|
-
case "Polygon":
|
|
3438
|
-
coordinates = this.parseNestedCoordinates(1);
|
|
3439
|
-
break;
|
|
3440
|
-
case "MultiPoint":
|
|
3441
|
-
coordinates = this.parseMultiPointCoordinates();
|
|
3442
|
-
break;
|
|
3443
|
-
case "MultiLineString":
|
|
3444
|
-
coordinates = this.parseNestedCoordinates(1);
|
|
3445
|
-
break;
|
|
3446
|
-
case "MultiPolygon":
|
|
3447
|
-
coordinates = this.parseNestedCoordinates(2);
|
|
3448
|
-
break;
|
|
3449
|
-
case "GeometryCollection":
|
|
3450
|
-
this.geometryCollectionDepth++;
|
|
3451
|
-
if (this.geometryCollectionDepth > this.maxGeometryCollectionDepth)
|
|
3452
|
-
return null;
|
|
3453
|
-
geometries = this.parseGeometryList();
|
|
3454
|
-
this.geometryCollectionDepth--;
|
|
3455
|
-
break;
|
|
3456
|
-
}
|
|
3457
|
-
if (coordinates === null || geometries === null || coordinates === void 0 && geometries === void 0)
|
|
3458
|
-
return null;
|
|
3459
|
-
if (!this.readCharacter(")"))
|
|
3460
|
-
return null;
|
|
3461
|
-
const parsedCoordinates = coordinates || void 0;
|
|
3462
|
-
const parsedGeometries = geometries || void 0;
|
|
3463
|
-
const inferredDimension = dimensionToken || inferDimension(parsedCoordinates, parsedGeometries);
|
|
3464
|
-
if (kind !== "GeometryCollection" && !hasValidArity(parsedCoordinates, void 0, inferredDimension)) {
|
|
3374
|
+
function parseWKT(input, maxGeometryCollectionDepth = 64) {
|
|
3375
|
+
try {
|
|
3376
|
+
if (/\(\s*\)/.test(input))
|
|
3465
3377
|
return null;
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
}
|
|
3474
|
-
parseCoordinateList() {
|
|
3475
|
-
const coordinates = [];
|
|
3476
|
-
while (true) {
|
|
3477
|
-
const coordinate = this.parseCoordinate();
|
|
3478
|
-
if (!coordinate)
|
|
3479
|
-
return null;
|
|
3480
|
-
coordinates.push(coordinate);
|
|
3481
|
-
this.skipWhitespace();
|
|
3482
|
-
if (!this.readCharacter(","))
|
|
3483
|
-
return coordinates;
|
|
3484
|
-
}
|
|
3485
|
-
}
|
|
3486
|
-
parseNestedCoordinates(depth) {
|
|
3487
|
-
const values = [];
|
|
3488
|
-
while (true) {
|
|
3489
|
-
if (!this.readCharacter("("))
|
|
3490
|
-
return null;
|
|
3491
|
-
const value = depth === 1 ? this.parseCoordinateList() : this.parseNestedCoordinates(depth - 1);
|
|
3492
|
-
if (!value || !this.readCharacter(")"))
|
|
3493
|
-
return null;
|
|
3494
|
-
values.push(value);
|
|
3495
|
-
this.skipWhitespace();
|
|
3496
|
-
if (!this.readCharacter(","))
|
|
3497
|
-
return values;
|
|
3498
|
-
}
|
|
3499
|
-
}
|
|
3500
|
-
parseMultiPointCoordinates() {
|
|
3501
|
-
this.skipWhitespace();
|
|
3502
|
-
if (this.peekCharacter("(")) {
|
|
3503
|
-
const coordinates = [];
|
|
3504
|
-
while (true) {
|
|
3505
|
-
if (!this.readCharacter("("))
|
|
3506
|
-
return null;
|
|
3507
|
-
const coordinate = this.parseCoordinate();
|
|
3508
|
-
if (!coordinate || !this.readCharacter(")"))
|
|
3509
|
-
return null;
|
|
3510
|
-
coordinates.push(coordinate);
|
|
3511
|
-
this.skipWhitespace();
|
|
3512
|
-
if (!this.readCharacter(","))
|
|
3513
|
-
return coordinates;
|
|
3514
|
-
}
|
|
3515
|
-
}
|
|
3516
|
-
return this.parseCoordinateList();
|
|
3517
|
-
}
|
|
3518
|
-
parseGeometryList() {
|
|
3519
|
-
const geometries = [];
|
|
3520
|
-
while (true) {
|
|
3521
|
-
const geometry = this.parseGeometry();
|
|
3522
|
-
if (!geometry)
|
|
3523
|
-
return null;
|
|
3524
|
-
geometries.push(geometry);
|
|
3525
|
-
this.skipWhitespace();
|
|
3526
|
-
if (!this.readCharacter(","))
|
|
3527
|
-
return geometries;
|
|
3528
|
-
}
|
|
3529
|
-
}
|
|
3530
|
-
parseCoordinate() {
|
|
3531
|
-
const coordinate = [];
|
|
3532
|
-
while (true) {
|
|
3533
|
-
this.skipWhitespace();
|
|
3534
|
-
const value = this.readNumber();
|
|
3535
|
-
if (value === null)
|
|
3536
|
-
break;
|
|
3537
|
-
coordinate.push(value);
|
|
3538
|
-
}
|
|
3539
|
-
return coordinate.length >= 2 ? coordinate : null;
|
|
3540
|
-
}
|
|
3541
|
-
readGeometryKind() {
|
|
3542
|
-
var _a;
|
|
3543
|
-
const word = (_a = this.readWord()) == null ? void 0 : _a.toUpperCase();
|
|
3544
|
-
const kind = GEOMETRY_KINDS.find((value) => value.toUpperCase() === word);
|
|
3545
|
-
return kind || null;
|
|
3546
|
-
}
|
|
3547
|
-
readDimensionToken() {
|
|
3548
|
-
var _a;
|
|
3549
|
-
const position = this.index;
|
|
3550
|
-
const word = (_a = this.readWord()) == null ? void 0 : _a.toUpperCase();
|
|
3551
|
-
if (word === "Z")
|
|
3552
|
-
return "xyz";
|
|
3553
|
-
if (word === "M")
|
|
3554
|
-
return "xym";
|
|
3555
|
-
if (word === "ZM")
|
|
3556
|
-
return "xyzm";
|
|
3557
|
-
this.index = position;
|
|
3378
|
+
const result = (0, import_arrow6.parseWKTWithMetadata)(input, {
|
|
3379
|
+
inferDimensions: true,
|
|
3380
|
+
allowMissingInheritedOrdinates: true,
|
|
3381
|
+
maximumDepth: maxGeometryCollectionDepth
|
|
3382
|
+
});
|
|
3383
|
+
return adaptParsedWKT(result);
|
|
3384
|
+
} catch {
|
|
3558
3385
|
return null;
|
|
3559
3386
|
}
|
|
3560
|
-
readWord() {
|
|
3561
|
-
const match = this.input.slice(this.index).match(/^[A-Za-z]+/);
|
|
3562
|
-
if (!match)
|
|
3563
|
-
return null;
|
|
3564
|
-
this.index += match[0].length;
|
|
3565
|
-
return match[0];
|
|
3566
|
-
}
|
|
3567
|
-
readNumber() {
|
|
3568
|
-
const match = this.input.slice(this.index).match(/^[+-]?(?:(?:\d+\.\d*|\.\d+|\d+)(?:[eE][+-]?\d+)?)/);
|
|
3569
|
-
if (!match)
|
|
3570
|
-
return null;
|
|
3571
|
-
this.index += match[0].length;
|
|
3572
|
-
const value = Number(match[0]);
|
|
3573
|
-
return Number.isFinite(value) ? value : null;
|
|
3574
|
-
}
|
|
3575
|
-
readLiteral(literal) {
|
|
3576
|
-
const position = this.index;
|
|
3577
|
-
const word = this.readWord();
|
|
3578
|
-
if ((word == null ? void 0 : word.toUpperCase()) === literal)
|
|
3579
|
-
return true;
|
|
3580
|
-
this.index = position;
|
|
3581
|
-
return false;
|
|
3582
|
-
}
|
|
3583
|
-
readCharacter(character) {
|
|
3584
|
-
if (this.input[this.index] !== character)
|
|
3585
|
-
return false;
|
|
3586
|
-
this.index++;
|
|
3587
|
-
this.skipWhitespace();
|
|
3588
|
-
return true;
|
|
3589
|
-
}
|
|
3590
|
-
peekCharacter(character) {
|
|
3591
|
-
return this.input[this.index] === character;
|
|
3592
|
-
}
|
|
3593
|
-
skipWhitespace() {
|
|
3594
|
-
while (/\s/.test(this.input[this.index] || ""))
|
|
3595
|
-
this.index++;
|
|
3596
|
-
}
|
|
3597
|
-
};
|
|
3598
|
-
function parseWKT(input, maxGeometryCollectionDepth = 64) {
|
|
3599
|
-
return new WKTParser(input, maxGeometryCollectionDepth).parse();
|
|
3600
|
-
}
|
|
3601
|
-
function getEmptyCoordinates(kind) {
|
|
3602
|
-
return kind === "Point" ? [] : [];
|
|
3603
|
-
}
|
|
3604
|
-
function inferDimension(coordinates, geometries) {
|
|
3605
|
-
const coordinateSize = findCoordinateSize(coordinates);
|
|
3606
|
-
if (coordinateSize)
|
|
3607
|
-
return dimensionFromSize2(coordinateSize);
|
|
3608
|
-
for (const geometry of geometries || [])
|
|
3609
|
-
return geometry.dimension;
|
|
3610
|
-
return "xy";
|
|
3611
3387
|
}
|
|
3612
|
-
function
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
return
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
if (size)
|
|
3622
|
-
return size;
|
|
3388
|
+
function adaptParsedWKT({ geometry, dimension, children }) {
|
|
3389
|
+
var _a;
|
|
3390
|
+
if (geometry.type === "GeometryCollection") {
|
|
3391
|
+
const geometries = children == null ? void 0 : children.map(adaptParsedWKT);
|
|
3392
|
+
return {
|
|
3393
|
+
kind: geometry.type,
|
|
3394
|
+
dimension: dimension === "xy" ? ((_a = geometries == null ? void 0 : geometries[0]) == null ? void 0 : _a.dimension) ?? dimension : dimension,
|
|
3395
|
+
geometries
|
|
3396
|
+
};
|
|
3623
3397
|
}
|
|
3624
|
-
return
|
|
3625
|
-
}
|
|
3626
|
-
function dimensionFromSize2(size) {
|
|
3627
|
-
return size === 4 ? "xyzm" : size === 3 ? "xyz" : "xy";
|
|
3628
|
-
}
|
|
3629
|
-
function hasValidArity(coordinates, geometries, dimension) {
|
|
3630
|
-
const expectedSize = dimension === "xy" ? 2 : dimension === "xyzm" ? 4 : 3;
|
|
3631
|
-
if (coordinates && !hasCoordinateArity(coordinates, expectedSize))
|
|
3632
|
-
return false;
|
|
3633
|
-
return (geometries || []).every((geometry) => geometry.dimension === dimension || geometry.kind === "GeometryCollection");
|
|
3634
|
-
}
|
|
3635
|
-
function hasCoordinateArity(value, expectedSize) {
|
|
3636
|
-
if (value.length === 0)
|
|
3637
|
-
return true;
|
|
3638
|
-
if (isCoordinate(value))
|
|
3639
|
-
return value.length === expectedSize;
|
|
3640
|
-
return value.every((child) => hasCoordinateArity(child, expectedSize));
|
|
3641
|
-
}
|
|
3642
|
-
function isCoordinate(value) {
|
|
3643
|
-
return typeof value[0] === "number";
|
|
3398
|
+
return { kind: geometry.type, dimension, coordinates: geometry.coordinates };
|
|
3644
3399
|
}
|
|
3645
3400
|
|
|
3646
3401
|
// dist/geoarrow/lib/kernels/encode-geoarrow-box.js
|
|
3647
3402
|
var arrow8 = __toESM(require("apache-arrow"), 1);
|
|
3648
|
-
var
|
|
3403
|
+
var import_arrow7 = require("@math.gl/core/arrow");
|
|
3649
3404
|
function encodeGeoArrowBoxVector(column, sourceEncoding, dimension) {
|
|
3650
|
-
const coordinateSize = dimension ? getDimensionSize2(dimension) :
|
|
3405
|
+
const coordinateSize = dimension ? getDimensionSize2(dimension) : inferDimension(column, sourceEncoding);
|
|
3651
3406
|
const effectiveDimension = dimension || getDimensionName(coordinateSize);
|
|
3652
3407
|
const bounds = [];
|
|
3653
3408
|
for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {
|
|
@@ -3682,7 +3437,7 @@ function getRowBounds(value, sourceEncoding, dimension) {
|
|
|
3682
3437
|
return null;
|
|
3683
3438
|
if (sourceEncoding === "geoarrow.wkb") {
|
|
3684
3439
|
const bytes = value;
|
|
3685
|
-
const statistics = (0,
|
|
3440
|
+
const statistics = (0, import_arrow7.scanWKB)(bytes);
|
|
3686
3441
|
return statistics.bounds ? boundsFromRecord(statistics.bounds, dimension) : null;
|
|
3687
3442
|
}
|
|
3688
3443
|
if (sourceEncoding === "geoarrow.wkt") {
|
|
@@ -3796,7 +3551,7 @@ function isBoxRecord(value) {
|
|
|
3796
3551
|
function isVectorLike2(value) {
|
|
3797
3552
|
return Boolean(value && typeof value.length === "number" && typeof value.get === "function");
|
|
3798
3553
|
}
|
|
3799
|
-
function
|
|
3554
|
+
function inferDimension(column, sourceEncoding) {
|
|
3800
3555
|
var _a, _b;
|
|
3801
3556
|
if (sourceEncoding === "geoarrow.wkb") {
|
|
3802
3557
|
let coordinateSize = 2;
|
|
@@ -3805,7 +3560,7 @@ function inferDimension2(column, sourceEncoding) {
|
|
|
3805
3560
|
if (value == null)
|
|
3806
3561
|
continue;
|
|
3807
3562
|
const bytes = value;
|
|
3808
|
-
const statistics = (0,
|
|
3563
|
+
const statistics = (0, import_arrow7.scanWKB)(bytes);
|
|
3809
3564
|
const hasZ = ((_a = statistics.bounds) == null ? void 0 : _a.zmin) !== void 0;
|
|
3810
3565
|
const hasM = ((_b = statistics.bounds) == null ? void 0 : _b.mmin) !== void 0;
|
|
3811
3566
|
coordinateSize = Math.max(coordinateSize, hasZ && hasM ? 4 : hasZ || hasM ? 3 : 2);
|
|
@@ -3865,7 +3620,7 @@ function getBoxFieldNames2(dimension) {
|
|
|
3865
3620
|
|
|
3866
3621
|
// dist/geoarrow/get-geoarrow-vertex-count.js
|
|
3867
3622
|
var arrow12 = __toESM(require("apache-arrow"), 1);
|
|
3868
|
-
var
|
|
3623
|
+
var import_arrow8 = require("@math.gl/core/arrow");
|
|
3869
3624
|
|
|
3870
3625
|
// dist/geoarrow/geoarrow-functions.js
|
|
3871
3626
|
var arrow9 = __toESM(require("apache-arrow"), 1);
|
|
@@ -4194,7 +3949,7 @@ function validateCoordinateType(type, path, state, issues) {
|
|
|
4194
3949
|
message: "GeoArrow coordinates must contain two, three, or four values."
|
|
4195
3950
|
});
|
|
4196
3951
|
} else {
|
|
4197
|
-
state.dimensions.push(
|
|
3952
|
+
state.dimensions.push(dimensionFromSize2(type.listSize));
|
|
4198
3953
|
state.coordinates.push("interleaved");
|
|
4199
3954
|
}
|
|
4200
3955
|
recordFloatPrecision(type.children[0].type, `${path}.child[0]`, state, issues);
|
|
@@ -4485,7 +4240,7 @@ function getCommonValue(values) {
|
|
|
4485
4240
|
function sameNames(left, right) {
|
|
4486
4241
|
return left.length === right.length && left.every((name, index) => name === right[index]);
|
|
4487
4242
|
}
|
|
4488
|
-
function
|
|
4243
|
+
function dimensionFromSize2(size) {
|
|
4489
4244
|
return size === 2 ? "xy" : size === 3 ? "xyz" : size === 4 ? "xyzm" : null;
|
|
4490
4245
|
}
|
|
4491
4246
|
|
|
@@ -4641,30 +4396,16 @@ function getWKTDataVertexCount(data) {
|
|
|
4641
4396
|
const value = vector.get(rowIndex);
|
|
4642
4397
|
if (value == null)
|
|
4643
4398
|
continue;
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4399
|
+
try {
|
|
4400
|
+
if (/\(\s*\)\s*$/.test(String(value)))
|
|
4401
|
+
throw new Error("Empty WKT geometry body");
|
|
4402
|
+
vertexCount += (0, import_arrow8.countWKTVertices)(String(value), { inferDimensions: true });
|
|
4403
|
+
} catch (cause) {
|
|
4404
|
+
throw new Error(`Invalid WKT geometry at row ${rowIndex}.`, { cause });
|
|
4405
|
+
}
|
|
4648
4406
|
}
|
|
4649
4407
|
return vertexCount;
|
|
4650
4408
|
}
|
|
4651
|
-
function countGeometryVertices(geometry) {
|
|
4652
|
-
switch (geometry.type) {
|
|
4653
|
-
case "Point":
|
|
4654
|
-
return geometry.coordinates.length > 0 ? 1 : 0;
|
|
4655
|
-
case "MultiPoint":
|
|
4656
|
-
case "LineString":
|
|
4657
|
-
return geometry.coordinates.length;
|
|
4658
|
-
case "Polygon":
|
|
4659
|
-
return geometry.coordinates.reduce((count, ring) => count + ring.length, 0);
|
|
4660
|
-
case "MultiLineString":
|
|
4661
|
-
return geometry.coordinates.reduce((count, line) => count + line.length, 0);
|
|
4662
|
-
case "MultiPolygon":
|
|
4663
|
-
return geometry.coordinates.reduce((count, polygon) => count + polygon.reduce((polygonCount, ring) => polygonCount + ring.length, 0), 0);
|
|
4664
|
-
case "GeometryCollection":
|
|
4665
|
-
return geometry.geometries.reduce((count, childGeometry) => count + countGeometryVertices(childGeometry), 0);
|
|
4666
|
-
}
|
|
4667
|
-
}
|
|
4668
4409
|
function getWKBDataVertexCount(data) {
|
|
4669
4410
|
const vector = new arrow12.Vector([data]);
|
|
4670
4411
|
let vertexCount = 0;
|
|
@@ -4678,7 +4419,7 @@ function getWKBDataVertexCount(data) {
|
|
|
4678
4419
|
}
|
|
4679
4420
|
function getWKBVertexCount(wkb) {
|
|
4680
4421
|
try {
|
|
4681
|
-
return (0,
|
|
4422
|
+
return (0, import_arrow8.scanWKB)(wkb).coordinateCount;
|
|
4682
4423
|
} catch (error) {
|
|
4683
4424
|
if (error instanceof Error && error.message.startsWith("Unsupported WKB geometry type")) {
|
|
4684
4425
|
throw new Error("Unsupported geometry type");
|
|
@@ -4735,7 +4476,7 @@ function getVariableLengthByteCount(column, sourceEncoding) {
|
|
|
4735
4476
|
}
|
|
4736
4477
|
|
|
4737
4478
|
// dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js
|
|
4738
|
-
var
|
|
4479
|
+
var import_arrow10 = require("@math.gl/core/arrow");
|
|
4739
4480
|
var DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH = 64;
|
|
4740
4481
|
function convertGeoArrowVector(column, sourceEncoding, targetEncoding, options) {
|
|
4741
4482
|
const maxGeometryCollectionDepth = getMaxGeometryCollectionDepth(options);
|
|
@@ -4911,26 +4652,39 @@ function convertGeometryColumn(column, sourceEncoding, targetEncoding, geometryC
|
|
|
4911
4652
|
return arrow13.vectorFromArray(nativeValues, getTargetArrowType(targetEncoding, targetDimension, options, (options == null ? void 0 : options.dimension) || getDimensionFromGeometryTypes(options == null ? void 0 : options.geometryTypes)));
|
|
4912
4653
|
}
|
|
4913
4654
|
function convertGeometryColumnWithMath(column, sourceEncoding, targetEncoding, options) {
|
|
4655
|
+
if (sourceEncoding === "geoarrow.wkt" && isConcreteNativeEncoding(targetEncoding) && (options == null ? void 0 : options.dimension) && options.maxGeometryCollectionDepth === DEFAULT_MAX_GEOMETRY_COLLECTION_DEPTH) {
|
|
4656
|
+
try {
|
|
4657
|
+
const source = (0, import_arrow10.makeGeoArrowColumnFromArrowVector)(column, { encoding: sourceEncoding });
|
|
4658
|
+
return (0, import_arrow10.makeArrowVectorFromGeoArrowColumn)((0, import_arrow9.decodeGeoArrowWKT)(source, {
|
|
4659
|
+
encoding: targetEncoding,
|
|
4660
|
+
dimension: options.dimension,
|
|
4661
|
+
coordinateLayout: options.coordinates,
|
|
4662
|
+
offsetType: options.offsetType
|
|
4663
|
+
}));
|
|
4664
|
+
} catch {
|
|
4665
|
+
return null;
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4914
4668
|
const sourceIsNative = isMathGeoArrowNativeEncoding(sourceEncoding);
|
|
4915
4669
|
const targetIsNative = isMathGeoArrowNativeEncoding(targetEncoding);
|
|
4916
4670
|
const supportsConversion = sourceEncoding === "geoarrow.wkb" && targetIsNative || sourceIsNative && (targetEncoding === "geoarrow.wkb" || targetEncoding === "geoarrow.wkt") || sourceIsNative && targetIsNative;
|
|
4917
4671
|
if (!supportsConversion)
|
|
4918
4672
|
return null;
|
|
4919
4673
|
const declaredDimension = getDimensionFromGeometryTypes(options == null ? void 0 : options.geometryTypes);
|
|
4920
|
-
const sourceColumn = (0,
|
|
4674
|
+
const sourceColumn = (0, import_arrow10.makeGeoArrowColumnFromArrowVector)(column, {
|
|
4921
4675
|
encoding: sourceEncoding,
|
|
4922
4676
|
dimension: sourceEncoding === "geoarrow.wkb" ? declaredDimension || "xy" : declaredDimension || (targetEncoding === "geoarrow.wkb" ? options == null ? void 0 : options.dimension : void 0)
|
|
4923
4677
|
});
|
|
4924
4678
|
if (sourceEncoding === "geoarrow.wkb") {
|
|
4925
4679
|
try {
|
|
4926
|
-
const decodedColumn = (0,
|
|
4680
|
+
const decodedColumn = (0, import_arrow9.decodeGeoArrowWKB)(sourceColumn, {
|
|
4927
4681
|
encoding: targetEncoding,
|
|
4928
4682
|
dimension: (options == null ? void 0 : options.dimension) || declaredDimension || "infer",
|
|
4929
4683
|
coordinateLayout: (options == null ? void 0 : options.coordinates) || "interleaved",
|
|
4930
4684
|
offsetType: (options == null ? void 0 : options.offsetType) || "int32",
|
|
4931
4685
|
traversal: { maximumDepth: options == null ? void 0 : options.maxGeometryCollectionDepth }
|
|
4932
4686
|
});
|
|
4933
|
-
return (0,
|
|
4687
|
+
return (0, import_arrow10.makeArrowVectorFromGeoArrowColumn)(decodedColumn);
|
|
4934
4688
|
} catch (error) {
|
|
4935
4689
|
if ((options == null ? void 0 : options.maxGeometryCollectionDepth) !== void 0 && error instanceof Error && error.message.includes("nesting exceeds maximumDepth")) {
|
|
4936
4690
|
throw new Error(`GeometryCollection nesting exceeds maxGeometryCollectionDepth (${options.maxGeometryCollectionDepth}).`);
|
|
@@ -4939,16 +4693,16 @@ function convertGeometryColumnWithMath(column, sourceEncoding, targetEncoding, o
|
|
|
4939
4693
|
}
|
|
4940
4694
|
}
|
|
4941
4695
|
if (targetEncoding === "geoarrow.wkb" || targetEncoding === "geoarrow.wkt") {
|
|
4942
|
-
const nativeColumn = targetEncoding === "geoarrow.wkt" && (options == null ? void 0 : options.dimension) ? (0,
|
|
4943
|
-
return (0,
|
|
4696
|
+
const nativeColumn = targetEncoding === "geoarrow.wkt" && (options == null ? void 0 : options.dimension) ? (0, import_arrow9.convertGeoArrowColumn)(sourceColumn, { dimension: options.dimension }) : sourceColumn;
|
|
4697
|
+
return (0, import_arrow10.makeArrowVectorFromGeoArrowColumn)((0, import_arrow9.convertGeoArrowColumn)(nativeColumn, { encoding: targetEncoding }));
|
|
4944
4698
|
}
|
|
4945
|
-
const convertedColumn = (0,
|
|
4699
|
+
const convertedColumn = (0, import_arrow9.convertGeoArrowColumn)(sourceColumn, {
|
|
4946
4700
|
encoding: targetEncoding,
|
|
4947
4701
|
dimension: options == null ? void 0 : options.dimension,
|
|
4948
4702
|
coordinateLayout: (options == null ? void 0 : options.coordinates) || "preserve",
|
|
4949
4703
|
offsetType: (options == null ? void 0 : options.offsetType) || "preserve"
|
|
4950
4704
|
});
|
|
4951
|
-
return convertedColumn === sourceColumn ? column : (0,
|
|
4705
|
+
return convertedColumn === sourceColumn ? column : (0, import_arrow10.makeArrowVectorFromGeoArrowColumn)(convertedColumn);
|
|
4952
4706
|
}
|
|
4953
4707
|
function isMathGeoArrowNativeEncoding(encoding) {
|
|
4954
4708
|
return encoding === "geoarrow.point" || encoding === "geoarrow.linestring" || encoding === "geoarrow.polygon" || encoding === "geoarrow.multipoint" || encoding === "geoarrow.multilinestring" || encoding === "geoarrow.multipolygon" || encoding === "geoarrow.geometry" || encoding === "geoarrow.geometrycollection";
|
|
@@ -5804,18 +5558,18 @@ function padPosition(position, targetDimension) {
|
|
|
5804
5558
|
}
|
|
5805
5559
|
|
|
5806
5560
|
// dist/geoarrow/geoarrow-bounds.js
|
|
5807
|
-
var import_arrow10 = require("@math.gl/core/arrow");
|
|
5808
|
-
var import_arrow11 = require("@math.gl/core/arrow");
|
|
5809
5561
|
var import_arrow12 = require("@math.gl/core/arrow");
|
|
5562
|
+
var import_arrow13 = require("@math.gl/core/arrow");
|
|
5563
|
+
var import_arrow14 = require("@math.gl/core/arrow");
|
|
5810
5564
|
|
|
5811
5565
|
// dist/geoarrow/binary-polygon-to-geoarrow.js
|
|
5812
|
-
var
|
|
5566
|
+
var import_arrow11 = require("@math.gl/core/arrow");
|
|
5813
5567
|
function makeGeoArrowColumnFromBinaryPolygon(geometry, options) {
|
|
5814
5568
|
const { dimension } = options;
|
|
5815
5569
|
if (!["xy", "xyz", "xym", "xyzm"].includes(dimension)) {
|
|
5816
5570
|
throw new Error("Binary polygon dimension must be xy, xyz, xym, or xyzm.");
|
|
5817
5571
|
}
|
|
5818
|
-
const coordinateSize = (0,
|
|
5572
|
+
const coordinateSize = (0, import_arrow11.getGeoArrowDimensionSize)(dimension);
|
|
5819
5573
|
const positions = geometry.positions.value;
|
|
5820
5574
|
if (!(positions instanceof Float32Array || positions instanceof Float64Array) || geometry.positions.size !== coordinateSize || positions.length % coordinateSize !== 0) {
|
|
5821
5575
|
throw new Error("Binary polygon positions must be floating-point tuples matching dimension.");
|
|
@@ -5884,7 +5638,7 @@ function getGeoArrowRowBounds(column, encodingOrOptions) {
|
|
|
5884
5638
|
if (typeof encodingOrOptions === "string") {
|
|
5885
5639
|
throw new Error("Binary polygon bounds require an explicit dimension option.");
|
|
5886
5640
|
}
|
|
5887
|
-
return (0,
|
|
5641
|
+
return (0, import_arrow14.getGeoArrowRowBounds)(makeGeoArrowColumnFromBinaryPolygon(column, encodingOrOptions));
|
|
5888
5642
|
}
|
|
5889
5643
|
if (typeof encodingOrOptions !== "string") {
|
|
5890
5644
|
throw new Error("Arrow vector bounds require a GeoArrow encoding.");
|
|
@@ -5893,7 +5647,7 @@ function getGeoArrowRowBounds(column, encodingOrOptions) {
|
|
|
5893
5647
|
if (encoding !== "geoarrow.wkb" && encoding !== "geoarrow.wkt") {
|
|
5894
5648
|
const names = encoding === "geoarrow.box" ? column.type.children.map((field) => field.name) : [];
|
|
5895
5649
|
const dimension = encoding === "geoarrow.box" ? names.includes("zmin") ? names.includes("mmin") ? "xyzm" : "xyz" : names.includes("mmin") ? "xym" : "xy" : void 0;
|
|
5896
|
-
return (0,
|
|
5650
|
+
return (0, import_arrow14.getGeoArrowRowBounds)((0, import_arrow13.makeGeoArrowColumnFromArrowVector)(column, { encoding, dimension }));
|
|
5897
5651
|
}
|
|
5898
5652
|
const bounds = [];
|
|
5899
5653
|
for (let rowIndex = 0; rowIndex < column.length; rowIndex++) {
|
|
@@ -5906,7 +5660,7 @@ function getGeoArrowBounds(value, encoding) {
|
|
|
5906
5660
|
return null;
|
|
5907
5661
|
if (encoding === "geoarrow.wkb") {
|
|
5908
5662
|
const bytes = value;
|
|
5909
|
-
const statistics = (0,
|
|
5663
|
+
const statistics = (0, import_arrow12.scanWKB)(bytes);
|
|
5910
5664
|
return statistics.bounds ? [
|
|
5911
5665
|
statistics.bounds.xmin,
|
|
5912
5666
|
statistics.bounds.ymin,
|