@loaders.gl/shapefile 4.2.0-alpha.3 → 4.2.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.
Files changed (49) hide show
  1. package/dist/dbf-loader.js +25 -20
  2. package/dist/dbf-worker.js +1 -1
  3. package/dist/dist.dev.js +227 -247
  4. package/dist/dist.min.js +12 -0
  5. package/dist/index.cjs +49 -57
  6. package/dist/index.cjs.map +7 -0
  7. package/dist/index.d.ts +6 -6
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/lib/parsers/parse-dbf.d.ts +1 -1
  11. package/dist/lib/parsers/parse-dbf.d.ts.map +1 -1
  12. package/dist/lib/parsers/parse-dbf.js +300 -259
  13. package/dist/lib/parsers/parse-shapefile.d.ts +3 -3
  14. package/dist/lib/parsers/parse-shapefile.d.ts.map +1 -1
  15. package/dist/lib/parsers/parse-shapefile.js +225 -184
  16. package/dist/lib/parsers/parse-shp-geometry.d.ts +1 -1
  17. package/dist/lib/parsers/parse-shp-geometry.d.ts.map +1 -1
  18. package/dist/lib/parsers/parse-shp-geometry.js +260 -168
  19. package/dist/lib/parsers/parse-shp-header.js +33 -23
  20. package/dist/lib/parsers/parse-shp.d.ts +1 -1
  21. package/dist/lib/parsers/parse-shp.d.ts.map +1 -1
  22. package/dist/lib/parsers/parse-shp.js +147 -110
  23. package/dist/lib/parsers/parse-shx.js +19 -15
  24. package/dist/lib/parsers/types.js +0 -1
  25. package/dist/lib/streaming/binary-chunk-reader.js +150 -95
  26. package/dist/lib/streaming/binary-reader.js +49 -23
  27. package/dist/lib/streaming/zip-batch-iterators.js +61 -45
  28. package/dist/shapefile-loader.js +26 -19
  29. package/dist/shp-loader.js +25 -19
  30. package/dist/shp-worker.js +1 -1
  31. package/dist/workers/dbf-worker.js +0 -1
  32. package/dist/workers/shp-worker.js +0 -1
  33. package/package.json +11 -7
  34. package/dist/dbf-loader.js.map +0 -1
  35. package/dist/index.js.map +0 -1
  36. package/dist/lib/parsers/parse-dbf.js.map +0 -1
  37. package/dist/lib/parsers/parse-shapefile.js.map +0 -1
  38. package/dist/lib/parsers/parse-shp-geometry.js.map +0 -1
  39. package/dist/lib/parsers/parse-shp-header.js.map +0 -1
  40. package/dist/lib/parsers/parse-shp.js.map +0 -1
  41. package/dist/lib/parsers/parse-shx.js.map +0 -1
  42. package/dist/lib/parsers/types.js.map +0 -1
  43. package/dist/lib/streaming/binary-chunk-reader.js.map +0 -1
  44. package/dist/lib/streaming/binary-reader.js.map +0 -1
  45. package/dist/lib/streaming/zip-batch-iterators.js.map +0 -1
  46. package/dist/shapefile-loader.js.map +0 -1
  47. package/dist/shp-loader.js.map +0 -1
  48. package/dist/workers/dbf-worker.js.map +0 -1
  49. package/dist/workers/shp-worker.js.map +0 -1
@@ -1,191 +1,283 @@
1
1
  const LITTLE_ENDIAN = true;
