@loaders.gl/scan 5.0.0-alpha.4 → 5.0.0-alpha.5

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/delta.cjs CHANGED
@@ -3135,6 +3135,12 @@ function serializeArrowType(arrowType) {
3135
3135
  type: "list",
3136
3136
  children: [serializeArrowField(listField)]
3137
3137
  };
3138
+ case arrow.LargeList:
3139
+ const largeListType = arrowType;
3140
+ return {
3141
+ type: "large-list",
3142
+ children: [serializeArrowField(largeListType.valueField)]
3143
+ };
3138
3144
  case arrow.FixedSizeList:
3139
3145
  const fixedSizeList = arrowType;
3140
3146
  return {
@@ -3148,6 +3154,15 @@ function serializeArrowType(arrowType) {
3148
3154
  type: "struct",
3149
3155
  children: structType.children.map((arrowField) => serializeArrowField(arrowField))
3150
3156
  };
3157
+ case arrow.SparseUnion:
3158
+ case arrow.DenseUnion:
3159
+ const unionType = arrowType;
3160
+ return {
3161
+ type: unionType instanceof arrow.DenseUnion ? "dense-union" : "sparse-union",
3162
+ typeIds: unionType.typeIds,
3163
+ children: unionType.children.map((arrowField) => serializeArrowField(arrowField)),
3164
+ typeIdToChildIndex: { ...unionType.typeIdToChildIndex }
3165
+ };
3151
3166
  case arrow.Dictionary:
3152
3167
  const dictionaryType = arrowType;
3153
3168
  return {
@@ -3176,6 +3191,10 @@ function deserializeArrowType(dataType, options) {
3176
3191
  const field = deserializeArrowField(dataType.children[0], options);
3177
3192
  return new arrow.List(field);
3178
3193
  }
3194
+ case "large-list": {
3195
+ const field = deserializeArrowField(dataType.children[0], options);
3196
+ return new arrow.LargeList(field);
3197
+ }
3179
3198
  case "fixed-size-list": {
3180
3199
  const child = deserializeArrowField(dataType.children[0], options);
3181
3200
  return new arrow.FixedSizeList(dataType.listSize, child);
@@ -3188,6 +3207,13 @@ function deserializeArrowType(dataType, options) {
3188
3207
  );
3189
3208
  return new arrow.Struct(children);
3190
3209
  }
3210
+ case "sparse-union":
3211
+ case "dense-union": {
3212
+ const children = dataType.children.map(
3213
+ (arrowField) => deserializeArrowField(arrowField, options)
3214
+ );
3215
+ return dataType.type === "dense-union" ? new arrow.DenseUnion(dataType.typeIds, children) : new arrow.SparseUnion(dataType.typeIds, children);
3216
+ }
3191
3217
  case "dictionary": {
3192
3218
  return new arrow.Dictionary(
3193
3219
  deserializeArrowType(dataType.dictionary, options),
@@ -3825,8 +3851,85 @@ var init_deprecated = __esm({
3825
3851
  }
3826
3852
  });
3827
3853
 
3828
- // ../schema-utils/src/index.ts
3854
+ // ../schema/src/metadata.ts
3855
+ function getMetadataValue(metadata, key) {
3856
+ return metadata instanceof Map ? metadata.get(key) || null : metadata[key] || null;
3857
+ }
3858
+ function setMetadataValue(metadata, key, value) {
3859
+ if (metadata instanceof Map) {
3860
+ metadata.set(key, value);
3861
+ } else {
3862
+ metadata[key] = value;
3863
+ }
3864
+ }
3865
+ function getGeoMetadata(metadata) {
3866
+ if (!metadata) {
3867
+ return null;
3868
+ }
3869
+ const stringifiedGeoMetadata = getMetadataValue(metadata, "geo");
3870
+ const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata(stringifiedGeoMetadata);
3871
+ if (!geoMetadata) {
3872
+ return null;
3873
+ }
3874
+ for (const column of Object.values(geoMetadata.columns || {})) {
3875
+ if (column && typeof column === "object" && typeof column.encoding === "string") {
3876
+ column.encoding = column.encoding.toLowerCase();
3877
+ }
3878
+ }
3879
+ return geoMetadata;
3880
+ }
3881
+ function unpackGeoMetadata(metadata) {
3882
+ const geoMetadata = getGeoMetadata(metadata);
3883
+ if (!geoMetadata) {
3884
+ return;
3885
+ }
3886
+ const { version: version2, primary_column: primaryColumn, columns } = geoMetadata;
3887
+ if (version2) {
3888
+ setMetadataValue(metadata, "geo.version", version2);
3889
+ }
3890
+ if (primaryColumn) {
3891
+ setMetadataValue(metadata, "geo.primary_column", primaryColumn);
3892
+ }
3893
+ setMetadataValue(metadata, "geo.columns", Object.keys(columns || {}).join(","));
3894
+ }
3895
+ function unpackJSONStringMetadata(metadata, metadataKey) {
3896
+ const stringifiedMetadata = getMetadataValue(metadata, metadataKey);
3897
+ const json = stringifiedMetadata && parseJSONStringMetadata(stringifiedMetadata);
3898
+ for (const [key, value] of Object.entries(json || {})) {
3899
+ setMetadataValue(
3900
+ metadata,
3901
+ `${metadataKey}.${key}`,
3902
+ typeof value === "string" ? value : JSON.stringify(value)
3903
+ );
3904
+ }
3905
+ }
3906
+ function parseJSONStringMetadata(stringifiedMetadata) {
3907
+ if (!stringifiedMetadata) {
3908
+ return null;
3909
+ }
3910
+ try {
3911
+ const metadata = JSON.parse(stringifiedMetadata);
3912
+ return metadata && typeof metadata === "object" ? metadata : null;
3913
+ } catch {
3914
+ return null;
3915
+ }
3916
+ }
3917
+ var init_metadata = __esm({
3918
+ "../schema/src/metadata.ts"() {
3919
+ "use strict";
3920
+ }
3921
+ });
3922
+
3923
+ // ../schema/src/index.ts
3829
3924
  var init_src3 = __esm({
3925
+ "../schema/src/index.ts"() {
3926
+ "use strict";
3927
+ init_metadata();
3928
+ }
3929
+ });
3930
+
3931
+ // ../schema-utils/src/index.ts
3932
+ var init_src4 = __esm({
3830
3933
  "../schema-utils/src/index.ts"() {
3831
3934
  "use strict";
3832
3935
  init_convert_arrow_schema();
@@ -4815,35 +4918,26 @@ var init_arrow_table_transport = __esm({
4815
4918
  "../arrow/src/lib/utils/arrow-table-transport.ts"() {
4816
4919
  "use strict";
4817
4920
  arrow6 = __toESM(require("apache-arrow"), 1);
4818
- init_src3();
4921
+ init_src4();
4819
4922
  init_split_arrow_buffers();
4820
4923
  }
4821
4924
  });
4822
4925
 
4823
4926
  // ../gis/src/lib/geoarrow/metadata-utils.ts
4824
- function getMetadataValue(metadata, key) {
4825
- return metadata instanceof Map ? metadata.get(key) || null : metadata[key] || null;
4826
- }
4827
- function setMetadataValue(metadata, key, value) {
4828
- if (metadata instanceof Map) {
4829
- metadata.set(key, value);
4830
- } else {
4831
- metadata[key] = value;
4832
- }
4833
- }
4834
4927
  var init_metadata_utils = __esm({
4835
4928
  "../gis/src/lib/geoarrow/metadata-utils.ts"() {
4836
4929
  "use strict";
4930
+ init_src3();
4837
4931
  }
4838
4932
  });
4839
4933
 
4840
4934
  // ../gis/src/lib/geoarrow/geoparquet-metadata.ts
4841
- function getGeoMetadata(metadata) {
4935
+ function getGeoMetadata2(metadata) {
4842
4936
  if (!metadata) {
4843
4937
  return null;
4844
4938
  }
4845
4939
  const stringifiedGeoMetadata = getMetadataValue(metadata, "geo");
4846
- const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata(stringifiedGeoMetadata);
4940
+ const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata2(stringifiedGeoMetadata);
4847
4941
  if (!geoMetadata) {
4848
4942
  return null;
4849
4943
  }
@@ -4854,32 +4948,7 @@ function getGeoMetadata(metadata) {
4854
4948
  }
4855
4949
  return geoMetadata;
4856
4950
  }
4857
- function unpackGeoMetadata(metadata) {
4858
- const geoMetadata = getGeoMetadata(metadata);
4859
- if (!geoMetadata) {
4860
- return;
4861
- }
4862
- const { version: version2, primary_column, columns } = geoMetadata;
4863
- if (version2) {
4864
- setMetadataValue(metadata, "geo.version", version2);
4865
- }
4866
- if (primary_column) {
4867
- setMetadataValue(metadata, "geo.primary_column", primary_column);
4868
- }
4869
- setMetadataValue(metadata, "geo.columns", Object.keys(columns || {}).join(","));
4870
- }
4871
- function unpackJSONStringMetadata(metadata, metadataKey) {
4872
- const stringifiedMetadata = getMetadataValue(metadata, metadataKey);
4873
- const json = stringifiedMetadata && parseJSONStringMetadata(stringifiedMetadata);
4874
- for (const [key, value] of Object.entries(json || {})) {
4875
- setMetadataValue(
4876
- metadata,
4877
- `${metadataKey}.${key}`,
4878
- typeof value === "string" ? value : JSON.stringify(value)
4879
- );
4880
- }
4881
- }
4882
- function parseJSONStringMetadata(stringifiedMetadata) {
4951
+ function parseJSONStringMetadata2(stringifiedMetadata) {
4883
4952
  if (!stringifiedMetadata) {
4884
4953
  return null;
4885
4954
  }
@@ -4901,16 +4970,15 @@ var init_geoparquet_metadata = __esm({
4901
4970
  });
4902
4971
 
4903
4972
  // ../gis/src/index.ts
4904
- var init_src4 = __esm({
4973
+ var init_src5 = __esm({
4905
4974
  "../gis/src/index.ts"() {
4906
4975
  "use strict";
4907
- init_metadata_utils();
4908
4976
  init_geoparquet_metadata();
4909
4977
  }
4910
4978
  });
4911
4979
 
4912
4980
  // ../arrow/src/index.ts
4913
- var init_src5 = __esm({
4981
+ var init_src6 = __esm({
4914
4982
  "../arrow/src/index.ts"() {
4915
4983
  "use strict";
4916
4984
  init_indexed_arrow_table();
@@ -5154,10 +5222,11 @@ function getGeoArrowMetadataFromGeoParquetField(field, columnMetadata) {
5154
5222
  if (!extensionName) {
5155
5223
  return null;
5156
5224
  }
5157
- if (normalizedEncoding === "wkb" && field.type !== "binary") {
5225
+ const isBinaryGeospatialEncoding = normalizedEncoding === "wkb" || normalizedEncoding === "geometry" || normalizedEncoding === "geography";
5226
+ if (isBinaryGeospatialEncoding && !isBinaryFieldType(field.type)) {
5158
5227
  return null;
5159
5228
  }
5160
- if (normalizedEncoding !== "wkb" && (field.type === "binary" || field.type === "utf8")) {
5229
+ if (!isBinaryGeospatialEncoding && (isBinaryFieldType(field.type) || isStringFieldType(field.type))) {
5161
5230
  return null;
5162
5231
  }
5163
5232
  const extensionMetadata = {};
@@ -5171,18 +5240,34 @@ function getGeoArrowMetadataFromGeoParquetField(field, columnMetadata) {
5171
5240
  if (columnMetadata.edges && columnMetadata.edges !== "planar") {
5172
5241
  extensionMetadata.edges = columnMetadata.edges;
5173
5242
  }
5243
+ if (normalizedEncoding === "geography" && !extensionMetadata.edges) {
5244
+ extensionMetadata.edges = "spherical";
5245
+ }
5246
+ for (const [metadataKey, metadataValue] of Object.entries(columnMetadata)) {
5247
+ if (metadataValue !== void 0 && metadataValue !== null && !["encoding", "geometry_types", "crs", "edges"].includes(metadataKey)) {
5248
+ extensionMetadata[metadataKey] = metadataValue;
5249
+ }
5250
+ }
5174
5251
  return Object.keys(extensionMetadata).length > 0 ? { extensionName, extensionMetadata } : { extensionName };
5175
5252
  }
5253
+ function isBinaryFieldType(fieldType) {
5254
+ return typeof fieldType === "string" && (fieldType === "binary" || fieldType === "binary-view");
5255
+ }
5256
+ function isStringFieldType(fieldType) {
5257
+ return typeof fieldType === "string" && (fieldType === "utf8" || fieldType === "utf8-view");
5258
+ }
5176
5259
  var arrow7, GEOARROW_EXTENSION_NAME_KEY, GEOARROW_EXTENSION_METADATA_KEY, GEOPARQUET_TO_GEOARROW_ENCODINGS;
5177
5260
  var init_geospatial_metadata = __esm({
5178
5261
  "../parquet/src/lib/geo/geospatial-metadata.ts"() {
5179
5262
  "use strict";
5180
5263
  arrow7 = __toESM(require("apache-arrow"), 1);
5181
- init_src4();
5264
+ init_src3();
5182
5265
  GEOARROW_EXTENSION_NAME_KEY = "ARROW:extension:name";
5183
5266
  GEOARROW_EXTENSION_METADATA_KEY = "ARROW:extension:metadata";
5184
5267
  GEOPARQUET_TO_GEOARROW_ENCODINGS = {
5185
5268
  wkb: "geoarrow.wkb",
5269
+ geometry: "geoarrow.wkb",
5270
+ geography: "geoarrow.wkb",
5186
5271
  point: "geoarrow.point",
5187
5272
  linestring: "geoarrow.linestring",
5188
5273
  polygon: "geoarrow.polygon",
@@ -5208,7 +5293,7 @@ async function getSchemaFromParquetReader(reader) {
5208
5293
  var init_get_parquet_schema = __esm({
5209
5294
  "../parquet/src/lib/parsers/get-parquet-schema.ts"() {
5210
5295
  "use strict";
5211
- init_src4();
5296
+ init_src3();
5212
5297
  init_convert_schema_from_parquet();
5213
5298
  init_geospatial_metadata();
5214
5299
  }
@@ -5320,7 +5405,7 @@ function doLongitudeIntervalsIntersect(firstWest, firstEast, secondWest, secondE
5320
5405
  var init_geoparquet_covering = __esm({
5321
5406
  "../parquet/src/lib/geo/geoparquet-covering.ts"() {
5322
5407
  "use strict";
5323
- init_src4();
5408
+ init_src3();
5324
5409
  }
5325
5410
  });
5326
5411
 
@@ -12044,7 +12129,7 @@ var init_parse_bson = __esm({
12044
12129
  });
12045
12130
 
12046
12131
  // ../bson/src/index.ts
12047
- var init_src6 = __esm({
12132
+ var init_src7 = __esm({
12048
12133
  "../bson/src/index.ts"() {
12049
12134
  "use strict";
12050
12135
  init_bson_writer();
@@ -12453,7 +12538,7 @@ var PARQUET_LOGICAL_TYPES, kMillisPerDay;
12453
12538
  var init_types = __esm({
12454
12539
  "../parquet/src/parquetjs/schema/types.ts"() {
12455
12540
  "use strict";
12456
- init_src6();
12541
+ init_src7();
12457
12542
  init_binary_utils();
12458
12543
  PARQUET_LOGICAL_TYPES = {
12459
12544
  BOOLEAN: {
@@ -16474,7 +16559,7 @@ var init_default_codecs = __esm({
16474
16559
  });
16475
16560
 
16476
16561
  // ../compression/src/index.ts
16477
- var init_src7 = __esm({
16562
+ var init_src8 = __esm({
16478
16563
  "../compression/src/index.ts"() {
16479
16564
  "use strict";
16480
16565
  init_compression();
@@ -16587,7 +16672,7 @@ var PARQUET_COMPRESSION_METHODS, ParquetSnappyDecompressor;
16587
16672
  var init_compression2 = __esm({
16588
16673
  "../parquet/src/parquetjs/compression.ts"() {
16589
16674
  "use strict";
16590
- init_src7();
16675
+ init_src8();
16591
16676
  init_snappy_decompressor_hysnappy();
16592
16677
  init_src2();
16593
16678
  init_binary_utils();
@@ -22749,10 +22834,10 @@ var _preloadParquetSourceLoader, _createMetadataDataSource, ParquetSourceLoaderB
22749
22834
  var init_parquet_source_loader = __esm({
22750
22835
  "../parquet/src/parquet-source-loader.ts"() {
22751
22836
  "use strict";
22752
- init_src5();
22837
+ init_src6();
22753
22838
  init_src2();
22754
- init_src3();
22755
22839
  init_src4();
22840
+ init_src5();
22756
22841
  init_get_parquet_schema();
22757
22842
  init_geoparquet_covering();
22758
22843
  init_parquet_bloom_filter();
@@ -22935,7 +23020,7 @@ var init_parquet_source_loader = __esm({
22935
23020
  );
22936
23021
  const projectedColumns = normalizeColumns(readOptions.columns, initialization.schema);
22937
23022
  const predicateColumns = physicalPlan.predicate ? getParquetPredicateColumns(physicalPlan.predicate) : [];
22938
- const geoMetadata = readOptions.bbox ? getGeoMetadata(initialization.schema.metadata) : void 0;
23023
+ const geoMetadata = readOptions.bbox ? getGeoMetadata2(initialization.schema.metadata) : void 0;
22939
23024
  const geometryColumn = readOptions.bbox ? readOptions.geometryColumn || (geoMetadata == null ? void 0 : geoMetadata.primary_column) : void 0;
22940
23025
  const filterColumns = [
22941
23026
  .../* @__PURE__ */ new Set([...predicateColumns, ...geometryColumn ? [geometryColumn] : []])