@loaders.gl/shapefile 4.0.0-alpha.5 → 4.0.0-alpha.7

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.
Files changed (124) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/dbf-loader.js +29 -20
  3. package/dist/dbf-worker.js +73 -447
  4. package/dist/dist.min.js +130 -489
  5. package/dist/es5/bundle.js +6 -0
  6. package/dist/es5/bundle.js.map +1 -0
  7. package/dist/es5/dbf-loader.js +53 -0
  8. package/dist/es5/dbf-loader.js.map +1 -0
  9. package/dist/es5/index.js +39 -0
  10. package/dist/es5/index.js.map +1 -0
  11. package/dist/es5/lib/parsers/parse-dbf.js +394 -0
  12. package/dist/es5/lib/parsers/parse-dbf.js.map +1 -0
  13. package/dist/es5/lib/parsers/parse-shapefile.js +373 -0
  14. package/dist/es5/lib/parsers/parse-shapefile.js.map +1 -0
  15. package/dist/es5/lib/parsers/parse-shp-geometry.js +220 -0
  16. package/dist/es5/lib/parsers/parse-shp-geometry.js.map +1 -0
  17. package/dist/es5/lib/parsers/parse-shp-header.js +35 -0
  18. package/dist/es5/lib/parsers/parse-shp-header.js.map +1 -0
  19. package/dist/es5/lib/parsers/parse-shp.js +227 -0
  20. package/dist/es5/lib/parsers/parse-shp.js.map +1 -0
  21. package/dist/es5/lib/parsers/parse-shx.js +26 -0
  22. package/dist/es5/lib/parsers/parse-shx.js.map +1 -0
  23. package/dist/es5/lib/parsers/types.js +2 -0
  24. package/dist/es5/lib/parsers/types.js.map +1 -0
  25. package/dist/es5/lib/streaming/binary-chunk-reader.js +178 -0
  26. package/dist/es5/lib/streaming/binary-chunk-reader.js.map +1 -0
  27. package/dist/es5/lib/streaming/binary-reader.js +48 -0
  28. package/dist/es5/lib/streaming/binary-reader.js.map +1 -0
  29. package/dist/es5/lib/streaming/zip-batch-iterators.js +91 -0
  30. package/dist/es5/lib/streaming/zip-batch-iterators.js.map +1 -0
  31. package/dist/es5/shapefile-loader.js +31 -0
  32. package/dist/es5/shapefile-loader.js.map +1 -0
  33. package/dist/es5/shp-loader.js +56 -0
  34. package/dist/es5/shp-loader.js.map +1 -0
  35. package/dist/es5/workers/dbf-worker.js +6 -0
  36. package/dist/es5/workers/dbf-worker.js.map +1 -0
  37. package/dist/es5/workers/shp-worker.js +6 -0
  38. package/dist/es5/workers/shp-worker.js.map +1 -0
  39. package/dist/esm/bundle.js +4 -0
  40. package/dist/esm/bundle.js.map +1 -0
  41. package/dist/esm/dbf-loader.js +24 -0
  42. package/dist/esm/dbf-loader.js.map +1 -0
  43. package/dist/esm/index.js +4 -0
  44. package/dist/esm/index.js.map +1 -0
  45. package/dist/esm/lib/parsers/parse-dbf.js +296 -0
  46. package/dist/esm/lib/parsers/parse-dbf.js.map +1 -0
  47. package/dist/esm/lib/parsers/parse-shapefile.js +187 -0
  48. package/dist/esm/lib/parsers/parse-shapefile.js.map +1 -0
  49. package/dist/esm/lib/parsers/parse-shp-geometry.js +191 -0
  50. package/dist/esm/lib/parsers/parse-shp-geometry.js.map +1 -0
  51. package/dist/esm/lib/parsers/parse-shp-header.js +29 -0
  52. package/dist/esm/lib/parsers/parse-shp-header.js.map +1 -0
  53. package/dist/esm/lib/parsers/parse-shp.js +134 -0
  54. package/dist/esm/lib/parsers/parse-shp.js.map +1 -0
  55. package/dist/esm/lib/parsers/parse-shx.js +20 -0
  56. package/dist/esm/lib/parsers/parse-shx.js.map +1 -0
  57. package/dist/esm/lib/parsers/types.js +2 -0
  58. package/dist/esm/lib/parsers/types.js.map +1 -0
  59. package/dist/esm/lib/streaming/binary-chunk-reader.js +106 -0
  60. package/dist/esm/lib/streaming/binary-chunk-reader.js.map +1 -0
  61. package/dist/esm/lib/streaming/binary-reader.js +27 -0
  62. package/dist/esm/lib/streaming/binary-reader.js.map +1 -0
  63. package/dist/esm/lib/streaming/zip-batch-iterators.js +44 -0
  64. package/dist/esm/lib/streaming/zip-batch-iterators.js.map +1 -0
  65. package/dist/esm/shapefile-loader.js +23 -0
  66. package/dist/esm/shapefile-loader.js.map +1 -0
  67. package/dist/esm/shp-loader.js +26 -0
  68. package/dist/esm/shp-loader.js.map +1 -0
  69. package/dist/esm/workers/dbf-worker.js +4 -0
  70. package/dist/esm/workers/dbf-worker.js.map +1 -0
  71. package/dist/esm/workers/shp-worker.js +4 -0
  72. package/dist/esm/workers/shp-worker.js.map +1 -0
  73. package/dist/index.js +11 -4
  74. package/dist/lib/parsers/parse-dbf.d.ts +4 -18
  75. package/dist/lib/parsers/parse-dbf.d.ts.map +1 -1
  76. package/dist/lib/parsers/parse-dbf.js +309 -264
  77. package/dist/lib/parsers/parse-shapefile.d.ts +3 -8
  78. package/dist/lib/parsers/parse-shapefile.d.ts.map +1 -1
  79. package/dist/lib/parsers/parse-shapefile.js +227 -209
  80. package/dist/lib/parsers/parse-shp-geometry.d.ts +2 -3
  81. package/dist/lib/parsers/parse-shp-geometry.d.ts.map +1 -1
  82. package/dist/lib/parsers/parse-shp-geometry.js +265 -212
  83. package/dist/lib/parsers/parse-shp-header.js +38 -27
  84. package/dist/lib/parsers/parse-shp.d.ts +3 -2
  85. package/dist/lib/parsers/parse-shp.d.ts.map +1 -1
  86. package/dist/lib/parsers/parse-shp.js +160 -136
  87. package/dist/lib/parsers/parse-shx.js +25 -19
  88. package/dist/lib/parsers/types.d.ts +68 -0
  89. package/dist/lib/parsers/types.d.ts.map +1 -0
  90. package/dist/lib/parsers/types.js +2 -0
  91. package/dist/lib/streaming/binary-chunk-reader.d.ts +5 -3
  92. package/dist/lib/streaming/binary-chunk-reader.d.ts.map +1 -1
  93. package/dist/lib/streaming/binary-chunk-reader.js +152 -128
  94. package/dist/lib/streaming/binary-reader.js +50 -33
  95. package/dist/lib/streaming/zip-batch-iterators.js +57 -48
  96. package/dist/shapefile-loader.js +30 -22
  97. package/dist/shp-loader.js +32 -22
  98. package/dist/shp-worker.js +57 -19
  99. package/dist/workers/dbf-worker.js +5 -4
  100. package/dist/workers/shp-worker.js +5 -4
  101. package/package.json +7 -7
  102. package/src/lib/parsers/parse-dbf.ts +41 -67
  103. package/src/lib/parsers/parse-shapefile.ts +3 -6
  104. package/src/lib/parsers/parse-shp-geometry.ts +3 -2
  105. package/src/lib/parsers/parse-shp.ts +26 -12
  106. package/src/lib/parsers/types.ts +79 -0
  107. package/src/lib/streaming/binary-chunk-reader.ts +5 -1
  108. package/src/lib/streaming/zip-batch-iterators.ts +2 -2
  109. package/dist/bundle.js.map +0 -1
  110. package/dist/dbf-loader.js.map +0 -1
  111. package/dist/index.js.map +0 -1
  112. package/dist/lib/parsers/parse-dbf.js.map +0 -1
  113. package/dist/lib/parsers/parse-shapefile.js.map +0 -1
  114. package/dist/lib/parsers/parse-shp-geometry.js.map +0 -1
  115. package/dist/lib/parsers/parse-shp-header.js.map +0 -1
  116. package/dist/lib/parsers/parse-shp.js.map +0 -1
  117. package/dist/lib/parsers/parse-shx.js.map +0 -1
  118. package/dist/lib/streaming/binary-chunk-reader.js.map +0 -1
  119. package/dist/lib/streaming/binary-reader.js.map +0 -1
  120. package/dist/lib/streaming/zip-batch-iterators.js.map +0 -1
  121. package/dist/shapefile-loader.js.map +0 -1
  122. package/dist/shp-loader.js.map +0 -1
  123. package/dist/workers/dbf-worker.js.map +0 -1
  124. package/dist/workers/shp-worker.js.map +0 -1
