@loaders.gl/geospatial 5.0.0-beta.10 → 5.0.0-beta.11
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/dbf-loader-types.cjs +1 -1
- package/dist/dbf-loader.cjs +2 -4
- package/dist/dbf-loader.cjs.map +2 -2
- package/dist/dbf-worker.js +22 -79
- package/dist/flatgeobuf/flatgeobuf-loader-types.cjs +1 -1
- package/dist/flatgeobuf/flatgeobuf-loader-types.js +1 -1
- package/dist/flatgeobuf/lib/parse-flatgeobuf.cjs +6 -20
- package/dist/flatgeobuf/lib/parse-flatgeobuf.cjs.map +2 -2
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts +4 -4
- package/dist/flatgeobuf/lib/parse-flatgeobuf.d.ts.map +1 -1
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js +9 -22
- package/dist/flatgeobuf/lib/parse-flatgeobuf.js.map +1 -1
- package/dist/flatgeobuf-loader-types.cjs +1 -1
- package/dist/flatgeobuf-worker.js +655 -77
- package/dist/geopackage/geopackage-source-loader.cjs +1 -1
- package/dist/geopackage/geopackage-source-loader.cjs.map +2 -2
- package/dist/geopackage/geopackage-source-loader.js +1 -1
- package/dist/geopackage/geopackage-source-loader.js.map +1 -1
- package/dist/geopackage/lib/parse-geopackage.cjs +2 -6
- package/dist/geopackage/lib/parse-geopackage.cjs.map +2 -2
- package/dist/geopackage/lib/parse-geopackage.d.ts +3 -3
- package/dist/geopackage/lib/parse-geopackage.d.ts.map +1 -1
- package/dist/geopackage/lib/parse-geopackage.js +2 -6
- package/dist/geopackage/lib/parse-geopackage.js.map +1 -1
- package/dist/geopackage-source-loader.cjs +1 -1
- package/dist/geopackage-source-loader.cjs.map +2 -2
- package/dist/gpx-loader-types.cjs +1 -1
- package/dist/kml/gpx-loader-types.cjs +1 -1
- package/dist/kml/gpx-loader-types.js +1 -1
- package/dist/kml/kml-loader-types.cjs +1 -1
- package/dist/kml/kml-loader-types.js +1 -1
- package/dist/kml/kml-writer.cjs +1 -1
- package/dist/kml/kml-writer.js +1 -1
- package/dist/kml/kmz-loader-types.cjs +1 -1
- package/dist/kml/kmz-loader-types.js +1 -1
- package/dist/kml/lib/feature-collection-to-arrow.cjs +1 -1
- package/dist/kml/lib/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/kml/lib/feature-collection-to-arrow.js +1 -1
- package/dist/kml/lib/feature-collection-to-arrow.js.map +1 -1
- package/dist/kml/tcx-loader-types.cjs +1 -1
- package/dist/kml/tcx-loader-types.js +1 -1
- package/dist/kml-loader-types.cjs +1 -1
- package/dist/kml-writer.cjs +1 -1
- package/dist/kmz-loader-types.cjs +1 -1
- package/dist/shapefile/dbf-loader-types.cjs +1 -1
- package/dist/shapefile/dbf-loader-types.js +1 -1
- package/dist/shapefile/dbf-loader.cjs +2 -4
- package/dist/shapefile/dbf-loader.cjs.map +2 -2
- package/dist/shapefile/dbf-loader.d.ts.map +1 -1
- package/dist/shapefile/dbf-loader.js +3 -5
- package/dist/shapefile/dbf-loader.js.map +1 -1
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.cjs +1 -5
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.cjs.map +2 -2
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts +5 -4
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.d.ts.map +1 -1
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js +2 -6
- package/dist/shapefile/lib/parsers/build-geoarrow-geometry-arrow.js.map +1 -1
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.cjs.map +2 -2
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts +4 -3
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.d.ts.map +1 -1
- package/dist/shapefile/lib/parsers/build-wkb-geometry-arrow.js.map +1 -1
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.cjs +7 -10
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.cjs.map +2 -2
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts +3 -3
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.d.ts.map +1 -1
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js +11 -9
- package/dist/shapefile/lib/parsers/parse-shp-to-arrow.js.map +1 -1
- package/dist/shapefile/lib/shapefile-worker-transport.cjs +0 -3
- package/dist/shapefile/lib/shapefile-worker-transport.cjs.map +2 -2
- package/dist/shapefile/lib/shapefile-worker-transport.d.ts.map +1 -1
- package/dist/shapefile/lib/shapefile-worker-transport.js +1 -5
- package/dist/shapefile/lib/shapefile-worker-transport.js.map +1 -1
- package/dist/shapefile/shapefile-arrow-loader.cjs +53 -48
- package/dist/shapefile/shapefile-arrow-loader.cjs.map +2 -2
- package/dist/shapefile/shapefile-arrow-loader.d.ts +5 -3
- package/dist/shapefile/shapefile-arrow-loader.d.ts.map +1 -1
- package/dist/shapefile/shapefile-arrow-loader.js +54 -52
- package/dist/shapefile/shapefile-arrow-loader.js.map +1 -1
- package/dist/shapefile/shapefile-loader-types.cjs +1 -1
- package/dist/shapefile/shapefile-loader-types.d.ts +4 -4
- package/dist/shapefile/shapefile-loader-types.js +1 -1
- package/dist/shapefile/shapefile-loader.cjs +19 -55
- package/dist/shapefile/shapefile-loader.cjs.map +2 -2
- package/dist/shapefile/shapefile-loader.d.ts +5 -42
- package/dist/shapefile/shapefile-loader.d.ts.map +1 -1
- package/dist/shapefile/shapefile-loader.js +22 -64
- package/dist/shapefile/shapefile-loader.js.map +1 -1
- package/dist/shapefile/shp-loader-types.cjs +1 -1
- package/dist/shapefile/shp-loader-types.js +1 -1
- package/dist/shapefile/shp-loader.cjs +1 -44
- package/dist/shapefile/shp-loader.cjs.map +2 -2
- package/dist/shapefile/shp-loader.d.ts +1 -115
- package/dist/shapefile/shp-loader.d.ts.map +1 -1
- package/dist/shapefile/shp-loader.js +1 -48
- package/dist/shapefile/shp-loader.js.map +1 -1
- package/dist/shapefile-arrow-loader.cjs +53 -48
- package/dist/shapefile-arrow-loader.cjs.map +2 -2
- package/dist/shapefile-loader-types.cjs +1 -1
- package/dist/shapefile-loader.cjs +19 -55
- package/dist/shapefile-loader.cjs.map +2 -2
- package/dist/shapefile-worker.js +117 -272
- package/dist/shp-loader-types.cjs +1 -1
- package/dist/shp-loader.cjs +1 -44
- package/dist/shp-loader.cjs.map +2 -2
- package/dist/shp-worker.js +16964 -17085
- package/dist/tcx-loader-types.cjs +1 -1
- package/dist/wkt/lib/version.cjs +1 -1
- package/dist/wkt/lib/version.js +1 -1
- package/dist/wkt-worker.js +1 -1
- package/dist/workers/shapefile-worker.cjs +3 -3
- package/dist/workers/shapefile-worker.cjs.map +2 -2
- package/dist/workers/shapefile-worker.js +4 -4
- package/dist/workers/shapefile-worker.js.map +1 -1
- package/dist/workers/shp-worker.cjs +1 -1
- package/dist/workers/shp-worker.cjs.map +2 -2
- package/dist/workers/shp-worker.js +2 -2
- package/dist/workers/shp-worker.js.map +1 -1
- package/package.json +6 -6
- package/src/flatgeobuf/lib/parse-flatgeobuf.ts +15 -33
- package/src/geopackage/geopackage-source-loader.ts +1 -1
- package/src/geopackage/lib/parse-geopackage.ts +4 -9
- package/src/kml/lib/feature-collection-to-arrow.ts +1 -1
- package/src/shapefile/dbf-loader.ts +4 -7
- package/src/shapefile/lib/parsers/build-geoarrow-geometry-arrow.ts +5 -9
- package/src/shapefile/lib/parsers/build-wkb-geometry-arrow.ts +4 -3
- package/src/shapefile/lib/parsers/parse-shp-to-arrow.ts +14 -20
- package/src/shapefile/lib/shapefile-worker-transport.ts +1 -6
- package/src/shapefile/shapefile-arrow-loader.ts +76 -70
- package/src/shapefile/shapefile-loader.ts +40 -90
- package/src/shapefile/shp-loader.ts +7 -61
- package/src/workers/shapefile-worker.ts +4 -4
- package/src/workers/shp-worker.ts +2 -2
package/dist/shapefile-worker.js
CHANGED
|
@@ -734,7 +734,7 @@
|
|
|
734
734
|
"../core/src/loader-utils/lib/log-utils/log.ts"() {
|
|
735
735
|
"use strict";
|
|
736
736
|
init_log();
|
|
737
|
-
VERSION2 = true ? "5.0.0-beta.
|
|
737
|
+
VERSION2 = true ? "5.0.0-beta.11" : "latest";
|
|
738
738
|
version = VERSION2[0] >= "0" && VERSION2[0] <= "9" ? `v${VERSION2}` : "";
|
|
739
739
|
log2 = createLog();
|
|
740
740
|
NullLog = class {
|
|
@@ -3230,16 +3230,6 @@
|
|
|
3230
3230
|
}
|
|
3231
3231
|
});
|
|
3232
3232
|
|
|
3233
|
-
// ../core/src/loader-utils/lib/scan-utils/table-scan-batch.ts
|
|
3234
|
-
function makeTableScanBatch(table) {
|
|
3235
|
-
return { ...table, batchType: "data", length: table.data.numRows };
|
|
3236
|
-
}
|
|
3237
|
-
var init_table_scan_batch = __esm({
|
|
3238
|
-
"../core/src/loader-utils/lib/scan-utils/table-scan-batch.ts"() {
|
|
3239
|
-
"use strict";
|
|
3240
|
-
}
|
|
3241
|
-
});
|
|
3242
|
-
|
|
3243
3233
|
// ../core/src/loader-utils/lib/crs/crs-reprojection.ts
|
|
3244
3234
|
var CRSReprojectionError;
|
|
3245
3235
|
var init_crs_reprojection = __esm({
|
|
@@ -6596,7 +6586,6 @@
|
|
|
6596
6586
|
init_binary_chunk_reader();
|
|
6597
6587
|
init_async_iteration();
|
|
6598
6588
|
init_request_credentials();
|
|
6599
|
-
init_table_scan_batch();
|
|
6600
6589
|
init_crs_reprojection();
|
|
6601
6590
|
}
|
|
6602
6591
|
});
|
|
@@ -22841,7 +22830,7 @@ return true;`);
|
|
|
22841
22830
|
});
|
|
22842
22831
|
|
|
22843
22832
|
// ../core/src/lib/loader-utils/native-arrow.ts
|
|
22844
|
-
function
|
|
22833
|
+
function isArrowRecordBatch2(value2) {
|
|
22845
22834
|
return Boolean(
|
|
22846
22835
|
value2 && typeof value2 === "object" && value2[/* @__PURE__ */ Symbol.for("apache-arrow/RecordBatch")] === true
|
|
22847
22836
|
);
|
|
@@ -33646,11 +33635,7 @@ return true;`);
|
|
|
33646
33635
|
for (const row of rows) {
|
|
33647
33636
|
arrowTableBuilder.addObjectRow(row);
|
|
33648
33637
|
}
|
|
33649
|
-
return
|
|
33650
|
-
shape: "arrow-table",
|
|
33651
|
-
schema: structuredClone(arrowTableBuilder.schema),
|
|
33652
|
-
data: arrowTableBuilder.finishTable()
|
|
33653
|
-
};
|
|
33638
|
+
return arrowTableBuilder.finishTable();
|
|
33654
33639
|
}
|
|
33655
33640
|
function convertFeaturesToNativeGeoArrowTable(features, options, preference) {
|
|
33656
33641
|
const geometries = features.map((feature) => feature.geometry || null);
|
|
@@ -33727,11 +33712,7 @@ return true;`);
|
|
|
33727
33712
|
nullCount: 0,
|
|
33728
33713
|
children: children2
|
|
33729
33714
|
});
|
|
33730
|
-
return
|
|
33731
|
-
shape: "arrow-table",
|
|
33732
|
-
schema: convertArrowToSchema(nextSchema),
|
|
33733
|
-
data: new Table(nextSchema, [new RecordBatch3(nextSchema, data)])
|
|
33734
|
-
};
|
|
33715
|
+
return new Table(nextSchema, [new RecordBatch3(nextSchema, data)]);
|
|
33735
33716
|
}
|
|
33736
33717
|
function resolveGeoArrowEncodingPreference(options) {
|
|
33737
33718
|
return options?.geoarrow?.encodingPreference ?? options?.encodingPreference;
|
|
@@ -34309,11 +34290,7 @@ return true;`);
|
|
|
34309
34290
|
geometryData
|
|
34310
34291
|
]);
|
|
34311
34292
|
const recordBatch = new RecordBatch3(arrowSchema, structData);
|
|
34312
|
-
return
|
|
34313
|
-
shape: "arrow-table",
|
|
34314
|
-
schema,
|
|
34315
|
-
data: new Table(arrowSchema, [recordBatch])
|
|
34316
|
-
};
|
|
34293
|
+
return new Table(arrowSchema, [recordBatch]);
|
|
34317
34294
|
}
|
|
34318
34295
|
function makeWKBGeometryData(geometries, options = {}) {
|
|
34319
34296
|
const valueOffsets = measureWKBGeometryOffsets(geometries);
|
|
@@ -34666,11 +34643,7 @@ return true;`);
|
|
|
34666
34643
|
geometryData
|
|
34667
34644
|
]);
|
|
34668
34645
|
const recordBatch = new RecordBatch3(arrowSchema, structData);
|
|
34669
|
-
return
|
|
34670
|
-
shape: "arrow-table",
|
|
34671
|
-
schema,
|
|
34672
|
-
data: new Table(arrowSchema, [recordBatch])
|
|
34673
|
-
};
|
|
34646
|
+
return new Table(arrowSchema, [recordBatch]);
|
|
34674
34647
|
}
|
|
34675
34648
|
function getDefaultGeoArrowEncoding(header) {
|
|
34676
34649
|
switch (header?.type) {
|
|
@@ -34787,9 +34760,11 @@ return true;`);
|
|
|
34787
34760
|
geometry: geometry ? convertWKBToGeometry(geometry.buffer) : null,
|
|
34788
34761
|
properties: {}
|
|
34789
34762
|
}));
|
|
34790
|
-
|
|
34791
|
-
|
|
34792
|
-
);
|
|
34763
|
+
const table = convertFeaturesToGeoArrowTable(geometryFeatures, {
|
|
34764
|
+
encodingPreference: preference
|
|
34765
|
+
});
|
|
34766
|
+
if (table.batches.length) yield* table.batches;
|
|
34767
|
+
else yield makeArrowMetadataBatch(table.schema);
|
|
34793
34768
|
return;
|
|
34794
34769
|
}
|
|
34795
34770
|
if (shouldUseTypedGeoArrow(options?.shp?.geoarrowEncoding, preference)) {
|
|
@@ -34807,7 +34782,7 @@ return true;`);
|
|
|
34807
34782
|
const schema = buildOutputSchema(header);
|
|
34808
34783
|
const arrowTable = makeWKBGeometryArrowTable2(geometries, schema);
|
|
34809
34784
|
yieldedDataBatch = true;
|
|
34810
|
-
yield
|
|
34785
|
+
yield* arrowTable.batches;
|
|
34811
34786
|
}
|
|
34812
34787
|
if (!yieldedDataBatch) {
|
|
34813
34788
|
yield makeEmptyArrowBatch(buildOutputSchema(header));
|
|
@@ -34867,17 +34842,12 @@ return true;`);
|
|
|
34867
34842
|
};
|
|
34868
34843
|
}
|
|
34869
34844
|
function makeEmptyArrowBatch(schema) {
|
|
34870
|
-
|
|
34871
|
-
throw new Error("SHP Arrow batch requires a schema");
|
|
34872
|
-
}
|
|
34873
|
-
const table = new ArrowTableBuilder(schema).finishTable();
|
|
34874
|
-
return makeTableScanBatch({ shape: "arrow-table", data: table, schema });
|
|
34845
|
+
return makeArrowMetadataBatch(convertSchemaToArrow(schema));
|
|
34875
34846
|
}
|
|
34876
34847
|
var GEOMETRY_COLUMN_NAME2, SHP_HEADER_SIZE4;
|
|
34877
34848
|
var init_parse_shp_to_arrow = __esm({
|
|
34878
34849
|
"src/shapefile/lib/parsers/parse-shp-to-arrow.ts"() {
|
|
34879
34850
|
"use strict";
|
|
34880
|
-
init_loader_utils();
|
|
34881
34851
|
init_feature_table();
|
|
34882
34852
|
init_geometry_codecs();
|
|
34883
34853
|
init_geometry_field();
|
|
@@ -34946,7 +34916,7 @@ return true;`);
|
|
|
34946
34916
|
"src/shapefile/shp-loader-types.ts"() {
|
|
34947
34917
|
"use strict";
|
|
34948
34918
|
init_shp_format();
|
|
34949
|
-
VERSION3 = true ? "5.0.0-beta.
|
|
34919
|
+
VERSION3 = true ? "5.0.0-beta.11" : "latest";
|
|
34950
34920
|
SHPLoader = {
|
|
34951
34921
|
dataType: null,
|
|
34952
34922
|
batchType: null,
|
|
@@ -35018,20 +34988,34 @@ return true;`);
|
|
|
35018
34988
|
}
|
|
35019
34989
|
});
|
|
35020
34990
|
|
|
34991
|
+
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js
|
|
34992
|
+
function isArrowTable3(value2) {
|
|
34993
|
+
const table = value2;
|
|
34994
|
+
return Boolean(table && Number.isInteger(table.numRows) && Array.isArray(table.batches) && Array.isArray(table.schema?.fields) && typeof table.get === "function" && typeof table.getChild === "function");
|
|
34995
|
+
}
|
|
34996
|
+
function isArrowRecordBatch3(value2) {
|
|
34997
|
+
const batch = value2;
|
|
34998
|
+
return Boolean(batch && Number.isInteger(batch.numRows) && Array.isArray(batch.schema?.fields) && Array.isArray(batch.data?.children) && typeof batch.get === "function" && typeof batch.getChild === "function");
|
|
34999
|
+
}
|
|
35000
|
+
var init_arrow_column_utils = __esm({
|
|
35001
|
+
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js"() {
|
|
35002
|
+
}
|
|
35003
|
+
});
|
|
35004
|
+
|
|
35021
35005
|
// ../../node_modules/@math.gl/arrow/dist/arrow/split-arrow-buffers.js
|
|
35022
35006
|
function splitArrowBuffers(input, options = {}) {
|
|
35023
35007
|
const retainedBuffers = /* @__PURE__ */ new Set();
|
|
35024
35008
|
const visited = /* @__PURE__ */ new Set();
|
|
35025
35009
|
for (const retained of options.retain ?? []) {
|
|
35026
|
-
const chunks =
|
|
35010
|
+
const chunks = isArrowTable3(retained) ? retained.batches.map((batch) => batch.data) : isArrowVector2(retained) ? retained.data : [isArrowRecordBatch3(retained) ? retained.data : retained];
|
|
35027
35011
|
for (const data of chunks)
|
|
35028
35012
|
collectArrowBuffers(data, retainedBuffers, visited);
|
|
35029
35013
|
}
|
|
35030
35014
|
const context = { ...options, copies: /* @__PURE__ */ new WeakMap(), retainedBuffers };
|
|
35031
|
-
if (
|
|
35015
|
+
if (isArrowTable3(input)) {
|
|
35032
35016
|
return splitArrowTableBuffersInternal(input, context);
|
|
35033
35017
|
}
|
|
35034
|
-
if (
|
|
35018
|
+
if (isArrowRecordBatch3(input)) {
|
|
35035
35019
|
return splitArrowRecordBatchBuffers(input, context);
|
|
35036
35020
|
}
|
|
35037
35021
|
if (isArrowVector2(input)) {
|
|
@@ -35039,12 +35023,6 @@ return true;`);
|
|
|
35039
35023
|
}
|
|
35040
35024
|
return splitArrowDataBuffers(input, context);
|
|
35041
35025
|
}
|
|
35042
|
-
function isArrowTable2(input) {
|
|
35043
|
-
return "batches" in input;
|
|
35044
|
-
}
|
|
35045
|
-
function isArrowRecordBatch2(input) {
|
|
35046
|
-
return "schema" in input && "data" in input && !Array.isArray(input.data);
|
|
35047
|
-
}
|
|
35048
35026
|
function isArrowVector2(input) {
|
|
35049
35027
|
return "data" in input && Array.isArray(input.data);
|
|
35050
35028
|
}
|
|
@@ -35116,6 +35094,7 @@ return true;`);
|
|
|
35116
35094
|
init_Arrow_dom();
|
|
35117
35095
|
init_arrow_record_batch();
|
|
35118
35096
|
init_arrow_data();
|
|
35097
|
+
init_arrow_column_utils();
|
|
35119
35098
|
}
|
|
35120
35099
|
});
|
|
35121
35100
|
|
|
@@ -35228,12 +35207,6 @@ return true;`);
|
|
|
35228
35207
|
}
|
|
35229
35208
|
});
|
|
35230
35209
|
|
|
35231
|
-
// ../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js
|
|
35232
|
-
var init_arrow_column_utils = __esm({
|
|
35233
|
-
"../../node_modules/@math.gl/arrow/dist/arrow/arrow-column-utils.js"() {
|
|
35234
|
-
}
|
|
35235
|
-
});
|
|
35236
|
-
|
|
35237
35210
|
// ../../node_modules/@math.gl/arrow/dist/arrow/index.js
|
|
35238
35211
|
var init_arrow = __esm({
|
|
35239
35212
|
"../../node_modules/@math.gl/arrow/dist/arrow/index.js"() {
|
|
@@ -35258,27 +35231,6 @@ return true;`);
|
|
|
35258
35231
|
});
|
|
35259
35232
|
|
|
35260
35233
|
// ../core/src/arrow-worker-transport.ts
|
|
35261
|
-
function serializeArrowWorkerTable(result) {
|
|
35262
|
-
if (!isArrowTableWrapper(result)) {
|
|
35263
|
-
throw new Error("Workers require Arrow table output");
|
|
35264
|
-
}
|
|
35265
|
-
const { data, shape: _shape, ...metadata } = result;
|
|
35266
|
-
return {
|
|
35267
|
-
transport: "arrow-column-envelope",
|
|
35268
|
-
metadata: structuredClone(metadata),
|
|
35269
|
-
...serializeWorkerColumns(data, { copy: "all" })
|
|
35270
|
-
};
|
|
35271
|
-
}
|
|
35272
|
-
function deserializeArrowWorkerTable(result) {
|
|
35273
|
-
if (isArrowWorkerEnvelope(result)) {
|
|
35274
|
-
return { ...result.metadata, shape: "arrow-table", data: hydrateWorkerTable(result) };
|
|
35275
|
-
}
|
|
35276
|
-
if (isLegacyArrowWorkerEnvelope(result)) {
|
|
35277
|
-
const { arrowBatchMetadata: _snapshots, data: _columns, ...metadata } = result;
|
|
35278
|
-
return { ...metadata, data: hydrateWorkerTable(result) };
|
|
35279
|
-
}
|
|
35280
|
-
throw new Error("Workers require Arrow column transport");
|
|
35281
|
-
}
|
|
35282
35234
|
function serializeNativeArrowWorkerResult(result, options = { copy: "all" }) {
|
|
35283
35235
|
const batch = result instanceof RecordBatch3;
|
|
35284
35236
|
if (!batch && !(result instanceof Table)) {
|
|
@@ -35300,41 +35252,19 @@ return true;`);
|
|
|
35300
35252
|
const data = hydrateWorkerTable(payload.columns);
|
|
35301
35253
|
return payload.transport === "arrow-record-batch" ? data.batches[0] : data;
|
|
35302
35254
|
}
|
|
35303
|
-
function isArrowTableWrapper(value2) {
|
|
35304
|
-
const table = value2;
|
|
35305
|
-
return Boolean(
|
|
35306
|
-
table && table.shape === "arrow-table" && table.data && typeof table.data === "object" && "batches" in table.data
|
|
35307
|
-
);
|
|
35308
|
-
}
|
|
35309
35255
|
function hasArrowWorkerColumns(value2) {
|
|
35310
35256
|
const columns = value2;
|
|
35311
35257
|
return columns?.data?.transport === "arrow-js" && Array.isArray(columns.data.batches);
|
|
35312
35258
|
}
|
|
35313
|
-
function isArrowWorkerEnvelope(value2) {
|
|
35314
|
-
return value2?.transport === "arrow-column-envelope" && hasArrowWorkerColumns(value2);
|
|
35315
|
-
}
|
|
35316
|
-
function isLegacyArrowWorkerEnvelope(value2) {
|
|
35317
|
-
return value2?.shape === "arrow-table" && hasArrowWorkerColumns(value2);
|
|
35318
|
-
}
|
|
35319
35259
|
function serializeWorkerColumns(table, options) {
|
|
35320
35260
|
return {
|
|
35321
35261
|
arrowBatchMetadata: snapshotBatchMetadata(table),
|
|
35322
|
-
data:
|
|
35262
|
+
data: dehydrateArrowTable(table, options)
|
|
35323
35263
|
};
|
|
35324
35264
|
}
|
|
35325
|
-
function dehydrateWorkerTable(table, options) {
|
|
35326
|
-
const payload = dehydrateArrowTable(table, options);
|
|
35327
|
-
if (table.numCols === 0) {
|
|
35328
|
-
for (const [index, batch] of table.batches.entries()) {
|
|
35329
|
-
payload.batches[index].length = batch.numRows;
|
|
35330
|
-
}
|
|
35331
|
-
}
|
|
35332
|
-
return payload;
|
|
35333
|
-
}
|
|
35334
35265
|
function snapshotBatchMetadata(table) {
|
|
35335
35266
|
return table.batches.map((batch) => ({
|
|
35336
|
-
schema: tableToIPC(new Table(batch.schema, []))
|
|
35337
|
-
metadata: Array.from(batch.metadata)
|
|
35267
|
+
schema: tableToIPC(new Table(batch.schema, []))
|
|
35338
35268
|
}));
|
|
35339
35269
|
}
|
|
35340
35270
|
function hydrateWorkerTable(result) {
|
|
@@ -35342,18 +35272,11 @@ return true;`);
|
|
|
35342
35272
|
const table = hydrateArrowTable(data);
|
|
35343
35273
|
const batches = table.batches.map((batch, index) => {
|
|
35344
35274
|
const snapshot = arrowBatchMetadata?.[index];
|
|
35345
|
-
|
|
35275
|
+
return snapshot ? createRecordBatchWithMetadata(
|
|
35346
35276
|
tableFromIPC(snapshot.schema).schema,
|
|
35347
35277
|
batch.data,
|
|
35348
|
-
new Map(snapshot.metadata)
|
|
35278
|
+
snapshot.metadata ? new Map(snapshot.metadata) : getRecordBatchMetadata(batch)
|
|
35349
35279
|
) : batch;
|
|
35350
|
-
const rowCount = data.batches[index].length;
|
|
35351
|
-
if (restored.numCols === 0 && restored.numRows !== rowCount) {
|
|
35352
|
-
Object.defineProperty(restored, "data", {
|
|
35353
|
-
value: new Data(new Struct([]), 0, rowCount, 0, void 0, [])
|
|
35354
|
-
});
|
|
35355
|
-
}
|
|
35356
|
-
return restored;
|
|
35357
35280
|
});
|
|
35358
35281
|
return new Table(table.schema, batches);
|
|
35359
35282
|
}
|
|
@@ -35369,7 +35292,6 @@ return true;`);
|
|
|
35369
35292
|
function serializeShapefileWorkerResult(result) {
|
|
35370
35293
|
if (result instanceof Table || result instanceof RecordBatch3)
|
|
35371
35294
|
return serializeNativeArrowWorkerResult(result);
|
|
35372
|
-
if (result?.shape === "arrow-table") return serializeArrowWorkerTable(result);
|
|
35373
35295
|
if (Array.isArray(result) && result.every((value2) => value2 === null || value2 instanceof Uint8Array)) {
|
|
35374
35296
|
return { transport: "shp-wkb", geometries: result.map((value2) => value2?.slice() ?? null) };
|
|
35375
35297
|
}
|
|
@@ -35389,8 +35311,6 @@ return true;`);
|
|
|
35389
35311
|
function deserializeShapefileWorkerResult(result) {
|
|
35390
35312
|
if (result?.transport === "arrow-table-columns" || result?.transport === "arrow-record-batch")
|
|
35391
35313
|
return deserializeNativeArrowWorkerResult(result);
|
|
35392
|
-
if (result?.transport === "arrow-column-envelope" || result?.shape === "arrow-table")
|
|
35393
|
-
return deserializeArrowWorkerTable(result);
|
|
35394
35314
|
if (result?.transport === "shapefile-header") return result.header;
|
|
35395
35315
|
if (result?.transport === "shp-wkb") {
|
|
35396
35316
|
return result.header ? {
|
|
@@ -35418,18 +35338,10 @@ return true;`);
|
|
|
35418
35338
|
function getSHPShape(options) {
|
|
35419
35339
|
return options?.shp?.shape || "arrow";
|
|
35420
35340
|
}
|
|
35421
|
-
|
|
35422
|
-
return result?.shape === "arrow-table";
|
|
35423
|
-
}
|
|
35424
|
-
function unwrapSHPTable(result) {
|
|
35425
|
-
if (!isSHPArrowTable(result)) return result;
|
|
35426
|
-
return result.data;
|
|
35427
|
-
}
|
|
35428
|
-
var _SHPWorkerLoaderPreload, SHPWorkerLoaderMetadataWithoutPreload, _SHPLoaderPreload, SHPLoaderMetadataWithoutPreload, SHPWorkerLoaderWithParser, SHPColumnLoader, SHPLoaderWithParser;
|
|
35341
|
+
var _SHPWorkerLoaderPreload, SHPWorkerLoaderMetadataWithoutPreload, _SHPLoaderPreload, SHPLoaderMetadataWithoutPreload, SHPWorkerLoaderWithParser, SHPLoaderWithParser;
|
|
35429
35342
|
var init_shp_loader = __esm({
|
|
35430
35343
|
"src/shapefile/shp-loader.ts"() {
|
|
35431
35344
|
"use strict";
|
|
35432
|
-
init_schema_utils();
|
|
35433
35345
|
init_parse_shp();
|
|
35434
35346
|
init_parse_shp_to_arrow();
|
|
35435
35347
|
init_shp_loader_types();
|
|
@@ -35440,7 +35352,7 @@ return true;`);
|
|
|
35440
35352
|
SHPWorkerLoaderWithParser = {
|
|
35441
35353
|
...SHPWorkerLoaderMetadataWithoutPreload
|
|
35442
35354
|
};
|
|
35443
|
-
|
|
35355
|
+
SHPLoaderWithParser = {
|
|
35444
35356
|
...SHPLoaderMetadataWithoutPreload,
|
|
35445
35357
|
dataType: null,
|
|
35446
35358
|
batchType: null,
|
|
@@ -35455,39 +35367,6 @@ return true;`);
|
|
|
35455
35367
|
serializeWorkerBatch: serializeShapefileWorkerBatch,
|
|
35456
35368
|
deserializeWorkerBatch: deserializeShapefileWorkerBatch
|
|
35457
35369
|
};
|
|
35458
|
-
SHPLoaderWithParser = {
|
|
35459
|
-
...SHPLoaderMetadataWithoutPreload,
|
|
35460
|
-
serializeWorkerResult: serializeShapefileWorkerResult,
|
|
35461
|
-
serializeWorkerBatch: serializeShapefileWorkerBatch,
|
|
35462
|
-
dataType: null,
|
|
35463
|
-
batchType: null,
|
|
35464
|
-
async parse(input, options, context) {
|
|
35465
|
-
return unwrapSHPTable(await SHPColumnLoader.parse(input, options, context));
|
|
35466
|
-
},
|
|
35467
|
-
parseSync(input, options, context) {
|
|
35468
|
-
return unwrapSHPTable(SHPColumnLoader.parseSync(input, options, context));
|
|
35469
|
-
},
|
|
35470
|
-
async *parseInBatches(input, options, context) {
|
|
35471
|
-
for await (const batch of SHPColumnLoader.parseInBatches(input, options, context)) {
|
|
35472
|
-
if (isSHPArrowTable(batch)) {
|
|
35473
|
-
const table = unwrapSHPTable(batch);
|
|
35474
|
-
if (table.batches.length) yield* table.batches;
|
|
35475
|
-
else yield makeArrowMetadataBatch(table.schema);
|
|
35476
|
-
} else yield batch;
|
|
35477
|
-
}
|
|
35478
|
-
},
|
|
35479
|
-
deserializeWorkerResult(result) {
|
|
35480
|
-
return unwrapSHPTable(deserializeShapefileWorkerResult(result));
|
|
35481
|
-
},
|
|
35482
|
-
deserializeWorkerBatch(result) {
|
|
35483
|
-
const batch = deserializeShapefileWorkerBatch(
|
|
35484
|
-
result
|
|
35485
|
-
);
|
|
35486
|
-
if (!isSHPArrowTable(batch)) return batch;
|
|
35487
|
-
const table = unwrapSHPTable(batch);
|
|
35488
|
-
return table.batches[0] ?? makeArrowMetadataBatch(table.schema);
|
|
35489
|
-
}
|
|
35490
|
-
};
|
|
35491
35370
|
}
|
|
35492
35371
|
});
|
|
35493
35372
|
|
|
@@ -36055,7 +35934,7 @@ return true;`);
|
|
|
36055
35934
|
var init_dbf_loader_types = __esm({
|
|
36056
35935
|
"src/shapefile/dbf-loader-types.ts"() {
|
|
36057
35936
|
"use strict";
|
|
36058
|
-
VERSION4 = true ? "5.0.0-beta.
|
|
35937
|
+
VERSION4 = true ? "5.0.0-beta.11" : "latest";
|
|
36059
35938
|
DBFLoader = {
|
|
36060
35939
|
name: "DBF",
|
|
36061
35940
|
dataType: null,
|
|
@@ -36085,8 +35964,7 @@ return true;`);
|
|
|
36085
35964
|
return options?.dbf?.shape || "arrow";
|
|
36086
35965
|
}
|
|
36087
35966
|
function deserializeDBFWorkerResult(result, options) {
|
|
36088
|
-
const
|
|
36089
|
-
const table = "shape" in value2 ? value2.data : value2;
|
|
35967
|
+
const table = deserializeShapefileWorkerResult(result);
|
|
36090
35968
|
const shape = getDBFShape(options);
|
|
36091
35969
|
if (shape === "arrow") return table;
|
|
36092
35970
|
const rows = table.toArray().map((row) => row.toJSON());
|
|
@@ -36096,8 +35974,7 @@ return true;`);
|
|
|
36096
35974
|
return { shape: "object-row-table", schema, data: rows };
|
|
36097
35975
|
}
|
|
36098
35976
|
function deserializeDBFWorkerBatch(result, options) {
|
|
36099
|
-
const
|
|
36100
|
-
const batch = "shape" in value2 ? value2.data.batches[0] ?? makeArrowMetadataBatch(value2.data.schema) : value2;
|
|
35977
|
+
const batch = deserializeShapefileWorkerResult(result);
|
|
36101
35978
|
return batch instanceof RecordBatch3 && getDBFShape(options) !== "arrow" ? batch.toArray().map((row) => row.toJSON()) : batch;
|
|
36102
35979
|
}
|
|
36103
35980
|
var _DBFWorkerLoaderPreload, DBFWorkerLoaderMetadataWithoutPreload, _DBFLoaderPreload, DBFLoaderMetadataWithoutPreload, DBFWorkerLoaderWithParser, DBFColumnLoader, DBFLoaderWithParser;
|
|
@@ -36421,7 +36298,7 @@ return true;`);
|
|
|
36421
36298
|
transform
|
|
36422
36299
|
);
|
|
36423
36300
|
if (options?.geoarrow?.encodingPreference === "geoarrow.geometry" || options?.shapefile?.geoarrow?.encodingPreference === "geoarrow.geometry") {
|
|
36424
|
-
const geometryColumn = geometryTable.
|
|
36301
|
+
const geometryColumn = geometryTable.getChild(GEOMETRY_COLUMN_NAME3);
|
|
36425
36302
|
const geometries = geometryColumn?.toArray() || [];
|
|
36426
36303
|
geometryTable = convertFeaturesToGeoArrowTable(
|
|
36427
36304
|
geometries.map((geometry) => ({
|
|
@@ -36451,11 +36328,18 @@ return true;`);
|
|
|
36451
36328
|
context
|
|
36452
36329
|
);
|
|
36453
36330
|
propertySchema = convertArrowToSchema(propertyData.schema);
|
|
36454
|
-
propertyTable =
|
|
36331
|
+
propertyTable = propertyData;
|
|
36455
36332
|
}
|
|
36456
|
-
const schema = buildOutputSchema2(
|
|
36333
|
+
const schema = buildOutputSchema2(
|
|
36334
|
+
propertySchema,
|
|
36335
|
+
header,
|
|
36336
|
+
convertArrowToSchema(geometryTable.schema)
|
|
36337
|
+
);
|
|
36457
36338
|
const table = propertyTable ? appendGeometryColumnToArrowTable(propertyTable, geometryTable, schema) : geometryTable;
|
|
36458
|
-
|
|
36339
|
+
const encoded = encodeShapefileHeader({ header, encoding: cpg, prj, shx });
|
|
36340
|
+
table.schema.metadata.set(SHAPEFILE_HEADER_KEY, encoded);
|
|
36341
|
+
for (const batch of table.batches) batch.schema.metadata.set(SHAPEFILE_HEADER_KEY, encoded);
|
|
36342
|
+
return table;
|
|
36459
36343
|
}
|
|
36460
36344
|
async function* parseShapefileToArrowInBatches(asyncIterator, options, context) {
|
|
36461
36345
|
if (getTypedGeoArrowEncoding(options)) {
|
|
@@ -36483,6 +36367,7 @@ return true;`);
|
|
|
36483
36367
|
const shapeIterator = getAsyncIterator(shapeIterable);
|
|
36484
36368
|
const shapeHeader = await getNextNonMetadataValue(shapeIterator);
|
|
36485
36369
|
const header = shapeHeader;
|
|
36370
|
+
const encodedHeader = encodeShapefileHeader({ header, encoding: cpg, prj, shx });
|
|
36486
36371
|
let propertyIterator = null;
|
|
36487
36372
|
let propertySchema = null;
|
|
36488
36373
|
const dbfResponse = context?.url ? await context.fetch(replaceExtension(context.url, "dbf")).catch(() => null) : null;
|
|
@@ -36504,13 +36389,13 @@ return true;`);
|
|
|
36504
36389
|
);
|
|
36505
36390
|
propertyIterator = getAsyncIterator(propertyIterable);
|
|
36506
36391
|
const firstPropertyBatch = await getNextArrowBatch(propertyIterator);
|
|
36507
|
-
propertySchema = firstPropertyBatch
|
|
36392
|
+
propertySchema = firstPropertyBatch ? convertArrowToSchema(firstPropertyBatch.schema) : null;
|
|
36508
36393
|
const outputSchema2 = buildOutputSchema2(propertySchema, header);
|
|
36509
36394
|
const propertyQueue = [];
|
|
36510
36395
|
const geometryQueue = [];
|
|
36511
36396
|
let yieldedDataBatch2 = false;
|
|
36512
|
-
if (firstPropertyBatch && firstPropertyBatch.
|
|
36513
|
-
propertyQueue.push(firstPropertyBatch.
|
|
36397
|
+
if (firstPropertyBatch && firstPropertyBatch.numRows > 0) {
|
|
36398
|
+
propertyQueue.push(new Table(firstPropertyBatch.schema, [firstPropertyBatch]));
|
|
36514
36399
|
}
|
|
36515
36400
|
let shapeDone = false;
|
|
36516
36401
|
let propertyDone = false;
|
|
@@ -36522,7 +36407,7 @@ return true;`);
|
|
|
36522
36407
|
} else if (shapeBatch.value?.batchType !== "metadata") {
|
|
36523
36408
|
const transform = getReprojectionTransform(prj, options);
|
|
36524
36409
|
geometryQueue.push(
|
|
36525
|
-
makeGeometryArrowTable(shapeBatch.value, header, transform)
|
|
36410
|
+
makeGeometryArrowTable(shapeBatch.value, header, transform)
|
|
36526
36411
|
);
|
|
36527
36412
|
}
|
|
36528
36413
|
}
|
|
@@ -36530,8 +36415,8 @@ return true;`);
|
|
|
36530
36415
|
const propertyBatch = await getNextArrowBatch(propertyIterator);
|
|
36531
36416
|
if (!propertyBatch) {
|
|
36532
36417
|
propertyDone = true;
|
|
36533
|
-
} else if (propertyBatch.
|
|
36534
|
-
propertyQueue.push(propertyBatch.
|
|
36418
|
+
} else if (propertyBatch.numRows > 0) {
|
|
36419
|
+
propertyQueue.push(new Table(propertyBatch.schema, [propertyBatch]));
|
|
36535
36420
|
}
|
|
36536
36421
|
}
|
|
36537
36422
|
const rowCount = Math.min(getQueuedRowCount(geometryQueue), getQueuedRowCount(propertyQueue));
|
|
@@ -36543,16 +36428,14 @@ return true;`);
|
|
|
36543
36428
|
}
|
|
36544
36429
|
const propertyTable = takeRowsFromQueue(propertyQueue, rowCount);
|
|
36545
36430
|
const geometryTable = takeRowsFromQueue(geometryQueue, rowCount);
|
|
36546
|
-
const batch = appendGeometryColumnToArrowTable(
|
|
36547
|
-
{ shape: "arrow-table", schema: propertySchema || void 0, data: propertyTable },
|
|
36548
|
-
{ shape: "arrow-table", data: geometryTable },
|
|
36549
|
-
outputSchema2
|
|
36550
|
-
);
|
|
36431
|
+
const batch = appendGeometryColumnToArrowTable(propertyTable, geometryTable, outputSchema2);
|
|
36551
36432
|
yieldedDataBatch2 = true;
|
|
36552
|
-
|
|
36433
|
+
const recordBatch = batch.batches[0];
|
|
36434
|
+
recordBatch.schema.metadata.set(SHAPEFILE_HEADER_KEY, encodedHeader);
|
|
36435
|
+
yield recordBatch;
|
|
36553
36436
|
}
|
|
36554
36437
|
if (!yieldedDataBatch2) {
|
|
36555
|
-
yield
|
|
36438
|
+
yield makeEmptyArrowBatch2(outputSchema2, encodedHeader);
|
|
36556
36439
|
}
|
|
36557
36440
|
return;
|
|
36558
36441
|
}
|
|
@@ -36573,13 +36456,13 @@ return true;`);
|
|
|
36573
36456
|
transform
|
|
36574
36457
|
);
|
|
36575
36458
|
yieldedDataBatch = true;
|
|
36576
|
-
|
|
36577
|
-
|
|
36578
|
-
|
|
36579
|
-
}
|
|
36459
|
+
for (const batch of arrowTable.batches) {
|
|
36460
|
+
batch.schema.metadata.set(SHAPEFILE_HEADER_KEY, encodedHeader);
|
|
36461
|
+
yield batch;
|
|
36462
|
+
}
|
|
36580
36463
|
}
|
|
36581
36464
|
if (!yieldedDataBatch) {
|
|
36582
|
-
yield
|
|
36465
|
+
yield makeEmptyArrowBatch2(outputSchema, encodedHeader);
|
|
36583
36466
|
}
|
|
36584
36467
|
}
|
|
36585
36468
|
function buildOutputSchema2(propertySchema, header, geometrySchema) {
|
|
@@ -36604,19 +36487,15 @@ return true;`);
|
|
|
36604
36487
|
return makeWKBGeometryArrowTable2(geometries, geometrySchema, transform);
|
|
36605
36488
|
}
|
|
36606
36489
|
function appendGeometryColumnToArrowTable(propertyTable, geometryTable, schema) {
|
|
36607
|
-
const propertyBatch = propertyTable.
|
|
36608
|
-
const geometryBatch = geometryTable.
|
|
36490
|
+
const propertyBatch = propertyTable.batches[0];
|
|
36491
|
+
const geometryBatch = geometryTable.batches[0];
|
|
36609
36492
|
const arrowSchema = convertSchemaToArrow(schema);
|
|
36610
36493
|
const structField = new Struct(arrowSchema.fields);
|
|
36611
36494
|
const children2 = [...propertyBatch.data.children, geometryBatch.data.children[0]];
|
|
36612
|
-
const rowCount = Math.max(propertyTable.
|
|
36495
|
+
const rowCount = Math.max(propertyTable.numRows, geometryTable.numRows);
|
|
36613
36496
|
const structData = new Data(structField, 0, rowCount, 0, void 0, children2);
|
|
36614
36497
|
const recordBatch = new RecordBatch3(arrowSchema, structData);
|
|
36615
|
-
return
|
|
36616
|
-
shape: "arrow-table",
|
|
36617
|
-
schema,
|
|
36618
|
-
data: new Table(arrowSchema, [recordBatch])
|
|
36619
|
-
};
|
|
36498
|
+
return new Table(arrowSchema, [recordBatch]);
|
|
36620
36499
|
}
|
|
36621
36500
|
function getReprojectionTransform(sourceCrs, options) {
|
|
36622
36501
|
const { reproject = false, targetCrs = "WGS84" } = options?.gis || {};
|
|
@@ -36694,21 +36573,11 @@ return true;`);
|
|
|
36694
36573
|
async function getNextArrowBatch(iterator) {
|
|
36695
36574
|
while (true) {
|
|
36696
36575
|
const result = await iterator.next();
|
|
36697
|
-
if (result.done)
|
|
36698
|
-
|
|
36576
|
+
if (result.done) return null;
|
|
36577
|
+
if (isArrowRecordBatch2(result.value)) {
|
|
36578
|
+
const batch = result.value;
|
|
36579
|
+
return Object.getPrototypeOf(batch) === RecordBatch3.prototype ? batch : importDBFRecordBatch(batch, convertArrowToSchema(batch.schema));
|
|
36699
36580
|
}
|
|
36700
|
-
if (isNativeArrowRecordBatch(result.value)) {
|
|
36701
|
-
const recordBatch = result.value;
|
|
36702
|
-
const schema = convertArrowToSchema(recordBatch.schema);
|
|
36703
|
-
const batch = Object.getPrototypeOf(recordBatch) === RecordBatch3.prototype ? recordBatch : importDBFRecordBatch(recordBatch, schema);
|
|
36704
|
-
const data = new Table(batch.schema, [batch]);
|
|
36705
|
-
return makeTableScanBatch({
|
|
36706
|
-
shape: "arrow-table",
|
|
36707
|
-
schema,
|
|
36708
|
-
data
|
|
36709
|
-
});
|
|
36710
|
-
}
|
|
36711
|
-
if (result.value?.shape === "arrow-table") return result.value;
|
|
36712
36581
|
}
|
|
36713
36582
|
}
|
|
36714
36583
|
function importDBFRecordBatch(batch, tableSchema) {
|
|
@@ -36742,14 +36611,24 @@ return true;`);
|
|
|
36742
36611
|
return table;
|
|
36743
36612
|
}
|
|
36744
36613
|
const result = table.slice(0, rowCount);
|
|
36745
|
-
queue[0] = table.slice(rowCount
|
|
36614
|
+
queue[0] = table.slice(rowCount);
|
|
36746
36615
|
return result;
|
|
36747
36616
|
}
|
|
36748
|
-
function makeEmptyArrowBatch2(schema) {
|
|
36749
|
-
const
|
|
36750
|
-
|
|
36617
|
+
function makeEmptyArrowBatch2(schema, header) {
|
|
36618
|
+
const nativeSchema = convertSchemaToArrow(schema);
|
|
36619
|
+
nativeSchema.metadata.set(SHAPEFILE_HEADER_KEY, header);
|
|
36620
|
+
return makeArrowMetadataBatch(nativeSchema);
|
|
36621
|
+
}
|
|
36622
|
+
function encodeShapefileHeader({
|
|
36623
|
+
shx,
|
|
36624
|
+
...header
|
|
36625
|
+
}) {
|
|
36626
|
+
return JSON.stringify({
|
|
36627
|
+
...header,
|
|
36628
|
+
...shx ? { shx: { offsets: Array.from(shx.offsets), lengths: Array.from(shx.lengths) } } : {}
|
|
36629
|
+
});
|
|
36751
36630
|
}
|
|
36752
|
-
var GEOMETRY_COLUMN_NAME3;
|
|
36631
|
+
var GEOMETRY_COLUMN_NAME3, SHAPEFILE_HEADER_KEY;
|
|
36753
36632
|
var init_shapefile_arrow_loader = __esm({
|
|
36754
36633
|
"src/shapefile/shapefile-arrow-loader.ts"() {
|
|
36755
36634
|
"use strict";
|
|
@@ -36768,6 +36647,7 @@ return true;`);
|
|
|
36768
36647
|
init_build_wkb_geometry_arrow();
|
|
36769
36648
|
init_build_geoarrow_geometry_arrow();
|
|
36770
36649
|
GEOMETRY_COLUMN_NAME3 = "geometry";
|
|
36650
|
+
SHAPEFILE_HEADER_KEY = "loaders.gl.shapefile.header";
|
|
36771
36651
|
}
|
|
36772
36652
|
});
|
|
36773
36653
|
|
|
@@ -36781,7 +36661,7 @@ return true;`);
|
|
|
36781
36661
|
"src/shapefile/shapefile-loader-types.ts"() {
|
|
36782
36662
|
"use strict";
|
|
36783
36663
|
init_shp_format();
|
|
36784
|
-
VERSION5 = true ? "5.0.0-beta.
|
|
36664
|
+
VERSION5 = true ? "5.0.0-beta.11" : "latest";
|
|
36785
36665
|
ShapefileLoader = {
|
|
36786
36666
|
defaultShape: "arrow",
|
|
36787
36667
|
supportsNativeArrow: true,
|
|
@@ -36807,16 +36687,23 @@ return true;`);
|
|
|
36807
36687
|
// src/shapefile/shapefile-loader.ts
|
|
36808
36688
|
var shapefile_loader_exports = {};
|
|
36809
36689
|
__export(shapefile_loader_exports, {
|
|
36810
|
-
ShapefileColumnLoader: () => ShapefileColumnLoader,
|
|
36811
36690
|
ShapefileLoaderWithParser: () => ShapefileLoaderWithParser
|
|
36812
36691
|
});
|
|
36813
36692
|
function getShapefileShape(options) {
|
|
36814
36693
|
return options?.shapefile?.shape || "arrow";
|
|
36815
36694
|
}
|
|
36816
|
-
function deserializeShapefileOutput(result, options) {
|
|
36695
|
+
function deserializeShapefileOutput(result, options, isBatch) {
|
|
36817
36696
|
const table = deserializeShapefileWorkerResult(result);
|
|
36818
36697
|
if (getShapefileShape(options) === "arrow") return table;
|
|
36819
|
-
const
|
|
36698
|
+
const header = JSON.parse(table.schema.metadata.get(SHAPEFILE_HEADER_KEY) || "{}");
|
|
36699
|
+
const loaderData = header.shx ? {
|
|
36700
|
+
...header,
|
|
36701
|
+
shx: {
|
|
36702
|
+
offsets: Int32Array.from(header.shx.offsets),
|
|
36703
|
+
lengths: Int32Array.from(header.shx.lengths)
|
|
36704
|
+
}
|
|
36705
|
+
} : header;
|
|
36706
|
+
const features = table.toArray().map((row) => {
|
|
36820
36707
|
const { geometry, ...properties } = row.toJSON();
|
|
36821
36708
|
return {
|
|
36822
36709
|
type: "Feature",
|
|
@@ -36824,39 +36711,23 @@ return true;`);
|
|
|
36824
36711
|
properties
|
|
36825
36712
|
};
|
|
36826
36713
|
});
|
|
36827
|
-
if (getShapefileShape(options) === "geojson-table" && !
|
|
36714
|
+
if (getShapefileShape(options) === "geojson-table" && !isBatch) {
|
|
36828
36715
|
return {
|
|
36829
|
-
...
|
|
36716
|
+
...loaderData,
|
|
36830
36717
|
shape: "geojson-table",
|
|
36831
36718
|
type: "FeatureCollection",
|
|
36832
36719
|
schema: {
|
|
36833
|
-
fields: table.schema
|
|
36720
|
+
fields: convertArrowToSchema(table.schema).fields.filter(
|
|
36721
|
+
(field) => field.name !== "geometry"
|
|
36722
|
+
),
|
|
36834
36723
|
metadata: {}
|
|
36835
36724
|
},
|
|
36836
36725
|
features
|
|
36837
36726
|
};
|
|
36838
36727
|
}
|
|
36839
|
-
return { ...
|
|
36840
|
-
}
|
|
36841
|
-
function isShapefileArrowTable(result) {
|
|
36842
|
-
return result?.shape === "arrow-table";
|
|
36843
|
-
}
|
|
36844
|
-
function unwrapShapefileTable(result) {
|
|
36845
|
-
if (!isShapefileArrowTable(result)) return result;
|
|
36846
|
-
const loaderData = result.loaderData;
|
|
36847
|
-
if (loaderData) {
|
|
36848
|
-
const { shx, ...header } = loaderData;
|
|
36849
|
-
const metadata = JSON.stringify({
|
|
36850
|
-
...header,
|
|
36851
|
-
...shx ? { shx: { offsets: Array.from(shx.offsets), lengths: Array.from(shx.lengths) } } : {}
|
|
36852
|
-
});
|
|
36853
|
-
result.data.schema.metadata.set("loaders.gl.shapefile.header", metadata);
|
|
36854
|
-
for (const batch of result.data.batches)
|
|
36855
|
-
batch.schema.metadata.set("loaders.gl.shapefile.header", metadata);
|
|
36856
|
-
}
|
|
36857
|
-
return result.data;
|
|
36728
|
+
return { ...loaderData, data: features };
|
|
36858
36729
|
}
|
|
36859
|
-
var _ShapefileLoaderPreload, ShapefileLoaderMetadataWithoutPreload,
|
|
36730
|
+
var _ShapefileLoaderPreload, ShapefileLoaderMetadataWithoutPreload, ShapefileLoaderWithParser;
|
|
36860
36731
|
var init_shapefile_loader = __esm({
|
|
36861
36732
|
"src/shapefile/shapefile-loader.ts"() {
|
|
36862
36733
|
"use strict";
|
|
@@ -36867,42 +36738,16 @@ return true;`);
|
|
|
36867
36738
|
init_shapefile_loader_types();
|
|
36868
36739
|
init_shapefile_worker_transport();
|
|
36869
36740
|
({ preload: _ShapefileLoaderPreload, ...ShapefileLoaderMetadataWithoutPreload } = ShapefileLoader);
|
|
36870
|
-
|
|
36741
|
+
ShapefileLoaderWithParser = {
|
|
36871
36742
|
...ShapefileLoaderMetadataWithoutPreload,
|
|
36872
36743
|
dataType: null,
|
|
36873
36744
|
batchType: null,
|
|
36874
36745
|
parse: (arrayBuffer, options, context) => getShapefileShape(options) === "arrow" ? parseShapefileToArrow(arrayBuffer, options, context) : parseShapefile(arrayBuffer, options, context),
|
|
36875
36746
|
parseInBatches: (asyncIterator, options, context) => getShapefileShape(options) === "arrow" ? parseShapefileToArrowInBatches(asyncIterator, options, context) : parseShapefileInBatches(asyncIterator, options, context),
|
|
36876
36747
|
serializeWorkerResult: serializeShapefileWorkerResult,
|
|
36877
|
-
deserializeWorkerResult: deserializeShapefileOutput,
|
|
36748
|
+
deserializeWorkerResult: (result, options) => deserializeShapefileOutput(result, options, false),
|
|
36878
36749
|
serializeWorkerBatch: serializeShapefileWorkerBatch,
|
|
36879
|
-
deserializeWorkerBatch: deserializeShapefileOutput
|
|
36880
|
-
};
|
|
36881
|
-
ShapefileLoaderWithParser = {
|
|
36882
|
-
...ShapefileColumnLoader,
|
|
36883
|
-
dataType: null,
|
|
36884
|
-
batchType: null,
|
|
36885
|
-
async parse(input, options, context) {
|
|
36886
|
-
return unwrapShapefileTable(await ShapefileColumnLoader.parse(input, options, context));
|
|
36887
|
-
},
|
|
36888
|
-
async *parseInBatches(input, options, context) {
|
|
36889
|
-
for await (const batch of ShapefileColumnLoader.parseInBatches(input, options, context)) {
|
|
36890
|
-
if (isShapefileArrowTable(batch)) {
|
|
36891
|
-
const table = unwrapShapefileTable(batch);
|
|
36892
|
-
if (table.batches.length) yield* table.batches;
|
|
36893
|
-
else yield makeArrowMetadataBatch(table.schema);
|
|
36894
|
-
} else yield batch;
|
|
36895
|
-
}
|
|
36896
|
-
},
|
|
36897
|
-
deserializeWorkerResult(result, options) {
|
|
36898
|
-
return unwrapShapefileTable(deserializeShapefileOutput(result, options));
|
|
36899
|
-
},
|
|
36900
|
-
deserializeWorkerBatch(result, options) {
|
|
36901
|
-
const batch = deserializeShapefileOutput(result, options);
|
|
36902
|
-
if (!isShapefileArrowTable(batch)) return batch;
|
|
36903
|
-
const table = unwrapShapefileTable(batch);
|
|
36904
|
-
return table.batches[0] ?? makeArrowMetadataBatch(table.schema);
|
|
36905
|
-
}
|
|
36750
|
+
deserializeWorkerBatch: (result, options) => deserializeShapefileOutput(result, options, true)
|
|
36906
36751
|
};
|
|
36907
36752
|
}
|
|
36908
36753
|
});
|
|
@@ -36957,10 +36802,10 @@ return true;`);
|
|
|
36957
36802
|
};
|
|
36958
36803
|
}
|
|
36959
36804
|
createLoaderWorker({
|
|
36960
|
-
...
|
|
36805
|
+
...ShapefileLoaderWithParser,
|
|
36961
36806
|
/** Parses geometries and sidecar attributes into owned transferable columns. */
|
|
36962
36807
|
parse(input, options, context) {
|
|
36963
|
-
return
|
|
36808
|
+
return ShapefileLoaderWithParser.parse(
|
|
36964
36809
|
input,
|
|
36965
36810
|
getArrowOptions(options),
|
|
36966
36811
|
createShapefileContext(context, options)
|
|
@@ -36968,7 +36813,7 @@ return true;`);
|
|
|
36968
36813
|
},
|
|
36969
36814
|
/** Joins streamed geometry and attribute batches without delegating their rows to the caller. */
|
|
36970
36815
|
parseInBatches(input, options, context) {
|
|
36971
|
-
return
|
|
36816
|
+
return ShapefileLoaderWithParser.parseInBatches(
|
|
36972
36817
|
input,
|
|
36973
36818
|
getArrowOptions(options),
|
|
36974
36819
|
createShapefileContext(context, options)
|