2
+ /**
3
+ * Parse individual record
4
+ *
5
+ * @param view Record data
6
+ * @return Binary Geometry Object
7
+ */
8
+ // eslint-disable-next-line complexity
2
9
  export function parseRecord(view, options) {
3
- const {
4
- _maxDimensions = 4
5
- } = (options === null || options === void 0 ? void 0 : options.shp) || {};
6
- let offset = 0;
7
- const type = view.getInt32(offset, LITTLE_ENDIAN);
8
- offset += Int32Array.BYTES_PER_ELEMENT;
9
- switch (type) {
10
- case 0:
11
- return parseNull();
12
- case 1:
13
- return parsePoint(view, offset, Math.min(2, _maxDimensions));
14
- case 3:
15
- return parsePoly(view, offset, Math.min(2, _maxDimensions), 'LineString');
16
- case 5:
17
- return parsePoly(view, offset, Math.min(2, _maxDimensions), 'Polygon');
18
- case 8:
19
- return parseMultiPoint(view, offset, Math.min(2, _maxDimensions));
20
- case 11:
21
- return parsePoint(view, offset, Math.min(4, _maxDimensions));
22
- case 13:
23
- return parsePoly(view, offset, Math.min(4, _maxDimensions), 'LineString');
24
- case 15:
25
- return parsePoly(view, offset, Math.min(4, _maxDimensions), 'Polygon');
26
- case 18:
27
- return parseMultiPoint(view, offset, Math.min(4, _maxDimensions));
28
- case 21:
29
- return parsePoint(view, offset, Math.min(3, _maxDimensions));
30
- case 23:
31
- return parsePoly(view, offset, Math.min(3, _maxDimensions), 'LineString');
32
- case 25:
33
- return parsePoly(view, offset, Math.min(3, _maxDimensions), 'Polygon');
34
- case 28:
35
- return parseMultiPoint(view, offset, Math.min(3, _maxDimensions));
36
- default:
37
- throw new Error(`unsupported shape type: ${type}`);
38
- }
10
+ const { _maxDimensions = 4 } = options?.shp || {};
11
+ let offset = 0;
12
+ const type = view.getInt32(offset, LITTLE_ENDIAN);
13
+ offset += Int32Array.BYTES_PER_ELEMENT;
14
+ switch (type) {
15
+ case 0:
16
+ // Null Shape
17
+ return parseNull();
18
+ case 1:
19
+ // Point
20
+ return parsePoint(view, offset, Math.min(2, _maxDimensions));
21
+ case 3:
22
+ // PolyLine
23
+ return parsePoly(view, offset, Math.min(2, _maxDimensions), 'LineString');
24
+ case 5:
25
+ // Polygon
26
+ return parsePoly(view, offset, Math.min(2, _maxDimensions), 'Polygon');
27
+ case 8:
28
+ // MultiPoint
29
+ return parseMultiPoint(view, offset, Math.min(2, _maxDimensions));
30
+ // GeometryZ can have 3 or 4 dimensions, since the M is not required to
31
+ // exist
32
+ case 11:
33
+ // PointZ
34
+ return parsePoint(view, offset, Math.min(4, _maxDimensions));
35
+ case 13:
36
+ // PolyLineZ
37
+ return parsePoly(view, offset, Math.min(4, _maxDimensions), 'LineString');
38
+ case 15:
39
+ // PolygonZ
40
+ return parsePoly(view, offset, Math.min(4, _maxDimensions), 'Polygon');
41
+ case 18:
42
+ // MultiPointZ
43
+ return parseMultiPoint(view, offset, Math.min(4, _maxDimensions));
44
+ case 21:
45
+ // PointM
46
+ return parsePoint(view, offset, Math.min(3, _maxDimensions));
47
+ case 23:
48
+ // PolyLineM
49
+ return parsePoly(view, offset, Math.min(3, _maxDimensions), 'LineString');
50
+ case 25:
51
+ // PolygonM
52
+ return parsePoly(view, offset, Math.min(3, _maxDimensions), 'Polygon');
53
+ case 28:
54
+ // MultiPointM
55
+ return parseMultiPoint(view, offset, Math.min(3, _maxDimensions));
56
+ default:
57
+ throw new Error(`unsupported shape type: ${type}`);
58
+ }
39
59
  }
60
+ // TODO handle null
61
+ /**
62
+ * Parse Null geometry
63
+ *
64
+ * @return null
65
+ */
40
66
  function parseNull() {
41
- return null;
67
+ return null;
42
68
  }
