@loaders.gl/shapefile 4.0.0-beta.3 → 4.0.0-beta.4

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.
@@ -372,7 +372,7 @@
372
372
  }
373
373
 
374
374
  // src/dbf-loader.ts
375
- var VERSION = true ? "4.0.0-beta.3" : "latest";
375
+ var VERSION = true ? "4.0.0-beta.4" : "latest";
376
376
  var DBFWorkerLoader = {
377
377
  name: "DBF",
378
378
  id: "dbf",
package/dist/dist.dev.js CHANGED
@@ -48,9 +48,6 @@ var __exports__ = (() => {
48
48
  this.ended = false;
49
49
  this.maxRewindBytes = maxRewindBytes;
50
50
  }
51
- /**
52
- * @param arrayBuffer
53
- */
54
51
  write(arrayBuffer) {
55
52
  this.arrayBuffers.push(arrayBuffer);
56
53
  }
@@ -58,12 +55,6 @@ var __exports__ = (() => {
58
55
  this.arrayBuffers = [];
59
56
  this.ended = true;
60
57
  }
61
- /**
62
- * Has enough bytes available in array buffers
63
- *
64
- * @param bytes Number of bytes
65
- * @return boolean
66
- */
67
58
  hasAvailableBytes(bytes) {
68
59
  let bytesAvailable = -this.offset;
69
60
  for (const arrayBuffer of this.arrayBuffers) {
@@ -74,12 +65,6 @@ var __exports__ = (() => {
74
65
  }
75
66
  return false;
76
67
  }
77
- /**
78
- * Find offsets of byte ranges within this.arrayBuffers
79
- *
80
- * @param bytes Byte length to read
81
- * @return Arrays with byte ranges pointing to this.arrayBuffers, Output type is nested array, e.g. [ [0, [1, 2]], ...]
82
- */
83
68
  findBufferOffsets(bytes) {
84
69
  let offset = -this.offset;
85
70
  const selectedBuffers = [];
@@ -103,12 +88,6 @@ var __exports__ = (() => {
103
88
  }
104
89
  return null;
105
90
  }
106
- /**
107
- * Get the required number of bytes from the iterator
108
- *
109
- * @param bytes Number of bytes
110
- * @return DataView with data
111
- */
112
91
  getDataView(bytes) {
113
92
  const bufferOffsets = this.findBufferOffsets(bytes);
114
93
  if (!bufferOffsets && this.ended) {
@@ -130,25 +109,12 @@ var __exports__ = (() => {
130
109
  this.disposeBuffers();
131
110
  return view;
132
111
  }
133
- /**
134
- * Dispose of old array buffers
135
- */
136
112
  disposeBuffers() {
137
113
  while (this.arrayBuffers.length > 0 && this.offset - this.maxRewindBytes >= this.arrayBuffers[0].byteLength) {
138
114
  this.offset -= this.arrayBuffers[0].byteLength;
139
115
  this.arrayBuffers.shift();
140
116
  }
141
117
  }
142
- /**
143
- * Copy multiple ArrayBuffers into one contiguous ArrayBuffer
144
- *
145
- * In contrast to concatenateArrayBuffers, this only copies the necessary
146
- * portions of the source arrays, rather than first copying the entire arrays
147
- * then taking a part of them.
148
- *
149
- * @param bufferOffsets List of internal array offsets
150
- * @return New contiguous ArrayBuffer
151
- */
152
118
  _combineArrayBuffers(bufferOffsets) {
153
119
  let byteLength = 0;
154
120
  for (const bufferOffset of bufferOffsets) {
@@ -165,15 +131,9 @@ var __exports__ = (() => {
165
131
  }
166
132
  return result.buffer;
167
133
  }
168
- /**
169
- * @param bytes
170
- */
171
134
  skip(bytes) {
172
135
  this.offset += bytes;
173
136
  }
174
- /**
175
- * @param bytes
176
- */
177
137
  rewind(bytes) {
178
138
  this.offset -= bytes;
179
139
  }
@@ -186,7 +146,6 @@ var __exports__ = (() => {
186
146
  function parseSHPHeader(headerView) {
187
147
  const header = {
188
148
  magic: headerView.getInt32(0, BIG_ENDIAN),
189
- // Length is stored as # of 2-byte words; multiply by 2 to get # of bytes
190
149
  length: headerView.getInt32(24, BIG_ENDIAN) * 2,
191
150
  version: headerView.getInt32(28, LITTLE_ENDIAN),
192
151
  type: headerView.getInt32(32, LITTLE_ENDIAN),
@@ -348,10 +307,6 @@ var __exports__ = (() => {
348
307
  value: ringIndices,
349
308
  size: 1
350
309
  },
351
- // TODO: Dynamically choose Uint32Array over Uint16Array only when
352
- // necessary. I believe the implementation requires nPoints to be the
353
- // largest value in the array, so you should be able to use Uint32Array only
354
- // when nPoints > 65535.
355
310
  polygonIndices: {
356
311
  value: new Uint32Array(polygonIndices),
357
312
  size: 1
@@ -425,8 +380,6 @@ var __exports__ = (() => {
425
380
  state = STATE.EXPECTING_HEADER;
426
381
  result = {
427
382
  geometries: [],
428
- // Initialize with number values to make TS happy
429
- // These are initialized for real in STATE.EXPECTING_HEADER
430
383
  progress: {
431
384
  bytesTotal: NaN,
432
385
  bytesUsed: NaN,
@@ -502,9 +455,7 @@ var __exports__ = (() => {
502
455
  const recordHeaderView = binaryReader.getDataView(SHP_RECORD_HEADER_SIZE);
503
456
  const recordHeader = {
504
457
  recordNumber: recordHeaderView.getInt32(0, BIG_ENDIAN2),
505
- // 2 byte words; includes the four words of record header
506
458
  byteLength: recordHeaderView.getInt32(4, BIG_ENDIAN2) * 2,
507
- // This is actually part of the record, not the header...
508
459
  type: recordHeaderView.getInt32(8, LITTLE_ENDIAN3)
509
460
  };
510
461
  if (!binaryReader.hasAvailableBytes(recordHeader.byteLength - 4)) {
@@ -552,7 +503,6 @@ var __exports__ = (() => {
552
503
  category: "geometry",
553
504
  extensions: ["shp"],
554
505
  mimeTypes: ["application/octet-stream"],
555
- // ISSUE: This also identifies SHX files, which are identical to SHP for the first 100 bytes...
556
506
  tests: [new Uint8Array(SHP_MAGIC_NUMBER2).buffer],
557
507
  options: {
558
508
  shp: {
@@ -6168,7 +6118,7 @@ var __exports__ = (() => {
6168
6118
  // src/lib/parsers/parse-dbf.ts
6169
6119
  var LITTLE_ENDIAN4 = true;
6170
6120
  var DBF_HEADER_SIZE = 32;
6171
- var STATE2 = /* @__PURE__ */ function(STATE3) {
6121
+ var STATE2 = function(STATE3) {
6172
6122
  STATE3[STATE3["START"] = 0] = "START";
6173
6123
  STATE3[STATE3["FIELD_DESCRIPTORS"] = 1] = "FIELD_DESCRIPTORS";
6174
6124
  STATE3[STATE3["FIELD_PROPERTIES"] = 2] = "FIELD_PROPERTIES";
@@ -6185,9 +6135,6 @@ var __exports__ = (() => {
6185
6135
  constructor(options) {
6186
6136
  this.textDecoder = new TextDecoder(options.encoding);
6187
6137
  }
6188
- /**
6189
- * @param arrayBuffer
6190
- */
6191
6138
  write(arrayBuffer) {
6192
6139
  this.binaryReader.write(arrayBuffer);
6193
6140
  this.state = parseState2(this.state, this.result, this.binaryReader, this.textDecoder);
@@ -6279,10 +6226,7 @@ var __exports__ = (() => {
6279
6226
  state = STATE2.FIELD_DESCRIPTORS;
6280
6227
  break;
6281
6228
  case STATE2.FIELD_DESCRIPTORS:
6282
- const fieldDescriptorView = binaryReader.getDataView(
6283
- // @ts-ignore
6284
- result.dbfHeader.headerLength - DBF_HEADER_SIZE
6285
- );
6229
+ const fieldDescriptorView = binaryReader.getDataView(result.dbfHeader.headerLength - DBF_HEADER_SIZE);
6286
6230
  if (!fieldDescriptorView) {
6287
6231
  return state;
6288
6232
  }
@@ -6325,17 +6269,12 @@ var __exports__ = (() => {
6325
6269
  }
6326
6270
  function parseDBFHeader(headerView) {
6327
6271
  return {
6328
- // Last updated date
6329
6272
  year: headerView.getUint8(1) + 1900,
6330
6273
  month: headerView.getUint8(2),
6331
6274
  day: headerView.getUint8(3),
6332
- // Number of records in data file
6333
6275
  nRecords: headerView.getUint32(4, LITTLE_ENDIAN4),
6334
- // Length of header in bytes
6335
6276
  headerLength: headerView.getUint16(8, LITTLE_ENDIAN4),
6336
- // Length of each record
6337
6277
  recordLength: headerView.getUint16(10, LITTLE_ENDIAN4),
6338
- // Not sure if this is usually set
6339
6278
  languageDriver: headerView.getUint8(29)
6340
6279
  };
6341
6280
  }
@@ -6598,7 +6537,6 @@ var __exports__ = (() => {
6598
6537
  const feature = {
6599
6538
  type: "Feature",
6600
6539
  geometry,
6601
- // properties can be undefined if dbfResponse above was empty
6602
6540
  properties: properties && properties[i] || {}
6603
6541
  };
6604
6542
  features.push(feature);
@@ -6697,21 +6635,9 @@ var __exports__ = (() => {
6697
6635
  this.offset = 0;
6698
6636
  this.arrayBuffer = arrayBuffer;
6699
6637
  }
6700
- /**
6701
- * Checks if there are available bytes in data
6702
- *
6703
- * @param bytes
6704
- * @returns boolean
6705
- */
6706
6638
  hasAvailableBytes(bytes) {
6707
6639
  return this.arrayBuffer.byteLength - this.offset >= bytes;
6708
6640
  }
6709
- /**
6710
- * Get the required number of bytes from the iterator
6711
- *
6712
- * @param bytes
6713
- * @returns Dataview
6714
- */
6715
6641
  getDataView(bytes) {
6716
6642
  if (bytes && !this.hasAvailableBytes(bytes)) {
6717
6643
  throw new Error("binary data exhausted");
@@ -6720,19 +6646,9 @@ var __exports__ = (() => {
6720
6646
  this.offset += bytes;
6721
6647
  return dataView;
6722
6648
  }
6723
- /**
6724
- * Skipping
6725
- *
6726
- * @param bytes
6727
- */
6728
6649
  skip(bytes) {
6729
6650
  this.offset += bytes;
6730
6651
  }
6731
- /**
6732
- * Rewinding
6733
- *
6734
- * @param bytes
6735
- */
6736
6652
  rewind(bytes) {
6737
6653
  this.offset -= bytes;
6738
6654
  }
@@ -480,7 +480,7 @@
480
480
  }
481
481
 
482
482
  // src/shp-loader.ts
483
- var VERSION = true ? "4.0.0-beta.3" : "latest";
483
+ var VERSION = true ? "4.0.0-beta.4" : "latest";
484
484
  var SHP_MAGIC_NUMBER2 = [0, 0, 39, 10];
485
485
  var SHPWorkerLoader = {
486
486
  name: "SHP",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@loaders.gl/shapefile",
3
3
  "description": "Loader for the Shapefile Format",
4
- "version": "4.0.0-beta.3",
4
+ "version": "4.0.0-beta.4",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -44,10 +44,10 @@
44
44
  "build-worker-dbf": "esbuild src/workers/dbf-worker.ts --bundle --outfile=dist/dbf-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
45
45
  },
46
46
  "dependencies": {
47
- "@loaders.gl/gis": "4.0.0-beta.3",
48
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
49
- "@loaders.gl/schema": "4.0.0-beta.3",
47
+ "@loaders.gl/gis": "4.0.0-beta.4",
48
+ "@loaders.gl/loader-utils": "4.0.0-beta.4",
49
+ "@loaders.gl/schema": "4.0.0-beta.4",
50
50
  "@math.gl/proj4": "^4.0.0"
51
51
  },
52
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
52
+ "gitHead": "848c20b474532d301f2c3f8d4e1fb9bf262b86d4"
53
53
  }