package/dist/dist.min.js CHANGED
@@ -155,7 +155,7 @@
155
155
 
156
156
  // src/lib/parsers/parse-shp-geometry.ts
157
157
  function parseRecord(view, options) {
158
- const { _maxDimensions } = options?.shp || {};
158
+ const { _maxDimensions = 4 } = options?.shp || {};
159
159
  let offset = 0;
160
160
  const type = view.getInt32(offset, LITTLE_ENDIAN2);
161
161
  offset += Int32Array.BYTES_PER_ELEMENT;
@@ -390,7 +390,7 @@
390
390
  binaryReader.rewind(SHP_RECORD_HEADER_SIZE);
391
391
  return state;
392
392
  }
393
- const invalidRecord = recordHeader.byteLength < 4 || recordHeader.type !== result.header.type || recordHeader.recordNumber !== result.currentIndex;
393
+ const invalidRecord = recordHeader.byteLength < 4 || recordHeader.type !== result.header?.type || recordHeader.recordNumber !== result.currentIndex;
394
394
  if (invalidRecord) {
395
395
  binaryReader.rewind(SHP_RECORD_HEADER_SIZE - 4);
396
396
  } else {
@@ -440,7 +440,13 @@
440
440
  this.binaryReader = new BinaryChunkReader({ maxRewindBytes: SHP_RECORD_HEADER_SIZE });
441
441
  this.state = STATE.EXPECTING_HEADER;
442
442
  this.result = {
443
- geometries: []
443
+ geometries: [],
444
+ progress: {
445
+ bytesTotal: NaN,
446
+ bytesUsed: NaN,
447
+ rows: NaN
448
+ },
449
+ currentIndex: NaN
444
450
  };
445
451
  this.options = options;
446
452
  }