69
+ /**
70
+ * Parse point geometry
71
+ *
72
+ * @param view Geometry data
73
+ * @param offset Offset in view
74
+ * @param dim Dimension size
75
+ */
43
76
  function parsePoint(view, offset, dim) {
44
- let positions;
45
- [positions, offset] = parsePositions(view, offset, 1, dim);
46
- return {
47
- positions: {
48
- value: positions,
49
- size: dim
50
- },
51
- type: 'Point'
52
- };
77
+ let positions;
78
+ [positions, offset] = parsePositions(view, offset, 1, dim);
79
+ return {
80
+ positions: { value: positions, size: dim },
81
+ type: 'Point'
82
+ };
53
83
  }
84
+ /**
85
+ * Parse MultiPoint geometry
86
+ *
87
+ * @param view Geometry data
88
+ * @param offset Offset in view
89
+ * @param dim Input dimension
90
+ * @return Binary geometry object
91
+ */
54
92
  function parseMultiPoint(view, offset, dim) {
55
- offset += 4 * Float64Array.BYTES_PER_ELEMENT;
56
- const nPoints = view.getInt32(offset, LITTLE_ENDIAN);
57
- offset += Int32Array.BYTES_PER_ELEMENT;
58
- let xyPositions = null;
59
- let mPositions = null;
60
- let zPositions = null;
61
- [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);
62
- if (dim === 4) {
63
- offset += 2 * Float64Array.BYTES_PER_ELEMENT;
64
- [zPositions, offset] = parsePositions(view, offset, nPoints, 1);
65
- }
66
- if (dim >= 3) {
67
- offset += 2 * Float64Array.BYTES_PER_ELEMENT;
68
- [mPositions, offset] = parsePositions(view, offset, nPoints, 1);
69
- }
70
- const positions = concatPositions(xyPositions, mPositions, zPositions);
71
- return {
72
- positions: {
73
- value: positions,
74
- size: dim
75
- },
76
- type: 'Point'
77
- };
78
- }
79
- function parsePoly(view, offset, dim, type) {
80
- offset += 4 * Float64Array.BYTES_PER_ELEMENT;
81
- const nParts = view.getInt32(offset, LITTLE_ENDIAN);
82
- offset += Int32Array.BYTES_PER_ELEMENT;
83
- const nPoints = view.getInt32(offset, LITTLE_ENDIAN);
84
- offset += Int32Array.BYTES_PER_ELEMENT;
85
- const bufferOffset = view.byteOffset + offset;
86
- const bufferLength = nParts * Int32Array.BYTES_PER_ELEMENT;
87
- const ringIndices = new Int32Array(nParts + 1);
88
- ringIndices.set(new Int32Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)));
89
- ringIndices[nParts] = nPoints;
90
- offset += nParts * Int32Array.BYTES_PER_ELEMENT;
91
- let xyPositions = null;
92
- let mPositions = null;
93
- let zPositions = null;
94
- [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);
95
- if (dim === 4) {
96
- offset += 2 * Float64Array.BYTES_PER_ELEMENT;
97
- [zPositions, offset] = parsePositions(view, offset, nPoints, 1);
98
- }
99
- if (dim >= 3) {
100
- offset += 2 * Float64Array.BYTES_PER_ELEMENT;
101
- [mPositions, offset] = parsePositions(view, offset, nPoints, 1);
102
- }
103
- const positions = concatPositions(xyPositions, mPositions, zPositions);
104
- if (type === 'LineString') {
93
+ // skip parsing box
94
+ offset += 4 * Float64Array.BYTES_PER_ELEMENT;
95
+ const nPoints = view.getInt32(offset, LITTLE_ENDIAN);
96
+ offset += Int32Array.BYTES_PER_ELEMENT;
97
+ let xyPositions = null;
98
+ let mPositions = null;
99
+ let zPositions = null;
100
+ [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);
101
+ // Parse Z coordinates
102
+ if (dim === 4) {
103
+ // skip parsing range
104
+ offset += 2 * Float64Array.BYTES_PER_ELEMENT;
105
+ [zPositions, offset] = parsePositions(view, offset, nPoints, 1);
106
+ }
107
+ // Parse M coordinates
108
+ if (dim >= 3) {
109
+ // skip parsing range
110
+ offset += 2 * Float64Array.BYTES_PER_ELEMENT;
111
+ [mPositions, offset] = parsePositions(view, offset, nPoints, 1);
112
+ }
113
+ const positions = concatPositions(xyPositions, mPositions, zPositions);
105
114
  return {
106
- type,
107
- positions: {
108
- value: positions,
109
- size: dim
110
- },
111
- pathIndices: {
112
- value: ringIndices,
113
- size: 1
114
- }
115
+ positions: { value: positions, size: dim },
116
+ type: 'Point'
115
117
  };
116
- }
117
- const polygonIndices = [];
118
- for (let i = 1; i < ringIndices.length; i++) {
119
- const startRingIndex = ringIndices[i - 1];
120
- const endRingIndex = ringIndices[i];
121
- const ring = xyPositions.subarray(startRingIndex * 2, endRingIndex * 2);
122
- const sign = getWindingDirection(ring);
123
- if (sign > 0) {
124
- polygonIndices.push(startRingIndex);
118
+ }
119
+ /**
120
+ * Polygon and PolyLine parsing
121
+ *
122
+ * @param view Geometry data
123
+ * @param offset Offset in view
124
+ * @param dim Input dimension
125
+ * @param type Either 'Polygon' or 'Polyline'
126
+ * @return Binary geometry object
127
+ */
128
+ // eslint-disable-next-line max-statements
129
+ function parsePoly(view, offset, dim, type) {
130
+ // skip parsing bounding box
131
+ offset += 4 * Float64Array.BYTES_PER_ELEMENT;
132
+ const nParts = view.getInt32(offset, LITTLE_ENDIAN);
133
+ offset += Int32Array.BYTES_PER_ELEMENT;
134
+ const nPoints = view.getInt32(offset, LITTLE_ENDIAN);
135
+ offset += Int32Array.BYTES_PER_ELEMENT;
136
+ // Create longer indices array by 1 because output format is expected to
137
+ // include the last index as the total number of positions
138
+ const bufferOffset = view.byteOffset + offset;
139
+ const bufferLength = nParts * Int32Array.BYTES_PER_ELEMENT;
140
+ const ringIndices = new Int32Array(nParts + 1);
141
+ ringIndices.set(new Int32Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)));
142
+ ringIndices[nParts] = nPoints;
143
+ offset += nParts * Int32Array.BYTES_PER_ELEMENT;
144
+ let xyPositions = null;
145
+ let mPositions = null;
146
+ let zPositions = null;
147
+ [xyPositions, offset] = parsePositions(view, offset, nPoints, 2);
148
+ // Parse Z coordinates
149
+ if (dim === 4) {
150
+ // skip parsing range
151
+ offset += 2 * Float64Array.BYTES_PER_ELEMENT;
152
+ [zPositions, offset] = parsePositions(view, offset, nPoints, 1);
125
153
  }
