@loaders.gl/arrow 4.0.4 → 4.1.0-alpha.2
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-worker.js +237 -2
- package/dist/dist.dev.js +1465 -630
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +8 -4
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js +75 -54
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts +13 -0
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +1 -0
- package/dist/geoarrow/{convert-geoarrow-to-geojson.js → convert-geoarrow-to-geojson-geometry.js} +34 -27
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.js.map +1 -0
- package/dist/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-loader.js +0 -1
- package/dist/geoarrow-loader.js.map +1 -1
- package/dist/index.cjs +429 -347
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/parsers/parse-arrow-sync.d.ts.map +1 -1
- package/dist/parsers/parse-arrow-sync.js +2 -0
- package/dist/parsers/parse-arrow-sync.js.map +1 -1
- package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +1 -1
- package/dist/tables/convert-arrow-to-columnar-table.js +1 -0
- package/dist/tables/convert-arrow-to-columnar-table.js.map +1 -1
- package/dist/tables/convert-arrow-to-geojson-table.d.ts +1 -1
- package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +1 -1
- package/dist/tables/convert-arrow-to-geojson-table.js +14 -8
- package/dist/tables/convert-arrow-to-geojson-table.js.map +1 -1
- package/dist/tables/convert-columnar-to-row-table.d.ts.map +1 -1
- package/dist/tables/convert-columnar-to-row-table.js +1 -0
- package/dist/tables/convert-columnar-to-row-table.js.map +1 -1
- package/dist/triangulate-on-worker.d.ts +40 -6
- package/dist/triangulate-on-worker.d.ts.map +1 -1
- package/dist/triangulate-on-worker.js +11 -1
- package/dist/triangulate-on-worker.js.map +1 -1
- package/dist/triangulation-worker.js +11703 -34
- package/dist/workers/hard-clone.d.ts +23 -0
- package/dist/workers/hard-clone.d.ts.map +1 -0
- package/dist/workers/hard-clone.js +57 -0
- package/dist/workers/hard-clone.js.map +1 -0
- package/dist/workers/triangulation-worker.js +37 -2
- package/dist/workers/triangulation-worker.js.map +1 -1
- package/package.json +16 -10
- package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +103 -61
- package/src/geoarrow/{convert-geoarrow-to-geojson.ts → convert-geoarrow-to-geojson-geometry.ts} +56 -46
- package/src/geoarrow-loader.ts +0 -4
- package/src/index.ts +9 -3
- package/src/parsers/parse-arrow-sync.ts +6 -1
- package/src/tables/convert-arrow-to-columnar-table.ts +1 -0
- package/src/tables/convert-arrow-to-geojson-table.ts +18 -7
- package/src/tables/convert-columnar-to-row-table.ts +1 -0
- package/src/triangulate-on-worker.ts +51 -8
- package/src/workers/hard-clone.ts +162 -0
- package/src/workers/triangulation-worker.ts +57 -3
- package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts +0 -20
- package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts.map +0 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson.js.map +0 -1
package/dist/dist.dev.js
CHANGED
|
@@ -30,7 +30,6 @@ var __exports__ = (() => {
|
|
|
30
30
|
ArrowLoader: () => ArrowLoader,
|
|
31
31
|
ArrowWorkerLoader: () => ArrowWorkerLoader,
|
|
32
32
|
ArrowWriter: () => ArrowWriter,
|
|
33
|
-
BINARY_GEOMETRY_TEMPLATE: () => BINARY_GEOMETRY_TEMPLATE,
|
|
34
33
|
GeoArrowLoader: () => GeoArrowLoader,
|
|
35
34
|
GeoArrowWorkerLoader: () => GeoArrowWorkerLoader,
|
|
36
35
|
TriangulationWorker: () => TriangulationWorker,
|
|
@@ -42,8 +41,11 @@ var __exports__ = (() => {
|
|
|
42
41
|
deserializeArrowType: () => deserializeArrowType,
|
|
43
42
|
getArrowType: () => getArrowType,
|
|
44
43
|
getBinaryGeometriesFromArrow: () => getBinaryGeometriesFromArrow,
|
|
44
|
+
getBinaryGeometryTemplate: () => getBinaryGeometryTemplate,
|
|
45
45
|
getMeanCentersFromBinaryGeometries: () => getMeanCentersFromBinaryGeometries,
|
|
46
46
|
getTriangleIndices: () => getTriangleIndices,
|
|
47
|
+
hardClone: () => hardClone,
|
|
48
|
+
parseGeoArrowOnWorker: () => parseGeoArrowOnWorker,
|
|
47
49
|
parseGeometryFromArrow: () => parseGeometryFromArrow,
|
|
48
50
|
serializeArrowField: () => serializeArrowField,
|
|
49
51
|
serializeArrowMetadata: () => serializeArrowMetadata,
|
|
@@ -12427,252 +12429,519 @@ return true;`);
|
|
|
12427
12429
|
}
|
|
12428
12430
|
return {
|
|
12429
12431
|
shape: "columnar-table",
|
|
12432
|
+
schema: table.schema,
|
|
12430
12433
|
data: columnarTable
|
|
12431
12434
|
};
|
|
12432
12435
|
}
|
|
12433
12436
|
|
|
12434
|
-
// src/
|
|
12435
|
-
function
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
data: apacheArrowTable
|
|
12437
|
+
// src/schema/convert-arrow-schema.ts
|
|
12438
|
+
function serializeArrowSchema(arrowSchema) {
|
|
12439
|
+
return {
|
|
12440
|
+
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
12441
|
+
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
12440
12442
|
};
|
|
12441
|
-
const shape = options?.shape || "arrow-table";
|
|
12442
|
-
switch (shape) {
|
|
12443
|
-
case "arrow-table":
|
|
12444
|
-
return arrowTable;
|
|
12445
|
-
case "columnar-table":
|
|
12446
|
-
return convertArrowToColumnarTable(arrowTable);
|
|
12447
|
-
case "object-row-table":
|
|
12448
|
-
let columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
12449
|
-
return convertTable(columnarTable, "object-row-table");
|
|
12450
|
-
case "array-row-table":
|
|
12451
|
-
columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
12452
|
-
return convertTable(columnarTable, "array-row-table");
|
|
12453
|
-
default:
|
|
12454
|
-
throw new Error(shape);
|
|
12455
|
-
}
|
|
12456
|
-
}
|
|
12457
|
-
|
|
12458
|
-
// src/parsers/parse-arrow-in-batches.ts
|
|
12459
|
-
function parseArrowInBatches(asyncIterator) {
|
|
12460
|
-
async function* makeArrowAsyncIterator() {
|
|
12461
|
-
const readers = RecordBatchReader.readAll(asyncIterator);
|
|
12462
|
-
for await (const reader of readers) {
|
|
12463
|
-
for await (const recordBatch of reader) {
|
|
12464
|
-
const arrowTabledBatch = {
|
|
12465
|
-
shape: "arrow-table",
|
|
12466
|
-
batchType: "data",
|
|
12467
|
-
data: new Table([recordBatch]),
|
|
12468
|
-
length: recordBatch.data.length
|
|
12469
|
-
};
|
|
12470
|
-
yield arrowTabledBatch;
|
|
12471
|
-
}
|
|
12472
|
-
break;
|
|
12473
|
-
}
|
|
12474
|
-
}
|
|
12475
|
-
return makeArrowAsyncIterator();
|
|
12476
|
-
}
|
|
12477
|
-
|
|
12478
|
-
// src/arrow-loader.ts
|
|
12479
|
-
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
12480
|
-
var ArrowWorkerLoader = {
|
|
12481
|
-
name: "Apache Arrow",
|
|
12482
|
-
id: "arrow",
|
|
12483
|
-
module: "arrow",
|
|
12484
|
-
version: VERSION,
|
|
12485
|
-
category: "table",
|
|
12486
|
-
extensions: ["arrow", "feather"],
|
|
12487
|
-
mimeTypes: ["application/vnd.apache.arrow.file", "application/vnd.apache.arrow.stream", "application/octet-stream"],
|
|
12488
|
-
binary: true,
|
|
12489
|
-
tests: ["ARROW"],
|
|
12490
|
-
options: {
|
|
12491
|
-
arrow: {
|
|
12492
|
-
shape: "columnar-table"
|
|
12493
|
-
}
|
|
12494
|
-
}
|
|
12495
|
-
};
|
|
12496
|
-
var ArrowLoader = {
|
|
12497
|
-
...ArrowWorkerLoader,
|
|
12498
|
-
parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),
|
|
12499
|
-
parseSync: (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),
|
|
12500
|
-
parseInBatches: parseArrowInBatches
|
|
12501
|
-
};
|
|
12502
|
-
|
|
12503
|
-
// src/lib/encode-arrow.ts
|
|
12504
|
-
function encodeArrowSync(data) {
|
|
12505
|
-
const vectors = {};
|
|
12506
|
-
for (const arrayData of data) {
|
|
12507
|
-
const arrayVector = createVector(arrayData.array, arrayData.type);
|
|
12508
|
-
vectors[arrayData.name] = arrayVector;
|
|
12509
|
-
}
|
|
12510
|
-
const table = new Table(vectors);
|
|
12511
|
-
const arrowBuffer = tableToIPC(table);
|
|
12512
|
-
return arrowBuffer;
|
|
12513
|
-
}
|
|
12514
|
-
function createVector(array, type) {
|
|
12515
|
-
switch (type) {
|
|
12516
|
-
case VECTOR_TYPES.DATE:
|
|
12517
|
-
return vectorFromArray(array);
|
|
12518
|
-
case VECTOR_TYPES.FLOAT:
|
|
12519
|
-
default:
|
|
12520
|
-
return vectorFromArray(array);
|
|
12521
|
-
}
|
|
12522
|
-
}
|
|
12523
|
-
|
|
12524
|
-
// src/arrow-writer.ts
|
|
12525
|
-
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
12526
|
-
var ArrowWriter = {
|
|
12527
|
-
name: "Apache Arrow",
|
|
12528
|
-
id: "arrow",
|
|
12529
|
-
module: "arrow",
|
|
12530
|
-
version: VERSION2,
|
|
12531
|
-
extensions: ["arrow", "feather"],
|
|
12532
|
-
mimeTypes: ["application/vnd.apache.arrow.file", "application/vnd.apache.arrow.stream", "application/octet-stream"],
|
|
12533
|
-
binary: true,
|
|
12534
|
-
options: {},
|
|
12535
|
-
encode: async function encodeArrow(data, options) {
|
|
12536
|
-
return encodeArrowSync(data);
|
|
12537
|
-
},
|
|
12538
|
-
encodeSync(data, options) {
|
|
12539
|
-
return encodeArrowSync(data);
|
|
12540
|
-
}
|
|
12541
|
-
};
|
|
12542
|
-
|
|
12543
|
-
// ../gis/src/lib/geo/geoarrow-metadata.ts
|
|
12544
|
-
var GEOARROW_ENCODINGS = ["geoarrow.multipolygon", "geoarrow.polygon", "geoarrow.multilinestring", "geoarrow.linestring", "geoarrow.multipoint", "geoarrow.point", "geoarrow.wkb", "geoarrow.wkt"];
|
|
12545
|
-
var GEOARROW_COLUMN_METADATA_ENCODING = "ARROW:extension:name";
|
|
12546
|
-
var GEOARROW_COLUMN_METADATA_METADATA = "ARROW:extension:metadata";
|
|
12547
|
-
function getGeometryColumnsFromSchema(schema) {
|
|
12548
|
-
const geometryColumns = {};
|
|
12549
|
-
for (const field of schema.fields) {
|
|
12550
|
-
const metadata = getGeometryMetadataForField(field);
|
|
12551
|
-
if (metadata) {
|
|
12552
|
-
geometryColumns[field.name] = metadata;
|
|
12553
|
-
}
|
|
12554
|
-
}
|
|
12555
|
-
return geometryColumns;
|
|
12556
|
-
}
|
|
12557
|
-
function getGeometryMetadataForField(field) {
|
|
12558
|
-
let metadata = null;
|
|
12559
|
-
const columnMetadata = field.metadata?.[GEOARROW_COLUMN_METADATA_METADATA];
|
|
12560
|
-
if (columnMetadata) {
|
|
12561
|
-
try {
|
|
12562
|
-
metadata = JSON.parse(columnMetadata);
|
|
12563
|
-
} catch (error) {
|
|
12564
|
-
console.warn("Failed to parse GeoArrow metadata", error);
|
|
12565
|
-
}
|
|
12566
|
-
}
|
|
12567
|
-
let geoEncoding = field.metadata?.[GEOARROW_COLUMN_METADATA_ENCODING];
|
|
12568
|
-
if (geoEncoding) {
|
|
12569
|
-
geoEncoding = geoEncoding.toLowerCase();
|
|
12570
|
-
if (!GEOARROW_ENCODINGS.includes(geoEncoding)) {
|
|
12571
|
-
console.warn(`Invalid GeoArrow encoding: ${geoEncoding}`);
|
|
12572
|
-
} else {
|
|
12573
|
-
metadata = metadata || {};
|
|
12574
|
-
metadata.encoding = geoEncoding;
|
|
12575
|
-
}
|
|
12576
|
-
}
|
|
12577
|
-
return metadata || null;
|
|
12578
12443
|
}
|
|
12579
|
-
|
|
12580
|
-
|
|
12581
|
-
function _typeof(obj) {
|
|
12582
|
-
"@babel/helpers - typeof";
|
|
12583
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
12584
|
-
return typeof obj2;
|
|
12585
|
-
} : function(obj2) {
|
|
12586
|
-
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
12587
|
-
}, _typeof(obj);
|
|
12444
|
+
function deserializeArrowSchema(schema) {
|
|
12445
|
+
return new Schema2(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));
|
|
12588
12446
|
}
|
|
12589
|
-
|
|
12590
|
-
|
|
12591
|
-
function _toPrimitive(input, hint) {
|
|
12592
|
-
if (_typeof(input) !== "object" || input === null)
|
|
12593
|
-
return input;
|
|
12594
|
-
var prim = input[Symbol.toPrimitive];
|
|
12595
|
-
if (prim !== void 0) {
|
|
12596
|
-
var res = prim.call(input, hint || "default");
|
|
12597
|
-
if (_typeof(res) !== "object")
|
|
12598
|
-
return res;
|
|
12599
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
12600
|
-
}
|
|
12601
|
-
return (hint === "string" ? String : Number)(input);
|
|
12447
|
+
function serializeArrowMetadata(arrowMetadata) {
|
|
12448
|
+
return Object.fromEntries(arrowMetadata);
|
|
12602
12449
|
}
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
function _toPropertyKey(arg) {
|
|
12606
|
-
var key = _toPrimitive(arg, "string");
|
|
12607
|
-
return _typeof(key) === "symbol" ? key : String(key);
|
|
12450
|
+
function deserializeArrowMetadata(metadata) {
|
|
12451
|
+
return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
|
|
12608
12452
|
}
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
|
|
12615
|
-
|
|
12616
|
-
enumerable: true,
|
|
12617
|
-
configurable: true,
|
|
12618
|
-
writable: true
|
|
12619
|
-
});
|
|
12620
|
-
} else {
|
|
12621
|
-
obj[key] = value;
|
|
12622
|
-
}
|
|
12623
|
-
return obj;
|
|
12453
|
+
function serializeArrowField(field) {
|
|
12454
|
+
return {
|
|
12455
|
+
name: field.name,
|
|
12456
|
+
type: serializeArrowType(field.type),
|
|
12457
|
+
nullable: field.nullable,
|
|
12458
|
+
metadata: serializeArrowMetadata(field.metadata)
|
|
12459
|
+
};
|
|
12624
12460
|
}
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
var DimIndex = {
|
|
12628
|
-
x: 0,
|
|
12629
|
-
y: 1,
|
|
12630
|
-
z: 2
|
|
12631
|
-
};
|
|
12632
|
-
function getPolygonSignedArea(points, options = {}) {
|
|
12633
|
-
const {
|
|
12634
|
-
start = 0,
|
|
12635
|
-
end = points.length,
|
|
12636
|
-
plane = "xy"
|
|
12637
|
-
} = options;
|
|
12638
|
-
const dim = options.size || 2;
|
|
12639
|
-
let area2 = 0;
|
|
12640
|
-
const i0 = DimIndex[plane[0]];
|
|
12641
|
-
const i1 = DimIndex[plane[1]];
|
|
12642
|
-
for (let i = start, j = end - dim; i < end; i += dim) {
|
|
12643
|
-
area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
|
|
12644
|
-
j = i;
|
|
12645
|
-
}
|
|
12646
|
-
return area2 / 2;
|
|
12461
|
+
function deserializeArrowField(field) {
|
|
12462
|
+
return new Field2(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));
|
|
12647
12463
|
}
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12655
|
-
|
|
12656
|
-
|
|
12657
|
-
|
|
12658
|
-
|
|
12659
|
-
|
|
12660
|
-
|
|
12661
|
-
|
|
12662
|
-
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
|
|
12666
|
-
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
|
|
12670
|
-
|
|
12671
|
-
|
|
12672
|
-
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12464
|
+
function serializeArrowType(arrowType) {
|
|
12465
|
+
switch (arrowType.constructor) {
|
|
12466
|
+
case Null:
|
|
12467
|
+
return "null";
|
|
12468
|
+
case Binary:
|
|
12469
|
+
return "binary";
|
|
12470
|
+
case Bool:
|
|
12471
|
+
return "bool";
|
|
12472
|
+
case Int_:
|
|
12473
|
+
const intType = arrowType;
|
|
12474
|
+
return `${intType.isSigned ? "u" : ""}int${intType.bitWidth}`;
|
|
12475
|
+
case Int8:
|
|
12476
|
+
return "int8";
|
|
12477
|
+
case Int16:
|
|
12478
|
+
return "int16";
|
|
12479
|
+
case Int32:
|
|
12480
|
+
return "int32";
|
|
12481
|
+
case Int64:
|
|
12482
|
+
return "int64";
|
|
12483
|
+
case Uint8:
|
|
12484
|
+
return "uint8";
|
|
12485
|
+
case Uint16:
|
|
12486
|
+
return "uint16";
|
|
12487
|
+
case Uint32:
|
|
12488
|
+
return "uint32";
|
|
12489
|
+
case Uint64:
|
|
12490
|
+
return "uint64";
|
|
12491
|
+
case Float:
|
|
12492
|
+
const precision = arrowType.precision;
|
|
12493
|
+
switch (precision) {
|
|
12494
|
+
case Precision.HALF:
|
|
12495
|
+
return "float16";
|
|
12496
|
+
case Precision.SINGLE:
|
|
12497
|
+
return "float32";
|
|
12498
|
+
case Precision.DOUBLE:
|
|
12499
|
+
return "float64";
|
|
12500
|
+
default:
|
|
12501
|
+
return "float16";
|
|
12502
|
+
}
|
|
12503
|
+
case Float16:
|
|
12504
|
+
return "float16";
|
|
12505
|
+
case Float32:
|
|
12506
|
+
return "float32";
|
|
12507
|
+
case Float64:
|
|
12508
|
+
return "float64";
|
|
12509
|
+
case Utf8:
|
|
12510
|
+
return "utf8";
|
|
12511
|
+
case Decimal:
|
|
12512
|
+
const decimal = arrowType;
|
|
12513
|
+
return {
|
|
12514
|
+
type: "decimal",
|
|
12515
|
+
bitWidth: decimal.bitWidth,
|
|
12516
|
+
precision: decimal.precision,
|
|
12517
|
+
scale: decimal.scale
|
|
12518
|
+
};
|
|
12519
|
+
case Date_:
|
|
12520
|
+
const dateUnit = arrowType.unit;
|
|
12521
|
+
return dateUnit === DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
12522
|
+
case DateDay:
|
|
12523
|
+
return "date-day";
|
|
12524
|
+
case DateMillisecond:
|
|
12525
|
+
return "date-millisecond";
|
|
12526
|
+
case Time_:
|
|
12527
|
+
const timeUnit = arrowType.unit;
|
|
12528
|
+
switch (timeUnit) {
|
|
12529
|
+
case TimeUnit.SECOND:
|
|
12530
|
+
return "time-second";
|
|
12531
|
+
case TimeUnit.MILLISECOND:
|
|
12532
|
+
return "time-millisecond";
|
|
12533
|
+
case TimeUnit.MICROSECOND:
|
|
12534
|
+
return "time-microsecond";
|
|
12535
|
+
case TimeUnit.NANOSECOND:
|
|
12536
|
+
return "time-nanosecond";
|
|
12537
|
+
default:
|
|
12538
|
+
return "time-second";
|
|
12539
|
+
}
|
|
12540
|
+
case TimeMillisecond:
|
|
12541
|
+
return "time-millisecond";
|
|
12542
|
+
case TimeSecond:
|
|
12543
|
+
return "time-second";
|
|
12544
|
+
case TimeMicrosecond:
|
|
12545
|
+
return "time-microsecond";
|
|
12546
|
+
case TimeNanosecond:
|
|
12547
|
+
return "time-nanosecond";
|
|
12548
|
+
case Timestamp_:
|
|
12549
|
+
const timeStampUnit = arrowType.unit;
|
|
12550
|
+
switch (timeStampUnit) {
|
|
12551
|
+
case TimeUnit.SECOND:
|
|
12552
|
+
return "timestamp-second";
|
|
12553
|
+
case TimeUnit.MILLISECOND:
|
|
12554
|
+
return "timestamp-millisecond";
|
|
12555
|
+
case TimeUnit.MICROSECOND:
|
|
12556
|
+
return "timestamp-microsecond";
|
|
12557
|
+
case TimeUnit.NANOSECOND:
|
|
12558
|
+
return "timestamp-nanosecond";
|
|
12559
|
+
default:
|
|
12560
|
+
return "timestamp-second";
|
|
12561
|
+
}
|
|
12562
|
+
case TimestampSecond:
|
|
12563
|
+
return "timestamp-second";
|
|
12564
|
+
case TimestampMillisecond:
|
|
12565
|
+
return "timestamp-millisecond";
|
|
12566
|
+
case TimestampMicrosecond:
|
|
12567
|
+
return "timestamp-microsecond";
|
|
12568
|
+
case TimestampNanosecond:
|
|
12569
|
+
return "timestamp-nanosecond";
|
|
12570
|
+
case Interval_:
|
|
12571
|
+
const intervalUnit = arrowType.unit;
|
|
12572
|
+
switch (intervalUnit) {
|
|
12573
|
+
case IntervalUnit.DAY_TIME:
|
|
12574
|
+
return "interval-daytime";
|
|
12575
|
+
case IntervalUnit.YEAR_MONTH:
|
|
12576
|
+
return "interval-yearmonth";
|
|
12577
|
+
default:
|
|
12578
|
+
return "interval-daytime";
|
|
12579
|
+
}
|
|
12580
|
+
case IntervalDayTime:
|
|
12581
|
+
return "interval-daytime";
|
|
12582
|
+
case IntervalYearMonth:
|
|
12583
|
+
return "interval-yearmonth";
|
|
12584
|
+
case Map_:
|
|
12585
|
+
const mapType = arrowType;
|
|
12586
|
+
return {
|
|
12587
|
+
type: "map",
|
|
12588
|
+
keysSorted: mapType.keysSorted,
|
|
12589
|
+
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
12590
|
+
};
|
|
12591
|
+
case List:
|
|
12592
|
+
const listType = arrowType;
|
|
12593
|
+
const listField = listType.valueField;
|
|
12594
|
+
return {
|
|
12595
|
+
type: "list",
|
|
12596
|
+
children: [serializeArrowField(listField)]
|
|
12597
|
+
};
|
|
12598
|
+
case FixedSizeList:
|
|
12599
|
+
const fixedSizeList = arrowType;
|
|
12600
|
+
return {
|
|
12601
|
+
type: "fixed-size-list",
|
|
12602
|
+
listSize: fixedSizeList.listSize,
|
|
12603
|
+
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
12604
|
+
};
|
|
12605
|
+
case Struct:
|
|
12606
|
+
const structType = arrowType;
|
|
12607
|
+
return {
|
|
12608
|
+
type: "struct",
|
|
12609
|
+
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
12610
|
+
};
|
|
12611
|
+
default:
|
|
12612
|
+
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
12613
|
+
}
|
|
12614
|
+
}
|
|
12615
|
+
function deserializeArrowType(dataType) {
|
|
12616
|
+
if (typeof dataType === "object") {
|
|
12617
|
+
switch (dataType.type) {
|
|
12618
|
+
case "decimal":
|
|
12619
|
+
return new Decimal(dataType.precision, dataType.scale, dataType.bitWidth);
|
|
12620
|
+
case "map":
|
|
12621
|
+
let children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
|
|
12622
|
+
return new Map_(children, dataType.keysSorted);
|
|
12623
|
+
case "list":
|
|
12624
|
+
const field = deserializeArrowField(dataType.children[0]);
|
|
12625
|
+
return new List(field);
|
|
12626
|
+
case "fixed-size-list":
|
|
12627
|
+
const child = deserializeArrowField(dataType.children[0]);
|
|
12628
|
+
return new FixedSizeList(dataType.listSize, child);
|
|
12629
|
+
case "struct":
|
|
12630
|
+
children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
|
|
12631
|
+
return new Struct(children);
|
|
12632
|
+
default:
|
|
12633
|
+
throw new Error("array type not supported");
|
|
12634
|
+
}
|
|
12635
|
+
}
|
|
12636
|
+
switch (dataType) {
|
|
12637
|
+
case "null":
|
|
12638
|
+
return new Null();
|
|
12639
|
+
case "binary":
|
|
12640
|
+
return new Binary();
|
|
12641
|
+
case "bool":
|
|
12642
|
+
return new Bool();
|
|
12643
|
+
case "int8":
|
|
12644
|
+
return new Int8();
|
|
12645
|
+
case "int16":
|
|
12646
|
+
return new Int16();
|
|
12647
|
+
case "int32":
|
|
12648
|
+
return new Int32();
|
|
12649
|
+
case "int64":
|
|
12650
|
+
return new Int64();
|
|
12651
|
+
case "uint8":
|
|
12652
|
+
return new Uint8();
|
|
12653
|
+
case "uint16":
|
|
12654
|
+
return new Uint16();
|
|
12655
|
+
case "uint32":
|
|
12656
|
+
return new Uint32();
|
|
12657
|
+
case "uint64":
|
|
12658
|
+
return new Uint64();
|
|
12659
|
+
case "float16":
|
|
12660
|
+
return new Float16();
|
|
12661
|
+
case "float32":
|
|
12662
|
+
return new Float32();
|
|
12663
|
+
case "float64":
|
|
12664
|
+
return new Float64();
|
|
12665
|
+
case "utf8":
|
|
12666
|
+
return new Utf8();
|
|
12667
|
+
case "date-day":
|
|
12668
|
+
return new DateDay();
|
|
12669
|
+
case "date-millisecond":
|
|
12670
|
+
return new DateMillisecond();
|
|
12671
|
+
case "time-second":
|
|
12672
|
+
return new TimeSecond();
|
|
12673
|
+
case "time-millisecond":
|
|
12674
|
+
return new TimeMillisecond();
|
|
12675
|
+
case "time-microsecond":
|
|
12676
|
+
return new TimeMicrosecond();
|
|
12677
|
+
case "time-nanosecond":
|
|
12678
|
+
return new TimeNanosecond();
|
|
12679
|
+
case "timestamp-second":
|
|
12680
|
+
return new TimestampSecond();
|
|
12681
|
+
case "timestamp-millisecond":
|
|
12682
|
+
return new TimestampMillisecond();
|
|
12683
|
+
case "timestamp-microsecond":
|
|
12684
|
+
return new TimestampMicrosecond();
|
|
12685
|
+
case "timestamp-nanosecond":
|
|
12686
|
+
return new TimestampNanosecond();
|
|
12687
|
+
case "interval-daytime":
|
|
12688
|
+
return new IntervalDayTime();
|
|
12689
|
+
case "interval-yearmonth":
|
|
12690
|
+
return new IntervalYearMonth();
|
|
12691
|
+
default:
|
|
12692
|
+
throw new Error("array type not supported");
|
|
12693
|
+
}
|
|
12694
|
+
}
|
|
12695
|
+
|
|
12696
|
+
// src/parsers/parse-arrow-sync.ts
|
|
12697
|
+
function parseArrowSync(arrayBuffer, options) {
|
|
12698
|
+
const apacheArrowTable = tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
12699
|
+
const arrowTable = {
|
|
12700
|
+
shape: "arrow-table",
|
|
12701
|
+
schema: serializeArrowSchema(apacheArrowTable.schema),
|
|
12702
|
+
data: apacheArrowTable
|
|
12703
|
+
};
|
|
12704
|
+
const shape = options?.shape || "arrow-table";
|
|
12705
|
+
switch (shape) {
|
|
12706
|
+
case "arrow-table":
|
|
12707
|
+
return arrowTable;
|
|
12708
|
+
case "columnar-table":
|
|
12709
|
+
return convertArrowToColumnarTable(arrowTable);
|
|
12710
|
+
case "object-row-table":
|
|
12711
|
+
let columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
12712
|
+
return convertTable(columnarTable, "object-row-table");
|
|
12713
|
+
case "array-row-table":
|
|
12714
|
+
columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
12715
|
+
return convertTable(columnarTable, "array-row-table");
|
|
12716
|
+
default:
|
|
12717
|
+
throw new Error(shape);
|
|
12718
|
+
}
|
|
12719
|
+
}
|
|
12720
|
+
|
|
12721
|
+
// src/parsers/parse-arrow-in-batches.ts
|
|
12722
|
+
function parseArrowInBatches(asyncIterator) {
|
|
12723
|
+
async function* makeArrowAsyncIterator() {
|
|
12724
|
+
const readers = RecordBatchReader.readAll(asyncIterator);
|
|
12725
|
+
for await (const reader of readers) {
|
|
12726
|
+
for await (const recordBatch of reader) {
|
|
12727
|
+
const arrowTabledBatch = {
|
|
12728
|
+
shape: "arrow-table",
|
|
12729
|
+
batchType: "data",
|
|
12730
|
+
data: new Table([recordBatch]),
|
|
12731
|
+
length: recordBatch.data.length
|
|
12732
|
+
};
|
|
12733
|
+
yield arrowTabledBatch;
|
|
12734
|
+
}
|
|
12735
|
+
break;
|
|
12736
|
+
}
|
|
12737
|
+
}
|
|
12738
|
+
return makeArrowAsyncIterator();
|
|
12739
|
+
}
|
|
12740
|
+
|
|
12741
|
+
// src/arrow-loader.ts
|
|
12742
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
12743
|
+
var ArrowWorkerLoader = {
|
|
12744
|
+
name: "Apache Arrow",
|
|
12745
|
+
id: "arrow",
|
|
12746
|
+
module: "arrow",
|
|
12747
|
+
version: VERSION,
|
|
12748
|
+
category: "table",
|
|
12749
|
+
extensions: ["arrow", "feather"],
|
|
12750
|
+
mimeTypes: ["application/vnd.apache.arrow.file", "application/vnd.apache.arrow.stream", "application/octet-stream"],
|
|
12751
|
+
binary: true,
|
|
12752
|
+
tests: ["ARROW"],
|
|
12753
|
+
options: {
|
|
12754
|
+
arrow: {
|
|
12755
|
+
shape: "columnar-table"
|
|
12756
|
+
}
|
|
12757
|
+
}
|
|
12758
|
+
};
|
|
12759
|
+
var ArrowLoader = {
|
|
12760
|
+
...ArrowWorkerLoader,
|
|
12761
|
+
parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),
|
|
12762
|
+
parseSync: (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),
|
|
12763
|
+
parseInBatches: parseArrowInBatches
|
|
12764
|
+
};
|
|
12765
|
+
|
|
12766
|
+
// src/lib/encode-arrow.ts
|
|
12767
|
+
function encodeArrowSync(data) {
|
|
12768
|
+
const vectors = {};
|
|
12769
|
+
for (const arrayData of data) {
|
|
12770
|
+
const arrayVector = createVector(arrayData.array, arrayData.type);
|
|
12771
|
+
vectors[arrayData.name] = arrayVector;
|
|
12772
|
+
}
|
|
12773
|
+
const table = new Table(vectors);
|
|
12774
|
+
const arrowBuffer = tableToIPC(table);
|
|
12775
|
+
return arrowBuffer;
|
|
12776
|
+
}
|
|
12777
|
+
function createVector(array, type) {
|
|
12778
|
+
switch (type) {
|
|
12779
|
+
case VECTOR_TYPES.DATE:
|
|
12780
|
+
return vectorFromArray(array);
|
|
12781
|
+
case VECTOR_TYPES.FLOAT:
|
|
12782
|
+
default:
|
|
12783
|
+
return vectorFromArray(array);
|
|
12784
|
+
}
|
|
12785
|
+
}
|
|
12786
|
+
|
|
12787
|
+
// src/arrow-writer.ts
|
|
12788
|
+
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
12789
|
+
var ArrowWriter = {
|
|
12790
|
+
name: "Apache Arrow",
|
|
12791
|
+
id: "arrow",
|
|
12792
|
+
module: "arrow",
|
|
12793
|
+
version: VERSION2,
|
|
12794
|
+
extensions: ["arrow", "feather"],
|
|
12795
|
+
mimeTypes: ["application/vnd.apache.arrow.file", "application/vnd.apache.arrow.stream", "application/octet-stream"],
|
|
12796
|
+
binary: true,
|
|
12797
|
+
options: {},
|
|
12798
|
+
encode: async function encodeArrow(data, options) {
|
|
12799
|
+
return encodeArrowSync(data);
|
|
12800
|
+
},
|
|
12801
|
+
encodeSync(data, options) {
|
|
12802
|
+
return encodeArrowSync(data);
|
|
12803
|
+
}
|
|
12804
|
+
};
|
|
12805
|
+
|
|
12806
|
+
// ../gis/src/lib/geo/geoarrow-metadata.ts
|
|
12807
|
+
var GEOARROW_ENCODINGS = ["geoarrow.multipolygon", "geoarrow.polygon", "geoarrow.multilinestring", "geoarrow.linestring", "geoarrow.multipoint", "geoarrow.point", "geoarrow.wkb", "geoarrow.wkt"];
|
|
12808
|
+
var GEOARROW_COLUMN_METADATA_ENCODING = "ARROW:extension:name";
|
|
12809
|
+
var GEOARROW_COLUMN_METADATA_METADATA = "ARROW:extension:metadata";
|
|
12810
|
+
function getGeometryColumnsFromSchema(schema) {
|
|
12811
|
+
const geometryColumns = {};
|
|
12812
|
+
for (const field of schema.fields) {
|
|
12813
|
+
const metadata = getGeometryMetadataForField(field);
|
|
12814
|
+
if (metadata) {
|
|
12815
|
+
geometryColumns[field.name] = metadata;
|
|
12816
|
+
}
|
|
12817
|
+
}
|
|
12818
|
+
return geometryColumns;
|
|
12819
|
+
}
|
|
12820
|
+
function getGeometryMetadataForField(field) {
|
|
12821
|
+
let metadata = null;
|
|
12822
|
+
let geoEncoding = field.metadata?.[GEOARROW_COLUMN_METADATA_ENCODING];
|
|
12823
|
+
if (geoEncoding) {
|
|
12824
|
+
geoEncoding = geoEncoding.toLowerCase();
|
|
12825
|
+
if (geoEncoding === "wkb") {
|
|
12826
|
+
geoEncoding = "geoarrow.wkb";
|
|
12827
|
+
}
|
|
12828
|
+
if (geoEncoding === "wkt") {
|
|
12829
|
+
geoEncoding = "geoarrow.wkt";
|
|
12830
|
+
}
|
|
12831
|
+
if (!GEOARROW_ENCODINGS.includes(geoEncoding)) {
|
|
12832
|
+
console.warn(`Invalid GeoArrow encoding: ${geoEncoding}`);
|
|
12833
|
+
} else {
|
|
12834
|
+
metadata = metadata || {};
|
|
12835
|
+
metadata.encoding = geoEncoding;
|
|
12836
|
+
}
|
|
12837
|
+
}
|
|
12838
|
+
const columnMetadata = field.metadata?.[GEOARROW_COLUMN_METADATA_METADATA];
|
|
12839
|
+
if (columnMetadata) {
|
|
12840
|
+
try {
|
|
12841
|
+
metadata = JSON.parse(columnMetadata);
|
|
12842
|
+
} catch (error) {
|
|
12843
|
+
console.warn("Failed to parse GeoArrow metadata", error);
|
|
12844
|
+
}
|
|
12845
|
+
}
|
|
12846
|
+
return metadata || null;
|
|
12847
|
+
}
|
|
12848
|
+
|
|
12849
|
+
// ../../node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
12850
|
+
function _typeof(obj) {
|
|
12851
|
+
"@babel/helpers - typeof";
|
|
12852
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
12853
|
+
return typeof obj2;
|
|
12854
|
+
} : function(obj2) {
|
|
12855
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
12856
|
+
}, _typeof(obj);
|
|
12857
|
+
}
|
|
12858
|
+
|
|
12859
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
12860
|
+
function _toPrimitive(input, hint) {
|
|
12861
|
+
if (_typeof(input) !== "object" || input === null)
|
|
12862
|
+
return input;
|
|
12863
|
+
var prim = input[Symbol.toPrimitive];
|
|
12864
|
+
if (prim !== void 0) {
|
|
12865
|
+
var res = prim.call(input, hint || "default");
|
|
12866
|
+
if (_typeof(res) !== "object")
|
|
12867
|
+
return res;
|
|
12868
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
12869
|
+
}
|
|
12870
|
+
return (hint === "string" ? String : Number)(input);
|
|
12871
|
+
}
|
|
12872
|
+
|
|
12873
|
+
// ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
|
|
12874
|
+
function _toPropertyKey(arg) {
|
|
12875
|
+
var key = _toPrimitive(arg, "string");
|
|
12876
|
+
return _typeof(key) === "symbol" ? key : String(key);
|
|
12877
|
+
}
|
|
12878
|
+
|
|
12879
|
+
// ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
|
|
12880
|
+
function _defineProperty(obj, key, value) {
|
|
12881
|
+
key = _toPropertyKey(key);
|
|
12882
|
+
if (key in obj) {
|
|
12883
|
+
Object.defineProperty(obj, key, {
|
|
12884
|
+
value,
|
|
12885
|
+
enumerable: true,
|
|
12886
|
+
configurable: true,
|
|
12887
|
+
writable: true
|
|
12888
|
+
});
|
|
12889
|
+
} else {
|
|
12890
|
+
obj[key] = value;
|
|
12891
|
+
}
|
|
12892
|
+
return obj;
|
|
12893
|
+
}
|
|
12894
|
+
|
|
12895
|
+
// ../../node_modules/@math.gl/polygon/dist/polygon-utils.js
|
|
12896
|
+
var DimIndex = {
|
|
12897
|
+
x: 0,
|
|
12898
|
+
y: 1,
|
|
12899
|
+
z: 2
|
|
12900
|
+
};
|
|
12901
|
+
function getPolygonSignedArea(points, options = {}) {
|
|
12902
|
+
const {
|
|
12903
|
+
start = 0,
|
|
12904
|
+
end = points.length,
|
|
12905
|
+
plane = "xy"
|
|
12906
|
+
} = options;
|
|
12907
|
+
const dim = options.size || 2;
|
|
12908
|
+
let area2 = 0;
|
|
12909
|
+
const i0 = DimIndex[plane[0]];
|
|
12910
|
+
const i1 = DimIndex[plane[1]];
|
|
12911
|
+
for (let i = start, j = end - dim; i < end; i += dim) {
|
|
12912
|
+
area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
|
|
12913
|
+
j = i;
|
|
12914
|
+
}
|
|
12915
|
+
return area2 / 2;
|
|
12916
|
+
}
|
|
12917
|
+
|
|
12918
|
+
// ../../node_modules/@math.gl/polygon/dist/earcut.js
|
|
12919
|
+
function earcut(positions, holeIndices, dim = 2, areas, plane = "xy") {
|
|
12920
|
+
const hasHoles = holeIndices && holeIndices.length;
|
|
12921
|
+
const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
|
|
12922
|
+
let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0], plane);
|
|
12923
|
+
const triangles = [];
|
|
12924
|
+
if (!outerNode || outerNode.next === outerNode.prev)
|
|
12925
|
+
return triangles;
|
|
12926
|
+
let invSize;
|
|
12927
|
+
let maxX;
|
|
12928
|
+
let maxY;
|
|
12929
|
+
let minX;
|
|
12930
|
+
let minY;
|
|
12931
|
+
let x;
|
|
12932
|
+
let y;
|
|
12933
|
+
if (hasHoles)
|
|
12934
|
+
outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
|
|
12935
|
+
if (positions.length > 80 * dim) {
|
|
12936
|
+
minX = maxX = positions[0];
|
|
12937
|
+
minY = maxY = positions[1];
|
|
12938
|
+
for (let i = dim; i < outerLen; i += dim) {
|
|
12939
|
+
x = positions[i];
|
|
12940
|
+
y = positions[i + 1];
|
|
12941
|
+
if (x < minX)
|
|
12942
|
+
minX = x;
|
|
12943
|
+
if (y < minY)
|
|
12944
|
+
minY = y;
|
|
12676
12945
|
if (x > maxX)
|
|
12677
12946
|
maxX = x;
|
|
12678
12947
|
if (y > maxY)
|
|
@@ -13136,329 +13405,175 @@ return true;`);
|
|
|
13136
13405
|
}
|
|
13137
13406
|
};
|
|
13138
13407
|
|
|
13139
|
-
// src/
|
|
13140
|
-
function
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13408
|
+
// ../gis/src/lib/binary-features/binary-to-geojson.ts
|
|
13409
|
+
function binaryToGeometry(data, startIndex, endIndex) {
|
|
13410
|
+
switch (data.type) {
|
|
13411
|
+
case "Point":
|
|
13412
|
+
return pointToGeoJson(data, startIndex, endIndex);
|
|
13413
|
+
case "LineString":
|
|
13414
|
+
return lineStringToGeoJson(data, startIndex, endIndex);
|
|
13415
|
+
case "Polygon":
|
|
13416
|
+
return polygonToGeoJson(data, startIndex, endIndex);
|
|
13417
|
+
default:
|
|
13418
|
+
const unexpectedInput = data;
|
|
13419
|
+
throw new Error(`Unsupported geometry type: ${unexpectedInput?.type}`);
|
|
13420
|
+
}
|
|
13421
|
+
}
|
|
13422
|
+
function polygonToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
|
|
13423
|
+
const {
|
|
13424
|
+
positions
|
|
13425
|
+
} = data;
|
|
13426
|
+
const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
13427
|
+
const primitivePolygonIndices = data.primitivePolygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
13428
|
+
const multi = polygonIndices.length > 2;
|
|
13429
|
+
if (!multi) {
|
|
13430
|
+
const coordinates2 = [];
|
|
13431
|
+
for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {
|
|
13432
|
+
const startRingIndex = primitivePolygonIndices[i];
|
|
13433
|
+
const endRingIndex = primitivePolygonIndices[i + 1];
|
|
13434
|
+
const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);
|
|
13435
|
+
coordinates2.push(ringCoordinates);
|
|
13155
13436
|
}
|
|
13437
|
+
return {
|
|
13438
|
+
type: "Polygon",
|
|
13439
|
+
coordinates: coordinates2
|
|
13440
|
+
};
|
|
13441
|
+
}
|
|
13442
|
+
const coordinates = [];
|
|
13443
|
+
for (let i = 0; i < polygonIndices.length - 1; i++) {
|
|
13444
|
+
const startPolygonIndex = polygonIndices[i];
|
|
13445
|
+
const endPolygonIndex = polygonIndices[i + 1];
|
|
13446
|
+
const polygonCoordinates = polygonToGeoJson(data, startPolygonIndex, endPolygonIndex).coordinates;
|
|
13447
|
+
coordinates.push(polygonCoordinates);
|
|
13156
13448
|
}
|
|
13157
13449
|
return {
|
|
13158
|
-
|
|
13159
|
-
|
|
13160
|
-
features
|
|
13450
|
+
type: "MultiPolygon",
|
|
13451
|
+
coordinates
|
|
13161
13452
|
};
|
|
13162
13453
|
}
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13454
|
+
function lineStringToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
|
|
13455
|
+
const {
|
|
13456
|
+
positions
|
|
13457
|
+
} = data;
|
|
13458
|
+
const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
13459
|
+
const multi = pathIndices.length > 2;
|
|
13460
|
+
if (!multi) {
|
|
13461
|
+
const coordinates2 = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);
|
|
13462
|
+
return {
|
|
13463
|
+
type: "LineString",
|
|
13464
|
+
coordinates: coordinates2
|
|
13465
|
+
};
|
|
13174
13466
|
}
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
return parseArrowInBatches(asyncIterator);
|
|
13180
|
-
}
|
|
13181
|
-
|
|
13182
|
-
// src/geoarrow-loader.ts
|
|
13183
|
-
var GeoArrowWorkerLoader = {
|
|
13184
|
-
...ArrowWorkerLoader,
|
|
13185
|
-
options: {
|
|
13186
|
-
arrow: {
|
|
13187
|
-
shape: "arrow-table"
|
|
13188
|
-
}
|
|
13467
|
+
const coordinates = [];
|
|
13468
|
+
for (let i = 0; i < pathIndices.length - 1; i++) {
|
|
13469
|
+
const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);
|
|
13470
|
+
coordinates.push(ringCoordinates);
|
|
13189
13471
|
}
|
|
13190
|
-
};
|
|
13191
|
-
var GeoArrowLoader = {
|
|
13192
|
-
...ArrowWorkerLoader,
|
|
13193
|
-
options: {
|
|
13194
|
-
arrow: {
|
|
13195
|
-
shape: "arrow-table"
|
|
13196
|
-
}
|
|
13197
|
-
},
|
|
13198
|
-
parse: async (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),
|
|
13199
|
-
parseSync: (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),
|
|
13200
|
-
parseInBatches: parseGeoArrowInBatches
|
|
13201
|
-
};
|
|
13202
|
-
|
|
13203
|
-
// src/schema/convert-arrow-schema.ts
|
|
13204
|
-
function serializeArrowSchema(arrowSchema) {
|
|
13205
13472
|
return {
|
|
13206
|
-
|
|
13207
|
-
|
|
13473
|
+
type: "MultiLineString",
|
|
13474
|
+
coordinates
|
|
13208
13475
|
};
|
|
13209
13476
|
}
|
|
13210
|
-
function
|
|
13211
|
-
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13217
|
-
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13223
|
-
|
|
13224
|
-
|
|
13477
|
+
function pointToGeoJson(data, startIndex, endIndex) {
|
|
13478
|
+
const {
|
|
13479
|
+
positions
|
|
13480
|
+
} = data;
|
|
13481
|
+
const coordinates = ringToGeoJson(positions, startIndex, endIndex);
|
|
13482
|
+
const multi = coordinates.length > 1;
|
|
13483
|
+
if (multi) {
|
|
13484
|
+
return {
|
|
13485
|
+
type: "MultiPoint",
|
|
13486
|
+
coordinates
|
|
13487
|
+
};
|
|
13488
|
+
}
|
|
13489
|
+
return {
|
|
13490
|
+
type: "Point",
|
|
13491
|
+
coordinates: coordinates[0]
|
|
13225
13492
|
};
|
|
13226
13493
|
}
|
|
13227
|
-
function
|
|
13228
|
-
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13234
|
-
|
|
13235
|
-
|
|
13236
|
-
|
|
13237
|
-
return "bool";
|
|
13238
|
-
case Int_:
|
|
13239
|
-
const intType = arrowType;
|
|
13240
|
-
return `${intType.isSigned ? "u" : ""}int${intType.bitWidth}`;
|
|
13241
|
-
case Int8:
|
|
13242
|
-
return "int8";
|
|
13243
|
-
case Int16:
|
|
13244
|
-
return "int16";
|
|
13245
|
-
case Int32:
|
|
13246
|
-
return "int32";
|
|
13247
|
-
case Int64:
|
|
13248
|
-
return "int64";
|
|
13249
|
-
case Uint8:
|
|
13250
|
-
return "uint8";
|
|
13251
|
-
case Uint16:
|
|
13252
|
-
return "uint16";
|
|
13253
|
-
case Uint32:
|
|
13254
|
-
return "uint32";
|
|
13255
|
-
case Uint64:
|
|
13256
|
-
return "uint64";
|
|
13257
|
-
case Float:
|
|
13258
|
-
const precision = arrowType.precision;
|
|
13259
|
-
switch (precision) {
|
|
13260
|
-
case Precision.HALF:
|
|
13261
|
-
return "float16";
|
|
13262
|
-
case Precision.SINGLE:
|
|
13263
|
-
return "float32";
|
|
13264
|
-
case Precision.DOUBLE:
|
|
13265
|
-
return "float64";
|
|
13266
|
-
default:
|
|
13267
|
-
return "float16";
|
|
13268
|
-
}
|
|
13269
|
-
case Float16:
|
|
13270
|
-
return "float16";
|
|
13271
|
-
case Float32:
|
|
13272
|
-
return "float32";
|
|
13273
|
-
case Float64:
|
|
13274
|
-
return "float64";
|
|
13275
|
-
case Utf8:
|
|
13276
|
-
return "utf8";
|
|
13277
|
-
case Decimal:
|
|
13278
|
-
const decimal = arrowType;
|
|
13279
|
-
return {
|
|
13280
|
-
type: "decimal",
|
|
13281
|
-
bitWidth: decimal.bitWidth,
|
|
13282
|
-
precision: decimal.precision,
|
|
13283
|
-
scale: decimal.scale
|
|
13284
|
-
};
|
|
13285
|
-
case Date_:
|
|
13286
|
-
const dateUnit = arrowType.unit;
|
|
13287
|
-
return dateUnit === DateUnit.DAY ? "date-day" : "date-millisecond";
|
|
13288
|
-
case DateDay:
|
|
13289
|
-
return "date-day";
|
|
13290
|
-
case DateMillisecond:
|
|
13291
|
-
return "date-millisecond";
|
|
13292
|
-
case Time_:
|
|
13293
|
-
const timeUnit = arrowType.unit;
|
|
13294
|
-
switch (timeUnit) {
|
|
13295
|
-
case TimeUnit.SECOND:
|
|
13296
|
-
return "time-second";
|
|
13297
|
-
case TimeUnit.MILLISECOND:
|
|
13298
|
-
return "time-millisecond";
|
|
13299
|
-
case TimeUnit.MICROSECOND:
|
|
13300
|
-
return "time-microsecond";
|
|
13301
|
-
case TimeUnit.NANOSECOND:
|
|
13302
|
-
return "time-nanosecond";
|
|
13303
|
-
default:
|
|
13304
|
-
return "time-second";
|
|
13305
|
-
}
|
|
13306
|
-
case TimeMillisecond:
|
|
13307
|
-
return "time-millisecond";
|
|
13308
|
-
case TimeSecond:
|
|
13309
|
-
return "time-second";
|
|
13310
|
-
case TimeMicrosecond:
|
|
13311
|
-
return "time-microsecond";
|
|
13312
|
-
case TimeNanosecond:
|
|
13313
|
-
return "time-nanosecond";
|
|
13314
|
-
case Timestamp_:
|
|
13315
|
-
const timeStampUnit = arrowType.unit;
|
|
13316
|
-
switch (timeStampUnit) {
|
|
13317
|
-
case TimeUnit.SECOND:
|
|
13318
|
-
return "timestamp-second";
|
|
13319
|
-
case TimeUnit.MILLISECOND:
|
|
13320
|
-
return "timestamp-millisecond";
|
|
13321
|
-
case TimeUnit.MICROSECOND:
|
|
13322
|
-
return "timestamp-microsecond";
|
|
13323
|
-
case TimeUnit.NANOSECOND:
|
|
13324
|
-
return "timestamp-nanosecond";
|
|
13325
|
-
default:
|
|
13326
|
-
return "timestamp-second";
|
|
13327
|
-
}
|
|
13328
|
-
case TimestampSecond:
|
|
13329
|
-
return "timestamp-second";
|
|
13330
|
-
case TimestampMillisecond:
|
|
13331
|
-
return "timestamp-millisecond";
|
|
13332
|
-
case TimestampMicrosecond:
|
|
13333
|
-
return "timestamp-microsecond";
|
|
13334
|
-
case TimestampNanosecond:
|
|
13335
|
-
return "timestamp-nanosecond";
|
|
13336
|
-
case Interval_:
|
|
13337
|
-
const intervalUnit = arrowType.unit;
|
|
13338
|
-
switch (intervalUnit) {
|
|
13339
|
-
case IntervalUnit.DAY_TIME:
|
|
13340
|
-
return "interval-daytime";
|
|
13341
|
-
case IntervalUnit.YEAR_MONTH:
|
|
13342
|
-
return "interval-yearmonth";
|
|
13343
|
-
default:
|
|
13344
|
-
return "interval-daytime";
|
|
13345
|
-
}
|
|
13346
|
-
case IntervalDayTime:
|
|
13347
|
-
return "interval-daytime";
|
|
13348
|
-
case IntervalYearMonth:
|
|
13349
|
-
return "interval-yearmonth";
|
|
13350
|
-
case Map_:
|
|
13351
|
-
const mapType = arrowType;
|
|
13352
|
-
return {
|
|
13353
|
-
type: "map",
|
|
13354
|
-
keysSorted: mapType.keysSorted,
|
|
13355
|
-
children: mapType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
13356
|
-
};
|
|
13357
|
-
case List:
|
|
13358
|
-
const listType = arrowType;
|
|
13359
|
-
const listField = listType.valueField;
|
|
13360
|
-
return {
|
|
13361
|
-
type: "list",
|
|
13362
|
-
children: [serializeArrowField(listField)]
|
|
13363
|
-
};
|
|
13364
|
-
case FixedSizeList:
|
|
13365
|
-
const fixedSizeList = arrowType;
|
|
13366
|
-
return {
|
|
13367
|
-
type: "fixed-size-list",
|
|
13368
|
-
listSize: fixedSizeList.listSize,
|
|
13369
|
-
children: [serializeArrowField(fixedSizeList.children[0])]
|
|
13370
|
-
};
|
|
13371
|
-
case Struct:
|
|
13372
|
-
const structType = arrowType;
|
|
13373
|
-
return {
|
|
13374
|
-
type: "struct",
|
|
13375
|
-
children: structType.children.map((arrowField) => serializeArrowField(arrowField))
|
|
13376
|
-
};
|
|
13377
|
-
default:
|
|
13378
|
-
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
13494
|
+
function ringToGeoJson(positions, startIndex, endIndex) {
|
|
13495
|
+
startIndex = startIndex || 0;
|
|
13496
|
+
endIndex = endIndex || positions.value.length / positions.size;
|
|
13497
|
+
const ringCoordinates = [];
|
|
13498
|
+
for (let j = startIndex; j < endIndex; j++) {
|
|
13499
|
+
const coord = Array();
|
|
13500
|
+
for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {
|
|
13501
|
+
coord.push(Number(positions.value[k]));
|
|
13502
|
+
}
|
|
13503
|
+
ringCoordinates.push(coord);
|
|
13379
13504
|
}
|
|
13505
|
+
return ringCoordinates;
|
|
13380
13506
|
}
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
|
|
13391
|
-
|
|
13392
|
-
|
|
13393
|
-
|
|
13394
|
-
|
|
13395
|
-
|
|
13396
|
-
|
|
13397
|
-
|
|
13398
|
-
|
|
13399
|
-
|
|
13507
|
+
|
|
13508
|
+
// src/tables/convert-arrow-to-geojson-table.ts
|
|
13509
|
+
function convertArrowToGeoJSONTable(table) {
|
|
13510
|
+
const arrowTable = table.data;
|
|
13511
|
+
const schema = serializeArrowSchema(arrowTable.schema);
|
|
13512
|
+
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
13513
|
+
const encoding = geometryColumns.geometry.encoding;
|
|
13514
|
+
const features = [];
|
|
13515
|
+
const propertyColumnNames = arrowTable.schema.fields.map((field) => field.name).filter((name) => !(name in geometryColumns));
|
|
13516
|
+
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
13517
|
+
const arrowGeometryColumn = arrowTable.getChild("geometry");
|
|
13518
|
+
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
13519
|
+
const arrowGeometry = arrowGeometryColumn?.get(row);
|
|
13520
|
+
const feature = parseGeometryFromArrow(arrowGeometry, encoding);
|
|
13521
|
+
if (feature) {
|
|
13522
|
+
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
13523
|
+
features.push({
|
|
13524
|
+
type: "Feature",
|
|
13525
|
+
geometry: feature,
|
|
13526
|
+
properties
|
|
13527
|
+
});
|
|
13400
13528
|
}
|
|
13401
13529
|
}
|
|
13402
|
-
|
|
13403
|
-
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
|
|
13407
|
-
|
|
13408
|
-
|
|
13409
|
-
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
|
|
13413
|
-
|
|
13414
|
-
|
|
13415
|
-
|
|
13416
|
-
|
|
13417
|
-
|
|
13418
|
-
return new Uint8();
|
|
13419
|
-
case "uint16":
|
|
13420
|
-
return new Uint16();
|
|
13421
|
-
case "uint32":
|
|
13422
|
-
return new Uint32();
|
|
13423
|
-
case "uint64":
|
|
13424
|
-
return new Uint64();
|
|
13425
|
-
case "float16":
|
|
13426
|
-
return new Float16();
|
|
13427
|
-
case "float32":
|
|
13428
|
-
return new Float32();
|
|
13429
|
-
case "float64":
|
|
13430
|
-
return new Float64();
|
|
13431
|
-
case "utf8":
|
|
13432
|
-
return new Utf8();
|
|
13433
|
-
case "date-day":
|
|
13434
|
-
return new DateDay();
|
|
13435
|
-
case "date-millisecond":
|
|
13436
|
-
return new DateMillisecond();
|
|
13437
|
-
case "time-second":
|
|
13438
|
-
return new TimeSecond();
|
|
13439
|
-
case "time-millisecond":
|
|
13440
|
-
return new TimeMillisecond();
|
|
13441
|
-
case "time-microsecond":
|
|
13442
|
-
return new TimeMicrosecond();
|
|
13443
|
-
case "time-nanosecond":
|
|
13444
|
-
return new TimeNanosecond();
|
|
13445
|
-
case "timestamp-second":
|
|
13446
|
-
return new TimestampSecond();
|
|
13447
|
-
case "timestamp-millisecond":
|
|
13448
|
-
return new TimestampMillisecond();
|
|
13449
|
-
case "timestamp-microsecond":
|
|
13450
|
-
return new TimestampMicrosecond();
|
|
13451
|
-
case "timestamp-nanosecond":
|
|
13452
|
-
return new TimestampNanosecond();
|
|
13453
|
-
case "interval-daytime":
|
|
13454
|
-
return new IntervalDayTime();
|
|
13455
|
-
case "interval-yearmonth":
|
|
13456
|
-
return new IntervalYearMonth();
|
|
13530
|
+
return {
|
|
13531
|
+
shape: "geojson-table",
|
|
13532
|
+
type: "FeatureCollection",
|
|
13533
|
+
schema: table.schema,
|
|
13534
|
+
features
|
|
13535
|
+
};
|
|
13536
|
+
}
|
|
13537
|
+
|
|
13538
|
+
// src/parsers/parse-geoarrow-sync.ts
|
|
13539
|
+
function parseGeoArrowSync(arrayBuffer, options) {
|
|
13540
|
+
const table = parseArrowSync(arrayBuffer, {
|
|
13541
|
+
shape: "arrow-table"
|
|
13542
|
+
});
|
|
13543
|
+
switch (options?.shape) {
|
|
13544
|
+
case "geojson-table":
|
|
13545
|
+
return convertArrowToGeoJSONTable(table);
|
|
13457
13546
|
default:
|
|
13458
|
-
|
|
13547
|
+
return table;
|
|
13459
13548
|
}
|
|
13460
13549
|
}
|
|
13461
13550
|
|
|
13551
|
+
// src/parsers/parse-geoarrow-in-batches.ts
|
|
13552
|
+
function parseGeoArrowInBatches(asyncIterator) {
|
|
13553
|
+
return parseArrowInBatches(asyncIterator);
|
|
13554
|
+
}
|
|
13555
|
+
|
|
13556
|
+
// src/geoarrow-loader.ts
|
|
13557
|
+
var GeoArrowWorkerLoader = {
|
|
13558
|
+
...ArrowWorkerLoader,
|
|
13559
|
+
options: {
|
|
13560
|
+
arrow: {
|
|
13561
|
+
shape: "arrow-table"
|
|
13562
|
+
}
|
|
13563
|
+
}
|
|
13564
|
+
};
|
|
13565
|
+
var GeoArrowLoader = {
|
|
13566
|
+
...ArrowWorkerLoader,
|
|
13567
|
+
options: {
|
|
13568
|
+
arrow: {
|
|
13569
|
+
shape: "arrow-table"
|
|
13570
|
+
}
|
|
13571
|
+
},
|
|
13572
|
+
parse: async (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),
|
|
13573
|
+
parseSync: (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),
|
|
13574
|
+
parseInBatches: parseGeoArrowInBatches
|
|
13575
|
+
};
|
|
13576
|
+
|
|
13462
13577
|
// src/geoarrow/get-arrow-bounds.ts
|
|
13463
13578
|
function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {
|
|
13464
13579
|
const numberOfFeatures = flatCoords.length / nDim;
|
|
@@ -13484,31 +13599,39 @@ return true;`);
|
|
|
13484
13599
|
}
|
|
13485
13600
|
|
|
13486
13601
|
// src/geoarrow/convert-geoarrow-to-binary-geometry.ts
|
|
13487
|
-
var
|
|
13488
|
-
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13492
|
-
|
|
13493
|
-
|
|
13494
|
-
|
|
13495
|
-
|
|
13496
|
-
|
|
13497
|
-
|
|
13498
|
-
|
|
13499
|
-
|
|
13500
|
-
|
|
13501
|
-
|
|
13502
|
-
|
|
13602
|
+
var BinaryGeometryType = function(BinaryGeometryType2) {
|
|
13603
|
+
BinaryGeometryType2["points"] = "points";
|
|
13604
|
+
BinaryGeometryType2["lines"] = "lines";
|
|
13605
|
+
BinaryGeometryType2["polygons"] = "polygons";
|
|
13606
|
+
return BinaryGeometryType2;
|
|
13607
|
+
}(BinaryGeometryType || {});
|
|
13608
|
+
function getBinaryGeometryTemplate() {
|
|
13609
|
+
return {
|
|
13610
|
+
globalFeatureIds: {
|
|
13611
|
+
value: new Uint32Array(0),
|
|
13612
|
+
size: 1
|
|
13613
|
+
},
|
|
13614
|
+
positions: {
|
|
13615
|
+
value: new Float32Array(0),
|
|
13616
|
+
size: 2
|
|
13617
|
+
},
|
|
13618
|
+
properties: [],
|
|
13619
|
+
numericProps: {},
|
|
13620
|
+
featureIds: {
|
|
13621
|
+
value: new Uint32Array(0),
|
|
13622
|
+
size: 1
|
|
13623
|
+
}
|
|
13624
|
+
};
|
|
13625
|
+
}
|
|
13503
13626
|
function getBinaryGeometriesFromArrow(geoColumn, geoEncoding, options) {
|
|
13504
13627
|
const featureTypes = {
|
|
13505
13628
|
polygon: geoEncoding === "geoarrow.multipolygon" || geoEncoding === "geoarrow.polygon",
|
|
13506
13629
|
point: geoEncoding === "geoarrow.multipoint" || geoEncoding === "geoarrow.point",
|
|
13507
13630
|
line: geoEncoding === "geoarrow.multilinestring" || geoEncoding === "geoarrow.linestring"
|
|
13508
13631
|
};
|
|
13509
|
-
const chunks = options?.chunkIndex ? [geoColumn.data[options?.chunkIndex]] : geoColumn.data;
|
|
13632
|
+
const chunks = options?.chunkIndex !== void 0 && options?.chunkIndex >= 0 ? [geoColumn.data[options?.chunkIndex]] : geoColumn.data;
|
|
13510
13633
|
let bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
13511
|
-
let globalFeatureIdOffset = 0;
|
|
13634
|
+
let globalFeatureIdOffset = options?.chunkOffset || 0;
|
|
13512
13635
|
const binaryGeometries = [];
|
|
13513
13636
|
chunks.forEach((chunk) => {
|
|
13514
13637
|
const {
|
|
@@ -13517,7 +13640,7 @@ return true;`);
|
|
|
13517
13640
|
nDim,
|
|
13518
13641
|
geomOffset,
|
|
13519
13642
|
triangles
|
|
13520
|
-
} = getBinaryGeometriesFromChunk(chunk, geoEncoding);
|
|
13643
|
+
} = getBinaryGeometriesFromChunk(chunk, geoEncoding, options);
|
|
13521
13644
|
const globalFeatureIds = new Uint32Array(featureIds.length);
|
|
13522
13645
|
for (let i = 0; i < featureIds.length; i++) {
|
|
13523
13646
|
globalFeatureIds[i] = featureIds[i] + globalFeatureIdOffset;
|
|
@@ -13544,12 +13667,12 @@ return true;`);
|
|
|
13544
13667
|
shape: "binary-feature-collection",
|
|
13545
13668
|
points: {
|
|
13546
13669
|
type: "Point",
|
|
13547
|
-
...
|
|
13670
|
+
...getBinaryGeometryTemplate(),
|
|
13548
13671
|
...featureTypes.point ? binaryContent : {}
|
|
13549
13672
|
},
|
|
13550
13673
|
lines: {
|
|
13551
13674
|
type: "LineString",
|
|
13552
|
-
...
|
|
13675
|
+
...getBinaryGeometryTemplate(),
|
|
13553
13676
|
...featureTypes.line ? binaryContent : {},
|
|
13554
13677
|
pathIndices: {
|
|
13555
13678
|
value: featureTypes.line ? geomOffset : new Uint16Array(0),
|
|
@@ -13558,7 +13681,7 @@ return true;`);
|
|
|
13558
13681
|
},
|
|
13559
13682
|
polygons: {
|
|
13560
13683
|
type: "Polygon",
|
|
13561
|
-
...
|
|
13684
|
+
...getBinaryGeometryTemplate(),
|
|
13562
13685
|
...featureTypes.polygon ? binaryContent : {},
|
|
13563
13686
|
polygonIndices: {
|
|
13564
13687
|
value: featureTypes.polygon ? geomOffset : new Uint16Array(0),
|
|
@@ -13582,7 +13705,7 @@ return true;`);
|
|
|
13582
13705
|
binaryGeometries,
|
|
13583
13706
|
bounds,
|
|
13584
13707
|
featureTypes,
|
|
13585
|
-
...options?.
|
|
13708
|
+
...options?.calculateMeanCenters ? {
|
|
13586
13709
|
meanCenters: getMeanCentersFromBinaryGeometries(binaryGeometries)
|
|
13587
13710
|
} : {}
|
|
13588
13711
|
};
|
|
@@ -13592,18 +13715,18 @@ return true;`);
|
|
|
13592
13715
|
binaryGeometries.forEach((binaryGeometry) => {
|
|
13593
13716
|
let binaryGeometryType = null;
|
|
13594
13717
|
if (binaryGeometry.points && binaryGeometry.points.positions.value.length > 0) {
|
|
13595
|
-
binaryGeometryType =
|
|
13718
|
+
binaryGeometryType = BinaryGeometryType.points;
|
|
13596
13719
|
} else if (binaryGeometry.lines && binaryGeometry.lines.positions.value.length > 0) {
|
|
13597
|
-
binaryGeometryType =
|
|
13720
|
+
binaryGeometryType = BinaryGeometryType.lines;
|
|
13598
13721
|
} else if (binaryGeometry.polygons && binaryGeometry.polygons.positions.value.length > 0) {
|
|
13599
|
-
binaryGeometryType =
|
|
13722
|
+
binaryGeometryType = BinaryGeometryType.polygons;
|
|
13600
13723
|
}
|
|
13601
13724
|
const binaryContent = binaryGeometryType ? binaryGeometry[binaryGeometryType] : null;
|
|
13602
13725
|
if (binaryContent && binaryGeometryType !== null) {
|
|
13603
13726
|
const featureIds = binaryContent.featureIds.value;
|
|
13604
13727
|
const flatCoordinateArray = binaryContent.positions.value;
|
|
13605
13728
|
const nDim = binaryContent.positions.size;
|
|
13606
|
-
const primitivePolygonIndices = binaryContent.primitivePolygonIndices?.value;
|
|
13729
|
+
const primitivePolygonIndices = binaryContent.type === "Polygon" ? binaryContent.primitivePolygonIndices?.value : void 0;
|
|
13607
13730
|
const meanCenters = getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, binaryGeometryType, primitivePolygonIndices);
|
|
13608
13731
|
meanCenters.forEach((center) => {
|
|
13609
13732
|
globalMeanCenters.push(center);
|
|
@@ -13616,19 +13739,23 @@ return true;`);
|
|
|
13616
13739
|
const meanCenters = [];
|
|
13617
13740
|
const vertexCount = flatCoordinateArray.length;
|
|
13618
13741
|
let vertexIndex = 0;
|
|
13742
|
+
let coordIdx = 0;
|
|
13743
|
+
let primitiveIdx = 0;
|
|
13619
13744
|
while (vertexIndex < vertexCount) {
|
|
13620
13745
|
const featureId = featureIds[vertexIndex / nDim];
|
|
13621
13746
|
const center = [0, 0];
|
|
13622
13747
|
let vertexCountInFeature = 0;
|
|
13623
|
-
while (vertexIndex < vertexCount && featureIds[
|
|
13624
|
-
if (geometryType ===
|
|
13748
|
+
while (vertexIndex < vertexCount && featureIds[coordIdx] === featureId) {
|
|
13749
|
+
if (geometryType === BinaryGeometryType.polygons && primitivePolygonIndices?.[primitiveIdx] === coordIdx) {
|
|
13625
13750
|
vertexIndex += nDim;
|
|
13751
|
+
primitiveIdx++;
|
|
13626
13752
|
} else {
|
|
13627
13753
|
center[0] += flatCoordinateArray[vertexIndex];
|
|
13628
13754
|
center[1] += flatCoordinateArray[vertexIndex + 1];
|
|
13629
13755
|
vertexIndex += nDim;
|
|
13630
13756
|
vertexCountInFeature++;
|
|
13631
13757
|
}
|
|
13758
|
+
coordIdx += 1;
|
|
13632
13759
|
}
|
|
13633
13760
|
center[0] /= vertexCountInFeature;
|
|
13634
13761
|
center[1] /= vertexCountInFeature;
|
|
@@ -13636,7 +13763,7 @@ return true;`);
|
|
|
13636
13763
|
}
|
|
13637
13764
|
return meanCenters;
|
|
13638
13765
|
}
|
|
13639
|
-
function getBinaryGeometriesFromChunk(chunk, geoEncoding) {
|
|
13766
|
+
function getBinaryGeometriesFromChunk(chunk, geoEncoding, options) {
|
|
13640
13767
|
switch (geoEncoding) {
|
|
13641
13768
|
case "geoarrow.point":
|
|
13642
13769
|
case "geoarrow.multipoint":
|
|
@@ -13646,37 +13773,44 @@ return true;`);
|
|
|
13646
13773
|
return getBinaryLinesFromChunk(chunk, geoEncoding);
|
|
13647
13774
|
case "geoarrow.polygon":
|
|
13648
13775
|
case "geoarrow.multipolygon":
|
|
13649
|
-
return getBinaryPolygonsFromChunk(chunk, geoEncoding);
|
|
13776
|
+
return getBinaryPolygonsFromChunk(chunk, geoEncoding, options);
|
|
13650
13777
|
default:
|
|
13651
13778
|
throw Error("invalid geoarrow encoding");
|
|
13652
13779
|
}
|
|
13653
13780
|
}
|
|
13654
13781
|
function getTriangleIndices(polygonIndices, primitivePolygonIndices, flatCoordinateArray, nDim) {
|
|
13655
|
-
|
|
13656
|
-
|
|
13657
|
-
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13782
|
+
try {
|
|
13783
|
+
let primitiveIndex = 0;
|
|
13784
|
+
const triangles = [];
|
|
13785
|
+
for (let i = 0; i < polygonIndices.length - 1; i++) {
|
|
13786
|
+
const startIdx = polygonIndices[i];
|
|
13787
|
+
const endIdx = polygonIndices[i + 1];
|
|
13788
|
+
const slicedFlatCoords = flatCoordinateArray.subarray(startIdx * nDim, endIdx * nDim);
|
|
13789
|
+
const holeIndices = [];
|
|
13790
|
+
while (primitivePolygonIndices[primitiveIndex] < endIdx) {
|
|
13791
|
+
if (primitivePolygonIndices[primitiveIndex] > startIdx) {
|
|
13792
|
+
holeIndices.push(primitivePolygonIndices[primitiveIndex] - startIdx);
|
|
13793
|
+
}
|
|
13794
|
+
primitiveIndex++;
|
|
13795
|
+
}
|
|
13796
|
+
const triangleIndices = earcut(slicedFlatCoords, holeIndices.length > 0 ? holeIndices : void 0, nDim);
|
|
13797
|
+
if (triangleIndices.length === 0) {
|
|
13798
|
+
throw Error("earcut failed e.g. invalid polygon");
|
|
13799
|
+
}
|
|
13800
|
+
for (let j = 0; j < triangleIndices.length; j++) {
|
|
13801
|
+
triangles.push(triangleIndices[j] + startIdx);
|
|
13665
13802
|
}
|
|
13666
|
-
primitiveIndex++;
|
|
13667
13803
|
}
|
|
13668
|
-
const
|
|
13669
|
-
for (let
|
|
13670
|
-
|
|
13804
|
+
const trianglesUint32 = new Uint32Array(triangles.length);
|
|
13805
|
+
for (let i = 0; i < triangles.length; i++) {
|
|
13806
|
+
trianglesUint32[i] = triangles[i];
|
|
13671
13807
|
}
|
|
13808
|
+
return trianglesUint32;
|
|
13809
|
+
} catch (error) {
|
|
13810
|
+
return null;
|
|
13672
13811
|
}
|
|
13673
|
-
const trianglesUint32 = new Uint32Array(triangles.length);
|
|
13674
|
-
for (let i = 0; i < triangles.length; i++) {
|
|
13675
|
-
trianglesUint32[i] = triangles[i];
|
|
13676
|
-
}
|
|
13677
|
-
return trianglesUint32;
|
|
13678
13812
|
}
|
|
13679
|
-
function getBinaryPolygonsFromChunk(chunk, geoEncoding) {
|
|
13813
|
+
function getBinaryPolygonsFromChunk(chunk, geoEncoding, options) {
|
|
13680
13814
|
const isMultiPolygon = geoEncoding === "geoarrow.multipolygon";
|
|
13681
13815
|
const polygonData = isMultiPolygon ? chunk.children[0] : chunk;
|
|
13682
13816
|
const polygonOffset = polygonData.valueOffsets;
|
|
@@ -13700,14 +13834,16 @@ return true;`);
|
|
|
13700
13834
|
featureIds[j] = i;
|
|
13701
13835
|
}
|
|
13702
13836
|
}
|
|
13703
|
-
const triangles = getTriangleIndices(geometryIndicies, geomOffset, flatCoordinateArray, nDim);
|
|
13837
|
+
const triangles = options?.triangulate ? getTriangleIndices(geometryIndicies, geomOffset, flatCoordinateArray, nDim) : null;
|
|
13704
13838
|
return {
|
|
13705
13839
|
featureIds,
|
|
13706
|
-
flatCoordinateArray,
|
|
13707
13840
|
nDim,
|
|
13841
|
+
flatCoordinateArray,
|
|
13708
13842
|
geomOffset,
|
|
13709
13843
|
geometryIndicies,
|
|
13710
|
-
triangles
|
|
13844
|
+
...options?.triangulate && triangles ? {
|
|
13845
|
+
triangles
|
|
13846
|
+
} : {}
|
|
13711
13847
|
};
|
|
13712
13848
|
}
|
|
13713
13849
|
function getBinaryLinesFromChunk(chunk, geoEncoding) {
|
|
@@ -13780,46 +13916,706 @@ return true;`);
|
|
|
13780
13916
|
};
|
|
13781
13917
|
}
|
|
13782
13918
|
|
|
13783
|
-
// src/
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13919
|
+
// ../wkt/src/lib/utils/version.ts
|
|
13920
|
+
var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
13921
|
+
|
|
13922
|
+
// ../wkt/src/lib/parse-wkt.ts
|
|
13923
|
+
var numberRegexp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
|
|
13924
|
+
var tuples = new RegExp("^" + numberRegexp.source + "(\\s" + numberRegexp.source + "){1,}");
|
|
13925
|
+
var WKT_MAGIC_STRINGS = ["POINT(", "LINESTRING(", "POLYGON(", "MULTIPOINT(", "MULTILINESTRING(", "MULTIPOLYGON(", "GEOMETRYCOLLECTION("];
|
|
13926
|
+
function isWKT(input) {
|
|
13927
|
+
return WKT_MAGIC_STRINGS.some((magicString) => input.startsWith(magicString));
|
|
13928
|
+
}
|
|
13929
|
+
function parseWKT(input, options) {
|
|
13930
|
+
return parseWKTToGeometry(input, options);
|
|
13931
|
+
}
|
|
13932
|
+
function parseWKTToGeometry(input, options) {
|
|
13933
|
+
const parts = input.split(";");
|
|
13934
|
+
let _ = parts.pop();
|
|
13935
|
+
const srid = (parts.shift() || "").split("=").pop();
|
|
13936
|
+
const state = {
|
|
13937
|
+
parts,
|
|
13938
|
+
_,
|
|
13939
|
+
i: 0
|
|
13940
|
+
};
|
|
13941
|
+
const geometry = parseGeometry(state);
|
|
13942
|
+
return options?.wkt?.crs ? addCRS(geometry, srid) : geometry;
|
|
13943
|
+
}
|
|
13944
|
+
function parseGeometry(state) {
|
|
13945
|
+
return parsePoint(state) || parseLineString(state) || parsePolygon(state) || parseMultiPoint(state) || parseMultiLineString(state) || parseMultiPolygon(state) || parseGeometryCollection(state);
|
|
13946
|
+
}
|
|
13947
|
+
function addCRS(obj, srid) {
|
|
13948
|
+
if (obj && srid?.match(/\d+/)) {
|
|
13949
|
+
const crs = {
|
|
13950
|
+
type: "name",
|
|
13951
|
+
properties: {
|
|
13952
|
+
name: "urn:ogc:def:crs:EPSG::" + srid
|
|
13953
|
+
}
|
|
13954
|
+
};
|
|
13955
|
+
obj.crs = crs;
|
|
13956
|
+
}
|
|
13957
|
+
return obj;
|
|
13958
|
+
}
|
|
13959
|
+
function parsePoint(state) {
|
|
13960
|
+
if (!$(/^(POINT(\sz)?)/i, state)) {
|
|
13961
|
+
return null;
|
|
13962
|
+
}
|
|
13963
|
+
white(state);
|
|
13964
|
+
if (!$(/^(\()/, state)) {
|
|
13965
|
+
return null;
|
|
13966
|
+
}
|
|
13967
|
+
const c = coords(state);
|
|
13968
|
+
if (!c) {
|
|
13969
|
+
return null;
|
|
13970
|
+
}
|
|
13971
|
+
white(state);
|
|
13972
|
+
if (!$(/^(\))/, state)) {
|
|
13973
|
+
return null;
|
|
13974
|
+
}
|
|
13975
|
+
return {
|
|
13976
|
+
type: "Point",
|
|
13977
|
+
coordinates: c[0]
|
|
13978
|
+
};
|
|
13979
|
+
}
|
|
13980
|
+
function parseMultiPoint(state) {
|
|
13981
|
+
if (!$(/^(MULTIPOINT)/i, state)) {
|
|
13982
|
+
return null;
|
|
13983
|
+
}
|
|
13984
|
+
white(state);
|
|
13985
|
+
const newCoordsFormat = state._?.substring(state._?.indexOf("(") + 1, state._.length - 1).replace(/\(/g, "").replace(/\)/g, "");
|
|
13986
|
+
state._ = "MULTIPOINT (" + newCoordsFormat + ")";
|
|
13987
|
+
const c = multicoords(state);
|
|
13988
|
+
if (!c) {
|
|
13989
|
+
return null;
|
|
13990
|
+
}
|
|
13991
|
+
white(state);
|
|
13992
|
+
return {
|
|
13993
|
+
type: "MultiPoint",
|
|
13994
|
+
coordinates: c
|
|
13995
|
+
};
|
|
13996
|
+
}
|
|
13997
|
+
function parseLineString(state) {
|
|
13998
|
+
if (!$(/^(LINESTRING(\sz)?)/i, state)) {
|
|
13999
|
+
return null;
|
|
14000
|
+
}
|
|
14001
|
+
white(state);
|
|
14002
|
+
if (!$(/^(\()/, state)) {
|
|
14003
|
+
return null;
|
|
14004
|
+
}
|
|
14005
|
+
const c = coords(state);
|
|
14006
|
+
if (!c) {
|
|
14007
|
+
return null;
|
|
14008
|
+
}
|
|
14009
|
+
if (!$(/^(\))/, state)) {
|
|
14010
|
+
return null;
|
|
14011
|
+
}
|
|
14012
|
+
return {
|
|
14013
|
+
type: "LineString",
|
|
14014
|
+
coordinates: c
|
|
14015
|
+
};
|
|
14016
|
+
}
|
|
14017
|
+
function parseMultiLineString(state) {
|
|
14018
|
+
if (!$(/^(MULTILINESTRING)/i, state))
|
|
14019
|
+
return null;
|
|
14020
|
+
white(state);
|
|
14021
|
+
const c = multicoords(state);
|
|
14022
|
+
if (!c) {
|
|
14023
|
+
return null;
|
|
14024
|
+
}
|
|
14025
|
+
white(state);
|
|
14026
|
+
return {
|
|
14027
|
+
type: "MultiLineString",
|
|
14028
|
+
coordinates: c
|
|
14029
|
+
};
|
|
14030
|
+
}
|
|
14031
|
+
function parsePolygon(state) {
|
|
14032
|
+
if (!$(/^(POLYGON(\sz)?)/i, state)) {
|
|
14033
|
+
return null;
|
|
14034
|
+
}
|
|
14035
|
+
white(state);
|
|
14036
|
+
const c = multicoords(state);
|
|
14037
|
+
if (!c) {
|
|
14038
|
+
return null;
|
|
14039
|
+
}
|
|
14040
|
+
return {
|
|
14041
|
+
type: "Polygon",
|
|
14042
|
+
coordinates: c
|
|
14043
|
+
};
|
|
14044
|
+
}
|
|
14045
|
+
function parseMultiPolygon(state) {
|
|
14046
|
+
if (!$(/^(MULTIPOLYGON)/i, state)) {
|
|
14047
|
+
return null;
|
|
14048
|
+
}
|
|
14049
|
+
white(state);
|
|
14050
|
+
const c = multicoords(state);
|
|
14051
|
+
if (!c) {
|
|
14052
|
+
return null;
|
|
14053
|
+
}
|
|
14054
|
+
return {
|
|
14055
|
+
type: "MultiPolygon",
|
|
14056
|
+
coordinates: c
|
|
14057
|
+
};
|
|
14058
|
+
}
|
|
14059
|
+
function parseGeometryCollection(state) {
|
|
14060
|
+
const geometries = [];
|
|
14061
|
+
let geometry;
|
|
14062
|
+
if (!$(/^(GEOMETRYCOLLECTION)/i, state)) {
|
|
14063
|
+
return null;
|
|
14064
|
+
}
|
|
14065
|
+
white(state);
|
|
14066
|
+
if (!$(/^(\()/, state)) {
|
|
14067
|
+
return null;
|
|
14068
|
+
}
|
|
14069
|
+
while (geometry = parseGeometry(state)) {
|
|
14070
|
+
geometries.push(geometry);
|
|
14071
|
+
white(state);
|
|
14072
|
+
$(/^(,)/, state);
|
|
14073
|
+
white(state);
|
|
14074
|
+
}
|
|
14075
|
+
if (!$(/^(\))/, state)) {
|
|
14076
|
+
return null;
|
|
14077
|
+
}
|
|
14078
|
+
return {
|
|
14079
|
+
type: "GeometryCollection",
|
|
14080
|
+
geometries
|
|
14081
|
+
};
|
|
14082
|
+
}
|
|
14083
|
+
function multicoords(state) {
|
|
14084
|
+
white(state);
|
|
14085
|
+
let depth = 0;
|
|
14086
|
+
const rings = [];
|
|
14087
|
+
const stack = [rings];
|
|
14088
|
+
let pointer = rings;
|
|
14089
|
+
let elem;
|
|
14090
|
+
while (elem = $(/^(\()/, state) || $(/^(\))/, state) || $(/^(,)/, state) || $(tuples, state)) {
|
|
14091
|
+
if (elem === "(") {
|
|
14092
|
+
stack.push(pointer);
|
|
14093
|
+
pointer = [];
|
|
14094
|
+
stack[stack.length - 1].push(pointer);
|
|
14095
|
+
depth++;
|
|
14096
|
+
} else if (elem === ")") {
|
|
14097
|
+
if (pointer.length === 0)
|
|
14098
|
+
return null;
|
|
14099
|
+
pointer = stack.pop();
|
|
14100
|
+
if (!pointer)
|
|
14101
|
+
return null;
|
|
14102
|
+
depth--;
|
|
14103
|
+
if (depth === 0)
|
|
14104
|
+
break;
|
|
14105
|
+
} else if (elem === ",") {
|
|
14106
|
+
pointer = [];
|
|
14107
|
+
stack[stack.length - 1].push(pointer);
|
|
14108
|
+
} else if (!elem.split(/\s/g).some(isNaN)) {
|
|
14109
|
+
Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
|
|
14110
|
+
} else {
|
|
14111
|
+
return null;
|
|
14112
|
+
}
|
|
14113
|
+
white(state);
|
|
14114
|
+
}
|
|
14115
|
+
if (depth !== 0)
|
|
14116
|
+
return null;
|
|
14117
|
+
return rings;
|
|
14118
|
+
}
|
|
14119
|
+
function coords(state) {
|
|
14120
|
+
const list = [];
|
|
14121
|
+
let item;
|
|
14122
|
+
let pt;
|
|
14123
|
+
while (pt = $(tuples, state) || $(/^(,)/, state)) {
|
|
14124
|
+
if (pt === ",") {
|
|
14125
|
+
list.push(item);
|
|
14126
|
+
item = [];
|
|
14127
|
+
} else if (!pt.split(/\s/g).some(isNaN)) {
|
|
14128
|
+
if (!item)
|
|
14129
|
+
item = [];
|
|
14130
|
+
Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
|
|
14131
|
+
}
|
|
14132
|
+
white(state);
|
|
14133
|
+
}
|
|
14134
|
+
if (item)
|
|
14135
|
+
list.push(item);
|
|
14136
|
+
else
|
|
14137
|
+
return null;
|
|
14138
|
+
return list.length ? list : null;
|
|
14139
|
+
}
|
|
14140
|
+
function $(regexp, state) {
|
|
14141
|
+
const match = state._?.substring(state.i).match(regexp);
|
|
14142
|
+
if (!match)
|
|
14143
|
+
return null;
|
|
14144
|
+
else {
|
|
14145
|
+
state.i += match[0].length;
|
|
14146
|
+
return match[0];
|
|
14147
|
+
}
|
|
14148
|
+
}
|
|
14149
|
+
function white(state) {
|
|
14150
|
+
$(/^\s*/, state);
|
|
14151
|
+
}
|
|
14152
|
+
|
|
14153
|
+
// ../wkt/src/wkt-loader.ts
|
|
14154
|
+
var WKTWorkerLoader = {
|
|
14155
|
+
name: "WKT (Well-Known Text)",
|
|
14156
|
+
id: "wkt",
|
|
14157
|
+
module: "wkt",
|
|
14158
|
+
version: VERSION3,
|
|
14159
|
+
worker: true,
|
|
14160
|
+
extensions: ["wkt"],
|
|
14161
|
+
mimeTypes: ["text/plain"],
|
|
14162
|
+
category: "geometry",
|
|
14163
|
+
text: true,
|
|
14164
|
+
tests: WKT_MAGIC_STRINGS,
|
|
14165
|
+
testText: isWKT,
|
|
14166
|
+
options: {
|
|
14167
|
+
wkt: {
|
|
14168
|
+
shape: "geojson-geometry",
|
|
14169
|
+
crs: true
|
|
14170
|
+
}
|
|
14171
|
+
}
|
|
14172
|
+
};
|
|
14173
|
+
var WKTLoader = {
|
|
14174
|
+
...WKTWorkerLoader,
|
|
14175
|
+
parse: async (arrayBuffer, options) => parseWKT(new TextDecoder().decode(arrayBuffer), options),
|
|
14176
|
+
parseTextSync: parseWKT
|
|
14177
|
+
};
|
|
14178
|
+
|
|
14179
|
+
// ../wkt/src/lib/parse-wkb-header.ts
|
|
14180
|
+
var EWKB_FLAG_Z = 2147483648;
|
|
14181
|
+
var EWKB_FLAG_M = 1073741824;
|
|
14182
|
+
var EWKB_FLAG_SRID = 536870912;
|
|
14183
|
+
var MAX_SRID = 1e4;
|
|
14184
|
+
var WKBGeometryType = function(WKBGeometryType2) {
|
|
14185
|
+
WKBGeometryType2[WKBGeometryType2["Point"] = 1] = "Point";
|
|
14186
|
+
WKBGeometryType2[WKBGeometryType2["LineString"] = 2] = "LineString";
|
|
14187
|
+
WKBGeometryType2[WKBGeometryType2["Polygon"] = 3] = "Polygon";
|
|
14188
|
+
WKBGeometryType2[WKBGeometryType2["MultiPoint"] = 4] = "MultiPoint";
|
|
14189
|
+
WKBGeometryType2[WKBGeometryType2["MultiLineString"] = 5] = "MultiLineString";
|
|
14190
|
+
WKBGeometryType2[WKBGeometryType2["MultiPolygon"] = 6] = "MultiPolygon";
|
|
14191
|
+
WKBGeometryType2[WKBGeometryType2["GeometryCollection"] = 7] = "GeometryCollection";
|
|
14192
|
+
return WKBGeometryType2;
|
|
14193
|
+
}({});
|
|
14194
|
+
function isWKB(arrayBuffer) {
|
|
14195
|
+
const dataView = new DataView(arrayBuffer);
|
|
14196
|
+
let byteOffset = 0;
|
|
14197
|
+
const endianness = dataView.getUint8(byteOffset);
|
|
14198
|
+
byteOffset += 1;
|
|
14199
|
+
if (endianness > 1) {
|
|
14200
|
+
return false;
|
|
14201
|
+
}
|
|
14202
|
+
const littleEndian = endianness === 1;
|
|
14203
|
+
const geometry = dataView.getUint32(byteOffset, littleEndian);
|
|
14204
|
+
byteOffset += 4;
|
|
14205
|
+
const geometryType = geometry & 7;
|
|
14206
|
+
if (geometryType === 0 || geometryType > 7) {
|
|
14207
|
+
return false;
|
|
14208
|
+
}
|
|
14209
|
+
const geometryFlags = geometry - geometryType;
|
|
14210
|
+
if (geometryFlags === 0 || geometryFlags === 1e3 || geometryFlags === 2e3 || geometryFlags === 3e3) {
|
|
14211
|
+
return true;
|
|
14212
|
+
}
|
|
14213
|
+
if ((geometryFlags & ~(EWKB_FLAG_Z | EWKB_FLAG_M | EWKB_FLAG_SRID)) !== 0) {
|
|
14214
|
+
return false;
|
|
14215
|
+
}
|
|
14216
|
+
if (geometryFlags & EWKB_FLAG_SRID) {
|
|
14217
|
+
const srid = dataView.getUint32(byteOffset, littleEndian);
|
|
14218
|
+
byteOffset += 4;
|
|
14219
|
+
if (srid > MAX_SRID) {
|
|
14220
|
+
return false;
|
|
14221
|
+
}
|
|
14222
|
+
}
|
|
14223
|
+
return true;
|
|
14224
|
+
}
|
|
14225
|
+
function parseWKBHeader(dataView, target) {
|
|
14226
|
+
const wkbHeader = Object.assign(target || {}, {
|
|
14227
|
+
type: "wkb",
|
|
14228
|
+
geometryType: 1,
|
|
14229
|
+
dimensions: 2,
|
|
14230
|
+
coordinates: "xy",
|
|
14231
|
+
littleEndian: true,
|
|
14232
|
+
byteOffset: 0
|
|
14233
|
+
});
|
|
14234
|
+
wkbHeader.littleEndian = dataView.getUint8(wkbHeader.byteOffset) === 1;
|
|
14235
|
+
wkbHeader.byteOffset++;
|
|
14236
|
+
const geometryCode = dataView.getUint32(wkbHeader.byteOffset, wkbHeader.littleEndian);
|
|
14237
|
+
wkbHeader.byteOffset += 4;
|
|
14238
|
+
wkbHeader.geometryType = geometryCode & 7;
|
|
14239
|
+
const isoType = (geometryCode - wkbHeader.geometryType) / 1e3;
|
|
14240
|
+
switch (isoType) {
|
|
14241
|
+
case 0:
|
|
14242
|
+
break;
|
|
14243
|
+
case 1:
|
|
14244
|
+
wkbHeader.type = "iso-wkb";
|
|
14245
|
+
wkbHeader.dimensions = 3;
|
|
14246
|
+
wkbHeader.coordinates = "xyz";
|
|
14247
|
+
break;
|
|
14248
|
+
case 2:
|
|
14249
|
+
wkbHeader.type = "iso-wkb";
|
|
14250
|
+
wkbHeader.dimensions = 3;
|
|
14251
|
+
wkbHeader.coordinates = "xym";
|
|
14252
|
+
break;
|
|
14253
|
+
case 3:
|
|
14254
|
+
wkbHeader.type = "iso-wkb";
|
|
14255
|
+
wkbHeader.dimensions = 4;
|
|
14256
|
+
wkbHeader.coordinates = "xyzm";
|
|
14257
|
+
break;
|
|
14258
|
+
default:
|
|
14259
|
+
throw new Error(`WKB: Unsupported iso-wkb type: ${isoType}`);
|
|
14260
|
+
}
|
|
14261
|
+
const ewkbZ = geometryCode & EWKB_FLAG_Z;
|
|
14262
|
+
const ewkbM = geometryCode & EWKB_FLAG_M;
|
|
14263
|
+
const ewkbSRID = geometryCode & EWKB_FLAG_SRID;
|
|
14264
|
+
if (ewkbZ && ewkbM) {
|
|
14265
|
+
wkbHeader.type = "ewkb";
|
|
14266
|
+
wkbHeader.dimensions = 4;
|
|
14267
|
+
wkbHeader.coordinates = "xyzm";
|
|
14268
|
+
} else if (ewkbZ) {
|
|
14269
|
+
wkbHeader.type = "ewkb";
|
|
14270
|
+
wkbHeader.dimensions = 3;
|
|
14271
|
+
wkbHeader.coordinates = "xyz";
|
|
14272
|
+
} else if (ewkbM) {
|
|
14273
|
+
wkbHeader.type = "ewkb";
|
|
14274
|
+
wkbHeader.dimensions = 3;
|
|
14275
|
+
wkbHeader.coordinates = "xym";
|
|
14276
|
+
}
|
|
14277
|
+
if (ewkbSRID) {
|
|
14278
|
+
wkbHeader.type = "ewkb";
|
|
14279
|
+
wkbHeader.srid = dataView.getUint32(wkbHeader.byteOffset, wkbHeader.littleEndian);
|
|
14280
|
+
wkbHeader.byteOffset += 4;
|
|
14281
|
+
}
|
|
14282
|
+
return wkbHeader;
|
|
14283
|
+
}
|
|
14284
|
+
|
|
14285
|
+
// ../wkt/src/lib/parse-wkb.ts
|
|
14286
|
+
function parseWKB(arrayBuffer, options) {
|
|
14287
|
+
const binaryGeometry = parseWKBToBinary(arrayBuffer, options);
|
|
14288
|
+
const shape = options?.wkb?.shape || "binary-geometry";
|
|
14289
|
+
switch (shape) {
|
|
14290
|
+
case "binary-geometry":
|
|
14291
|
+
return binaryGeometry;
|
|
14292
|
+
case "geojson-geometry":
|
|
14293
|
+
return binaryToGeometry(binaryGeometry);
|
|
14294
|
+
case "geometry":
|
|
14295
|
+
console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead');
|
|
14296
|
+
return binaryToGeometry(binaryGeometry);
|
|
14297
|
+
default:
|
|
14298
|
+
throw new Error(shape);
|
|
14299
|
+
}
|
|
14300
|
+
}
|
|
14301
|
+
function parseWKBToBinary(arrayBuffer, options) {
|
|
14302
|
+
const dataView = new DataView(arrayBuffer);
|
|
14303
|
+
const wkbHeader = parseWKBHeader(dataView);
|
|
14304
|
+
const {
|
|
14305
|
+
geometryType,
|
|
14306
|
+
dimensions,
|
|
14307
|
+
littleEndian
|
|
14308
|
+
} = wkbHeader;
|
|
14309
|
+
const offset = wkbHeader.byteOffset;
|
|
14310
|
+
switch (geometryType) {
|
|
14311
|
+
case WKBGeometryType.Point:
|
|
14312
|
+
const point = parsePoint2(dataView, offset, dimensions, littleEndian);
|
|
14313
|
+
return point.geometry;
|
|
14314
|
+
case WKBGeometryType.LineString:
|
|
14315
|
+
const line = parseLineString2(dataView, offset, dimensions, littleEndian);
|
|
14316
|
+
return line.geometry;
|
|
14317
|
+
case WKBGeometryType.Polygon:
|
|
14318
|
+
const polygon = parsePolygon2(dataView, offset, dimensions, littleEndian);
|
|
14319
|
+
return polygon.geometry;
|
|
14320
|
+
case WKBGeometryType.MultiPoint:
|
|
14321
|
+
const multiPoint = parseMultiPoint2(dataView, offset, dimensions, littleEndian);
|
|
14322
|
+
multiPoint.type = "Point";
|
|
14323
|
+
return multiPoint;
|
|
14324
|
+
case WKBGeometryType.MultiLineString:
|
|
14325
|
+
const multiLine = parseMultiLineString2(dataView, offset, dimensions, littleEndian);
|
|
14326
|
+
multiLine.type = "LineString";
|
|
14327
|
+
return multiLine;
|
|
14328
|
+
case WKBGeometryType.MultiPolygon:
|
|
14329
|
+
const multiPolygon = parseMultiPolygon2(dataView, offset, dimensions, littleEndian);
|
|
14330
|
+
multiPolygon.type = "Polygon";
|
|
14331
|
+
return multiPolygon;
|
|
14332
|
+
default:
|
|
14333
|
+
throw new Error(`WKB: Unsupported geometry type: ${geometryType}`);
|
|
14334
|
+
}
|
|
14335
|
+
}
|
|
14336
|
+
function parsePoint2(dataView, offset, dimension, littleEndian) {
|
|
14337
|
+
const positions = new Float64Array(dimension);
|
|
14338
|
+
for (let i = 0; i < dimension; i++) {
|
|
14339
|
+
positions[i] = dataView.getFloat64(offset, littleEndian);
|
|
14340
|
+
offset += 8;
|
|
14341
|
+
}
|
|
14342
|
+
return {
|
|
14343
|
+
geometry: {
|
|
14344
|
+
type: "Point",
|
|
14345
|
+
positions: {
|
|
14346
|
+
value: positions,
|
|
14347
|
+
size: dimension
|
|
14348
|
+
}
|
|
14349
|
+
},
|
|
14350
|
+
offset
|
|
14351
|
+
};
|
|
14352
|
+
}
|
|
14353
|
+
function parseLineString2(dataView, offset, dimension, littleEndian) {
|
|
14354
|
+
const nPoints = dataView.getUint32(offset, littleEndian);
|
|
14355
|
+
offset += 4;
|
|
14356
|
+
const positions = new Float64Array(nPoints * dimension);
|
|
14357
|
+
for (let i = 0; i < nPoints * dimension; i++) {
|
|
14358
|
+
positions[i] = dataView.getFloat64(offset, littleEndian);
|
|
14359
|
+
offset += 8;
|
|
14360
|
+
}
|
|
14361
|
+
const pathIndices = [0];
|
|
14362
|
+
if (nPoints > 0) {
|
|
14363
|
+
pathIndices.push(nPoints);
|
|
14364
|
+
}
|
|
14365
|
+
return {
|
|
14366
|
+
geometry: {
|
|
14367
|
+
type: "LineString",
|
|
14368
|
+
positions: {
|
|
14369
|
+
value: positions,
|
|
14370
|
+
size: dimension
|
|
14371
|
+
},
|
|
14372
|
+
pathIndices: {
|
|
14373
|
+
value: new Uint16Array(pathIndices),
|
|
14374
|
+
size: 1
|
|
14375
|
+
}
|
|
14376
|
+
},
|
|
14377
|
+
offset
|
|
14378
|
+
};
|
|
14379
|
+
}
|
|
14380
|
+
var cumulativeSum = (sum2) => (value) => sum2 += value;
|
|
14381
|
+
function parsePolygon2(dataView, offset, dimension, littleEndian) {
|
|
14382
|
+
const nRings = dataView.getUint32(offset, littleEndian);
|
|
14383
|
+
offset += 4;
|
|
14384
|
+
const rings = [];
|
|
14385
|
+
for (let i = 0; i < nRings; i++) {
|
|
14386
|
+
const parsed = parseLineString2(dataView, offset, dimension, littleEndian);
|
|
14387
|
+
const {
|
|
14388
|
+
positions
|
|
14389
|
+
} = parsed.geometry;
|
|
14390
|
+
offset = parsed.offset;
|
|
14391
|
+
rings.push(positions.value);
|
|
14392
|
+
}
|
|
14393
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(rings).buffer);
|
|
14394
|
+
const polygonIndices = [0];
|
|
14395
|
+
if (concatenatedPositions.length > 0) {
|
|
14396
|
+
polygonIndices.push(concatenatedPositions.length / dimension);
|
|
14397
|
+
}
|
|
14398
|
+
const primitivePolygonIndices = rings.map((l) => l.length / dimension).map(cumulativeSum(0));
|
|
14399
|
+
primitivePolygonIndices.unshift(0);
|
|
14400
|
+
return {
|
|
14401
|
+
geometry: {
|
|
14402
|
+
type: "Polygon",
|
|
14403
|
+
positions: {
|
|
14404
|
+
value: concatenatedPositions,
|
|
14405
|
+
size: dimension
|
|
14406
|
+
},
|
|
14407
|
+
polygonIndices: {
|
|
14408
|
+
value: new Uint16Array(polygonIndices),
|
|
14409
|
+
size: 1
|
|
14410
|
+
},
|
|
14411
|
+
primitivePolygonIndices: {
|
|
14412
|
+
value: new Uint16Array(primitivePolygonIndices),
|
|
14413
|
+
size: 1
|
|
14414
|
+
}
|
|
14415
|
+
},
|
|
14416
|
+
offset
|
|
14417
|
+
};
|
|
14418
|
+
}
|
|
14419
|
+
function parseMultiPoint2(dataView, offset, dimension, littleEndian) {
|
|
14420
|
+
const nPoints = dataView.getUint32(offset, littleEndian);
|
|
14421
|
+
offset += 4;
|
|
14422
|
+
const binaryPointGeometries = [];
|
|
14423
|
+
for (let i = 0; i < nPoints; i++) {
|
|
14424
|
+
const littleEndianPoint = dataView.getUint8(offset) === 1;
|
|
14425
|
+
offset++;
|
|
14426
|
+
if (dataView.getUint32(offset, littleEndianPoint) % 1e3 !== 1) {
|
|
14427
|
+
throw new Error("WKB: Inner geometries of MultiPoint not of type Point");
|
|
14428
|
+
}
|
|
14429
|
+
offset += 4;
|
|
14430
|
+
const parsed = parsePoint2(dataView, offset, dimension, littleEndianPoint);
|
|
14431
|
+
offset = parsed.offset;
|
|
14432
|
+
binaryPointGeometries.push(parsed.geometry);
|
|
14433
|
+
}
|
|
14434
|
+
return concatenateBinaryPointGeometries(binaryPointGeometries, dimension);
|
|
14435
|
+
}
|
|
14436
|
+
function parseMultiLineString2(dataView, offset, dimension, littleEndian) {
|
|
14437
|
+
const nLines = dataView.getUint32(offset, littleEndian);
|
|
14438
|
+
offset += 4;
|
|
14439
|
+
const binaryLineGeometries = [];
|
|
14440
|
+
for (let i = 0; i < nLines; i++) {
|
|
14441
|
+
const littleEndianLine = dataView.getUint8(offset) === 1;
|
|
14442
|
+
offset++;
|
|
14443
|
+
if (dataView.getUint32(offset, littleEndianLine) % 1e3 !== 2) {
|
|
14444
|
+
throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");
|
|
14445
|
+
}
|
|
14446
|
+
offset += 4;
|
|
14447
|
+
const parsed = parseLineString2(dataView, offset, dimension, littleEndianLine);
|
|
14448
|
+
offset = parsed.offset;
|
|
14449
|
+
binaryLineGeometries.push(parsed.geometry);
|
|
14450
|
+
}
|
|
14451
|
+
return concatenateBinaryLineGeometries(binaryLineGeometries, dimension);
|
|
14452
|
+
}
|
|
14453
|
+
function parseMultiPolygon2(dataView, offset, dimension, littleEndian) {
|
|
14454
|
+
const nPolygons = dataView.getUint32(offset, littleEndian);
|
|
14455
|
+
offset += 4;
|
|
14456
|
+
const binaryPolygonGeometries = [];
|
|
14457
|
+
for (let i = 0; i < nPolygons; i++) {
|
|
14458
|
+
const littleEndianPolygon = dataView.getUint8(offset) === 1;
|
|
14459
|
+
offset++;
|
|
14460
|
+
if (dataView.getUint32(offset, littleEndianPolygon) % 1e3 !== 3) {
|
|
14461
|
+
throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");
|
|
14462
|
+
}
|
|
14463
|
+
offset += 4;
|
|
14464
|
+
const parsed = parsePolygon2(dataView, offset, dimension, littleEndianPolygon);
|
|
14465
|
+
offset = parsed.offset;
|
|
14466
|
+
binaryPolygonGeometries.push(parsed.geometry);
|
|
14467
|
+
}
|
|
14468
|
+
return concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension);
|
|
14469
|
+
}
|
|
14470
|
+
function concatenateBinaryPointGeometries(binaryPointGeometries, dimension) {
|
|
14471
|
+
const positions = binaryPointGeometries.map((geometry) => geometry.positions.value);
|
|
14472
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(positions).buffer);
|
|
14473
|
+
return {
|
|
14474
|
+
type: "Point",
|
|
14475
|
+
positions: {
|
|
14476
|
+
value: concatenatedPositions,
|
|
14477
|
+
size: dimension
|
|
14478
|
+
}
|
|
14479
|
+
};
|
|
14480
|
+
}
|
|
14481
|
+
function concatenateBinaryLineGeometries(binaryLineGeometries, dimension) {
|
|
14482
|
+
const lines = binaryLineGeometries.map((geometry) => geometry.positions.value);
|
|
14483
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(lines).buffer);
|
|
14484
|
+
const pathIndices = lines.map((line) => line.length / dimension).map(cumulativeSum(0));
|
|
14485
|
+
pathIndices.unshift(0);
|
|
14486
|
+
return {
|
|
14487
|
+
type: "LineString",
|
|
14488
|
+
positions: {
|
|
14489
|
+
value: concatenatedPositions,
|
|
14490
|
+
size: dimension
|
|
14491
|
+
},
|
|
14492
|
+
pathIndices: {
|
|
14493
|
+
value: new Uint16Array(pathIndices),
|
|
14494
|
+
size: 1
|
|
14495
|
+
}
|
|
14496
|
+
};
|
|
14497
|
+
}
|
|
14498
|
+
function concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension) {
|
|
14499
|
+
const polygons = [];
|
|
14500
|
+
const primitivePolygons = [];
|
|
14501
|
+
for (const binaryPolygon of binaryPolygonGeometries) {
|
|
14502
|
+
const {
|
|
14503
|
+
positions,
|
|
14504
|
+
primitivePolygonIndices: primitivePolygonIndices2
|
|
14505
|
+
} = binaryPolygon;
|
|
14506
|
+
polygons.push(positions.value);
|
|
14507
|
+
primitivePolygons.push(primitivePolygonIndices2.value);
|
|
14508
|
+
}
|
|
14509
|
+
const concatenatedPositions = new Float64Array(concatTypedArrays(polygons).buffer);
|
|
14510
|
+
const polygonIndices = polygons.map((p) => p.length / dimension).map(cumulativeSum(0));
|
|
14511
|
+
polygonIndices.unshift(0);
|
|
14512
|
+
const primitivePolygonIndices = [0];
|
|
14513
|
+
for (const primitivePolygon of primitivePolygons) {
|
|
14514
|
+
primitivePolygonIndices.push(...primitivePolygon.filter((x) => x > 0).map((x) => x + primitivePolygonIndices[primitivePolygonIndices.length - 1]));
|
|
14515
|
+
}
|
|
14516
|
+
return {
|
|
14517
|
+
type: "Polygon",
|
|
14518
|
+
positions: {
|
|
14519
|
+
value: concatenatedPositions,
|
|
14520
|
+
size: dimension
|
|
14521
|
+
},
|
|
14522
|
+
polygonIndices: {
|
|
14523
|
+
value: new Uint16Array(polygonIndices),
|
|
14524
|
+
size: 1
|
|
14525
|
+
},
|
|
14526
|
+
primitivePolygonIndices: {
|
|
14527
|
+
value: new Uint16Array(primitivePolygonIndices),
|
|
14528
|
+
size: 1
|
|
14529
|
+
}
|
|
14530
|
+
};
|
|
14531
|
+
}
|
|
14532
|
+
function concatTypedArrays(arrays) {
|
|
14533
|
+
let byteLength = 0;
|
|
14534
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
14535
|
+
byteLength += arrays[i].byteLength;
|
|
14536
|
+
}
|
|
14537
|
+
const buffer = new Uint8Array(byteLength);
|
|
14538
|
+
let byteOffset = 0;
|
|
14539
|
+
for (let i = 0; i < arrays.length; ++i) {
|
|
14540
|
+
const data = new Uint8Array(arrays[i].buffer);
|
|
14541
|
+
byteLength = data.length;
|
|
14542
|
+
for (let j = 0; j < byteLength; ++j) {
|
|
14543
|
+
buffer[byteOffset++] = data[j];
|
|
14544
|
+
}
|
|
14545
|
+
}
|
|
14546
|
+
return buffer;
|
|
14547
|
+
}
|
|
14548
|
+
|
|
14549
|
+
// ../wkt/src/wkb-loader.ts
|
|
14550
|
+
var WKBWorkerLoader = {
|
|
14551
|
+
name: "WKB",
|
|
14552
|
+
id: "wkb",
|
|
14553
|
+
module: "wkt",
|
|
14554
|
+
version: VERSION3,
|
|
14555
|
+
worker: true,
|
|
14556
|
+
category: "geometry",
|
|
14557
|
+
extensions: ["wkb"],
|
|
14558
|
+
mimeTypes: [],
|
|
14559
|
+
tests: [isWKB],
|
|
14560
|
+
options: {
|
|
14561
|
+
wkb: {
|
|
14562
|
+
shape: "binary-geometry"
|
|
14563
|
+
}
|
|
14564
|
+
}
|
|
14565
|
+
};
|
|
14566
|
+
var WKBLoader = {
|
|
14567
|
+
...WKBWorkerLoader,
|
|
14568
|
+
parse: async (arrayBuffer) => parseWKB(arrayBuffer),
|
|
14569
|
+
parseSync: parseWKB
|
|
14570
|
+
};
|
|
14571
|
+
|
|
14572
|
+
// src/geoarrow/convert-geoarrow-to-geojson-geometry.ts
|
|
14573
|
+
function parseGeometryFromArrow(arrowCellValue, encoding) {
|
|
14574
|
+
encoding = encoding?.toLowerCase();
|
|
14575
|
+
if (!encoding || !arrowCellValue) {
|
|
13788
14576
|
return null;
|
|
13789
14577
|
}
|
|
13790
14578
|
let geometry;
|
|
13791
14579
|
switch (encoding) {
|
|
13792
14580
|
case "geoarrow.multipolygon":
|
|
13793
|
-
geometry = arrowMultiPolygonToFeature(
|
|
14581
|
+
geometry = arrowMultiPolygonToFeature(arrowCellValue);
|
|
13794
14582
|
break;
|
|
13795
14583
|
case "geoarrow.polygon":
|
|
13796
|
-
geometry = arrowPolygonToFeature(
|
|
14584
|
+
geometry = arrowPolygonToFeature(arrowCellValue);
|
|
13797
14585
|
break;
|
|
13798
14586
|
case "geoarrow.multipoint":
|
|
13799
|
-
geometry = arrowMultiPointToFeature(
|
|
14587
|
+
geometry = arrowMultiPointToFeature(arrowCellValue);
|
|
13800
14588
|
break;
|
|
13801
14589
|
case "geoarrow.point":
|
|
13802
|
-
geometry = arrowPointToFeature(
|
|
14590
|
+
geometry = arrowPointToFeature(arrowCellValue);
|
|
13803
14591
|
break;
|
|
13804
14592
|
case "geoarrow.multilinestring":
|
|
13805
|
-
geometry = arrowMultiLineStringToFeature(
|
|
14593
|
+
geometry = arrowMultiLineStringToFeature(arrowCellValue);
|
|
13806
14594
|
break;
|
|
13807
14595
|
case "geoarrow.linestring":
|
|
13808
|
-
geometry = arrowLineStringToFeature(
|
|
14596
|
+
geometry = arrowLineStringToFeature(arrowCellValue);
|
|
13809
14597
|
break;
|
|
13810
14598
|
case "geoarrow.wkb":
|
|
13811
|
-
|
|
14599
|
+
geometry = arrowWKBToFeature(arrowCellValue);
|
|
14600
|
+
break;
|
|
13812
14601
|
case "geoarrow.wkt":
|
|
13813
|
-
|
|
14602
|
+
geometry = arrowWKTToFeature(arrowCellValue);
|
|
14603
|
+
break;
|
|
13814
14604
|
default: {
|
|
13815
14605
|
throw Error(`GeoArrow encoding not supported ${encoding}`);
|
|
13816
14606
|
}
|
|
13817
14607
|
}
|
|
13818
|
-
return
|
|
13819
|
-
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
14608
|
+
return geometry;
|
|
14609
|
+
}
|
|
14610
|
+
function arrowWKBToFeature(arrowCellValue) {
|
|
14611
|
+
const arrayBuffer = arrowCellValue.buffer.slice(arrowCellValue.byteOffset, arrowCellValue.byteOffset + arrowCellValue.byteLength);
|
|
14612
|
+
const binaryGeometry = WKBLoader.parseSync?.(arrayBuffer);
|
|
14613
|
+
const geometry = binaryToGeometry(binaryGeometry);
|
|
14614
|
+
return geometry;
|
|
14615
|
+
}
|
|
14616
|
+
function arrowWKTToFeature(arrowCellValue) {
|
|
14617
|
+
const string = arrowCellValue;
|
|
14618
|
+
return WKTLoader.parseTextSync?.(string);
|
|
13823
14619
|
}
|
|
13824
14620
|
function arrowMultiPolygonToFeature(arrowMultiPolygon) {
|
|
13825
14621
|
const multiPolygon = [];
|
|
@@ -13851,8 +14647,8 @@ return true;`);
|
|
|
13851
14647
|
const ring = [];
|
|
13852
14648
|
for (let j = 0; arrowRing && j < arrowRing.length; j++) {
|
|
13853
14649
|
const arrowCoord = arrowRing.get(j);
|
|
13854
|
-
const
|
|
13855
|
-
ring.push(
|
|
14650
|
+
const coords2 = Array.from(arrowCoord);
|
|
14651
|
+
ring.push(coords2);
|
|
13856
14652
|
}
|
|
13857
14653
|
polygon.push(ring);
|
|
13858
14654
|
}
|
|
@@ -13871,19 +14667,17 @@ return true;`);
|
|
|
13871
14667
|
multiPoint.push(coord);
|
|
13872
14668
|
}
|
|
13873
14669
|
}
|
|
13874
|
-
|
|
14670
|
+
return {
|
|
13875
14671
|
type: "MultiPoint",
|
|
13876
14672
|
coordinates: multiPoint
|
|
13877
14673
|
};
|
|
13878
|
-
return geometry;
|
|
13879
14674
|
}
|
|
13880
14675
|
function arrowPointToFeature(arrowPoint) {
|
|
13881
14676
|
const point = Array.from(arrowPoint);
|
|
13882
|
-
|
|
14677
|
+
return {
|
|
13883
14678
|
type: "Point",
|
|
13884
14679
|
coordinates: point
|
|
13885
14680
|
};
|
|
13886
|
-
return geometry;
|
|
13887
14681
|
}
|
|
13888
14682
|
function arrowMultiLineStringToFeature(arrowMultiLineString) {
|
|
13889
14683
|
const multiLineString = [];
|
|
@@ -13893,32 +14687,64 @@ return true;`);
|
|
|
13893
14687
|
for (let j = 0; arrowLineString && j < arrowLineString.length; j++) {
|
|
13894
14688
|
const arrowCoord = arrowLineString.get(j);
|
|
13895
14689
|
if (arrowCoord) {
|
|
13896
|
-
const
|
|
13897
|
-
lineString.push(
|
|
14690
|
+
const coords2 = Array.from(arrowCoord);
|
|
14691
|
+
lineString.push(coords2);
|
|
13898
14692
|
}
|
|
13899
14693
|
}
|
|
13900
14694
|
multiLineString.push(lineString);
|
|
13901
14695
|
}
|
|
13902
|
-
|
|
14696
|
+
return {
|
|
13903
14697
|
type: "MultiLineString",
|
|
13904
14698
|
coordinates: multiLineString
|
|
13905
14699
|
};
|
|
13906
|
-
return geometry;
|
|
13907
14700
|
}
|
|
13908
14701
|
function arrowLineStringToFeature(arrowLineString) {
|
|
13909
14702
|
const lineString = [];
|
|
13910
14703
|
for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
|
|
13911
14704
|
const arrowCoord = arrowLineString.get(i);
|
|
13912
14705
|
if (arrowCoord) {
|
|
13913
|
-
const
|
|
13914
|
-
lineString.push(
|
|
14706
|
+
const coords2 = Array.from(arrowCoord);
|
|
14707
|
+
lineString.push(coords2);
|
|
13915
14708
|
}
|
|
13916
14709
|
}
|
|
13917
|
-
|
|
14710
|
+
return {
|
|
13918
14711
|
type: "LineString",
|
|
13919
14712
|
coordinates: lineString
|
|
13920
14713
|
};
|
|
13921
|
-
|
|
14714
|
+
}
|
|
14715
|
+
|
|
14716
|
+
// src/workers/hard-clone.ts
|
|
14717
|
+
function hardClone(data, force = false) {
|
|
14718
|
+
if ("data" in data) {
|
|
14719
|
+
return new Vector(data.data.map((data2) => hardClone(data2, force)));
|
|
14720
|
+
}
|
|
14721
|
+
const clonedChildren = [];
|
|
14722
|
+
for (const childData of data.children) {
|
|
14723
|
+
clonedChildren.push(hardClone(childData, force));
|
|
14724
|
+
}
|
|
14725
|
+
let clonedDictionary;
|
|
14726
|
+
if (data.dictionary !== void 0) {
|
|
14727
|
+
clonedDictionary = hardClone(data.dictionary, force);
|
|
14728
|
+
}
|
|
14729
|
+
const clonedBuffers = {
|
|
14730
|
+
[BufferType.OFFSET]: cloneBuffer(data.buffers[BufferType.OFFSET], force),
|
|
14731
|
+
[BufferType.DATA]: cloneBuffer(data.buffers[BufferType.DATA], force),
|
|
14732
|
+
[BufferType.VALIDITY]: cloneBuffer(data.buffers[BufferType.VALIDITY], force),
|
|
14733
|
+
[BufferType.TYPE]: cloneBuffer(data.buffers[BufferType.TYPE], force)
|
|
14734
|
+
};
|
|
14735
|
+
return new Data(data.type, data.offset, data.length, data._nullCount, clonedBuffers, clonedChildren, clonedDictionary);
|
|
14736
|
+
}
|
|
14737
|
+
function isTypedArraySliced(arr) {
|
|
14738
|
+
return !(arr.byteOffset === 0 && arr.byteLength === arr.buffer.byteLength);
|
|
14739
|
+
}
|
|
14740
|
+
function cloneBuffer(arr, force) {
|
|
14741
|
+
if (arr === void 0) {
|
|
14742
|
+
return arr;
|
|
14743
|
+
}
|
|
14744
|
+
if (!force && !isTypedArraySliced(arr)) {
|
|
14745
|
+
return arr;
|
|
14746
|
+
}
|
|
14747
|
+
return arr.slice();
|
|
13922
14748
|
}
|
|
13923
14749
|
|
|
13924
14750
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
@@ -13935,7 +14761,7 @@ return true;`);
|
|
|
13935
14761
|
}
|
|
13936
14762
|
return globalThis._loadersgl_.version;
|
|
13937
14763
|
}
|
|
13938
|
-
var
|
|
14764
|
+
var VERSION4 = getVersion();
|
|
13939
14765
|
|
|
13940
14766
|
// ../worker-utils/src/lib/env-utils/assert.ts
|
|
13941
14767
|
function assert(condition, message) {
|
|
@@ -14377,7 +15203,7 @@ return true;`);
|
|
|
14377
15203
|
|
|
14378
15204
|
// ../worker-utils/src/lib/worker-api/get-worker-url.ts
|
|
14379
15205
|
function getWorkerName(worker) {
|
|
14380
|
-
const warning = worker.version !==
|
|
15206
|
+
const warning = worker.version !== VERSION4 ? ` (worker-utils@${VERSION4})` : "";
|
|
14381
15207
|
return `${worker.name}@${worker.version}${warning}`;
|
|
14382
15208
|
}
|
|
14383
15209
|
function getWorkerURL(worker, options = {}) {
|
|
@@ -14472,16 +15298,25 @@ return true;`);
|
|
|
14472
15298
|
}
|
|
14473
15299
|
|
|
14474
15300
|
// src/triangulate-on-worker.ts
|
|
14475
|
-
var
|
|
15301
|
+
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
14476
15302
|
var TriangulationWorker = {
|
|
14477
15303
|
id: "triangulation",
|
|
14478
15304
|
name: "Triangulate",
|
|
14479
15305
|
module: "arrow",
|
|
14480
|
-
version:
|
|
15306
|
+
version: VERSION5,
|
|
14481
15307
|
options: {}
|
|
14482
15308
|
};
|
|
14483
15309
|
function triangulateOnWorker(data, options = {}) {
|
|
14484
|
-
return processOnWorker(TriangulationWorker,
|
|
15310
|
+
return processOnWorker(TriangulationWorker, {
|
|
15311
|
+
...data,
|
|
15312
|
+
operation: "triangulate"
|
|
15313
|
+
}, options);
|
|
15314
|
+
}
|
|
15315
|
+
function parseGeoArrowOnWorker(data, options = {}) {
|
|
15316
|
+
return processOnWorker(TriangulationWorker, {
|
|
15317
|
+
...data,
|
|
15318
|
+
operation: "parse-geoarrow"
|
|
15319
|
+
}, options);
|
|
14485
15320
|
}
|
|
14486
15321
|
|
|
14487
15322
|
// src/index.ts
|