@@ -492,6 +498,72 @@
492
498
  }
493
499
  });
494
500
 
501
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
502
+ function _typeof(obj) {
503
+ "@babel/helpers - typeof";
504
+ return _typeof = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(obj2) {
505
+ return typeof obj2;
506
+ } : function(obj2) {
507
+ return obj2 && typeof Symbol == "function" && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
508
+ }, _typeof(obj);
509
+ }
510
+ var init_typeof = __esm({
511
+ "../../node_modules/@babel/runtime/helpers/esm/typeof.js"() {
512
+ }
513
+ });
514
+
515
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
516
+ function _toPrimitive(input, hint) {
517
+ if (_typeof(input) !== "object" || input === null)
518
+ return input;
519
+ var prim = input[Symbol.toPrimitive];
520
+ if (prim !== void 0) {
521
+ var res = prim.call(input, hint || "default");
522
+ if (_typeof(res) !== "object")
523
+ return res;
524
+ throw new TypeError("@@toPrimitive must return a primitive value.");
525
+ }
526
+ return (hint === "string" ? String : Number)(input);
527
+ }
528
+ var init_toPrimitive = __esm({
529
+ "../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js"() {
530
+ init_typeof();
531
+ }
532
+ });
533
+
534
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
535
+ function _toPropertyKey(arg) {
536
+ var key = _toPrimitive(arg, "string");
537
+ return _typeof(key) === "symbol" ? key : String(key);
538
+ }
539
+ var init_toPropertyKey = __esm({
540
+ "../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js"() {
541
+ init_typeof();
542
+ init_toPrimitive();
543
+ }
544
+ });
545
+
546
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
547
+ function _defineProperty(obj, key, value) {
548
+ key = _toPropertyKey(key);
549
+ if (key in obj) {
550
+ Object.defineProperty(obj, key, {
551
+ value,
552
+ enumerable: true,
553
+ configurable: true,
554
+ writable: true
555
+ });
556
+ } else {
557
+ obj[key] = value;
558
+ }
559
+ return obj;
560
+ }
561
+ var init_defineProperty = __esm({
562
+ "../../node_modules/@babel/runtime/helpers/esm/defineProperty.js"() {
563
+ init_toPropertyKey();
564
+ }
565
+ });
566
+
495
567
  // ../gis/src/lib/binary-to-geojson.ts