126
- }
127
- polygonIndices.push(nPoints);
128
- return {
129
- type,
130
- positions: {
131
- value: positions,
132
- size: dim
133
- },
134
- primitivePolygonIndices: {
135
- value: ringIndices,
136
- size: 1
137
- },
138
- polygonIndices: {
139
- value: new Uint32Array(polygonIndices),
140
- size: 1
154
+ // Parse M coordinates
155
+ if (dim >= 3) {
156
+ // skip parsing range
157
+ offset += 2 * Float64Array.BYTES_PER_ELEMENT;
158
+ [mPositions, offset] = parsePositions(view, offset, nPoints, 1);
141
159
  }
142
- };
160
+ const positions = concatPositions(xyPositions, mPositions, zPositions);
161
+ // parsePoly only accepts type = LineString or Polygon
162
+ if (type === 'LineString') {
163
+ return {
164
+ type,
165
+ positions: { value: positions, size: dim },
166
+ pathIndices: { value: ringIndices, size: 1 }
167
+ };
168
+ }
169
+ // for every ring, determine sign of polygon
170
+ // Use only 2D positions for ring calc
171
+ const polygonIndices = [];
172
+ for (let i = 1; i < ringIndices.length; i++) {
173
+ const startRingIndex = ringIndices[i - 1];
174
+ const endRingIndex = ringIndices[i];
175
+ // @ts-ignore
176
+ const ring = xyPositions.subarray(startRingIndex * 2, endRingIndex * 2);
177
+ const sign = getWindingDirection(ring);
178
+ // A positive sign implies clockwise
179
+ // A clockwise ring is a filled ring
180
+ if (sign > 0) {
181
+ polygonIndices.push(startRingIndex);
182
+ }
183
+ }
184
+ polygonIndices.push(nPoints);
185
+ return {
186
+ type,
187
+ positions: { value: positions, size: dim },
188
+ primitivePolygonIndices: { value: ringIndices, size: 1 },
189
+ // TODO: Dynamically choose Uint32Array over Uint16Array only when
190
+ // necessary. I believe the implementation requires nPoints to be the
191
+ // largest value in the array, so you should be able to use Uint32Array only
192
+ // when nPoints > 65535.
193
+ polygonIndices: { value: new Uint32Array(polygonIndices), size: 1 }
194
+ };
143
195
  }
