@loaders.gl/arrow 4.3.2 → 4.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow-loader.d.ts +1 -1
- package/dist/arrow-worker.js +638 -1292
- package/dist/arrow-writer.js +1 -1
- package/dist/dist.dev.js +2140 -3383
- package/dist/dist.min.js +5 -5
- package/dist/exports/arrow-format.d.ts +12 -0
- package/dist/exports/arrow-format.d.ts.map +1 -0
- package/dist/exports/arrow-format.js +18 -0
- package/dist/exports/arrow-loader.d.ts +1 -1
- package/dist/exports/arrow-loader.d.ts.map +1 -1
- package/dist/exports/arrow-loader.js +1 -1
- package/dist/exports/geoarrow-loader.d.ts +1 -1
- package/dist/exports/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-loader.d.ts +1 -2
- package/dist/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-writer.d.ts +3 -3
- package/dist/geoarrow-writer.d.ts.map +1 -1
- package/dist/geoarrow-writer.js +1 -1
- package/dist/index.cjs +39 -952
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -14
- package/dist/lib/parsers/parse-arrow.d.ts +1 -2
- package/dist/lib/parsers/parse-arrow.d.ts.map +1 -1
- package/dist/lib/parsers/parse-arrow.js +1 -1
- package/dist/lib/parsers/parse-geoarrow.d.ts +1 -2
- package/dist/lib/parsers/parse-geoarrow.d.ts.map +1 -1
- package/dist/lib/parsers/parse-geoarrow.js +2 -2
- package/dist/triangulate-on-worker.d.ts +2 -1
- package/dist/triangulate-on-worker.d.ts.map +1 -1
- package/dist/triangulate-on-worker.js +1 -1
- package/dist/triangulation-worker.js +212 -154
- package/dist/workers/triangulation-worker.js +2 -2
- package/package.json +10 -9
- package/src/exports/arrow-format.ts +21 -0
- package/src/exports/arrow-loader.ts +1 -1
- package/src/exports/geoarrow-loader.ts +1 -2
- package/src/geoarrow-loader.ts +6 -2
- package/src/geoarrow-writer.ts +1 -1
- package/src/index.ts +2 -42
- package/src/lib/parsers/parse-arrow.ts +2 -3
- package/src/lib/parsers/parse-geoarrow.ts +8 -4
- package/src/triangulate-on-worker.ts +2 -1
- package/src/workers/triangulation-worker.ts +3 -3
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +0 -74
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +0 -1
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.js +0 -377
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts +0 -13
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +0 -1
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.js +0 -176
- package/dist/lib/geoarrow/get-arrow-bounds.d.ts +0 -11
- package/dist/lib/geoarrow/get-arrow-bounds.d.ts.map +0 -1
- package/dist/lib/geoarrow/get-arrow-bounds.js +0 -34
- package/dist/lib/tables/convert-arrow-schema.d.ts +0 -23
- package/dist/lib/tables/convert-arrow-schema.d.ts.map +0 -1
- package/dist/lib/tables/convert-arrow-schema.js +0 -280
- package/dist/lib/tables/convert-arrow-to-table.d.ts +0 -15
- package/dist/lib/tables/convert-arrow-to-table.d.ts.map +0 -1
- package/dist/lib/tables/convert-arrow-to-table.js +0 -104
- package/dist/lib/tables/convert-table-to-arrow.d.ts +0 -16
- package/dist/lib/tables/convert-table-to-arrow.d.ts.map +0 -1
- package/dist/lib/tables/convert-table-to-arrow.js +0 -56
- package/dist/schema/arrow-table-batch.d.ts +0 -10
- package/dist/schema/arrow-table-batch.d.ts.map +0 -1
- package/dist/schema/arrow-table-batch.js +0 -67
- package/dist/schema/arrow-table-type.d.ts +0 -25
- package/dist/schema/arrow-table-type.d.ts.map +0 -1
- package/dist/schema/arrow-table-type.js +0 -4
- package/src/lib/geoarrow/convert-geoarrow-to-binary-geometry.ts +0 -494
- package/src/lib/geoarrow/convert-geoarrow-to-geojson-geometry.ts +0 -207
- package/src/lib/geoarrow/get-arrow-bounds.ts +0 -41
- package/src/lib/tables/convert-arrow-schema.ts +0 -301
- package/src/lib/tables/convert-arrow-to-table.ts +0 -144
- package/src/lib/tables/convert-table-to-arrow.ts +0 -72
- package/src/schema/arrow-table-batch.ts +0 -82
- package/src/schema/arrow-table-type.ts +0 -30
package/dist/arrow-worker.js
CHANGED
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
return await parser(data, { ...options }, context, loader);
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
-
// ../../node_modules/tslib/tslib.es6.mjs
|
|
208
|
+
// ../../node_modules/apache-arrow/node_modules/tslib/tslib.es6.mjs
|
|
209
209
|
function __rest(s, e) {
|
|
210
210
|
var t = {};
|
|
211
211
|
for (var p in s)
|
|
@@ -1610,9 +1610,22 @@
|
|
|
1610
1610
|
this.addInt8(0);
|
|
1611
1611
|
this.startVector(1, utf8.length, 1);
|
|
1612
1612
|
this.bb.setPosition(this.space -= utf8.length);
|
|
1613
|
-
|
|
1614
|
-
|
|
1613
|
+
this.bb.bytes().set(utf8, this.space);
|
|
1614
|
+
return this.endVector();
|
|
1615
|
+
}
|
|
1616
|
+
/**
|
|
1617
|
+
* Create a byte vector.
|
|
1618
|
+
*
|
|
1619
|
+
* @param v The bytes to add
|
|
1620
|
+
* @returns The offset in the buffer where the byte vector starts
|
|
1621
|
+
*/
|
|
1622
|
+
createByteVector(v) {
|
|
1623
|
+
if (v === null || v === void 0) {
|
|
1624
|
+
return 0;
|
|
1615
1625
|
}
|
|
1626
|
+
this.startVector(1, v.length, 1);
|
|
1627
|
+
this.bb.setPosition(this.space -= v.length);
|
|
1628
|
+
this.bb.bytes().set(v, this.space);
|
|
1616
1629
|
return this.endVector();
|
|
1617
1630
|
}
|
|
1618
1631
|
/**
|
|
@@ -3215,9 +3228,9 @@
|
|
|
3215
3228
|
// ../../node_modules/apache-arrow/util/vector.mjs
|
|
3216
3229
|
var vector_exports = {};
|
|
3217
3230
|
__export(vector_exports, {
|
|
3218
|
-
clampIndex: () => clampIndex,
|
|
3219
3231
|
clampRange: () => clampRange,
|
|
3220
|
-
createElementComparator: () => createElementComparator
|
|
3232
|
+
createElementComparator: () => createElementComparator,
|
|
3233
|
+
wrapIndex: () => wrapIndex
|
|
3221
3234
|
});
|
|
3222
3235
|
|
|
3223
3236
|
// ../../node_modules/apache-arrow/util/pretty.mjs
|
|
@@ -3258,9 +3271,23 @@
|
|
|
3258
3271
|
__export(bn_exports, {
|
|
3259
3272
|
BN: () => BN,
|
|
3260
3273
|
bigNumToBigInt: () => bigNumToBigInt,
|
|
3274
|
+
bigNumToNumber: () => bigNumToNumber,
|
|
3261
3275
|
bigNumToString: () => bigNumToString,
|
|
3262
3276
|
isArrowBigNumSymbol: () => isArrowBigNumSymbol
|
|
3263
3277
|
});
|
|
3278
|
+
|
|
3279
|
+
// ../../node_modules/apache-arrow/util/bigint.mjs
|
|
3280
|
+
function bigIntToNumber(number) {
|
|
3281
|
+
if (typeof number === "bigint" && (number < Number.MIN_SAFE_INTEGER || number > Number.MAX_SAFE_INTEGER)) {
|
|
3282
|
+
throw new TypeError(`${number} is not safe to convert to a number.`);
|
|
3283
|
+
}
|
|
3284
|
+
return Number(number);
|
|
3285
|
+
}
|
|
3286
|
+
function divideBigInts(number, divisor) {
|
|
3287
|
+
return bigIntToNumber(number / divisor) + bigIntToNumber(number % divisor) / bigIntToNumber(divisor);
|
|
3288
|
+
}
|
|
3289
|
+
|
|
3290
|
+
// ../../node_modules/apache-arrow/util/bn.mjs
|
|
3264
3291
|
var isArrowBigNumSymbol = Symbol.for("isArrowBigNum");
|
|
3265
3292
|
function BigNum(x, ...xs) {
|
|
3266
3293
|
if (xs.length === 0) {
|
|
@@ -3272,8 +3299,8 @@
|
|
|
3272
3299
|
BigNum.prototype.toJSON = function() {
|
|
3273
3300
|
return `"${bigNumToString(this)}"`;
|
|
3274
3301
|
};
|
|
3275
|
-
BigNum.prototype.valueOf = function() {
|
|
3276
|
-
return bigNumToNumber(this);
|
|
3302
|
+
BigNum.prototype.valueOf = function(scale) {
|
|
3303
|
+
return bigNumToNumber(this, scale);
|
|
3277
3304
|
};
|
|
3278
3305
|
BigNum.prototype.toString = function() {
|
|
3279
3306
|
return bigNumToString(this);
|
|
@@ -3304,25 +3331,34 @@
|
|
|
3304
3331
|
Object.assign(SignedBigNum.prototype, BigNum.prototype, { "constructor": SignedBigNum, "signed": true, "TypedArray": Int32Array, "BigIntArray": BigInt64Array });
|
|
3305
3332
|
Object.assign(UnsignedBigNum.prototype, BigNum.prototype, { "constructor": UnsignedBigNum, "signed": false, "TypedArray": Uint32Array, "BigIntArray": BigUint64Array });
|
|
3306
3333
|
Object.assign(DecimalBigNum.prototype, BigNum.prototype, { "constructor": DecimalBigNum, "signed": true, "TypedArray": Uint32Array, "BigIntArray": BigUint64Array });
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3334
|
+
var TWO_TO_THE_64 = BigInt(4294967296) * BigInt(4294967296);
|
|
3335
|
+
var TWO_TO_THE_64_MINUS_1 = TWO_TO_THE_64 - BigInt(1);
|
|
3336
|
+
function bigNumToNumber(bn, scale) {
|
|
3337
|
+
const { buffer, byteOffset, byteLength, "signed": signed } = bn;
|
|
3338
|
+
const words = new BigUint64Array(buffer, byteOffset, byteLength / 8);
|
|
3310
3339
|
const negative = signed && words.at(-1) & BigInt(1) << BigInt(63);
|
|
3311
|
-
let number =
|
|
3312
|
-
let i =
|
|
3313
|
-
if (
|
|
3340
|
+
let number = BigInt(0);
|
|
3341
|
+
let i = 0;
|
|
3342
|
+
if (negative) {
|
|
3314
3343
|
for (const word of words) {
|
|
3315
|
-
number
|
|
3344
|
+
number |= (word ^ TWO_TO_THE_64_MINUS_1) * (BigInt(1) << BigInt(64 * i++));
|
|
3316
3345
|
}
|
|
3346
|
+
number *= BigInt(-1);
|
|
3347
|
+
number -= BigInt(1);
|
|
3317
3348
|
} else {
|
|
3318
3349
|
for (const word of words) {
|
|
3319
|
-
number
|
|
3350
|
+
number |= word * (BigInt(1) << BigInt(64 * i++));
|
|
3320
3351
|
}
|
|
3321
|
-
number *= BigInt(-1);
|
|
3322
3352
|
}
|
|
3323
|
-
|
|
3353
|
+
if (typeof scale === "number") {
|
|
3354
|
+
const denominator = BigInt(Math.pow(10, scale));
|
|
3355
|
+
const quotient = number / denominator;
|
|
3356
|
+
const remainder = number % denominator;
|
|
3357
|
+
return bigIntToNumber(quotient) + bigIntToNumber(remainder) / bigIntToNumber(denominator);
|
|
3358
|
+
}
|
|
3359
|
+
return bigIntToNumber(number);
|
|
3324
3360
|
}
|
|
3325
|
-
|
|
3361
|
+
function bigNumToString(a) {
|
|
3326
3362
|
if (a.byteLength === 8) {
|
|
3327
3363
|
const bigIntArray = new a["BigIntArray"](a.buffer, a.byteOffset, 1);
|
|
3328
3364
|
return `${bigIntArray[0]}`;
|
|
@@ -3345,15 +3381,15 @@
|
|
|
3345
3381
|
}
|
|
3346
3382
|
const negated = unsignedBigNumToString(array);
|
|
3347
3383
|
return `-${negated}`;
|
|
3348
|
-
}
|
|
3349
|
-
|
|
3384
|
+
}
|
|
3385
|
+
function bigNumToBigInt(a) {
|
|
3350
3386
|
if (a.byteLength === 8) {
|
|
3351
3387
|
const bigIntArray = new a["BigIntArray"](a.buffer, a.byteOffset, 1);
|
|
3352
3388
|
return bigIntArray[0];
|
|
3353
3389
|
} else {
|
|
3354
3390
|
return bigNumToString(a);
|
|
3355
3391
|
}
|
|
3356
|
-
}
|
|
3392
|
+
}
|
|
3357
3393
|
function unsignedBigNumToString(a) {
|
|
3358
3394
|
let digits = "";
|
|
3359
3395
|
const base64 = new Uint32Array(2);
|
|
@@ -3410,14 +3446,6 @@
|
|
|
3410
3446
|
}
|
|
3411
3447
|
};
|
|
3412
3448
|
|
|
3413
|
-
// ../../node_modules/apache-arrow/util/bigint.mjs
|
|
3414
|
-
function bigIntToNumber(number) {
|
|
3415
|
-
if (typeof number === "bigint" && (number < Number.MIN_SAFE_INTEGER || number > Number.MAX_SAFE_INTEGER)) {
|
|
3416
|
-
throw new TypeError(`${number} is not safe to convert to a number.`);
|
|
3417
|
-
}
|
|
3418
|
-
return Number(number);
|
|
3419
|
-
}
|
|
3420
|
-
|
|
3421
3449
|
// ../../node_modules/apache-arrow/type.mjs
|
|
3422
3450
|
var _a;
|
|
3423
3451
|
var _b;
|
|
@@ -3792,11 +3820,13 @@
|
|
|
3792
3820
|
toString() {
|
|
3793
3821
|
return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
|
|
3794
3822
|
}
|
|
3823
|
+
get ArrayType() {
|
|
3824
|
+
return this.unit === DateUnit.DAY ? Int32Array : BigInt64Array;
|
|
3825
|
+
}
|
|
3795
3826
|
};
|
|
3796
3827
|
_l = Symbol.toStringTag;
|
|
3797
3828
|
Date_[_l] = ((proto) => {
|
|
3798
3829
|
proto.unit = null;
|
|
3799
|
-
proto.ArrayType = Int32Array;
|
|
3800
3830
|
return proto[Symbol.toStringTag] = "Date";
|
|
3801
3831
|
})(Date_.prototype);
|
|
3802
3832
|
var DateDay = class extends Date_ {
|
|
@@ -3868,7 +3898,7 @@
|
|
|
3868
3898
|
Timestamp_[_o] = ((proto) => {
|
|
3869
3899
|
proto.unit = null;
|
|
3870
3900
|
proto.timezone = null;
|
|
3871
|
-
proto.ArrayType =
|
|
3901
|
+
proto.ArrayType = BigInt64Array;
|
|
3872
3902
|
return proto[Symbol.toStringTag] = "Timestamp";
|
|
3873
3903
|
})(Timestamp_.prototype);
|
|
3874
3904
|
var TimestampSecond = class extends Timestamp_ {
|
|
@@ -4103,10 +4133,6 @@
|
|
|
4103
4133
|
switch (type.typeId) {
|
|
4104
4134
|
case Type2.Decimal:
|
|
4105
4135
|
return type.bitWidth / 32;
|
|
4106
|
-
case Type2.Timestamp:
|
|
4107
|
-
return 2;
|
|
4108
|
-
case Type2.Date:
|
|
4109
|
-
return 1 + t.unit;
|
|
4110
4136
|
case Type2.Interval:
|
|
4111
4137
|
return 1 + t.unit;
|
|
4112
4138
|
case Type2.FixedSizeList:
|
|
@@ -4573,19 +4599,7 @@
|
|
|
4573
4599
|
};
|
|
4574
4600
|
}
|
|
4575
4601
|
var setEpochMsToDays = (data, index, epochMs) => {
|
|
4576
|
-
data[index] = Math.
|
|
4577
|
-
};
|
|
4578
|
-
var setEpochMsToMillisecondsLong = (data, index, epochMs) => {
|
|
4579
|
-
data[index] = Math.trunc(epochMs % 4294967296);
|
|
4580
|
-
data[index + 1] = Math.trunc(epochMs / 4294967296);
|
|
4581
|
-
};
|
|
4582
|
-
var setEpochMsToMicrosecondsLong = (data, index, epochMs) => {
|
|
4583
|
-
data[index] = Math.trunc(epochMs * 1e3 % 4294967296);
|
|
4584
|
-
data[index + 1] = Math.trunc(epochMs * 1e3 / 4294967296);
|
|
4585
|
-
};
|
|
4586
|
-
var setEpochMsToNanosecondsLong = (data, index, epochMs) => {
|
|
4587
|
-
data[index] = Math.trunc(epochMs * 1e6 % 4294967296);
|
|
4588
|
-
data[index + 1] = Math.trunc(epochMs * 1e6 / 4294967296);
|
|
4602
|
+
data[index] = Math.floor(epochMs / 864e5);
|
|
4589
4603
|
};
|
|
4590
4604
|
var setVariableWidthBytes = (values, valueOffsets, index, value) => {
|
|
4591
4605
|
if (index + 1 < valueOffsets.length) {
|
|
@@ -4620,7 +4634,7 @@
|
|
|
4620
4634
|
setEpochMsToDays(values, index, value.valueOf());
|
|
4621
4635
|
};
|
|
4622
4636
|
var setDateMillisecond = ({ values }, index, value) => {
|
|
4623
|
-
|
|
4637
|
+
values[index] = BigInt(value);
|
|
4624
4638
|
};
|
|
4625
4639
|
var setFixedSizeBinary = ({ stride, values }, index, value) => {
|
|
4626
4640
|
values.set(value.subarray(0, stride), stride * index);
|
|
@@ -4630,10 +4644,18 @@
|
|
|
4630
4644
|
var setDate = (data, index, value) => {
|
|
4631
4645
|
data.type.unit === DateUnit.DAY ? setDateDay(data, index, value) : setDateMillisecond(data, index, value);
|
|
4632
4646
|
};
|
|
4633
|
-
var setTimestampSecond = ({ values }, index, value) =>
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
var
|
|
4647
|
+
var setTimestampSecond = ({ values }, index, value) => {
|
|
4648
|
+
values[index] = BigInt(value / 1e3);
|
|
4649
|
+
};
|
|
4650
|
+
var setTimestampMillisecond = ({ values }, index, value) => {
|
|
4651
|
+
values[index] = BigInt(value);
|
|
4652
|
+
};
|
|
4653
|
+
var setTimestampMicrosecond = ({ values }, index, value) => {
|
|
4654
|
+
values[index] = BigInt(value * 1e3);
|
|
4655
|
+
};
|
|
4656
|
+
var setTimestampNanosecond = ({ values }, index, value) => {
|
|
4657
|
+
values[index] = BigInt(value * 1e6);
|
|
4658
|
+
};
|
|
4637
4659
|
var setTimestamp = (data, index, value) => {
|
|
4638
4660
|
switch (data.type.unit) {
|
|
4639
4661
|
case TimeUnit.SECOND:
|
|
@@ -4938,12 +4960,6 @@
|
|
|
4938
4960
|
return (data, _1) => data.getValid(_1) ? fn(data, _1) : null;
|
|
4939
4961
|
}
|
|
4940
4962
|
var epochDaysToMs = (data, index) => 864e5 * data[index];
|
|
4941
|
-
var epochMillisecondsLongToMs = (data, index) => 4294967296 * data[index + 1] + (data[index] >>> 0);
|
|
4942
|
-
var epochMicrosecondsLongToMs = (data, index) => 4294967296 * (data[index + 1] / 1e3) + (data[index] >>> 0) / 1e3;
|
|
4943
|
-
var epochNanosecondsLongToMs = (data, index) => 4294967296 * (data[index + 1] / 1e6) + (data[index] >>> 0) / 1e6;
|
|
4944
|
-
var epochMillisecondsToDate = (epochMs) => new Date(epochMs);
|
|
4945
|
-
var epochDaysToDate = (data, index) => epochMillisecondsToDate(epochDaysToMs(data, index));
|
|
4946
|
-
var epochMillisecondsLongToDate = (data, index) => epochMillisecondsToDate(epochMillisecondsLongToMs(data, index));
|
|
4947
4963
|
var getNull = (_data, _index) => null;
|
|
4948
4964
|
var getVariableWidthBytes = (values, valueOffsets, index) => {
|
|
4949
4965
|
if (index + 1 >= valueOffsets.length) {
|
|
@@ -4958,8 +4974,8 @@
|
|
|
4958
4974
|
const byte = values[idx >> 3];
|
|
4959
4975
|
return (byte & 1 << idx % 8) !== 0;
|
|
4960
4976
|
};
|
|
4961
|
-
var getDateDay = ({ values }, index) =>
|
|
4962
|
-
var getDateMillisecond = ({ values }, index) =>
|
|
4977
|
+
var getDateDay = ({ values }, index) => epochDaysToMs(values, index);
|
|
4978
|
+
var getDateMillisecond = ({ values }, index) => bigIntToNumber(values[index]);
|
|
4963
4979
|
var getNumeric = ({ stride, values }, index) => values[stride * index];
|
|
4964
4980
|
var getFloat16 = ({ stride, values }, index) => uint16ToFloat64(values[stride * index]);
|
|
4965
4981
|
var getBigInts = ({ values }, index) => values[index];
|
|
@@ -4972,10 +4988,10 @@
|
|
|
4972
4988
|
var getInt = ({ values }, index) => values[index];
|
|
4973
4989
|
var getFloat = ({ type, values }, index) => type.precision !== Precision.HALF ? values[index] : uint16ToFloat64(values[index]);
|
|
4974
4990
|
var getDate = (data, index) => data.type.unit === DateUnit.DAY ? getDateDay(data, index) : getDateMillisecond(data, index);
|
|
4975
|
-
var getTimestampSecond = ({ values }, index) => 1e3 *
|
|
4976
|
-
var getTimestampMillisecond = ({ values }, index) =>
|
|
4977
|
-
var getTimestampMicrosecond = ({ values }, index) =>
|
|
4978
|
-
var getTimestampNanosecond = ({ values }, index) =>
|
|
4991
|
+
var getTimestampSecond = ({ values }, index) => 1e3 * bigIntToNumber(values[index]);
|
|
4992
|
+
var getTimestampMillisecond = ({ values }, index) => bigIntToNumber(values[index]);
|
|
4993
|
+
var getTimestampMicrosecond = ({ values }, index) => divideBigInts(values[index], BigInt(1e3));
|
|
4994
|
+
var getTimestampNanosecond = ({ values }, index) => divideBigInts(values[index], BigInt(1e6));
|
|
4979
4995
|
var getTimestamp = (data, index) => {
|
|
4980
4996
|
switch (data.type.unit) {
|
|
4981
4997
|
case TimeUnit.SECOND:
|
|
@@ -5124,12 +5140,18 @@
|
|
|
5124
5140
|
// ../../node_modules/apache-arrow/row/map.mjs
|
|
5125
5141
|
var kKeys = Symbol.for("keys");
|
|
5126
5142
|
var kVals = Symbol.for("vals");
|
|
5143
|
+
var kKeysAsStrings = Symbol.for("kKeysAsStrings");
|
|
5144
|
+
var _kKeysAsStrings = Symbol.for("_kKeysAsStrings");
|
|
5127
5145
|
var MapRow = class {
|
|
5128
5146
|
constructor(slice) {
|
|
5129
5147
|
this[kKeys] = new Vector([slice.children[0]]).memoize();
|
|
5130
5148
|
this[kVals] = slice.children[1];
|
|
5131
5149
|
return new Proxy(this, new MapRowProxyHandler());
|
|
5132
5150
|
}
|
|
5151
|
+
/** @ignore */
|
|
5152
|
+
get [kKeysAsStrings]() {
|
|
5153
|
+
return this[_kKeysAsStrings] || (this[_kKeysAsStrings] = Array.from(this[kKeys].toArray(), String));
|
|
5154
|
+
}
|
|
5133
5155
|
[Symbol.iterator]() {
|
|
5134
5156
|
return new MapRowIterator(this[kKeys], this[kVals]);
|
|
5135
5157
|
}
|
|
@@ -5191,13 +5213,13 @@
|
|
|
5191
5213
|
return true;
|
|
5192
5214
|
}
|
|
5193
5215
|
ownKeys(row) {
|
|
5194
|
-
return row[
|
|
5216
|
+
return row[kKeysAsStrings];
|
|
5195
5217
|
}
|
|
5196
5218
|
has(row, key) {
|
|
5197
|
-
return row[
|
|
5219
|
+
return row[kKeysAsStrings].includes(key);
|
|
5198
5220
|
}
|
|
5199
5221
|
getOwnPropertyDescriptor(row, key) {
|
|
5200
|
-
const idx = row[
|
|
5222
|
+
const idx = row[kKeysAsStrings].indexOf(key);
|
|
5201
5223
|
if (idx !== -1) {
|
|
5202
5224
|
return { writable: true, enumerable: true, configurable: true };
|
|
5203
5225
|
}
|
|
@@ -5207,7 +5229,7 @@
|
|
|
5207
5229
|
if (Reflect.has(row, key)) {
|
|
5208
5230
|
return row[key];
|
|
5209
5231
|
}
|
|
5210
|
-
const idx = row[
|
|
5232
|
+
const idx = row[kKeysAsStrings].indexOf(key);
|
|
5211
5233
|
if (idx !== -1) {
|
|
5212
5234
|
const val = instance2.visit(Reflect.get(row, kVals), idx);
|
|
5213
5235
|
Reflect.set(row, key, val);
|
|
@@ -5215,7 +5237,7 @@
|
|
|
5215
5237
|
}
|
|
5216
5238
|
}
|
|
5217
5239
|
set(row, key, val) {
|
|
5218
|
-
const idx = row[
|
|
5240
|
+
const idx = row[kKeysAsStrings].indexOf(key);
|
|
5219
5241
|
if (idx !== -1) {
|
|
5220
5242
|
instance.visit(Reflect.get(row, kVals), idx, val);
|
|
5221
5243
|
return Reflect.set(row, key, val);
|
|
@@ -5228,15 +5250,11 @@
|
|
|
5228
5250
|
Object.defineProperties(MapRow.prototype, {
|
|
5229
5251
|
[Symbol.toStringTag]: { enumerable: false, configurable: false, value: "Row" },
|
|
5230
5252
|
[kKeys]: { writable: true, enumerable: false, configurable: false, value: null },
|
|
5231
|
-
[kVals]: { writable: true, enumerable: false, configurable: false, value: null }
|
|
5253
|
+
[kVals]: { writable: true, enumerable: false, configurable: false, value: null },
|
|
5254
|
+
[_kKeysAsStrings]: { writable: true, enumerable: false, configurable: false, value: null }
|
|
5232
5255
|
});
|
|
5233
5256
|
|
|
5234
5257
|
// ../../node_modules/apache-arrow/util/vector.mjs
|
|
5235
|
-
function clampIndex(source, index, then) {
|
|
5236
|
-
const length = source.length;
|
|
5237
|
-
const adjust = index > -1 ? index : length + index % length;
|
|
5238
|
-
return then ? then(source, adjust) : adjust;
|
|
5239
|
-
}
|
|
5240
5258
|
var tmp;
|
|
5241
5259
|
function clampRange(source, begin, end, then) {
|
|
5242
5260
|
const { length: len = 0 } = source;
|
|
@@ -5248,6 +5266,7 @@
|
|
|
5248
5266
|
rhs > len && (rhs = len);
|
|
5249
5267
|
return then ? then(source, lhs, rhs) : [lhs, rhs];
|
|
5250
5268
|
}
|
|
5269
|
+
var wrapIndex = (index, len) => index < 0 ? len + index : index;
|
|
5251
5270
|
var isNaNFast = (value) => value !== value;
|
|
5252
5271
|
function createElementComparator(search) {
|
|
5253
5272
|
const typeofSearch = typeof search;
|
|
@@ -5536,7 +5555,10 @@
|
|
|
5536
5555
|
let nullCount = this._nullCount;
|
|
5537
5556
|
let nullBitmap;
|
|
5538
5557
|
if (nullCount <= kUnknownNullCount && (nullBitmap = this.nullBitmap)) {
|
|
5539
|
-
this._nullCount = nullCount =
|
|
5558
|
+
this._nullCount = nullCount = nullBitmap.length === 0 ? (
|
|
5559
|
+
// no null bitmap, so all values are valid
|
|
5560
|
+
0
|
|
5561
|
+
) : this.length - popcnt_bit_range(nullBitmap, this.offset, this.offset + this.length);
|
|
5540
5562
|
}
|
|
5541
5563
|
return nullCount;
|
|
5542
5564
|
}
|
|
@@ -5598,12 +5620,14 @@
|
|
|
5598
5620
|
nullBitmap = new Uint8Array((offset + length + 63 & ~63) >> 3).fill(255);
|
|
5599
5621
|
if (this.nullCount > 0) {
|
|
5600
5622
|
nullBitmap.set(truncateBitmap(offset, length, this.nullBitmap), 0);
|
|
5623
|
+
Object.assign(this, { nullBitmap });
|
|
5624
|
+
} else {
|
|
5625
|
+
Object.assign(this, { nullBitmap, _nullCount: 0 });
|
|
5601
5626
|
}
|
|
5602
|
-
Object.assign(this, { nullBitmap, _nullCount: -1 });
|
|
5603
5627
|
}
|
|
5604
5628
|
const byte = nullBitmap[byteOffset];
|
|
5605
5629
|
prev = (byte & mask) !== 0;
|
|
5606
|
-
|
|
5630
|
+
nullBitmap[byteOffset] = value ? byte | mask : byte & ~mask;
|
|
5607
5631
|
}
|
|
5608
5632
|
if (prev !== !!value) {
|
|
5609
5633
|
this._nullCount = this.nullCount + (value ? -1 : 1);
|
|
@@ -6044,7 +6068,9 @@
|
|
|
6044
6068
|
};
|
|
6045
6069
|
function vectorIterator(vector) {
|
|
6046
6070
|
const { type } = vector;
|
|
6047
|
-
if (vector.nullCount === 0 && vector.stride === 1 &&
|
|
6071
|
+
if (vector.nullCount === 0 && vector.stride === 1 && // Don't defer to native iterator for timestamps since Numbers are expected
|
|
6072
|
+
// (DataType.isTimestamp(type)) && type.unit === TimeUnit.MILLISECOND ||
|
|
6073
|
+
(DataType.isInt(type) && type.bitWidth !== 64 || DataType.isTime(type) && type.bitWidth !== 64 || DataType.isFloat(type) && type.precision !== Precision.HALF)) {
|
|
6048
6074
|
return new ChunkedIterator(vector.data.length, (chunkIndex) => {
|
|
6049
6075
|
const data = vector.data[chunkIndex];
|
|
6050
6076
|
return data.values.subarray(0, data.length)[Symbol.iterator]();
|
|
@@ -6218,6 +6244,13 @@
|
|
|
6218
6244
|
get(index) {
|
|
6219
6245
|
return null;
|
|
6220
6246
|
}
|
|
6247
|
+
/**
|
|
6248
|
+
* Get an element value by position.
|
|
6249
|
+
* @param index The index of the element to read. A negative index will count back from the last element.
|
|
6250
|
+
*/
|
|
6251
|
+
at(index) {
|
|
6252
|
+
return this.get(wrapIndex(index, this.length));
|
|
6253
|
+
}
|
|
6221
6254
|
/**
|
|
6222
6255
|
* Set an element value by position.
|
|
6223
6256
|
* @param index The index of the element to write.
|
|
@@ -6995,7 +7028,7 @@ return true;`);
|
|
|
6995
7028
|
this.fields = fields || [];
|
|
6996
7029
|
this.metadata = metadata || /* @__PURE__ */ new Map();
|
|
6997
7030
|
if (!dictionaries) {
|
|
6998
|
-
dictionaries = generateDictionaryMap(fields);
|
|
7031
|
+
dictionaries = generateDictionaryMap(this.fields);
|
|
6999
7032
|
}
|
|
7000
7033
|
this.dictionaries = dictionaries;
|
|
7001
7034
|
this.metadataVersion = metadataVersion;
|
|
@@ -7497,8 +7530,8 @@ return true;`);
|
|
|
7497
7530
|
return (yield this.next(size, "peek")).value;
|
|
7498
7531
|
});
|
|
7499
7532
|
}
|
|
7500
|
-
next(
|
|
7501
|
-
return __awaiter(this,
|
|
7533
|
+
next(size_1) {
|
|
7534
|
+
return __awaiter(this, arguments, void 0, function* (size, cmd = "read") {
|
|
7502
7535
|
return yield this.source.next({ cmd, size });
|
|
7503
7536
|
});
|
|
7504
7537
|
}
|
|
@@ -9075,6 +9108,14 @@ return true;`);
|
|
|
9075
9108
|
get(index) {
|
|
9076
9109
|
return null;
|
|
9077
9110
|
}
|
|
9111
|
+
/**
|
|
9112
|
+
* Get an element value by position.
|
|
9113
|
+
* @param index The index of the element to read. A negative index will count back from the last element.
|
|
9114
|
+
*/
|
|
9115
|
+
// @ts-ignore
|
|
9116
|
+
at(index) {
|
|
9117
|
+
return this.get(wrapIndex(index, this.numRows));
|
|
9118
|
+
}
|
|
9078
9119
|
/**
|
|
9079
9120
|
* Set an element value by position.
|
|
9080
9121
|
*
|
|
@@ -9312,7 +9353,7 @@ return true;`);
|
|
|
9312
9353
|
return this.data.nullCount;
|
|
9313
9354
|
}
|
|
9314
9355
|
/**
|
|
9315
|
-
* Check whether an
|
|
9356
|
+
* Check whether an row is null.
|
|
9316
9357
|
* @param index The index at which to read the validity bitmap.
|
|
9317
9358
|
*/
|
|
9318
9359
|
isValid(index) {
|
|
@@ -9320,14 +9361,21 @@ return true;`);
|
|
|
9320
9361
|
}
|
|
9321
9362
|
/**
|
|
9322
9363
|
* Get a row by position.
|
|
9323
|
-
* @param index The index of the
|
|
9364
|
+
* @param index The index of the row to read.
|
|
9324
9365
|
*/
|
|
9325
9366
|
get(index) {
|
|
9326
9367
|
return instance2.visit(this.data, index);
|
|
9327
9368
|
}
|
|
9369
|
+
/**
|
|
9370
|
+
* Get a row value by position.
|
|
9371
|
+
* @param index The index of the row to read. A negative index will count back from the last row.
|
|
9372
|
+
*/
|
|
9373
|
+
at(index) {
|
|
9374
|
+
return this.get(wrapIndex(index, this.numRows));
|
|
9375
|
+
}
|
|
9328
9376
|
/**
|
|
9329
9377
|
* Set a row by position.
|
|
9330
|
-
* @param index The index of the
|
|
9378
|
+
* @param index The index of the row to write.
|
|
9331
9379
|
* @param value The value to set.
|
|
9332
9380
|
*/
|
|
9333
9381
|
set(index, value) {
|
|
@@ -9364,7 +9412,7 @@ return true;`);
|
|
|
9364
9412
|
/**
|
|
9365
9413
|
* Return a zero-copy sub-section of this RecordBatch.
|
|
9366
9414
|
* @param start The beginning of the specified portion of the RecordBatch.
|
|
9367
|
-
* @param end The end of the specified portion of the RecordBatch. This is exclusive of the
|
|
9415
|
+
* @param end The end of the specified portion of the RecordBatch. This is exclusive of the row at the index 'end'.
|
|
9368
9416
|
*/
|
|
9369
9417
|
slice(begin, end) {
|
|
9370
9418
|
const [slice] = new Vector([this.data]).slice(begin, end).data;
|
|
@@ -10452,8 +10500,8 @@ return true;`);
|
|
|
10452
10500
|
);
|
|
10453
10501
|
});
|
|
10454
10502
|
}
|
|
10455
|
-
readSchema(
|
|
10456
|
-
return __awaiter(this,
|
|
10503
|
+
readSchema() {
|
|
10504
|
+
return __awaiter(this, arguments, void 0, function* (throwIfNull = false) {
|
|
10457
10505
|
const type = MessageHeader.Schema;
|
|
10458
10506
|
const message = yield this.readMessage(type);
|
|
10459
10507
|
const schema = message === null || message === void 0 ? void 0 : message.header();
|
|
@@ -10701,8 +10749,8 @@ return true;`);
|
|
|
10701
10749
|
this._impl = _impl;
|
|
10702
10750
|
}
|
|
10703
10751
|
readAll() {
|
|
10704
|
-
var _a5, e_1, _b2, _c2;
|
|
10705
10752
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10753
|
+
var _a5, e_1, _b2, _c2;
|
|
10706
10754
|
const batches = new Array();
|
|
10707
10755
|
try {
|
|
10708
10756
|
for (var _d2 = true, _e2 = __asyncValues(this), _f2; _f2 = yield _e2.next(), _a5 = _f2.done, !_a5; _d2 = true) {
|
|
@@ -10786,12 +10834,9 @@ return true;`);
|
|
|
10786
10834
|
const { id, isDelta } = header;
|
|
10787
10835
|
const { dictionaries, schema } = this;
|
|
10788
10836
|
const dictionary = dictionaries.get(id);
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
|
|
10792
|
-
return (dictionary && isDelta ? dictionary.concat(new Vector(data)) : new Vector(data)).memoize();
|
|
10793
|
-
}
|
|
10794
|
-
return dictionary.memoize();
|
|
10837
|
+
const type = schema.dictionaries.get(id);
|
|
10838
|
+
const data = this._loadVectors(header.data, body, [type]);
|
|
10839
|
+
return (dictionary && isDelta ? dictionary.concat(new Vector(data)) : new Vector(data)).memoize();
|
|
10795
10840
|
}
|
|
10796
10841
|
_loadVectors(header, body, types) {
|
|
10797
10842
|
return new VectorLoader(body, header.nodes, header.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(types);
|
|
@@ -11077,8 +11122,8 @@ return true;`);
|
|
|
11077
11122
|
});
|
|
11078
11123
|
}
|
|
11079
11124
|
readRecordBatch(index) {
|
|
11080
|
-
var _a5;
|
|
11081
11125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11126
|
+
var _a5;
|
|
11082
11127
|
if (this.closed) {
|
|
11083
11128
|
return null;
|
|
11084
11129
|
}
|
|
@@ -11099,8 +11144,8 @@ return true;`);
|
|
|
11099
11144
|
});
|
|
11100
11145
|
}
|
|
11101
11146
|
_readDictionaryBatch(index) {
|
|
11102
|
-
var _a5;
|
|
11103
11147
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11148
|
+
var _a5;
|
|
11104
11149
|
const block = (_a5 = this._footer) === null || _a5 === void 0 ? void 0 : _a5.getDictionaryBatch(index);
|
|
11105
11150
|
if (block && (yield this._handle.seek(block.offset))) {
|
|
11106
11151
|
const message = yield this._reader.readMessage(MessageHeader.DictionaryBatch);
|
|
@@ -11375,6 +11420,7 @@ return true;`);
|
|
|
11375
11420
|
this._schema = null;
|
|
11376
11421
|
this._dictionaryBlocks = [];
|
|
11377
11422
|
this._recordBatchBlocks = [];
|
|
11423
|
+
this._seenDictionaries = /* @__PURE__ */ new Map();
|
|
11378
11424
|
this._dictionaryDeltaOffsets = /* @__PURE__ */ new Map();
|
|
11379
11425
|
isObject(options) || (options = { autoDestroy: true, writeLegacyIpcFormat: false });
|
|
11380
11426
|
this._autoDestroy = typeof options.autoDestroy === "boolean" ? options.autoDestroy : true;
|
|
@@ -11433,6 +11479,7 @@ return true;`);
|
|
|
11433
11479
|
this._started = false;
|
|
11434
11480
|
this._dictionaryBlocks = [];
|
|
11435
11481
|
this._recordBatchBlocks = [];
|
|
11482
|
+
this._seenDictionaries = /* @__PURE__ */ new Map();
|
|
11436
11483
|
this._dictionaryDeltaOffsets = /* @__PURE__ */ new Map();
|
|
11437
11484
|
if (!schema || !compareSchemas(schema, this._schema)) {
|
|
11438
11485
|
if (schema == null) {
|
|
@@ -11524,7 +11571,6 @@ return true;`);
|
|
|
11524
11571
|
return this._writeDictionaries(batch)._writeMessage(message)._writeBodyBuffers(buffers);
|
|
11525
11572
|
}
|
|
11526
11573
|
_writeDictionaryBatch(dictionary, id, isDelta = false) {
|
|
11527
|
-
this._dictionaryDeltaOffsets.set(id, dictionary.length + (this._dictionaryDeltaOffsets.get(id) || 0));
|
|
11528
11574
|
const { byteLength, nodes, bufferRegions, buffers } = VectorAssembler.assemble(new Vector([dictionary]));
|
|
11529
11575
|
const recordBatch = new RecordBatch3(dictionary.length, nodes, bufferRegions);
|
|
11530
11576
|
const dictionaryBatch = new DictionaryBatch2(recordBatch, id, isDelta);
|
|
@@ -11545,14 +11591,20 @@ return true;`);
|
|
|
11545
11591
|
return this;
|
|
11546
11592
|
}
|
|
11547
11593
|
_writeDictionaries(batch) {
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
|
|
11551
|
-
|
|
11552
|
-
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11594
|
+
var _a5, _b2;
|
|
11595
|
+
for (const [id, dictionary] of batch.dictionaries) {
|
|
11596
|
+
const chunks = (_a5 = dictionary === null || dictionary === void 0 ? void 0 : dictionary.data) !== null && _a5 !== void 0 ? _a5 : [];
|
|
11597
|
+
const prevDictionary = this._seenDictionaries.get(id);
|
|
11598
|
+
const offset = (_b2 = this._dictionaryDeltaOffsets.get(id)) !== null && _b2 !== void 0 ? _b2 : 0;
|
|
11599
|
+
if (!prevDictionary || prevDictionary.data[0] !== chunks[0]) {
|
|
11600
|
+
for (const [index, chunk] of chunks.entries())
|
|
11601
|
+
this._writeDictionaryBatch(chunk, id, index > 0);
|
|
11602
|
+
} else if (offset < chunks.length) {
|
|
11603
|
+
for (const chunk of chunks.slice(offset))
|
|
11604
|
+
this._writeDictionaryBatch(chunk, id, true);
|
|
11605
|
+
}
|
|
11606
|
+
this._seenDictionaries.set(id, dictionary);
|
|
11607
|
+
this._dictionaryDeltaOffsets.set(id, chunks.length);
|
|
11556
11608
|
}
|
|
11557
11609
|
return this;
|
|
11558
11610
|
}
|
|
@@ -11588,6 +11640,12 @@ return true;`);
|
|
|
11588
11640
|
_writeSchema(schema) {
|
|
11589
11641
|
return this._writeMagic()._writePadding(2);
|
|
11590
11642
|
}
|
|
11643
|
+
_writeDictionaryBatch(dictionary, id, isDelta = false) {
|
|
11644
|
+
if (!isDelta && this._seenDictionaries.has(id)) {
|
|
11645
|
+
throw new Error("The Arrow File format does not support replacement dictionaries. ");
|
|
11646
|
+
}
|
|
11647
|
+
return super._writeDictionaryBatch(dictionary, id, isDelta);
|
|
11648
|
+
}
|
|
11591
11649
|
_writeFooter(schema) {
|
|
11592
11650
|
const buffer = Footer_.encode(new Footer_(schema, MetadataVersion.V5, this._recordBatchBlocks, this._dictionaryBlocks));
|
|
11593
11651
|
return super._writeFooter(schema)._write(buffer)._write(Int32Array.of(buffer.byteLength))._writeMagic();
|
|
@@ -11605,9 +11663,9 @@ return true;`);
|
|
|
11605
11663
|
return writer.finish();
|
|
11606
11664
|
}
|
|
11607
11665
|
function writeAllAsync(writer, batches) {
|
|
11608
|
-
var _a5, batches_1, batches_1_1;
|
|
11609
|
-
var _b2, e_1, _c2, _d2;
|
|
11610
11666
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11667
|
+
var _a5, batches_1, batches_1_1;
|
|
11668
|
+
var _b2, e_1, _c2, _d2;
|
|
11611
11669
|
try {
|
|
11612
11670
|
for (_a5 = true, batches_1 = __asyncValues(batches); batches_1_1 = yield batches_1.next(), _b2 = batches_1_1.done, !_b2; _a5 = true) {
|
|
11613
11671
|
_d2 = batches_1_1.value;
|
|
@@ -11902,7 +11960,7 @@ return true;`);
|
|
|
11902
11960
|
RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
11903
11961
|
RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
11904
11962
|
|
|
11905
|
-
// ../schema/src/lib/
|
|
11963
|
+
// ../schema-utils/src/lib/schema/data-type.ts
|
|
11906
11964
|
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
11907
11965
|
if (value instanceof Date) {
|
|
11908
11966
|
return "date-millisecond";
|
|
@@ -11978,459 +12036,30 @@ return true;`);
|
|
|
11978
12036
|
return Array;
|
|
11979
12037
|
}
|
|
11980
12038
|
|
|
11981
|
-
// ../schema/src/lib/
|
|
11982
|
-
function
|
|
11983
|
-
|
|
11984
|
-
case "array-row-table":
|
|
11985
|
-
case "object-row-table":
|
|
11986
|
-
return table.data.length;
|
|
11987
|
-
case "geojson-table":
|
|
11988
|
-
return table.features.length;
|
|
11989
|
-
case "arrow-table":
|
|
11990
|
-
const arrowTable = table.data;
|
|
11991
|
-
return arrowTable.numRows;
|
|
11992
|
-
case "columnar-table":
|
|
11993
|
-
for (const column of Object.values(table.data)) {
|
|
11994
|
-
return column.length || 0;
|
|
11995
|
-
}
|
|
11996
|
-
return 0;
|
|
11997
|
-
default:
|
|
11998
|
-
throw new Error("table");
|
|
11999
|
-
}
|
|
12000
|
-
}
|
|
12001
|
-
function getTableCell(table, rowIndex, columnName) {
|
|
12002
|
-
switch (table.shape) {
|
|
12003
|
-
case "array-row-table":
|
|
12004
|
-
const columnIndex = getTableColumnIndex(table, columnName);
|
|
12005
|
-
return table.data[rowIndex][columnIndex];
|
|
12006
|
-
case "object-row-table":
|
|
12007
|
-
return table.data[rowIndex][columnName];
|
|
12008
|
-
case "geojson-table":
|
|
12009
|
-
return table.features[rowIndex][columnName];
|
|
12010
|
-
case "columnar-table":
|
|
12011
|
-
const column = table.data[columnName];
|
|
12012
|
-
return column[rowIndex];
|
|
12013
|
-
case "arrow-table":
|
|
12014
|
-
const arrowTable = table.data;
|
|
12015
|
-
const arrowColumnIndex = arrowTable.schema.fields.findIndex(
|
|
12016
|
-
(field) => field.name === columnName
|
|
12017
|
-
);
|
|
12018
|
-
return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);
|
|
12019
|
-
default:
|
|
12020
|
-
throw new Error("todo");
|
|
12021
|
-
}
|
|
12039
|
+
// ../schema-utils/src/lib/schema/convert-arrow-schema.ts
|
|
12040
|
+
function convertArrowToSchema(arrowSchema) {
|
|
12041
|
+
return serializeArrowSchema(arrowSchema);
|
|
12022
12042
|
}
|
|
12023
|
-
function
|
|
12024
|
-
|
|
12025
|
-
if (columnIndex === void 0) {
|
|
12026
|
-
throw new Error(columnName);
|
|
12027
|
-
}
|
|
12028
|
-
return columnIndex;
|
|
12043
|
+
function convertSchemaToArrow(schema) {
|
|
12044
|
+
return deserializeArrowSchema(schema);
|
|
12029
12045
|
}
|
|
12030
|
-
function
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
if (table.schema) {
|
|
12036
|
-
const objectRow2 = target || {};
|
|
12037
|
-
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12038
|
-
objectRow2[table.schema.fields[i].name] = table.data[rowIndex][i];
|
|
12039
|
-
}
|
|
12040
|
-
return objectRow2;
|
|
12041
|
-
}
|
|
12042
|
-
throw new Error("no schema");
|
|
12043
|
-
case "geojson-table":
|
|
12044
|
-
if (table.schema) {
|
|
12045
|
-
const objectRow2 = target || {};
|
|
12046
|
-
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12047
|
-
objectRow2[table.schema.fields[i].name] = table.features[rowIndex][i];
|
|
12048
|
-
}
|
|
12049
|
-
return objectRow2;
|
|
12050
|
-
}
|
|
12051
|
-
throw new Error("no schema");
|
|
12052
|
-
case "columnar-table":
|
|
12053
|
-
if (table.schema) {
|
|
12054
|
-
const objectRow2 = target || {};
|
|
12055
|
-
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12056
|
-
objectRow2[table.schema.fields[i].name] = table.data[table.schema.fields[i].name][rowIndex];
|
|
12057
|
-
}
|
|
12058
|
-
return objectRow2;
|
|
12059
|
-
} else {
|
|
12060
|
-
const objectRow2 = target || {};
|
|
12061
|
-
for (const [name, column] of Object.entries(table.data)) {
|
|
12062
|
-
objectRow2[name] = column[rowIndex];
|
|
12063
|
-
}
|
|
12064
|
-
return objectRow2;
|
|
12065
|
-
}
|
|
12066
|
-
case "arrow-table":
|
|
12067
|
-
const arrowTable = table.data;
|
|
12068
|
-
const objectRow = target || {};
|
|
12069
|
-
const row = arrowTable.get(rowIndex);
|
|
12070
|
-
const schema = arrowTable.schema;
|
|
12071
|
-
for (let i = 0; i < schema.fields.length; i++) {
|
|
12072
|
-
objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];
|
|
12073
|
-
}
|
|
12074
|
-
return objectRow;
|
|
12075
|
-
default:
|
|
12076
|
-
throw new Error("shape");
|
|
12077
|
-
}
|
|
12046
|
+
function serializeArrowSchema(arrowSchema) {
|
|
12047
|
+
return {
|
|
12048
|
+
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
12049
|
+
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
12050
|
+
};
|
|
12078
12051
|
}
|
|
12079
|
-
function
|
|
12080
|
-
|
|
12081
|
-
|
|
12082
|
-
|
|
12083
|
-
|
|
12084
|
-
if (table.schema) {
|
|
12085
|
-
const arrayRow2 = target || [];
|
|
12086
|
-
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12087
|
-
arrayRow2[i] = table.data[rowIndex][table.schema.fields[i].name];
|
|
12088
|
-
}
|
|
12089
|
-
return arrayRow2;
|
|
12090
|
-
}
|
|
12091
|
-
return Object.values(table.data[rowIndex]);
|
|
12092
|
-
case "geojson-table":
|
|
12093
|
-
if (table.schema) {
|
|
12094
|
-
const arrayRow2 = target || [];
|
|
12095
|
-
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12096
|
-
arrayRow2[i] = table.features[rowIndex][table.schema.fields[i].name];
|
|
12097
|
-
}
|
|
12098
|
-
return arrayRow2;
|
|
12099
|
-
}
|
|
12100
|
-
return Object.values(table.features[rowIndex]);
|
|
12101
|
-
case "columnar-table":
|
|
12102
|
-
if (table.schema) {
|
|
12103
|
-
const arrayRow2 = target || [];
|
|
12104
|
-
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12105
|
-
arrayRow2[i] = table.data[table.schema.fields[i].name][rowIndex];
|
|
12106
|
-
}
|
|
12107
|
-
return arrayRow2;
|
|
12108
|
-
} else {
|
|
12109
|
-
const arrayRow2 = target || [];
|
|
12110
|
-
let i = 0;
|
|
12111
|
-
for (const column of Object.values(table.data)) {
|
|
12112
|
-
arrayRow2[i] = column[rowIndex];
|
|
12113
|
-
i++;
|
|
12114
|
-
}
|
|
12115
|
-
return arrayRow2;
|
|
12116
|
-
}
|
|
12117
|
-
case "arrow-table":
|
|
12118
|
-
const arrowTable = table.data;
|
|
12119
|
-
const arrayRow = target || [];
|
|
12120
|
-
const row = arrowTable.get(rowIndex);
|
|
12121
|
-
const schema = arrowTable.schema;
|
|
12122
|
-
for (let i = 0; i < schema.fields.length; i++) {
|
|
12123
|
-
arrayRow[i] = row?.[schema.fields[i].name];
|
|
12124
|
-
}
|
|
12125
|
-
return arrayRow;
|
|
12126
|
-
default:
|
|
12127
|
-
throw new Error("shape");
|
|
12128
|
-
}
|
|
12052
|
+
function deserializeArrowSchema(schema) {
|
|
12053
|
+
return new Schema2(
|
|
12054
|
+
schema.fields.map((field) => deserializeArrowField(field)),
|
|
12055
|
+
deserializeArrowMetadata(schema.metadata)
|
|
12056
|
+
);
|
|
12129
12057
|
}
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
function deduceTableSchema(table) {
|
|
12133
|
-
switch (table.shape) {
|
|
12134
|
-
case "array-row-table":
|
|
12135
|
-
case "object-row-table":
|
|
12136
|
-
return deduceSchemaFromRows(table.data);
|
|
12137
|
-
case "geojson-table":
|
|
12138
|
-
return deduceSchemaFromGeoJSON(table.features);
|
|
12139
|
-
case "columnar-table":
|
|
12140
|
-
return deduceSchemaFromColumns(table.data);
|
|
12141
|
-
case "arrow-table":
|
|
12142
|
-
default:
|
|
12143
|
-
throw new Error("Deduce schema");
|
|
12144
|
-
}
|
|
12058
|
+
function serializeArrowMetadata(arrowMetadata) {
|
|
12059
|
+
return Object.fromEntries(arrowMetadata);
|
|
12145
12060
|
}
|
|
12146
|
-
function
|
|
12147
|
-
|
|
12148
|
-
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
12149
|
-
const field = deduceFieldFromColumn(column, columnName);
|
|
12150
|
-
fields.push(field);
|
|
12151
|
-
}
|
|
12152
|
-
return { fields, metadata: {} };
|
|
12153
|
-
}
|
|
12154
|
-
function deduceSchemaFromRows(rowTable) {
|
|
12155
|
-
if (!rowTable.length) {
|
|
12156
|
-
throw new Error("deduce from empty table");
|
|
12157
|
-
}
|
|
12158
|
-
const fields = [];
|
|
12159
|
-
const row0 = rowTable[0];
|
|
12160
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
12161
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
12162
|
-
}
|
|
12163
|
-
return { fields, metadata: {} };
|
|
12164
|
-
}
|
|
12165
|
-
function deduceSchemaFromGeoJSON(features) {
|
|
12166
|
-
if (!features.length) {
|
|
12167
|
-
throw new Error("deduce from empty table");
|
|
12168
|
-
}
|
|
12169
|
-
const fields = [];
|
|
12170
|
-
const row0 = features[0].properties || {};
|
|
12171
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
12172
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
12173
|
-
}
|
|
12174
|
-
return { fields, metadata: {} };
|
|
12175
|
-
}
|
|
12176
|
-
function deduceFieldFromColumn(column, name) {
|
|
12177
|
-
if (ArrayBuffer.isView(column)) {
|
|
12178
|
-
const type = getDataTypeFromArray(column);
|
|
12179
|
-
return {
|
|
12180
|
-
name,
|
|
12181
|
-
type: type.type || "null",
|
|
12182
|
-
nullable: type.nullable
|
|
12183
|
-
// metadata: {}
|
|
12184
|
-
};
|
|
12185
|
-
}
|
|
12186
|
-
if (Array.isArray(column) && column.length > 0) {
|
|
12187
|
-
const value = column[0];
|
|
12188
|
-
const type = getDataTypeFromValue(value);
|
|
12189
|
-
return {
|
|
12190
|
-
name,
|
|
12191
|
-
type,
|
|
12192
|
-
nullable: true
|
|
12193
|
-
// metadata: {},
|
|
12194
|
-
};
|
|
12195
|
-
}
|
|
12196
|
-
throw new Error("empty table");
|
|
12197
|
-
}
|
|
12198
|
-
function deduceFieldFromValue(value, name) {
|
|
12199
|
-
const type = getDataTypeFromValue(value);
|
|
12200
|
-
return {
|
|
12201
|
-
name,
|
|
12202
|
-
type,
|
|
12203
|
-
nullable: true
|
|
12204
|
-
// metadata: {}
|
|
12205
|
-
};
|
|
12206
|
-
}
|
|
12207
|
-
|
|
12208
|
-
// ../schema/src/lib/table/simple-table/table-column.ts
|
|
12209
|
-
function makeColumnFromField(field, length) {
|
|
12210
|
-
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
12211
|
-
return new ArrayType(length);
|
|
12212
|
-
}
|
|
12213
|
-
|
|
12214
|
-
// ../schema/src/lib/table/simple-table/convert-table.ts
|
|
12215
|
-
function convertTable(table, shape) {
|
|
12216
|
-
switch (shape) {
|
|
12217
|
-
case "object-row-table":
|
|
12218
|
-
return makeObjectRowTable(table);
|
|
12219
|
-
case "array-row-table":
|
|
12220
|
-
return makeArrayRowTable(table);
|
|
12221
|
-
case "columnar-table":
|
|
12222
|
-
return makeColumnarTable(table);
|
|
12223
|
-
case "arrow-table":
|
|
12224
|
-
return makeArrowTable(table);
|
|
12225
|
-
default:
|
|
12226
|
-
throw new Error(shape);
|
|
12227
|
-
}
|
|
12228
|
-
}
|
|
12229
|
-
function makeArrowTable(table) {
|
|
12230
|
-
const _makeArrowTable = globalThis.__loaders?._makeArrowTable;
|
|
12231
|
-
if (!_makeArrowTable) {
|
|
12232
|
-
throw new Error("");
|
|
12233
|
-
}
|
|
12234
|
-
return _makeArrowTable(table);
|
|
12235
|
-
}
|
|
12236
|
-
function makeColumnarTable(table) {
|
|
12237
|
-
const schema = table.schema || deduceTableSchema(table);
|
|
12238
|
-
const fields = table.schema?.fields || [];
|
|
12239
|
-
if (table.shape === "columnar-table") {
|
|
12240
|
-
return { ...table, schema };
|
|
12241
|
-
}
|
|
12242
|
-
const length = getTableLength(table);
|
|
12243
|
-
const columns = {};
|
|
12244
|
-
for (const field of fields) {
|
|
12245
|
-
const column = makeColumnFromField(field, length);
|
|
12246
|
-
columns[field.name] = column;
|
|
12247
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12248
|
-
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
12249
|
-
}
|
|
12250
|
-
}
|
|
12251
|
-
return {
|
|
12252
|
-
shape: "columnar-table",
|
|
12253
|
-
schema,
|
|
12254
|
-
data: columns
|
|
12255
|
-
};
|
|
12256
|
-
}
|
|
12257
|
-
function makeArrayRowTable(table) {
|
|
12258
|
-
if (table.shape === "array-row-table") {
|
|
12259
|
-
return table;
|
|
12260
|
-
}
|
|
12261
|
-
const length = getTableLength(table);
|
|
12262
|
-
const data = new Array(length);
|
|
12263
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12264
|
-
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
12265
|
-
}
|
|
12266
|
-
return {
|
|
12267
|
-
shape: "array-row-table",
|
|
12268
|
-
schema: table.schema,
|
|
12269
|
-
data
|
|
12270
|
-
};
|
|
12271
|
-
}
|
|
12272
|
-
function makeObjectRowTable(table) {
|
|
12273
|
-
if (table.shape === "object-row-table") {
|
|
12274
|
-
return table;
|
|
12275
|
-
}
|
|
12276
|
-
const length = getTableLength(table);
|
|
12277
|
-
const data = new Array(length);
|
|
12278
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12279
|
-
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
12280
|
-
}
|
|
12281
|
-
return {
|
|
12282
|
-
shape: "object-row-table",
|
|
12283
|
-
schema: table.schema,
|
|
12284
|
-
data
|
|
12285
|
-
};
|
|
12286
|
-
}
|
|
12287
|
-
|
|
12288
|
-
// ../gis/src/lib/geo/geoarrow-metadata.ts
|
|
12289
|
-
var GEOARROW_ENCODINGS = [
|
|
12290
|
-
"geoarrow.multipolygon",
|
|
12291
|
-
"geoarrow.polygon",
|
|
12292
|
-
"geoarrow.multilinestring",
|
|
12293
|
-
"geoarrow.linestring",
|
|
12294
|
-
"geoarrow.multipoint",
|
|
12295
|
-
"geoarrow.point",
|
|
12296
|
-
"geoarrow.wkb",
|
|
12297
|
-
"geoarrow.wkt"
|
|
12298
|
-
];
|
|
12299
|
-
var GEOARROW_COLUMN_METADATA_ENCODING = "ARROW:extension:name";
|
|
12300
|
-
var GEOARROW_COLUMN_METADATA_METADATA = "ARROW:extension:metadata";
|
|
12301
|
-
function getGeometryColumnsFromSchema(schema) {
|
|
12302
|
-
const geometryColumns = {};
|
|
12303
|
-
for (const field of schema.fields) {
|
|
12304
|
-
const metadata = getGeometryMetadataForField(field);
|
|
12305
|
-
if (metadata) {
|
|
12306
|
-
geometryColumns[field.name] = metadata;
|
|
12307
|
-
}
|
|
12308
|
-
}
|
|
12309
|
-
return geometryColumns;
|
|
12310
|
-
}
|
|
12311
|
-
function getGeometryMetadataForField(field) {
|
|
12312
|
-
let metadata = null;
|
|
12313
|
-
let geoEncoding = field.metadata?.[GEOARROW_COLUMN_METADATA_ENCODING];
|
|
12314
|
-
if (geoEncoding) {
|
|
12315
|
-
geoEncoding = geoEncoding.toLowerCase();
|
|
12316
|
-
if (geoEncoding === "wkb") {
|
|
12317
|
-
geoEncoding = "geoarrow.wkb";
|
|
12318
|
-
}
|
|
12319
|
-
if (geoEncoding === "wkt") {
|
|
12320
|
-
geoEncoding = "geoarrow.wkt";
|
|
12321
|
-
}
|
|
12322
|
-
if (!GEOARROW_ENCODINGS.includes(geoEncoding)) {
|
|
12323
|
-
console.warn(`Invalid GeoArrow encoding: ${geoEncoding}`);
|
|
12324
|
-
} else {
|
|
12325
|
-
metadata = metadata || {};
|
|
12326
|
-
metadata.encoding = geoEncoding;
|
|
12327
|
-
}
|
|
12328
|
-
}
|
|
12329
|
-
const columnMetadata = field.metadata?.[GEOARROW_COLUMN_METADATA_METADATA];
|
|
12330
|
-
if (columnMetadata) {
|
|
12331
|
-
try {
|
|
12332
|
-
metadata = JSON.parse(columnMetadata);
|
|
12333
|
-
} catch (error) {
|
|
12334
|
-
console.warn("Failed to parse GeoArrow metadata", error);
|
|
12335
|
-
}
|
|
12336
|
-
}
|
|
12337
|
-
return metadata || null;
|
|
12338
|
-
}
|
|
12339
|
-
|
|
12340
|
-
// ../gis/src/lib/binary-features/binary-to-geojson.ts
|
|
12341
|
-
function binaryToGeometry(data, startIndex, endIndex) {
|
|
12342
|
-
switch (data.type) {
|
|
12343
|
-
case "Point":
|
|
12344
|
-
return pointToGeoJson(data, startIndex, endIndex);
|
|
12345
|
-
case "LineString":
|
|
12346
|
-
return lineStringToGeoJson(data, startIndex, endIndex);
|
|
12347
|
-
case "Polygon":
|
|
12348
|
-
return polygonToGeoJson(data, startIndex, endIndex);
|
|
12349
|
-
default:
|
|
12350
|
-
const unexpectedInput = data;
|
|
12351
|
-
throw new Error(`Unsupported geometry type: ${unexpectedInput?.type}`);
|
|
12352
|
-
}
|
|
12353
|
-
}
|
|
12354
|
-
function polygonToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
|
|
12355
|
-
const { positions } = data;
|
|
12356
|
-
const polygonIndices = data.polygonIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
12357
|
-
const primitivePolygonIndices = data.primitivePolygonIndices.value.filter(
|
|
12358
|
-
(x) => x >= startIndex && x <= endIndex
|
|
12359
|
-
);
|
|
12360
|
-
const multi = polygonIndices.length > 2;
|
|
12361
|
-
if (!multi) {
|
|
12362
|
-
const coordinates2 = [];
|
|
12363
|
-
for (let i = 0; i < primitivePolygonIndices.length - 1; i++) {
|
|
12364
|
-
const startRingIndex = primitivePolygonIndices[i];
|
|
12365
|
-
const endRingIndex = primitivePolygonIndices[i + 1];
|
|
12366
|
-
const ringCoordinates = ringToGeoJson(positions, startRingIndex, endRingIndex);
|
|
12367
|
-
coordinates2.push(ringCoordinates);
|
|
12368
|
-
}
|
|
12369
|
-
return { type: "Polygon", coordinates: coordinates2 };
|
|
12370
|
-
}
|
|
12371
|
-
const coordinates = [];
|
|
12372
|
-
for (let i = 0; i < polygonIndices.length - 1; i++) {
|
|
12373
|
-
const startPolygonIndex = polygonIndices[i];
|
|
12374
|
-
const endPolygonIndex = polygonIndices[i + 1];
|
|
12375
|
-
const polygonCoordinates = polygonToGeoJson(
|
|
12376
|
-
data,
|
|
12377
|
-
startPolygonIndex,
|
|
12378
|
-
endPolygonIndex
|
|
12379
|
-
).coordinates;
|
|
12380
|
-
coordinates.push(polygonCoordinates);
|
|
12381
|
-
}
|
|
12382
|
-
return { type: "MultiPolygon", coordinates };
|
|
12383
|
-
}
|
|
12384
|
-
function lineStringToGeoJson(data, startIndex = -Infinity, endIndex = Infinity) {
|
|
12385
|
-
const { positions } = data;
|
|
12386
|
-
const pathIndices = data.pathIndices.value.filter((x) => x >= startIndex && x <= endIndex);
|
|
12387
|
-
const multi = pathIndices.length > 2;
|
|
12388
|
-
if (!multi) {
|
|
12389
|
-
const coordinates2 = ringToGeoJson(positions, pathIndices[0], pathIndices[1]);
|
|
12390
|
-
return { type: "LineString", coordinates: coordinates2 };
|
|
12391
|
-
}
|
|
12392
|
-
const coordinates = [];
|
|
12393
|
-
for (let i = 0; i < pathIndices.length - 1; i++) {
|
|
12394
|
-
const ringCoordinates = ringToGeoJson(positions, pathIndices[i], pathIndices[i + 1]);
|
|
12395
|
-
coordinates.push(ringCoordinates);
|
|
12396
|
-
}
|
|
12397
|
-
return { type: "MultiLineString", coordinates };
|
|
12398
|
-
}
|
|
12399
|
-
function pointToGeoJson(data, startIndex, endIndex) {
|
|
12400
|
-
const { positions } = data;
|
|
12401
|
-
const coordinates = ringToGeoJson(positions, startIndex, endIndex);
|
|
12402
|
-
const multi = coordinates.length > 1;
|
|
12403
|
-
if (multi) {
|
|
12404
|
-
return { type: "MultiPoint", coordinates };
|
|
12405
|
-
}
|
|
12406
|
-
return { type: "Point", coordinates: coordinates[0] };
|
|
12407
|
-
}
|
|
12408
|
-
function ringToGeoJson(positions, startIndex, endIndex) {
|
|
12409
|
-
startIndex = startIndex || 0;
|
|
12410
|
-
endIndex = endIndex || positions.value.length / positions.size;
|
|
12411
|
-
const ringCoordinates = [];
|
|
12412
|
-
for (let j = startIndex; j < endIndex; j++) {
|
|
12413
|
-
const coord = Array();
|
|
12414
|
-
for (let k = j * positions.size; k < (j + 1) * positions.size; k++) {
|
|
12415
|
-
coord.push(Number(positions.value[k]));
|
|
12416
|
-
}
|
|
12417
|
-
ringCoordinates.push(coord);
|
|
12418
|
-
}
|
|
12419
|
-
return ringCoordinates;
|
|
12420
|
-
}
|
|
12421
|
-
|
|
12422
|
-
// src/lib/tables/convert-arrow-schema.ts
|
|
12423
|
-
function convertArrowToSchema(arrowSchema) {
|
|
12424
|
-
return serializeArrowSchema(arrowSchema);
|
|
12425
|
-
}
|
|
12426
|
-
function serializeArrowSchema(arrowSchema) {
|
|
12427
|
-
return {
|
|
12428
|
-
fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),
|
|
12429
|
-
metadata: serializeArrowMetadata(arrowSchema.metadata)
|
|
12430
|
-
};
|
|
12431
|
-
}
|
|
12432
|
-
function serializeArrowMetadata(arrowMetadata) {
|
|
12433
|
-
return Object.fromEntries(arrowMetadata);
|
|
12061
|
+
function deserializeArrowMetadata(metadata) {
|
|
12062
|
+
return metadata ? new Map(Object.entries(metadata)) : /* @__PURE__ */ new Map();
|
|
12434
12063
|
}
|
|
12435
12064
|
function serializeArrowField(field) {
|
|
12436
12065
|
return {
|
|
@@ -12440,6 +12069,14 @@ return true;`);
|
|
|
12440
12069
|
metadata: serializeArrowMetadata(field.metadata)
|
|
12441
12070
|
};
|
|
12442
12071
|
}
|
|
12072
|
+
function deserializeArrowField(field) {
|
|
12073
|
+
return new Field2(
|
|
12074
|
+
field.name,
|
|
12075
|
+
deserializeArrowType(field.type),
|
|
12076
|
+
field.nullable,
|
|
12077
|
+
deserializeArrowMetadata(field.metadata)
|
|
12078
|
+
);
|
|
12079
|
+
}
|
|
12443
12080
|
function serializeArrowType(arrowType) {
|
|
12444
12081
|
switch (arrowType.constructor) {
|
|
12445
12082
|
case Null2:
|
|
@@ -12591,771 +12228,414 @@ return true;`);
|
|
|
12591
12228
|
throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);
|
|
12592
12229
|
}
|
|
12593
12230
|
}
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
|
|
12597
|
-
|
|
12598
|
-
|
|
12599
|
-
|
|
12600
|
-
|
|
12601
|
-
|
|
12602
|
-
|
|
12603
|
-
|
|
12604
|
-
|
|
12605
|
-
|
|
12606
|
-
|
|
12607
|
-
|
|
12608
|
-
|
|
12609
|
-
|
|
12610
|
-
|
|
12611
|
-
|
|
12612
|
-
|
|
12613
|
-
|
|
12614
|
-
function parseWKT(input, options) {
|
|
12615
|
-
return parseWKTToGeometry(input, options);
|
|
12616
|
-
}
|
|
12617
|
-
function parseWKTToGeometry(input, options) {
|
|
12618
|
-
const parts = input.split(";");
|
|
12619
|
-
let _ = parts.pop();
|
|
12620
|
-
const srid = (parts.shift() || "").split("=").pop();
|
|
12621
|
-
const state = { parts, _, i: 0 };
|
|
12622
|
-
const geometry = parseGeometry(state);
|
|
12623
|
-
return options?.wkt?.crs ? addCRS(geometry, srid) : geometry;
|
|
12624
|
-
}
|
|
12625
|
-
function parseGeometry(state) {
|
|
12626
|
-
return parsePoint(state) || parseLineString(state) || parsePolygon(state) || parseMultiPoint(state) || parseMultiLineString(state) || parseMultiPolygon(state) || parseGeometryCollection(state);
|
|
12627
|
-
}
|
|
12628
|
-
function addCRS(obj, srid) {
|
|
12629
|
-
if (obj && srid?.match(/\d+/)) {
|
|
12630
|
-
const crs = {
|
|
12631
|
-
type: "name",
|
|
12632
|
-
properties: {
|
|
12633
|
-
name: "urn:ogc:def:crs:EPSG::" + srid
|
|
12634
|
-
}
|
|
12635
|
-
};
|
|
12636
|
-
obj.crs = crs;
|
|
12637
|
-
}
|
|
12638
|
-
return obj;
|
|
12639
|
-
}
|
|
12640
|
-
function parsePoint(state) {
|
|
12641
|
-
if (!$(/^(POINT(\sz)?)/i, state)) {
|
|
12642
|
-
return null;
|
|
12231
|
+
function deserializeArrowType(dataType) {
|
|
12232
|
+
if (typeof dataType === "object") {
|
|
12233
|
+
switch (dataType.type) {
|
|
12234
|
+
case "decimal":
|
|
12235
|
+
return new Decimal2(dataType.precision, dataType.scale, dataType.bitWidth);
|
|
12236
|
+
case "map":
|
|
12237
|
+
let children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
|
|
12238
|
+
return new Map_(children, dataType.keysSorted);
|
|
12239
|
+
case "list":
|
|
12240
|
+
const field = deserializeArrowField(dataType.children[0]);
|
|
12241
|
+
return new List2(field);
|
|
12242
|
+
case "fixed-size-list":
|
|
12243
|
+
const child = deserializeArrowField(dataType.children[0]);
|
|
12244
|
+
return new FixedSizeList2(dataType.listSize, child);
|
|
12245
|
+
case "struct":
|
|
12246
|
+
children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));
|
|
12247
|
+
return new Struct(children);
|
|
12248
|
+
default:
|
|
12249
|
+
throw new Error("array type not supported");
|
|
12250
|
+
}
|
|
12643
12251
|
}
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12252
|
+
switch (dataType) {
|
|
12253
|
+
case "null":
|
|
12254
|
+
return new Null2();
|
|
12255
|
+
case "binary":
|
|
12256
|
+
return new Binary2();
|
|
12257
|
+
case "bool":
|
|
12258
|
+
return new Bool2();
|
|
12259
|
+
case "int8":
|
|
12260
|
+
return new Int8();
|
|
12261
|
+
case "int16":
|
|
12262
|
+
return new Int16();
|
|
12263
|
+
case "int32":
|
|
12264
|
+
return new Int32();
|
|
12265
|
+
case "int64":
|
|
12266
|
+
return new Int64();
|
|
12267
|
+
case "uint8":
|
|
12268
|
+
return new Uint8();
|
|
12269
|
+
case "uint16":
|
|
12270
|
+
return new Uint16();
|
|
12271
|
+
case "uint32":
|
|
12272
|
+
return new Uint32();
|
|
12273
|
+
case "uint64":
|
|
12274
|
+
return new Uint64();
|
|
12275
|
+
case "float16":
|
|
12276
|
+
return new Float16();
|
|
12277
|
+
case "float32":
|
|
12278
|
+
return new Float32();
|
|
12279
|
+
case "float64":
|
|
12280
|
+
return new Float64();
|
|
12281
|
+
case "utf8":
|
|
12282
|
+
return new Utf82();
|
|
12283
|
+
case "date-day":
|
|
12284
|
+
return new DateDay();
|
|
12285
|
+
case "date-millisecond":
|
|
12286
|
+
return new DateMillisecond();
|
|
12287
|
+
case "time-second":
|
|
12288
|
+
return new TimeSecond();
|
|
12289
|
+
case "time-millisecond":
|
|
12290
|
+
return new TimeMillisecond();
|
|
12291
|
+
case "time-microsecond":
|
|
12292
|
+
return new TimeMicrosecond();
|
|
12293
|
+
case "time-nanosecond":
|
|
12294
|
+
return new TimeNanosecond();
|
|
12295
|
+
case "timestamp-second":
|
|
12296
|
+
return new TimestampSecond();
|
|
12297
|
+
case "timestamp-millisecond":
|
|
12298
|
+
return new TimestampMillisecond();
|
|
12299
|
+
case "timestamp-microsecond":
|
|
12300
|
+
return new TimestampMicrosecond();
|
|
12301
|
+
case "timestamp-nanosecond":
|
|
12302
|
+
return new TimestampNanosecond();
|
|
12303
|
+
case "interval-daytime":
|
|
12304
|
+
return new IntervalDayTime();
|
|
12305
|
+
case "interval-yearmonth":
|
|
12306
|
+
return new IntervalYearMonth();
|
|
12307
|
+
default:
|
|
12308
|
+
throw new Error("array type not supported");
|
|
12647
12309
|
}
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12310
|
+
}
|
|
12311
|
+
|
|
12312
|
+
// ../schema-utils/src/lib/schema/deduce-table-schema.ts
|
|
12313
|
+
function deduceTableSchema(table) {
|
|
12314
|
+
switch (table.shape) {
|
|
12315
|
+
case "array-row-table":
|
|
12316
|
+
case "object-row-table":
|
|
12317
|
+
return deduceSchemaFromRows(table.data);
|
|
12318
|
+
case "geojson-table":
|
|
12319
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
12320
|
+
case "columnar-table":
|
|
12321
|
+
return deduceSchemaFromColumns(table.data);
|
|
12322
|
+
case "arrow-table":
|
|
12323
|
+
default:
|
|
12324
|
+
throw new Error("Deduce schema");
|
|
12651
12325
|
}
|
|
12652
|
-
|
|
12653
|
-
|
|
12654
|
-
|
|
12326
|
+
}
|
|
12327
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
12328
|
+
const fields = [];
|
|
12329
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
12330
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
12331
|
+
fields.push(field);
|
|
12655
12332
|
}
|
|
12656
|
-
return {
|
|
12657
|
-
type: "Point",
|
|
12658
|
-
coordinates: c[0]
|
|
12659
|
-
};
|
|
12333
|
+
return { fields, metadata: {} };
|
|
12660
12334
|
}
|
|
12661
|
-
function
|
|
12662
|
-
if (
|
|
12663
|
-
|
|
12335
|
+
function deduceSchemaFromRows(rowTable) {
|
|
12336
|
+
if (!rowTable.length) {
|
|
12337
|
+
throw new Error("deduce from empty table");
|
|
12664
12338
|
}
|
|
12665
|
-
|
|
12666
|
-
const
|
|
12667
|
-
|
|
12668
|
-
|
|
12669
|
-
if (!c) {
|
|
12670
|
-
return null;
|
|
12339
|
+
const fields = [];
|
|
12340
|
+
const row0 = rowTable[0];
|
|
12341
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
12342
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
12671
12343
|
}
|
|
12672
|
-
|
|
12673
|
-
return {
|
|
12674
|
-
type: "MultiPoint",
|
|
12675
|
-
coordinates: c
|
|
12676
|
-
};
|
|
12344
|
+
return { fields, metadata: {} };
|
|
12677
12345
|
}
|
|
12678
|
-
function
|
|
12679
|
-
if (
|
|
12680
|
-
|
|
12346
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
12347
|
+
if (!features.length) {
|
|
12348
|
+
throw new Error("deduce from empty table");
|
|
12681
12349
|
}
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
|
|
12350
|
+
const fields = [];
|
|
12351
|
+
const row0 = features[0].properties || {};
|
|
12352
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
12353
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
12685
12354
|
}
|
|
12686
|
-
|
|
12687
|
-
|
|
12688
|
-
|
|
12355
|
+
return { fields, metadata: {} };
|
|
12356
|
+
}
|
|
12357
|
+
function deduceFieldFromColumn(column, name) {
|
|
12358
|
+
if (ArrayBuffer.isView(column)) {
|
|
12359
|
+
const type = getDataTypeFromArray(column);
|
|
12360
|
+
return {
|
|
12361
|
+
name,
|
|
12362
|
+
type: type.type || "null",
|
|
12363
|
+
nullable: type.nullable
|
|
12364
|
+
// metadata: {}
|
|
12365
|
+
};
|
|
12689
12366
|
}
|
|
12690
|
-
if (
|
|
12691
|
-
|
|
12367
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
12368
|
+
const value = column[0];
|
|
12369
|
+
const type = getDataTypeFromValue(value);
|
|
12370
|
+
return {
|
|
12371
|
+
name,
|
|
12372
|
+
type,
|
|
12373
|
+
nullable: true
|
|
12374
|
+
// metadata: {},
|
|
12375
|
+
};
|
|
12692
12376
|
}
|
|
12693
|
-
|
|
12694
|
-
type: "LineString",
|
|
12695
|
-
coordinates: c
|
|
12696
|
-
};
|
|
12377
|
+
throw new Error("empty table");
|
|
12697
12378
|
}
|
|
12698
|
-
function
|
|
12699
|
-
|
|
12700
|
-
return null;
|
|
12701
|
-
white(state);
|
|
12702
|
-
const c = multicoords(state);
|
|
12703
|
-
if (!c) {
|
|
12704
|
-
return null;
|
|
12705
|
-
}
|
|
12706
|
-
white(state);
|
|
12379
|
+
function deduceFieldFromValue(value, name) {
|
|
12380
|
+
const type = getDataTypeFromValue(value);
|
|
12707
12381
|
return {
|
|
12708
|
-
|
|
12709
|
-
type
|
|
12710
|
-
|
|
12711
|
-
|
|
12382
|
+
name,
|
|
12383
|
+
type,
|
|
12384
|
+
nullable: true
|
|
12385
|
+
// metadata: {}
|
|
12712
12386
|
};
|
|
12713
12387
|
}
|
|
12714
|
-
function parsePolygon(state) {
|
|
12715
|
-
if (!$(/^(POLYGON(\sz)?)/i, state)) {
|
|
12716
|
-
return null;
|
|
12717
|
-
}
|
|
12718
|
-
white(state);
|
|
12719
|
-
const c = multicoords(state);
|
|
12720
|
-
if (!c) {
|
|
12721
|
-
return null;
|
|
12722
|
-
}
|
|
12723
|
-
return {
|
|
12724
|
-
// @ts-ignore
|
|
12725
|
-
type: "Polygon",
|
|
12726
|
-
// @ts-expect-error
|
|
12727
|
-
coordinates: c
|
|
12728
|
-
};
|
|
12729
|
-
}
|
|
12730
|
-
function parseMultiPolygon(state) {
|
|
12731
|
-
if (!$(/^(MULTIPOLYGON)/i, state)) {
|
|
12732
|
-
return null;
|
|
12733
|
-
}
|
|
12734
|
-
white(state);
|
|
12735
|
-
const c = multicoords(state);
|
|
12736
|
-
if (!c) {
|
|
12737
|
-
return null;
|
|
12738
|
-
}
|
|
12739
|
-
return {
|
|
12740
|
-
type: "MultiPolygon",
|
|
12741
|
-
// @ts-expect-error
|
|
12742
|
-
coordinates: c
|
|
12743
|
-
};
|
|
12744
|
-
}
|
|
12745
|
-
function parseGeometryCollection(state) {
|
|
12746
|
-
const geometries = [];
|
|
12747
|
-
let geometry;
|
|
12748
|
-
if (!$(/^(GEOMETRYCOLLECTION)/i, state)) {
|
|
12749
|
-
return null;
|
|
12750
|
-
}
|
|
12751
|
-
white(state);
|
|
12752
|
-
if (!$(/^(\()/, state)) {
|
|
12753
|
-
return null;
|
|
12754
|
-
}
|
|
12755
|
-
while (geometry = parseGeometry(state)) {
|
|
12756
|
-
geometries.push(geometry);
|
|
12757
|
-
white(state);
|
|
12758
|
-
$(/^(,)/, state);
|
|
12759
|
-
white(state);
|
|
12760
|
-
}
|
|
12761
|
-
if (!$(/^(\))/, state)) {
|
|
12762
|
-
return null;
|
|
12763
|
-
}
|
|
12764
|
-
return {
|
|
12765
|
-
type: "GeometryCollection",
|
|
12766
|
-
geometries
|
|
12767
|
-
};
|
|
12768
|
-
}
|
|
12769
|
-
function multicoords(state) {
|
|
12770
|
-
white(state);
|
|
12771
|
-
let depth = 0;
|
|
12772
|
-
const rings = [];
|
|
12773
|
-
const stack = [rings];
|
|
12774
|
-
let pointer = rings;
|
|
12775
|
-
let elem;
|
|
12776
|
-
while (elem = $(/^(\()/, state) || $(/^(\))/, state) || $(/^(,)/, state) || $(tuples, state)) {
|
|
12777
|
-
if (elem === "(") {
|
|
12778
|
-
stack.push(pointer);
|
|
12779
|
-
pointer = [];
|
|
12780
|
-
stack[stack.length - 1].push(pointer);
|
|
12781
|
-
depth++;
|
|
12782
|
-
} else if (elem === ")") {
|
|
12783
|
-
if (pointer.length === 0)
|
|
12784
|
-
return null;
|
|
12785
|
-
pointer = stack.pop();
|
|
12786
|
-
if (!pointer)
|
|
12787
|
-
return null;
|
|
12788
|
-
depth--;
|
|
12789
|
-
if (depth === 0)
|
|
12790
|
-
break;
|
|
12791
|
-
} else if (elem === ",") {
|
|
12792
|
-
pointer = [];
|
|
12793
|
-
stack[stack.length - 1].push(pointer);
|
|
12794
|
-
} else if (!elem.split(/\s/g).some(isNaN)) {
|
|
12795
|
-
Array.prototype.push.apply(pointer, elem.split(/\s/g).map(parseFloat));
|
|
12796
|
-
} else {
|
|
12797
|
-
return null;
|
|
12798
|
-
}
|
|
12799
|
-
white(state);
|
|
12800
|
-
}
|
|
12801
|
-
if (depth !== 0)
|
|
12802
|
-
return null;
|
|
12803
|
-
return rings;
|
|
12804
|
-
}
|
|
12805
|
-
function coords(state) {
|
|
12806
|
-
const list = [];
|
|
12807
|
-
let item;
|
|
12808
|
-
let pt;
|
|
12809
|
-
while (pt = $(tuples, state) || $(/^(,)/, state)) {
|
|
12810
|
-
if (pt === ",") {
|
|
12811
|
-
list.push(item);
|
|
12812
|
-
item = [];
|
|
12813
|
-
} else if (!pt.split(/\s/g).some(isNaN)) {
|
|
12814
|
-
if (!item)
|
|
12815
|
-
item = [];
|
|
12816
|
-
Array.prototype.push.apply(item, pt.split(/\s/g).map(parseFloat));
|
|
12817
|
-
}
|
|
12818
|
-
white(state);
|
|
12819
|
-
}
|
|
12820
|
-
if (item)
|
|
12821
|
-
list.push(item);
|
|
12822
|
-
else
|
|
12823
|
-
return null;
|
|
12824
|
-
return list.length ? list : null;
|
|
12825
|
-
}
|
|
12826
|
-
function $(regexp, state) {
|
|
12827
|
-
const match = state._?.substring(state.i).match(regexp);
|
|
12828
|
-
if (!match)
|
|
12829
|
-
return null;
|
|
12830
|
-
else {
|
|
12831
|
-
state.i += match[0].length;
|
|
12832
|
-
return match[0];
|
|
12833
|
-
}
|
|
12834
|
-
}
|
|
12835
|
-
function white(state) {
|
|
12836
|
-
$(/^\s*/, state);
|
|
12837
|
-
}
|
|
12838
|
-
|
|
12839
|
-
// ../wkt/src/wkt-loader.ts
|
|
12840
|
-
var WKTWorkerLoader = {
|
|
12841
|
-
dataType: null,
|
|
12842
|
-
batchType: null,
|
|
12843
|
-
name: "WKT (Well-Known Text)",
|
|
12844
|
-
id: "wkt",
|
|
12845
|
-
module: "wkt",
|
|
12846
|
-
version: VERSION,
|
|
12847
|
-
worker: true,
|
|
12848
|
-
extensions: ["wkt"],
|
|
12849
|
-
mimeTypes: ["text/plain"],
|
|
12850
|
-
category: "geometry",
|
|
12851
|
-
text: true,
|
|
12852
|
-
tests: WKT_MAGIC_STRINGS,
|
|
12853
|
-
testText: isWKT,
|
|
12854
|
-
options: {
|
|
12855
|
-
wkt: {
|
|
12856
|
-
shape: "geojson-geometry",
|
|
12857
|
-
crs: true
|
|
12858
|
-
}
|
|
12859
|
-
}
|
|
12860
|
-
};
|
|
12861
|
-
var WKTLoader = {
|
|
12862
|
-
...WKTWorkerLoader,
|
|
12863
|
-
parse: async (arrayBuffer, options) => parseWKT(new TextDecoder().decode(arrayBuffer), options),
|
|
12864
|
-
parseTextSync: (string, options) => parseWKT(string, options)
|
|
12865
|
-
};
|
|
12866
12388
|
|
|
12867
|
-
// ../
|
|
12868
|
-
|
|
12869
|
-
|
|
12870
|
-
|
|
12871
|
-
|
|
12872
|
-
|
|
12873
|
-
|
|
12874
|
-
|
|
12875
|
-
|
|
12876
|
-
|
|
12877
|
-
|
|
12878
|
-
|
|
12389
|
+
// ../schema-utils/src/lib/table/tables/table-accessors.ts
|
|
12390
|
+
function getTableLength(table) {
|
|
12391
|
+
switch (table.shape) {
|
|
12392
|
+
case "array-row-table":
|
|
12393
|
+
case "object-row-table":
|
|
12394
|
+
return table.data.length;
|
|
12395
|
+
case "geojson-table":
|
|
12396
|
+
return table.features.length;
|
|
12397
|
+
case "arrow-table":
|
|
12398
|
+
const arrowTable = table.data;
|
|
12399
|
+
return arrowTable.numRows;
|
|
12400
|
+
case "columnar-table":
|
|
12401
|
+
for (const column of Object.values(table.data)) {
|
|
12402
|
+
return column.length || 0;
|
|
12403
|
+
}
|
|
12404
|
+
return 0;
|
|
12405
|
+
default:
|
|
12406
|
+
throw new Error("table");
|
|
12879
12407
|
}
|
|
12880
|
-
|
|
12881
|
-
|
|
12882
|
-
|
|
12883
|
-
|
|
12884
|
-
if (geometryType === 0 || geometryType > 7) {
|
|
12885
|
-
return false;
|
|
12408
|
+
}
|
|
12409
|
+
function getTableNumCols(table) {
|
|
12410
|
+
if (table.schema) {
|
|
12411
|
+
return table.schema.fields.length;
|
|
12886
12412
|
}
|
|
12887
|
-
|
|
12888
|
-
|
|
12889
|
-
return true;
|
|
12413
|
+
if (getTableLength(table) === 0) {
|
|
12414
|
+
throw new Error("empty table");
|
|
12890
12415
|
}
|
|
12891
|
-
|
|
12892
|
-
|
|
12893
|
-
|
|
12894
|
-
|
|
12895
|
-
|
|
12896
|
-
|
|
12897
|
-
|
|
12898
|
-
|
|
12899
|
-
|
|
12416
|
+
switch (table.shape) {
|
|
12417
|
+
case "array-row-table":
|
|
12418
|
+
return table.data[0].length;
|
|
12419
|
+
case "object-row-table":
|
|
12420
|
+
return Object.keys(table.data[0]).length;
|
|
12421
|
+
case "geojson-table":
|
|
12422
|
+
return Object.keys(table.features[0]).length;
|
|
12423
|
+
case "columnar-table":
|
|
12424
|
+
return Object.keys(table.data).length;
|
|
12425
|
+
case "arrow-table":
|
|
12426
|
+
const arrowTable = table.data;
|
|
12427
|
+
return arrowTable.numCols;
|
|
12428
|
+
default:
|
|
12429
|
+
throw new Error("table");
|
|
12900
12430
|
}
|
|
12901
|
-
return true;
|
|
12902
12431
|
}
|
|
12903
|
-
function
|
|
12904
|
-
|
|
12905
|
-
|
|
12906
|
-
|
|
12907
|
-
|
|
12908
|
-
|
|
12909
|
-
|
|
12910
|
-
|
|
12911
|
-
|
|
12912
|
-
|
|
12913
|
-
|
|
12914
|
-
|
|
12915
|
-
|
|
12916
|
-
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
case 1:
|
|
12922
|
-
wkbHeader.type = "iso-wkb";
|
|
12923
|
-
wkbHeader.dimensions = 3;
|
|
12924
|
-
wkbHeader.coordinates = "xyz";
|
|
12925
|
-
break;
|
|
12926
|
-
case 2:
|
|
12927
|
-
wkbHeader.type = "iso-wkb";
|
|
12928
|
-
wkbHeader.dimensions = 3;
|
|
12929
|
-
wkbHeader.coordinates = "xym";
|
|
12930
|
-
break;
|
|
12931
|
-
case 3:
|
|
12932
|
-
wkbHeader.type = "iso-wkb";
|
|
12933
|
-
wkbHeader.dimensions = 4;
|
|
12934
|
-
wkbHeader.coordinates = "xyzm";
|
|
12935
|
-
break;
|
|
12936
|
-
default:
|
|
12937
|
-
throw new Error(`WKB: Unsupported iso-wkb type: ${isoType}`);
|
|
12938
|
-
}
|
|
12939
|
-
const ewkbZ = geometryCode & EWKB_FLAG_Z;
|
|
12940
|
-
const ewkbM = geometryCode & EWKB_FLAG_M;
|
|
12941
|
-
const ewkbSRID = geometryCode & EWKB_FLAG_SRID;
|
|
12942
|
-
if (ewkbZ && ewkbM) {
|
|
12943
|
-
wkbHeader.type = "ewkb";
|
|
12944
|
-
wkbHeader.dimensions = 4;
|
|
12945
|
-
wkbHeader.coordinates = "xyzm";
|
|
12946
|
-
} else if (ewkbZ) {
|
|
12947
|
-
wkbHeader.type = "ewkb";
|
|
12948
|
-
wkbHeader.dimensions = 3;
|
|
12949
|
-
wkbHeader.coordinates = "xyz";
|
|
12950
|
-
} else if (ewkbM) {
|
|
12951
|
-
wkbHeader.type = "ewkb";
|
|
12952
|
-
wkbHeader.dimensions = 3;
|
|
12953
|
-
wkbHeader.coordinates = "xym";
|
|
12954
|
-
}
|
|
12955
|
-
if (ewkbSRID) {
|
|
12956
|
-
wkbHeader.type = "ewkb";
|
|
12957
|
-
wkbHeader.srid = dataView.getUint32(wkbHeader.byteOffset, wkbHeader.littleEndian);
|
|
12958
|
-
wkbHeader.byteOffset += 4;
|
|
12959
|
-
}
|
|
12960
|
-
return wkbHeader;
|
|
12961
|
-
}
|
|
12962
|
-
|
|
12963
|
-
// ../wkt/src/lib/parse-wkb.ts
|
|
12964
|
-
function parseWKB(arrayBuffer, options) {
|
|
12965
|
-
const binaryGeometry = parseWKBToBinary(arrayBuffer, options);
|
|
12966
|
-
const shape = options?.wkb?.shape || "binary-geometry";
|
|
12967
|
-
switch (shape) {
|
|
12968
|
-
case "binary-geometry":
|
|
12969
|
-
return binaryGeometry;
|
|
12970
|
-
case "geojson-geometry":
|
|
12971
|
-
return binaryToGeometry(binaryGeometry);
|
|
12972
|
-
case "geometry":
|
|
12973
|
-
console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead');
|
|
12974
|
-
return binaryToGeometry(binaryGeometry);
|
|
12432
|
+
function getTableCell(table, rowIndex, columnName) {
|
|
12433
|
+
switch (table.shape) {
|
|
12434
|
+
case "array-row-table":
|
|
12435
|
+
const columnIndex = getTableColumnIndex(table, columnName);
|
|
12436
|
+
return table.data[rowIndex][columnIndex];
|
|
12437
|
+
case "object-row-table":
|
|
12438
|
+
return table.data[rowIndex][columnName];
|
|
12439
|
+
case "geojson-table":
|
|
12440
|
+
return table.features[rowIndex][columnName];
|
|
12441
|
+
case "columnar-table":
|
|
12442
|
+
const column = table.data[columnName];
|
|
12443
|
+
return column[rowIndex];
|
|
12444
|
+
case "arrow-table":
|
|
12445
|
+
const arrowTable = table.data;
|
|
12446
|
+
const arrowColumnIndex = arrowTable.schema.fields.findIndex(
|
|
12447
|
+
(field) => field.name === columnName
|
|
12448
|
+
);
|
|
12449
|
+
return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);
|
|
12975
12450
|
default:
|
|
12976
|
-
throw new Error(
|
|
12451
|
+
throw new Error("todo");
|
|
12977
12452
|
}
|
|
12978
12453
|
}
|
|
12979
|
-
function
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
12992
|
-
|
|
12993
|
-
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
multiPoint.type = "Point";
|
|
12997
|
-
return multiPoint;
|
|
12998
|
-
case 5 /* MultiLineString */:
|
|
12999
|
-
const multiLine = parseMultiLineString2(dataView, offset, dimensions, littleEndian);
|
|
13000
|
-
multiLine.type = "LineString";
|
|
13001
|
-
return multiLine;
|
|
13002
|
-
case 6 /* MultiPolygon */:
|
|
13003
|
-
const multiPolygon = parseMultiPolygon2(dataView, offset, dimensions, littleEndian);
|
|
13004
|
-
multiPolygon.type = "Polygon";
|
|
13005
|
-
return multiPolygon;
|
|
12454
|
+
function getTableCellAt(table, rowIndex, columnIndex) {
|
|
12455
|
+
switch (table.shape) {
|
|
12456
|
+
case "array-row-table":
|
|
12457
|
+
return table.data[rowIndex][columnIndex];
|
|
12458
|
+
case "object-row-table":
|
|
12459
|
+
const columnName1 = getTableColumnName(table, columnIndex);
|
|
12460
|
+
return table.data[rowIndex][columnName1];
|
|
12461
|
+
case "geojson-table":
|
|
12462
|
+
const columnName2 = getTableColumnName(table, columnIndex);
|
|
12463
|
+
return table.features[rowIndex][columnName2];
|
|
12464
|
+
case "columnar-table":
|
|
12465
|
+
const columnName3 = getTableColumnName(table, columnIndex);
|
|
12466
|
+
const column = table.data[columnName3];
|
|
12467
|
+
return column[rowIndex];
|
|
12468
|
+
case "arrow-table":
|
|
12469
|
+
const arrowTable = table.data;
|
|
12470
|
+
return arrowTable.getChildAt(columnIndex)?.get(rowIndex);
|
|
13006
12471
|
default:
|
|
13007
|
-
throw new Error(
|
|
12472
|
+
throw new Error("todo");
|
|
13008
12473
|
}
|
|
13009
12474
|
}
|
|
13010
|
-
function
|
|
13011
|
-
const
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
offset += 8;
|
|
12475
|
+
function getTableColumnIndex(table, columnName) {
|
|
12476
|
+
const columnIndex = table.schema?.fields.findIndex((field) => field.name === columnName);
|
|
12477
|
+
if (columnIndex === void 0) {
|
|
12478
|
+
throw new Error(columnName);
|
|
13015
12479
|
}
|
|
13016
|
-
return
|
|
13017
|
-
geometry: { type: "Point", positions: { value: positions, size: dimension } },
|
|
13018
|
-
offset
|
|
13019
|
-
};
|
|
12480
|
+
return columnIndex;
|
|
13020
12481
|
}
|
|
13021
|
-
function
|
|
13022
|
-
const
|
|
13023
|
-
|
|
13024
|
-
|
|
13025
|
-
for (let i = 0; i < nPoints * dimension; i++) {
|
|
13026
|
-
positions[i] = dataView.getFloat64(offset, littleEndian);
|
|
13027
|
-
offset += 8;
|
|
13028
|
-
}
|
|
13029
|
-
const pathIndices = [0];
|
|
13030
|
-
if (nPoints > 0) {
|
|
13031
|
-
pathIndices.push(nPoints);
|
|
12482
|
+
function getTableColumnName(table, columnIndex) {
|
|
12483
|
+
const columnName = table.schema?.fields[columnIndex]?.name;
|
|
12484
|
+
if (!columnName) {
|
|
12485
|
+
throw new Error(`${columnIndex}`);
|
|
13032
12486
|
}
|
|
13033
|
-
return
|
|
13034
|
-
geometry: {
|
|
13035
|
-
type: "LineString",
|
|
13036
|
-
positions: { value: positions, size: dimension },
|
|
13037
|
-
pathIndices: { value: new Uint32Array(pathIndices), size: 1 }
|
|
13038
|
-
},
|
|
13039
|
-
offset
|
|
13040
|
-
};
|
|
13041
|
-
}
|
|
13042
|
-
var cumulativeSum = (sum) => (value) => sum += value;
|
|
13043
|
-
function parsePolygon2(dataView, offset, dimension, littleEndian) {
|
|
13044
|
-
const nRings = dataView.getUint32(offset, littleEndian);
|
|
13045
|
-
offset += 4;
|
|
13046
|
-
const rings = [];
|
|
13047
|
-
for (let i = 0; i < nRings; i++) {
|
|
13048
|
-
const parsed = parseLineString2(dataView, offset, dimension, littleEndian);
|
|
13049
|
-
const { positions } = parsed.geometry;
|
|
13050
|
-
offset = parsed.offset;
|
|
13051
|
-
rings.push(positions.value);
|
|
13052
|
-
}
|
|
13053
|
-
const concatenatedPositions = new Float64Array(concatTypedArrays(rings).buffer);
|
|
13054
|
-
const polygonIndices = [0];
|
|
13055
|
-
if (concatenatedPositions.length > 0) {
|
|
13056
|
-
polygonIndices.push(concatenatedPositions.length / dimension);
|
|
13057
|
-
}
|
|
13058
|
-
const primitivePolygonIndices = rings.map((l) => l.length / dimension).map(cumulativeSum(0));
|
|
13059
|
-
primitivePolygonIndices.unshift(0);
|
|
13060
|
-
return {
|
|
13061
|
-
geometry: {
|
|
13062
|
-
type: "Polygon",
|
|
13063
|
-
positions: { value: concatenatedPositions, size: dimension },
|
|
13064
|
-
polygonIndices: {
|
|
13065
|
-
value: new Uint32Array(polygonIndices),
|
|
13066
|
-
size: 1
|
|
13067
|
-
},
|
|
13068
|
-
primitivePolygonIndices: { value: new Uint32Array(primitivePolygonIndices), size: 1 }
|
|
13069
|
-
},
|
|
13070
|
-
offset
|
|
13071
|
-
};
|
|
12487
|
+
return columnName;
|
|
13072
12488
|
}
|
|
13073
|
-
function
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
|
|
13083
|
-
|
|
13084
|
-
|
|
13085
|
-
|
|
13086
|
-
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13091
|
-
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
binaryPolygonGeometries.push(parsed.geometry);
|
|
13121
|
-
}
|
|
13122
|
-
return concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension);
|
|
13123
|
-
}
|
|
13124
|
-
function concatenateBinaryPointGeometries(binaryPointGeometries, dimension) {
|
|
13125
|
-
const positions = binaryPointGeometries.map((geometry) => geometry.positions.value);
|
|
13126
|
-
const concatenatedPositions = new Float64Array(concatTypedArrays(positions).buffer);
|
|
13127
|
-
return {
|
|
13128
|
-
type: "Point",
|
|
13129
|
-
positions: { value: concatenatedPositions, size: dimension }
|
|
13130
|
-
};
|
|
13131
|
-
}
|
|
13132
|
-
function concatenateBinaryLineGeometries(binaryLineGeometries, dimension) {
|
|
13133
|
-
const lines = binaryLineGeometries.map((geometry) => geometry.positions.value);
|
|
13134
|
-
const concatenatedPositions = new Float64Array(concatTypedArrays(lines).buffer);
|
|
13135
|
-
const pathIndices = lines.map((line) => line.length / dimension).map(cumulativeSum(0));
|
|
13136
|
-
pathIndices.unshift(0);
|
|
13137
|
-
return {
|
|
13138
|
-
type: "LineString",
|
|
13139
|
-
positions: { value: concatenatedPositions, size: dimension },
|
|
13140
|
-
pathIndices: { value: new Uint32Array(pathIndices), size: 1 }
|
|
13141
|
-
};
|
|
13142
|
-
}
|
|
13143
|
-
function concatenateBinaryPolygonGeometries(binaryPolygonGeometries, dimension) {
|
|
13144
|
-
const polygons = [];
|
|
13145
|
-
const primitivePolygons = [];
|
|
13146
|
-
for (const binaryPolygon of binaryPolygonGeometries) {
|
|
13147
|
-
const { positions, primitivePolygonIndices: primitivePolygonIndices2 } = binaryPolygon;
|
|
13148
|
-
polygons.push(positions.value);
|
|
13149
|
-
primitivePolygons.push(primitivePolygonIndices2.value);
|
|
13150
|
-
}
|
|
13151
|
-
const concatenatedPositions = new Float64Array(concatTypedArrays(polygons).buffer);
|
|
13152
|
-
const polygonIndices = polygons.map((p) => p.length / dimension).map(cumulativeSum(0));
|
|
13153
|
-
polygonIndices.unshift(0);
|
|
13154
|
-
const primitivePolygonIndices = [0];
|
|
13155
|
-
for (const primitivePolygon of primitivePolygons) {
|
|
13156
|
-
primitivePolygonIndices.push(
|
|
13157
|
-
...primitivePolygon.filter((x) => x > 0).map((x) => x + primitivePolygonIndices[primitivePolygonIndices.length - 1])
|
|
13158
|
-
);
|
|
12489
|
+
function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
12490
|
+
switch (table.shape) {
|
|
12491
|
+
case "object-row-table":
|
|
12492
|
+
return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];
|
|
12493
|
+
case "array-row-table":
|
|
12494
|
+
if (table.schema) {
|
|
12495
|
+
const objectRow2 = target || {};
|
|
12496
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12497
|
+
objectRow2[table.schema.fields[i].name] = table.data[rowIndex][i];
|
|
12498
|
+
}
|
|
12499
|
+
return objectRow2;
|
|
12500
|
+
}
|
|
12501
|
+
throw new Error("no schema");
|
|
12502
|
+
case "geojson-table":
|
|
12503
|
+
if (table.schema) {
|
|
12504
|
+
const objectRow2 = target || {};
|
|
12505
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12506
|
+
objectRow2[table.schema.fields[i].name] = table.features[rowIndex][i];
|
|
12507
|
+
}
|
|
12508
|
+
return objectRow2;
|
|
12509
|
+
}
|
|
12510
|
+
throw new Error("no schema");
|
|
12511
|
+
case "columnar-table":
|
|
12512
|
+
if (table.schema) {
|
|
12513
|
+
const objectRow2 = target || {};
|
|
12514
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12515
|
+
objectRow2[table.schema.fields[i].name] = table.data[table.schema.fields[i].name][rowIndex];
|
|
12516
|
+
}
|
|
12517
|
+
return objectRow2;
|
|
12518
|
+
} else {
|
|
12519
|
+
const objectRow2 = target || {};
|
|
12520
|
+
for (const [name, column] of Object.entries(table.data)) {
|
|
12521
|
+
objectRow2[name] = column[rowIndex];
|
|
12522
|
+
}
|
|
12523
|
+
return objectRow2;
|
|
12524
|
+
}
|
|
12525
|
+
case "arrow-table":
|
|
12526
|
+
const arrowTable = table.data;
|
|
12527
|
+
const objectRow = target || {};
|
|
12528
|
+
const row = arrowTable.get(rowIndex);
|
|
12529
|
+
const schema = arrowTable.schema;
|
|
12530
|
+
for (let i = 0; i < schema.fields.length; i++) {
|
|
12531
|
+
objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];
|
|
12532
|
+
}
|
|
12533
|
+
return objectRow;
|
|
12534
|
+
default:
|
|
12535
|
+
throw new Error("shape");
|
|
13159
12536
|
}
|
|
13160
|
-
return {
|
|
13161
|
-
type: "Polygon",
|
|
13162
|
-
positions: { value: concatenatedPositions, size: dimension },
|
|
13163
|
-
polygonIndices: { value: new Uint32Array(polygonIndices), size: 1 },
|
|
13164
|
-
primitivePolygonIndices: { value: new Uint32Array(primitivePolygonIndices), size: 1 }
|
|
13165
|
-
};
|
|
13166
12537
|
}
|
|
13167
|
-
function
|
|
13168
|
-
|
|
13169
|
-
|
|
13170
|
-
|
|
13171
|
-
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
|
|
13177
|
-
|
|
13178
|
-
|
|
13179
|
-
|
|
12538
|
+
function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
12539
|
+
switch (table.shape) {
|
|
12540
|
+
case "array-row-table":
|
|
12541
|
+
return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];
|
|
12542
|
+
case "object-row-table":
|
|
12543
|
+
if (table.schema) {
|
|
12544
|
+
const arrayRow2 = target || [];
|
|
12545
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12546
|
+
arrayRow2[i] = table.data[rowIndex][table.schema.fields[i].name];
|
|
12547
|
+
}
|
|
12548
|
+
return arrayRow2;
|
|
12549
|
+
}
|
|
12550
|
+
return Object.values(table.data[rowIndex]);
|
|
12551
|
+
case "geojson-table":
|
|
12552
|
+
if (table.schema) {
|
|
12553
|
+
const arrayRow2 = target || [];
|
|
12554
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12555
|
+
arrayRow2[i] = table.features[rowIndex][table.schema.fields[i].name];
|
|
12556
|
+
}
|
|
12557
|
+
return arrayRow2;
|
|
12558
|
+
}
|
|
12559
|
+
return Object.values(table.features[rowIndex]);
|
|
12560
|
+
case "columnar-table":
|
|
12561
|
+
if (table.schema) {
|
|
12562
|
+
const arrayRow2 = target || [];
|
|
12563
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
12564
|
+
arrayRow2[i] = table.data[table.schema.fields[i].name][rowIndex];
|
|
12565
|
+
}
|
|
12566
|
+
return arrayRow2;
|
|
12567
|
+
} else {
|
|
12568
|
+
const arrayRow2 = target || [];
|
|
12569
|
+
let i = 0;
|
|
12570
|
+
for (const column of Object.values(table.data)) {
|
|
12571
|
+
arrayRow2[i] = column[rowIndex];
|
|
12572
|
+
i++;
|
|
12573
|
+
}
|
|
12574
|
+
return arrayRow2;
|
|
12575
|
+
}
|
|
12576
|
+
case "arrow-table":
|
|
12577
|
+
const arrowTable = table.data;
|
|
12578
|
+
const arrayRow = target || [];
|
|
12579
|
+
const row = arrowTable.get(rowIndex);
|
|
12580
|
+
const schema = arrowTable.schema;
|
|
12581
|
+
for (let i = 0; i < schema.fields.length; i++) {
|
|
12582
|
+
arrayRow[i] = row?.[schema.fields[i].name];
|
|
12583
|
+
}
|
|
12584
|
+
return arrayRow;
|
|
12585
|
+
default:
|
|
12586
|
+
throw new Error("shape");
|
|
13180
12587
|
}
|
|
13181
|
-
return buffer;
|
|
13182
12588
|
}
|
|
13183
12589
|
|
|
13184
|
-
// ../
|
|
13185
|
-
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
name: "WKB",
|
|
13189
|
-
id: "wkb",
|
|
13190
|
-
module: "wkt",
|
|
13191
|
-
version: VERSION,
|
|
13192
|
-
worker: true,
|
|
13193
|
-
category: "geometry",
|
|
13194
|
-
extensions: ["wkb"],
|
|
13195
|
-
mimeTypes: [],
|
|
13196
|
-
// TODO can we define static, serializable tests, eg. some binary strings?
|
|
13197
|
-
tests: [isWKB],
|
|
13198
|
-
options: {
|
|
13199
|
-
wkb: {
|
|
13200
|
-
shape: "binary-geometry"
|
|
13201
|
-
// 'geojson-geometry'
|
|
13202
|
-
}
|
|
13203
|
-
}
|
|
13204
|
-
};
|
|
13205
|
-
var WKBLoader = {
|
|
13206
|
-
...WKBWorkerLoader,
|
|
13207
|
-
parse: async (arrayBuffer) => parseWKB(arrayBuffer),
|
|
13208
|
-
parseSync: parseWKB
|
|
13209
|
-
};
|
|
13210
|
-
|
|
13211
|
-
// src/lib/geoarrow/convert-geoarrow-to-geojson-geometry.ts
|
|
13212
|
-
function parseGeometryFromArrow(arrowCellValue, encoding) {
|
|
13213
|
-
encoding = encoding?.toLowerCase();
|
|
13214
|
-
if (!encoding || !arrowCellValue) {
|
|
13215
|
-
return null;
|
|
13216
|
-
}
|
|
13217
|
-
let geometry;
|
|
13218
|
-
switch (encoding) {
|
|
13219
|
-
case "geoarrow.multipolygon":
|
|
13220
|
-
geometry = arrowMultiPolygonToFeature(arrowCellValue);
|
|
13221
|
-
break;
|
|
13222
|
-
case "geoarrow.polygon":
|
|
13223
|
-
geometry = arrowPolygonToFeature(arrowCellValue);
|
|
13224
|
-
break;
|
|
13225
|
-
case "geoarrow.multipoint":
|
|
13226
|
-
geometry = arrowMultiPointToFeature(arrowCellValue);
|
|
13227
|
-
break;
|
|
13228
|
-
case "geoarrow.point":
|
|
13229
|
-
geometry = arrowPointToFeature(arrowCellValue);
|
|
13230
|
-
break;
|
|
13231
|
-
case "geoarrow.multilinestring":
|
|
13232
|
-
geometry = arrowMultiLineStringToFeature(arrowCellValue);
|
|
13233
|
-
break;
|
|
13234
|
-
case "geoarrow.linestring":
|
|
13235
|
-
geometry = arrowLineStringToFeature(arrowCellValue);
|
|
13236
|
-
break;
|
|
13237
|
-
case "geoarrow.wkb":
|
|
13238
|
-
geometry = arrowWKBToFeature(arrowCellValue);
|
|
13239
|
-
break;
|
|
13240
|
-
case "geoarrow.wkt":
|
|
13241
|
-
geometry = arrowWKTToFeature(arrowCellValue);
|
|
13242
|
-
break;
|
|
13243
|
-
default: {
|
|
13244
|
-
throw Error(`GeoArrow encoding not supported ${encoding}`);
|
|
13245
|
-
}
|
|
13246
|
-
}
|
|
13247
|
-
return geometry;
|
|
13248
|
-
}
|
|
13249
|
-
function arrowWKBToFeature(arrowCellValue) {
|
|
13250
|
-
const arrayBuffer = arrowCellValue.buffer.slice(
|
|
13251
|
-
arrowCellValue.byteOffset,
|
|
13252
|
-
arrowCellValue.byteOffset + arrowCellValue.byteLength
|
|
13253
|
-
);
|
|
13254
|
-
const binaryGeometry = WKBLoader.parseSync?.(arrayBuffer);
|
|
13255
|
-
const geometry = binaryToGeometry(binaryGeometry);
|
|
13256
|
-
return geometry;
|
|
13257
|
-
}
|
|
13258
|
-
function arrowWKTToFeature(arrowCellValue) {
|
|
13259
|
-
const string = arrowCellValue;
|
|
13260
|
-
return WKTLoader.parseTextSync?.(string);
|
|
13261
|
-
}
|
|
13262
|
-
function arrowMultiPolygonToFeature(arrowMultiPolygon) {
|
|
13263
|
-
const multiPolygon = [];
|
|
13264
|
-
for (let m = 0; m < arrowMultiPolygon.length; m++) {
|
|
13265
|
-
const arrowPolygon = arrowMultiPolygon.get(m);
|
|
13266
|
-
const polygon = [];
|
|
13267
|
-
for (let i = 0; arrowPolygon && i < arrowPolygon?.length; i++) {
|
|
13268
|
-
const arrowRing = arrowPolygon?.get(i);
|
|
13269
|
-
const ring = [];
|
|
13270
|
-
for (let j = 0; arrowRing && j < arrowRing.length; j++) {
|
|
13271
|
-
const arrowCoord = arrowRing.get(j);
|
|
13272
|
-
const coord = Array.from(arrowCoord);
|
|
13273
|
-
ring.push(coord);
|
|
13274
|
-
}
|
|
13275
|
-
polygon.push(ring);
|
|
13276
|
-
}
|
|
13277
|
-
multiPolygon.push(polygon);
|
|
13278
|
-
}
|
|
13279
|
-
const geometry = {
|
|
13280
|
-
type: "MultiPolygon",
|
|
13281
|
-
coordinates: multiPolygon
|
|
13282
|
-
};
|
|
13283
|
-
return geometry;
|
|
13284
|
-
}
|
|
13285
|
-
function arrowPolygonToFeature(arrowPolygon) {
|
|
13286
|
-
const polygon = [];
|
|
13287
|
-
for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {
|
|
13288
|
-
const arrowRing = arrowPolygon.get(i);
|
|
13289
|
-
const ring = [];
|
|
13290
|
-
for (let j = 0; arrowRing && j < arrowRing.length; j++) {
|
|
13291
|
-
const arrowCoord = arrowRing.get(j);
|
|
13292
|
-
const coords2 = Array.from(arrowCoord);
|
|
13293
|
-
ring.push(coords2);
|
|
13294
|
-
}
|
|
13295
|
-
polygon.push(ring);
|
|
13296
|
-
}
|
|
13297
|
-
const geometry = {
|
|
13298
|
-
type: "Polygon",
|
|
13299
|
-
coordinates: polygon
|
|
13300
|
-
};
|
|
13301
|
-
return geometry;
|
|
13302
|
-
}
|
|
13303
|
-
function arrowMultiPointToFeature(arrowMultiPoint) {
|
|
13304
|
-
const multiPoint = [];
|
|
13305
|
-
for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {
|
|
13306
|
-
const arrowPoint = arrowMultiPoint.get(i);
|
|
13307
|
-
if (arrowPoint) {
|
|
13308
|
-
const coord = Array.from(arrowPoint);
|
|
13309
|
-
multiPoint.push(coord);
|
|
13310
|
-
}
|
|
13311
|
-
}
|
|
13312
|
-
return {
|
|
13313
|
-
type: "MultiPoint",
|
|
13314
|
-
coordinates: multiPoint
|
|
13315
|
-
};
|
|
13316
|
-
}
|
|
13317
|
-
function arrowPointToFeature(arrowPoint) {
|
|
13318
|
-
const point = Array.from(arrowPoint);
|
|
13319
|
-
return {
|
|
13320
|
-
type: "Point",
|
|
13321
|
-
coordinates: point
|
|
13322
|
-
};
|
|
12590
|
+
// ../schema-utils/src/lib/table/tables/table-column.ts
|
|
12591
|
+
function makeColumnFromField(field, length) {
|
|
12592
|
+
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
12593
|
+
return new ArrayType(length);
|
|
13323
12594
|
}
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
12595
|
+
|
|
12596
|
+
// ../schema-utils/src/lib/table/batches/make-arrow-batch-iterator.ts
|
|
12597
|
+
function* makeArrowRecordBatchIterator(table, options) {
|
|
12598
|
+
const arrowSchema = convertSchemaToArrow(table.schema);
|
|
12599
|
+
const length = getTableLength(table);
|
|
12600
|
+
const numColumns = getTableNumCols(table);
|
|
12601
|
+
const batchSize = options?.batchSize || length;
|
|
12602
|
+
const builders = arrowSchema?.fields.map((arrowField) => makeBuilder(arrowField));
|
|
12603
|
+
const structField = new Struct(arrowSchema.fields);
|
|
12604
|
+
let batchLength = 0;
|
|
12605
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12606
|
+
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
12607
|
+
const value = getTableCellAt(table, rowIndex, columnIndex);
|
|
12608
|
+
const builder = builders[columnIndex];
|
|
12609
|
+
builder.append(value);
|
|
12610
|
+
batchLength++;
|
|
12611
|
+
if (batchLength >= batchSize) {
|
|
12612
|
+
const datas = builders.map((builder2) => builder2.flush());
|
|
12613
|
+
const structData = new Data(structField, 0, batchLength, 0, void 0, datas);
|
|
12614
|
+
yield new RecordBatch2(arrowSchema, structData);
|
|
12615
|
+
batchLength = 0;
|
|
13334
12616
|
}
|
|
13335
12617
|
}
|
|
13336
|
-
multiLineString.push(lineString);
|
|
13337
12618
|
}
|
|
13338
|
-
|
|
13339
|
-
|
|
13340
|
-
|
|
13341
|
-
|
|
13342
|
-
|
|
13343
|
-
function arrowLineStringToFeature(arrowLineString) {
|
|
13344
|
-
const lineString = [];
|
|
13345
|
-
for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {
|
|
13346
|
-
const arrowCoord = arrowLineString.get(i);
|
|
13347
|
-
if (arrowCoord) {
|
|
13348
|
-
const coords2 = Array.from(arrowCoord);
|
|
13349
|
-
lineString.push(coords2);
|
|
13350
|
-
}
|
|
12619
|
+
if (batchLength > 0) {
|
|
12620
|
+
const datas = builders.map((builder) => builder.flush());
|
|
12621
|
+
const structData = new Data(structField, 0, batchLength, 0, void 0, datas);
|
|
12622
|
+
yield new RecordBatch2(arrowSchema, structData);
|
|
12623
|
+
batchLength = 0;
|
|
13351
12624
|
}
|
|
13352
|
-
|
|
13353
|
-
type: "LineString",
|
|
13354
|
-
coordinates: lineString
|
|
13355
|
-
};
|
|
12625
|
+
builders.map((builder) => builder.finish());
|
|
13356
12626
|
}
|
|
13357
12627
|
|
|
13358
|
-
// src/lib/tables/convert-arrow-
|
|
12628
|
+
// ../schema-utils/src/lib/table/tables/convert-arrow-table.ts
|
|
12629
|
+
function convertTableToArrow(table, options) {
|
|
12630
|
+
switch (table.shape) {
|
|
12631
|
+
case "arrow-table":
|
|
12632
|
+
return table.data;
|
|
12633
|
+
case "columnar-table":
|
|
12634
|
+
default:
|
|
12635
|
+
const arrowBatchIterator = makeArrowRecordBatchIterator(table, options);
|
|
12636
|
+
return new Table(arrowBatchIterator);
|
|
12637
|
+
}
|
|
12638
|
+
}
|
|
13359
12639
|
function convertArrowToTable(arrowTable, shape) {
|
|
13360
12640
|
switch (shape) {
|
|
13361
12641
|
case "arrow-table":
|
|
@@ -13403,19 +12683,10 @@ return true;`);
|
|
|
13403
12683
|
}
|
|
13404
12684
|
function convertArrowToGeoJSONTable(arrowTable) {
|
|
13405
12685
|
const schema = convertArrowToSchema(arrowTable.schema);
|
|
13406
|
-
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
13407
|
-
const encoding = geometryColumns.geometry.encoding;
|
|
13408
12686
|
const features = [];
|
|
13409
|
-
const propertyColumnNames = arrowTable.schema.fields.map((field) => field.name).filter((name) => !(name in geometryColumns));
|
|
13410
|
-
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
13411
|
-
const arrowGeometryColumn = arrowTable.getChild("geometry");
|
|
13412
12687
|
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
13413
|
-
const
|
|
13414
|
-
|
|
13415
|
-
if (feature) {
|
|
13416
|
-
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
13417
|
-
features.push({ type: "Feature", geometry: feature, properties });
|
|
13418
|
-
}
|
|
12688
|
+
const properties = arrowTable.get(row)?.toJSON() || {};
|
|
12689
|
+
features.push({ type: "Feature", geometry: null, properties });
|
|
13419
12690
|
}
|
|
13420
12691
|
return {
|
|
13421
12692
|
shape: "geojson-table",
|
|
@@ -13425,6 +12696,81 @@ return true;`);
|
|
|
13425
12696
|
};
|
|
13426
12697
|
}
|
|
13427
12698
|
|
|
12699
|
+
// ../schema-utils/src/lib/table/tables/convert-table.ts
|
|
12700
|
+
function convertTable(table, shape) {
|
|
12701
|
+
switch (shape) {
|
|
12702
|
+
case "object-row-table":
|
|
12703
|
+
return convertToObjectRowTable(table);
|
|
12704
|
+
case "array-row-table":
|
|
12705
|
+
return convertToArrayRowTable(table);
|
|
12706
|
+
case "columnar-table":
|
|
12707
|
+
return convertToColumnarTable(table);
|
|
12708
|
+
case "arrow-table":
|
|
12709
|
+
return convertToArrowTable(table);
|
|
12710
|
+
default:
|
|
12711
|
+
throw new Error(shape);
|
|
12712
|
+
}
|
|
12713
|
+
}
|
|
12714
|
+
function convertToColumnarTable(table) {
|
|
12715
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
12716
|
+
const fields = table.schema?.fields || [];
|
|
12717
|
+
if (table.shape === "columnar-table") {
|
|
12718
|
+
return { ...table, schema };
|
|
12719
|
+
}
|
|
12720
|
+
const length = getTableLength(table);
|
|
12721
|
+
const columns = {};
|
|
12722
|
+
for (const field of fields) {
|
|
12723
|
+
const column = makeColumnFromField(field, length);
|
|
12724
|
+
columns[field.name] = column;
|
|
12725
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12726
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
12727
|
+
}
|
|
12728
|
+
}
|
|
12729
|
+
return {
|
|
12730
|
+
shape: "columnar-table",
|
|
12731
|
+
schema,
|
|
12732
|
+
data: columns
|
|
12733
|
+
};
|
|
12734
|
+
}
|
|
12735
|
+
function convertToArrayRowTable(table) {
|
|
12736
|
+
if (table.shape === "array-row-table") {
|
|
12737
|
+
return table;
|
|
12738
|
+
}
|
|
12739
|
+
const length = getTableLength(table);
|
|
12740
|
+
const data = new Array(length);
|
|
12741
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12742
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
12743
|
+
}
|
|
12744
|
+
return {
|
|
12745
|
+
shape: "array-row-table",
|
|
12746
|
+
schema: table.schema,
|
|
12747
|
+
data
|
|
12748
|
+
};
|
|
12749
|
+
}
|
|
12750
|
+
function convertToObjectRowTable(table) {
|
|
12751
|
+
if (table.shape === "object-row-table") {
|
|
12752
|
+
return table;
|
|
12753
|
+
}
|
|
12754
|
+
const length = getTableLength(table);
|
|
12755
|
+
const data = new Array(length);
|
|
12756
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
12757
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
12758
|
+
}
|
|
12759
|
+
return {
|
|
12760
|
+
shape: "object-row-table",
|
|
12761
|
+
schema: table.schema,
|
|
12762
|
+
data
|
|
12763
|
+
};
|
|
12764
|
+
}
|
|
12765
|
+
function convertToArrowTable(table) {
|
|
12766
|
+
const arrowTable = convertTableToArrow(table);
|
|
12767
|
+
return {
|
|
12768
|
+
shape: "arrow-table",
|
|
12769
|
+
schema: table.schema,
|
|
12770
|
+
data: arrowTable
|
|
12771
|
+
};
|
|
12772
|
+
}
|
|
12773
|
+
|
|
13428
12774
|
// src/lib/parsers/parse-arrow.ts
|
|
13429
12775
|
function parseArrowSync(arrayBuffer, options) {
|
|
13430
12776
|
const shape = options?.shape || "arrow-table";
|
|
@@ -13454,14 +12800,14 @@ return true;`);
|
|
|
13454
12800
|
}
|
|
13455
12801
|
|
|
13456
12802
|
// src/exports/arrow-loader.ts
|
|
13457
|
-
var
|
|
12803
|
+
var VERSION = true ? "4.4.0-alpha.0" : "latest";
|
|
13458
12804
|
var ArrowWorkerLoader = {
|
|
13459
12805
|
dataType: null,
|
|
13460
12806
|
batchType: null,
|
|
13461
12807
|
name: "Apache Arrow",
|
|
13462
12808
|
id: "arrow",
|
|
13463
12809
|
module: "arrow",
|
|
13464
|
-
version:
|
|
12810
|
+
version: VERSION,
|
|
13465
12811
|
// worker: true,
|
|
13466
12812
|
category: "table",
|
|
13467
12813
|
extensions: ["arrow", "feather"],
|