496
568
  function binaryToGeometry(data, startIndex, endIndex) {
497
569
  switch (data.type) {
@@ -863,7 +935,7 @@
863
935
  ENDED = -1;
864
936
  whitespace = /\s/;
865
937
  latin = /[A-Za-z]/;
866
- keyword = /[A-Za-z84]/;
938
+ keyword = /[A-Za-z84_]/;
867
939
  endThings = /[,\]]/;
868
940
  digets = /[\d\.E\-\+]/;
869
941
  Parser.prototype.readCharicter = function() {
@@ -1150,15 +1222,14 @@
1150
1222
  if (wkt.AXIS) {
1151
1223
  var axisOrder = "";
1152
1224
  for (var i = 0, ii = wkt.AXIS.length; i < ii; ++i) {
1153
- var axis = wkt.AXIS[i];
1154
- var descriptor = axis[0].toLowerCase();
1155
- if (descriptor.indexOf("north") !== -1) {
1225
+ var axis = [wkt.AXIS[i][0].toLowerCase(), wkt.AXIS[i][1].toLowerCase()];
1226
+ if (axis[0].indexOf("north") !== -1 || (axis[0] === "y" || axis[0] === "lat") && axis[1] === "north") {
1156
1227
  axisOrder += "n";
1157
- } else if (descriptor.indexOf("south") !== -1) {
1228
+ } else if (axis[0].indexOf("south") !== -1 || (axis[0] === "y" || axis[0] === "lat") && axis[1] === "south") {
1158
1229
  axisOrder += "s";
1159
- } else if (descriptor.indexOf("east") !== -1) {
1230
+ } else if (axis[0].indexOf("east") !== -1 || (axis[0] === "x" || axis[0] === "lon") && axis[1] === "east") {
1160
1231
  axisOrder += "e";
1161
- } else if (descriptor.indexOf("west") !== -1) {
1232
+ } else if (axis[0].indexOf("west") !== -1 || (axis[0] === "x" || axis[0] === "lon") && axis[1] === "west") {
1162
1233
  axisOrder += "w";
1163
1234
  }
1164
1235
  }
@@ -1254,12 +1325,22 @@
1254
1325
  };
1255
1326
  var list = [
1256
1327
  ["standard_parallel_1", "Standard_Parallel_1"],
1328
+ ["standard_parallel_1", "Latitude of 1st standard parallel"],
1257
1329
  ["standard_parallel_2", "Standard_Parallel_2"],
1330
+ ["standard_parallel_2", "Latitude of 2nd standard parallel"],
1258
1331
  ["false_easting", "False_Easting"],
1332
+ ["false_easting", "False easting"],
1333
+ ["false-easting", "Easting at false origin"],
1259
1334
  ["false_northing", "False_Northing"],
1335
+ ["false_northing", "False northing"],
1336
+ ["false_northing", "Northing at false origin"],
1260
1337
  ["central_meridian", "Central_Meridian"],
1338
+ ["central_meridian", "Longitude of natural origin"],
1339
+ ["central_meridian", "Longitude of false origin"],
1261
1340
  ["latitude_of_origin", "Latitude_Of_Origin"],
1262
1341
  ["latitude_of_origin", "Central_Parallel"],
1342
+ ["latitude_of_origin", "Latitude of natural origin"],
1343
+ ["latitude_of_origin", "Latitude of false origin"],
1263
1344
  ["scale_factor", "Scale_Factor"],
1264
1345
  ["k0", "scale_factor"],
1265
1346
  ["latitude_of_center", "Latitude_Of_Center"],
@@ -6528,6 +6609,7 @@
6528
6609
  var Proj4Projection;
6529
6610
  var init_proj4_projection = __esm({
6530
6611
  "../../node_modules/@math.gl/proj4/dist/esm/lib/proj4-projection.js"() {
6612
+ init_defineProperty();
6531
6613
  init_lib();
6532
6614
  Proj4Projection = class {
6533
6615
  static defineProjectionAliases(aliases) {
@@ -6541,12 +6623,19 @@
6541
6623
  from = "WGS84",
6542
6624
  to = "WGS84"
6543
6625
  }) {
6544
- const projection = lib_default(from, to);
6545
- if (!projection) {
6626
+ _defineProperty(this, "_projection", void 0);
6627
+ this._projection = lib_default(from, to);
6628
+ if (!this._projection) {
6546
6629
  throw new Error("Invalid projection");
6547
6630
  }
6548
- this.project = projection.forward;
6549
- this.unproject = projection.inverse;
6631
+ this.project = this.project.bind(this);
6632
+ this.unproject = this.unproject.bind(this);
6633
+ }
6634
+ project(coord) {
6635
+ return this._projection.forward(coord);
6636
+ }
6637
+ unproject(coord) {
6638
+ return this._projection.inverse(coord);
6550
6639
  }
6551
6640
  };
6552
6641
  }
@@ -6628,472 +6717,23 @@
6628
6717
  }
6629
6718
  });
6630
6719
 
6631
- // ../schema/src/lib/utils/assert.ts
6632
- function assert(condition, message) {
6633
- if (!condition) {
6634
- throw new Error(message || "loader assertion failed.");
6635
- }
6636
- }
6637
- var init_assert = __esm({
6638
- "../schema/src/lib/utils/assert.ts"() {
6639
- }
6640
- });
6641
-
6642
- // ../schema/src/lib/schema/impl/schema.ts
6643
- function checkNames(fields) {
6644
- const usedNames = {};
6645
- for (const field of fields) {
6646
- if (usedNames[field.name]) {
6647
- console.warn("Schema: duplicated field name", field.name, field);
6648
- }
6649
- usedNames[field.name] = true;
6650
- }
6651
- }
6652
- function mergeMaps(m1, m2) {
6653
- return new Map([...m1 || new Map(), ...m2 || new Map()]);
6654
- }
6655
- var Schema;
6656
- var init_schema = __esm({
6657
- "../schema/src/lib/schema/impl/schema.ts"() {
6658
- init_assert();
6659
- Schema = class {
6660
- constructor(fields, metadata) {
6661
- assert(Array.isArray(fields));
6662
- checkNames(fields);
6663
- this.fields = fields;
6664
- this.metadata = metadata || new Map();
6665
- }
6666
- compareTo(other) {
6667
- if (this.metadata !== other.metadata) {
6668
- return false;
6669
- }
6670
- if (this.fields.length !== other.fields.length) {
6671
- return false;
6672
- }
6673
- for (let i = 0; i < this.fields.length; ++i) {
6674
- if (!this.fields[i].compareTo(other.fields[i])) {
6675
- return false;
6676
- }
6677
- }
6678
- return true;
6679
- }
6680
- select(...columnNames) {
6681
- const nameMap = Object.create(null);
6682
- for (const name of columnNames) {
6683
- nameMap[name] = true;
6684
- }
6685
- const selectedFields = this.fields.filter((field) => nameMap[field.name]);
6686
- return new Schema(selectedFields, this.metadata);
6687
- }
6688
- selectAt(...columnIndices) {
6689
- const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
6690
- return new Schema(selectedFields, this.metadata);
6691
- }
6692
- assign(schemaOrFields) {
6693
- let fields;
6694
- let metadata = this.metadata;
6695
- if (schemaOrFields instanceof Schema) {
6696
- const otherSchema = schemaOrFields;
6697
- fields = otherSchema.fields;
6698
- metadata = mergeMaps(mergeMaps(new Map(), this.metadata), otherSchema.metadata);
6699
- } else {
6700
- fields = schemaOrFields;
6701
- }
6702
- const fieldMap = Object.create(null);
6703
- for (const field of this.fields) {
6704
- fieldMap[field.name] = field;
6705
- }
6706
- for (const field of fields) {
6707
- fieldMap[field.name] = field;
6708
- }
6709
- const mergedFields = Object.values(fieldMap);
6710
- return new Schema(mergedFields, metadata);
6711
- }
6712
- };
6713
- }
6714
- });
6715
-
6716
- // ../schema/src/lib/schema/impl/field.ts
6717
- var Field;
6718
- var init_field = __esm({
6719
- "../schema/src/lib/schema/impl/field.ts"() {
6720
- Field = class {
6721
- constructor(name, type, nullable = false, metadata = new Map()) {
6722
- this.name = name;
6723
- this.type = type;
6724
- this.nullable = nullable;
6725
- this.metadata = metadata;
6726
- }
6727
- get typeId() {
6728
- return this.type && this.type.typeId;
6729
- }
6730
- clone() {
6731
- return new Field(this.name, this.type, this.nullable, this.metadata);
6732
- }
6733
- compareTo(other) {
6734
- return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
6735
- }
6736
- toString() {
6737
- return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
6738
- }
6739
- };
6740
- }
6741
- });
6742
-
6743
- // ../schema/src/lib/schema/impl/enum.ts
6744
- var Type;
6745
- var init_enum = __esm({
6746
- "../schema/src/lib/schema/impl/enum.ts"() {
6747
- (function(Type2) {
6748
- Type2[Type2["NONE"] = 0] = "NONE";
6749
- Type2[Type2["Null"] = 1] = "Null";
6750
- Type2[Type2["Int"] = 2] = "Int";
6751
- Type2[Type2["Float"] = 3] = "Float";
6752
- Type2[Type2["Binary"] = 4] = "Binary";
6753
- Type2[Type2["Utf8"] = 5] = "Utf8";
6754
- Type2[Type2["Bool"] = 6] = "Bool";
6755
- Type2[Type2["Decimal"] = 7] = "Decimal";
6756
- Type2[Type2["Date"] = 8] = "Date";
6757
- Type2[Type2["Time"] = 9] = "Time";
6758
- Type2[Type2["Timestamp"] = 10] = "Timestamp";
6759
- Type2[Type2["Interval"] = 11] = "Interval";
6760
- Type2[Type2["List"] = 12] = "List";
6761
- Type2[Type2["Struct"] = 13] = "Struct";
6762
- Type2[Type2["Union"] = 14] = "Union";
6763
- Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
6764
- Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
6765
- Type2[Type2["Map"] = 17] = "Map";
6766
- Type2[Type2["Dictionary"] = -1] = "Dictionary";
6767
- Type2[Type2["Int8"] = -2] = "Int8";
6768
- Type2[Type2["Int16"] = -3] = "Int16";
6769
- Type2[Type2["Int32"] = -4] = "Int32";
6770
- Type2[Type2["Int64"] = -5] = "Int64";
6771
- Type2[Type2["Uint8"] = -6] = "Uint8";
6772
- Type2[Type2["Uint16"] = -7] = "Uint16";
6773
- Type2[Type2["Uint32"] = -8] = "Uint32";
6774
- Type2[Type2["Uint64"] = -9] = "Uint64";
6775
- Type2[Type2["Float16"] = -10] = "Float16";
6776
- Type2[Type2["Float32"] = -11] = "Float32";
6777
- Type2[Type2["Float64"] = -12] = "Float64";
6778
- Type2[Type2["DateDay"] = -13] = "DateDay";
6779
- Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
6780
- Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
6781
- Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
6782
- Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
6783
- Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
6784
- Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
6785
- Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
6786
- Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
6787
- Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
6788
- Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
6789
- Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
6790
- Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
6791
- Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
6792
- })(Type || (Type = {}));
6793
- }
6794
- });
6795
-
6796
- // ../schema/src/lib/schema/impl/type.ts
6797
- var DataType, Null, Bool, Int, Precision, Float, Float64, Binary, Utf8, DateUnit, Date2, TimeUnit, Time, Timestamp, TimestampMillisecond, IntervalUnit, Interval, FixedSizeList, Struct;
6798
- var init_type = __esm({
6799
- "../schema/src/lib/schema/impl/type.ts"() {
6800
- init_enum();
6801
- DataType = class {
6802
- static isNull(x) {
6803
- return x && x.typeId === Type.Null;
6804
- }
6805
- static isInt(x) {
6806
- return x && x.typeId === Type.Int;
6807
- }
6808
- static isFloat(x) {
6809
- return x && x.typeId === Type.Float;
6810
- }
6811
- static isBinary(x) {
6812
- return x && x.typeId === Type.Binary;
6813
- }
6814
- static isUtf8(x) {
6815
- return x && x.typeId === Type.Utf8;
6816
- }
6817
- static isBool(x) {
6818
- return x && x.typeId === Type.Bool;
6819
- }
6820
- static isDecimal(x) {
6821
- return x && x.typeId === Type.Decimal;
6822
- }
6823
- static isDate(x) {
6824
- return x && x.typeId === Type.Date;
6825
- }
6826
- static isTime(x) {
6827
- return x && x.typeId === Type.Time;
6828
- }
6829
- static isTimestamp(x) {
6830
- return x && x.typeId === Type.Timestamp;
6831
- }
6832
- static isInterval(x) {
6833
- return x && x.typeId === Type.Interval;
6834
- }
6835
- static isList(x) {
6836
- return x && x.typeId === Type.List;
6837
- }
6838
- static isStruct(x) {
6839
- return x && x.typeId === Type.Struct;
6840
- }
6841
- static isUnion(x) {
6842
- return x && x.typeId === Type.Union;
6843
- }
6844
- static isFixedSizeBinary(x) {
6845
- return x && x.typeId === Type.FixedSizeBinary;
6846
- }
6847
- static isFixedSizeList(x) {
6848
- return x && x.typeId === Type.FixedSizeList;
6849
- }
6850
- static isMap(x) {
6851
- return x && x.typeId === Type.Map;
6852
- }
6853
- static isDictionary(x) {
6854
- return x && x.typeId === Type.Dictionary;
6855
- }
6856
- get typeId() {
6857
- return Type.NONE;
6858
- }
6859
- compareTo(other) {
6860
- return this === other;
6861
- }
6862
- };
6863
- Null = class extends DataType {
6864
- get typeId() {
6865
- return Type.Null;
6866
- }
6867
- get [Symbol.toStringTag]() {
6868
- return "Null";
6869
- }
6870
- toString() {
6871
- return "Null";
6872
- }
6873
- };
6874
- Bool = class extends DataType {
6875
- get typeId() {
6876
- return Type.Bool;
6877
- }
6878
- get [Symbol.toStringTag]() {
6879
- return "Bool";
6880
- }
6881
- toString() {
6882
- return "Bool";
6883
- }
6884
- };
6885
- Int = class extends DataType {
6886
- constructor(isSigned, bitWidth) {
6887
- super();
6888
- this.isSigned = isSigned;
6889
- this.bitWidth = bitWidth;
6890
- }
6891
- get typeId() {
6892
- return Type.Int;
6893
- }
6894
- get [Symbol.toStringTag]() {
6895
- return "Int";
6896
- }
6897
- toString() {
6898
- return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
6899
- }
6900
- };
6901
- Precision = {
6902
- HALF: 16,
6903
- SINGLE: 32,
6904
- DOUBLE: 64
6905
- };
6906
- Float = class extends DataType {
6907
- constructor(precision) {
6908
- super();
6909
- this.precision = precision;
6910
- }
6911
- get typeId() {
6912
- return Type.Float;
6913
- }
6914
- get [Symbol.toStringTag]() {
6915
- return "Float";
6916
- }
6917
- toString() {
6918
- return `Float${this.precision}`;
6919
- }
6920
- };
6921
- Float64 = class extends Float {
6922
- constructor() {
6923
- super(Precision.DOUBLE);
6924
- }
6925
- };
6926
- Binary = class extends DataType {
6927
- constructor() {
6928
- super();
6929
- }
6930
- get typeId() {
6931
- return Type.Binary;
6932
- }
6933
- toString() {
6934
- return "Binary";
6935
- }
6936
- get [Symbol.toStringTag]() {
6937
- return "Binary";
6938
- }
6939
- };
6940
- Utf8 = class extends DataType {
6941
- get typeId() {
6942
- return Type.Utf8;
6943
- }
6944
- get [Symbol.toStringTag]() {
6945
- return "Utf8";
6946
- }
6947
- toString() {
6948
- return "Utf8";
6949
- }
6950
- };
6951
- DateUnit = {
6952
- DAY: 0,
6953
- MILLISECOND: 1
6954
- };
6955
- Date2 = class extends DataType {
6956
- constructor(unit) {
6957
- super();
6958
- this.unit = unit;
6959
- }
6960
- get typeId() {
6961
- return Type.Date;
6962
- }
6963
- get [Symbol.toStringTag]() {
6964
- return "Date";
6965
- }
6966
- toString() {
6967
- return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
6968
- }
6969
- };
6970
- TimeUnit = {
6971
- SECOND: 1,
6972
- MILLISECOND: 1e3,
6973
- MICROSECOND: 1e6,
6974
- NANOSECOND: 1e9
6975
- };
6976
- Time = class extends DataType {
6977
- constructor(unit, bitWidth) {
6978
- super();
6979
- this.unit = unit;
6980
- this.bitWidth = bitWidth;
6981
- }
6982
- get typeId() {
6983
- return Type.Time;
6984
- }
6985
- toString() {
6986
- return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
6987
- }
6988
- get [Symbol.toStringTag]() {
6989
- return "Time";
6990
- }
6991
- };
6992
- Timestamp = class extends DataType {
6993
- constructor(unit, timezone = null) {
6994
- super();
6995
- this.unit = unit;
6996
- this.timezone = timezone;
6997
- }
6998
- get typeId() {
6999
- return Type.Timestamp;
7000
- }
7001
- get [Symbol.toStringTag]() {
7002
- return "Timestamp";
7003
- }
7004
- toString() {
7005
- return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
7006
- }
7007
- };
7008
- TimestampMillisecond = class extends Timestamp {
7009
- constructor(timezone = null) {
7010
- super(TimeUnit.MILLISECOND, timezone);
7011
- }
7012
- };
7013
- IntervalUnit = {
7014
- DAY_TIME: 0,
7015
- YEAR_MONTH: 1
7016
- };
7017
- Interval = class extends DataType {
7018
- constructor(unit) {
7019
- super();
7020
- this.unit = unit;
7021
- }
7022
- get typeId() {
7023
- return Type.Interval;
7024
- }
7025
- get [Symbol.toStringTag]() {
7026
- return "Interval";
7027
- }
7028
- toString() {
7029
- return `Interval<${IntervalUnit[this.unit]}>`;
7030
- }
7031
- };
7032
- FixedSizeList = class extends DataType {
7033
- constructor(listSize, child) {
7034
- super();
7035
- this.listSize = listSize;
7036
- this.children = [child];
7037
- }
7038
- get typeId() {
7039
- return Type.FixedSizeList;
7040
- }
7041
- get valueType() {
7042
- return this.children[0].type;
7043
- }
7044
- get valueField() {
7045
- return this.children[0];
7046
- }
7047
- get [Symbol.toStringTag]() {
7048
- return "FixedSizeList";
7049
- }
7050
- toString() {
7051
- return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
7052
- }
7053
- };
7054
- Struct = class extends DataType {
7055
- constructor(children) {
7056
- super();
7057
- this.children = children;
7058
- }
7059
- get typeId() {
7060
- return Type.Struct;
7061
- }
7062
- toString() {
7063
- return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
7064
- }
7065
- get [Symbol.toStringTag]() {
7066
- return "Struct";
7067
- }
7068
- };
7069
- }
7070
- });
7071
-
7072
- // ../schema/src/lib/schema/schema.ts
7073
- var init_schema2 = __esm({
7074
- "../schema/src/lib/schema/schema.ts"() {
7075
- init_schema();
7076
- init_field();
7077
- init_type();
7078
- }
7079
- });
7080
-
7081
- // ../schema/src/index.ts
7082
- var init_src2 = __esm({
7083
- "../schema/src/index.ts"() {
7084
- init_schema2();
7085
- }
7086
- });
7087
-
7088
6720
  // src/lib/parsers/parse-dbf.ts
7089
6721
  function parseDBF(arrayBuffer, options = {}) {
7090
- const loaderOptions = options.dbf || {};
7091
- const { encoding } = loaderOptions;
6722
+ const { encoding = "latin1" } = options.dbf || {};
7092
6723
  const dbfParser = new DBFParser({ encoding });
7093
6724
  dbfParser.write(arrayBuffer);
7094
6725
  dbfParser.end();
7095
6726
  const { data, schema } = dbfParser.result;
7096
- switch (options.tables && options.tables.format) {
6727
+ const shape = options?.tables?.format || options?.dbf?.shape;
6728
+ switch (shape) {
6729
+ case "object-row-table": {
6730
+ const table = {
6731
+ shape: "object-row-table",
6732
+ schema,
6733
+ data
6734
+ };
6735
+ return table;
6736
+ }
7097
6737
  case "table":
7098
6738
  return { schema, rows: data };
7099
6739
  case "rows":
@@ -7102,8 +6742,7 @@
7102
6742
  }
7103
6743
  }
7104
6744
  async function* parseDBFInBatches(asyncIterator, options = {}) {
7105
- const loaderOptions = options.dbf || {};
7106
- const { encoding } = loaderOptions;
6745
+ const { encoding = "latin1" } = options.dbf || {};
7107
6746
  const parser = new DBFParser({ encoding });
7108
6747
  let headerReturned = false;
7109
6748
  for await (const arrayBuffer of asyncIterator) {
@@ -7130,7 +6769,7 @@
7130
6769
  case 3:
7131
6770
  return state;
7132
6771
  case 0:
7133
- const dataView = binaryReader.getDataView(DBF_HEADER_SIZE, "DBF header");
6772
+ const dataView = binaryReader.getDataView(DBF_HEADER_SIZE);
7134
6773
  if (!dataView) {
7135
6774
  return state;
7136
6775
  }
@@ -7143,12 +6782,15 @@
7143
6782
  state = 1;
7144
6783
  break;
7145
6784
  case 1:
7146
- const fieldDescriptorView = binaryReader.getDataView(result.dbfHeader.headerLength - DBF_HEADER_SIZE, "DBF field descriptors");
6785
+ const fieldDescriptorView = binaryReader.getDataView(result.dbfHeader.headerLength - DBF_HEADER_SIZE);
7147
6786
  if (!fieldDescriptorView) {
7148
6787
  return state;
7149
6788
  }
7150
6789
  result.dbfFields = parseFieldDescriptors(fieldDescriptorView, textDecoder);
7151
- result.schema = new Schema(result.dbfFields.map((dbfField) => makeField(dbfField)));
6790
+ result.schema = {
6791
+ fields: result.dbfFields.map((dbfField) => makeField(dbfField)),
6792
+ metadata: {}
6793
+ };
7152
6794
  state = 2;
7153
6795
  binaryReader.skip(1);
7154
6796
  break;
@@ -7251,19 +6893,19 @@
7251
6893
  function makeField({ name, dataType, fieldLength, decimal }) {
7252
6894
  switch (dataType) {
7253
6895
  case "B":
7254
- return new Field(name, new Float64(), true);
6896
+ return { name, type: "float64", nullable: true, metadata: {} };
7255
6897
  case "C":
7256
- return new Field(name, new Utf8(), true);
6898
+ return { name, type: "utf8", nullable: true, metadata: {} };
7257
6899
  case "F":
7258
- return new Field(name, new Float64(), true);
6900
+ return { name, type: "float64", nullable: true, metadata: {} };
7259
6901
  case "N":
7260
- return new Field(name, new Float64(), true);
6902
+ return { name, type: "float64", nullable: true, metadata: {} };
7261
6903
  case "O":
7262
- return new Field(name, new Float64(), true);
6904
+ return { name, type: "float64", nullable: true, metadata: {} };
7263
6905
  case "D":
7264
- return new Field(name, new TimestampMillisecond(), true);
6906
+ return { name, type: "timestamp-millisecond", nullable: true, metadata: {} };
7265
6907
  case "L":
7266
- return new Field(name, new Bool(), true);
6908
+ return { name, type: "bool", nullable: true, metadata: {} };
7267
6909
  default:
7268
6910
  throw new Error("Unsupported data type");
7269
6911
  }
@@ -7271,7 +6913,6 @@
7271
6913
  var LITTLE_ENDIAN4, DBF_HEADER_SIZE, STATE2, DBFParser;
7272
6914
  var init_parse_dbf = __esm({
7273
6915
  "src/lib/parsers/parse-dbf.ts"() {
7274
- init_src2();
7275
6916
  init_binary_chunk_reader();
7276
6917
  LITTLE_ENDIAN4 = true;
7277
6918
  DBF_HEADER_SIZE = 32;
@@ -7537,7 +7178,7 @@
7537
7178
  SHPWorkerLoader: () => SHPWorkerLoader,
7538
7179
  ShapefileLoader: () => ShapefileLoader
7539
7180
  });
7540
- var init_src3 = __esm({
7181
+ var init_src2 = __esm({
7541
7182
  "src/index.ts"() {
7542
7183
  init_shapefile_loader();
7543
7184
  init_dbf_loader();
@@ -7548,7 +7189,7 @@
7548
7189
  // src/bundle.ts
7549
7190
  var require_bundle = __commonJS({
7550
7191
  "src/bundle.ts"(exports4, module) {
7551
- var moduleExports = (init_src3(), src_exports);
7192
+ var moduleExports = (init_src2(), src_exports);
7552
7193
  globalThis.loaders = globalThis.loaders || {};
7553
7194
  module.exports = Object.assign(globalThis.loaders, moduleExports);
7554
7195
  }