196
+ /**
197
+ * Parse a contiguous block of positions into a Float64Array
198
+ *
199
+ * @param view Geometry data
200
+ * @param offset Offset in view
201
+ * @param nPoints Number of points
202
+ * @param dim Input dimension
203
+ * @return Data and offset
204
+ */
144
205
  function parsePositions(view, offset, nPoints, dim) {
145
- const bufferOffset = view.byteOffset + offset;
146
- const bufferLength = nPoints * dim * Float64Array.BYTES_PER_ELEMENT;
147
- return [new Float64Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)), offset + bufferLength];
206
+ const bufferOffset = view.byteOffset + offset;
207
+ const bufferLength = nPoints * dim * Float64Array.BYTES_PER_ELEMENT;
208
+ return [
209
+ new Float64Array(view.buffer.slice(bufferOffset, bufferOffset + bufferLength)),
210
+ offset + bufferLength
211
+ ];
148
212
  }
213
+ /**
214
+ * Concatenate and interleave positions arrays
215
+ * xy positions are interleaved; mPositions, zPositions are their own arrays
216
+ *
217
+ * @param xyPositions 2d positions
218
+ * @param mPositions M positions
219
+ * @param zPositions Z positions
220
+ * @return Combined interleaved positions
221
+ */
222
+ // eslint-disable-next-line complexity
149
223
  function concatPositions(xyPositions, mPositions, zPositions) {
150
- if (!(mPositions || zPositions)) {
151
- return xyPositions;
152
- }
153
- let arrayLength = xyPositions.length;
154
- let nDim = 2;
155
- if (zPositions && zPositions.length) {
156
- arrayLength += zPositions.length;
157
- nDim++;
158
- }
159
- if (mPositions && mPositions.length) {
160
- arrayLength += mPositions.length;
161
- nDim++;
162
- }
163
- const positions = new Float64Array(arrayLength);
164
- for (let i = 0; i < xyPositions.length / 2; i++) {
165
- positions[nDim * i] = xyPositions[i * 2];
166
- positions[nDim * i + 1] = xyPositions[i * 2 + 1];
167
- }
168
- if (zPositions && zPositions.length) {
169
- for (let i = 0; i < zPositions.length; i++) {
170
- positions[nDim * i + 2] = zPositions[i];
224
+ if (!(mPositions || zPositions)) {
225
+ return xyPositions;
226
+ }
227
+ let arrayLength = xyPositions.length;
228
+ let nDim = 2;
229
+ if (zPositions && zPositions.length) {
230
+ arrayLength += zPositions.length;
231
+ nDim++;
171
232
  }
172
- }
173
- if (mPositions && mPositions.length) {
174
- for (let i = 0; i < mPositions.length; i++) {
175
- positions[nDim * i + (nDim - 1)] = mPositions[i];
233
+ if (mPositions && mPositions.length) {
234
+ arrayLength += mPositions.length;
235
+ nDim++;
176
236
  }
177
- }
178
- return positions;
237
+ const positions = new Float64Array(arrayLength);
238
+ for (let i = 0; i < xyPositions.length / 2; i++) {
239
+ positions[nDim * i] = xyPositions[i * 2];
240
+ positions[nDim * i + 1] = xyPositions[i * 2 + 1];
241
+ }
242
+ if (zPositions && zPositions.length) {
243
+ for (let i = 0; i < zPositions.length; i++) {
244
+ // If Z coordinates exist; used as third coord in positions array
245
+ positions[nDim * i + 2] = zPositions[i];
246
+ }
247
+ }
248
+ if (mPositions && mPositions.length) {
249
+ for (let i = 0; i < mPositions.length; i++) {
250
+ // M is always last, either 3rd or 4th depending on if Z exists
251
+ positions[nDim * i + (nDim - 1)] = mPositions[i];
252
+ }
253
+ }
254
+ return positions;
179
255
  }
256
+ /**
257
+ * Returns the direction of the polygon path
258
+ * A positive number is clockwise.
259
+ * A negative number is counter clockwise.
260
+ *
261
+ * @param positions
262
+ * @return Sign of polygon ring
263
+ */
180
264
  function getWindingDirection(positions) {
181
- return Math.sign(getSignedArea(positions));
265
+ return Math.sign(getSignedArea(positions));
182
266
  }
267
+ /**
268
+ * Get signed area of flat typed array of 2d positions
269
+ *
270
+ * @param positions
271
+ * @return Signed area of polygon ring
272
+ */
183
273
  function getSignedArea(positions) {
184
- let area = 0;
185
- const nCoords = positions.length / 2 - 1;
186
- for (let i = 0; i < nCoords; i++) {
187
- area += (positions[i * 2] + positions[(i + 1) * 2]) * (positions[i * 2 + 1] - positions[(i + 1) * 2 + 1]);
188
- }
189
- return area / 2;
274
+ let area = 0;
275
+ // Rings are closed according to shapefile spec
276
+ const nCoords = positions.length / 2 - 1;
277
+ for (let i = 0; i < nCoords; i++) {
278
+ area +=
279
+ (positions[i * 2] + positions[(i + 1) * 2]) *
280
+ (positions[i * 2 + 1] - positions[(i + 1) * 2 + 1]);
281
+ }
282
+ return area / 2;
190
283
  }
191
- //# sourceMappingURL=parse-shp-geometry.js.map
@@ -1,29 +1,39 @@
1
1
  const LITTLE_ENDIAN = true;
2
2
  const BIG_ENDIAN = false;
3
3
  const SHP_MAGIC_NUMBER = 0x0000270a;
4
+ /**
5
+ * Extract the binary header
6
+ * Note: Also used by SHX
7
+ * @param headerView
8
+ * @returns SHPHeader
9
+ */
4
10
  export function parseSHPHeader(headerView) {
5
- const header = {
6
- magic: headerView.getInt32(0, BIG_ENDIAN),
7
- length: headerView.getInt32(24, BIG_ENDIAN) * 2,
8
- version: headerView.getInt32(28, LITTLE_ENDIAN),
9
- type: headerView.getInt32(32, LITTLE_ENDIAN),
10
- bbox: {
11
- minX: headerView.getFloat64(36, LITTLE_ENDIAN),
12
- minY: headerView.getFloat64(44, LITTLE_ENDIAN),
13
- minZ: headerView.getFloat64(68, LITTLE_ENDIAN),
14
- minM: headerView.getFloat64(84, LITTLE_ENDIAN),
15
- maxX: headerView.getFloat64(52, LITTLE_ENDIAN),
16
- maxY: headerView.getFloat64(60, LITTLE_ENDIAN),
17
- maxZ: headerView.getFloat64(76, LITTLE_ENDIAN),
18
- maxM: headerView.getFloat64(92, LITTLE_ENDIAN)
11
+ // Note: The SHP format switches endianness between fields!
12
+ // https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf
13
+ const header = {
14
+ magic: headerView.getInt32(0, BIG_ENDIAN),
15
+ // Length is stored as # of 2-byte words; multiply by 2 to get # of bytes
16
+ length: headerView.getInt32(24, BIG_ENDIAN) * 2,
17
+ version: headerView.getInt32(28, LITTLE_ENDIAN),
18
+ type: headerView.getInt32(32, LITTLE_ENDIAN),
19
+ bbox: {
20
+ minX: headerView.getFloat64(36, LITTLE_ENDIAN),
21
+ minY: headerView.getFloat64(44, LITTLE_ENDIAN),
22
+ minZ: headerView.getFloat64(68, LITTLE_ENDIAN),
23
+ minM: headerView.getFloat64(84, LITTLE_ENDIAN),
24
+ maxX: headerView.getFloat64(52, LITTLE_ENDIAN),
25
+ maxY: headerView.getFloat64(60, LITTLE_ENDIAN),
26
+ maxZ: headerView.getFloat64(76, LITTLE_ENDIAN),
27
+ maxM: headerView.getFloat64(92, LITTLE_ENDIAN)
28
+ }
29
+ };
30
+ if (header.magic !== SHP_MAGIC_NUMBER) {
31
+ // eslint-disable-next-line
32
+ console.error(`SHP file: bad magic number ${header.magic}`);
19
33
  }
20
- };
21
- if (header.magic !== SHP_MAGIC_NUMBER) {
22
- console.error(`SHP file: bad magic number ${header.magic}`);
23
- }
24
- if (header.version !== 1000) {
25
- console.error(`SHP file: bad version ${header.version}`);
26
- }
27
- return header;
34
+ if (header.version !== 1000) {
35
+ // eslint-disable-next-line
36
+ console.error(`SHP file: bad version ${header.version}`);
37
+ }
38
+ return header;
28
39
  }
29
- //# sourceMappingURL=parse-shp-header.js.map
@@ -1,5 +1,5 @@
1
1
  import type { BinaryGeometry } from '@loaders.gl/schema';
2
- import { SHPLoaderOptions } from './types';
2
+ import { SHPLoaderOptions } from "./types.js";
3
3
  export declare function parseSHP(arrayBuffer: ArrayBuffer, options?: SHPLoaderOptions): BinaryGeometry[];
4
4
  /**
5
5
  * @param asyncIterator
@@ -1 +1 @@
1
- {"version":3,"file":"parse-shp.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-shp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAIvD,OAAO,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAiEzC,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAO/F;AAED;;;;GAIG;AACH,wBAAuB,iBAAiB,CACtC,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACjE,OAAO,CAAC,EAAE,gBAAgB,GACzB,cAAc,CAAC,cAAc,GAAG,MAAM,CAAC,CAqBzC"}
1
+ {"version":3,"file":"parse-shp.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-shp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAIvD,OAAO,EAAC,gBAAgB,EAAC,mBAAgB;AAiEzC,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAO/F;AAED;;;;GAIG;AACH,wBAAuB,iBAAiB,CACtC,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACjE,OAAO,CAAC,EAAE,gBAAgB,GACzB,cAAc,CAAC,cAAc,GAAG,MAAM,CAAC,CAqBzC"}