@loaders.gl/shapefile 3.1.3 → 4.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/bundle.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/dbf-loader.js +20 -29
- package/dist/dbf-loader.js.map +1 -0
- package/dist/dbf-worker.js +1 -1
- package/dist/index.js +4 -11
- package/dist/index.js.map +1 -0
- package/dist/lib/parsers/parse-dbf.js +264 -300
- package/dist/lib/parsers/parse-dbf.js.map +1 -0
- package/dist/lib/parsers/parse-shapefile.js +209 -231
- package/dist/lib/parsers/parse-shapefile.js.map +1 -0
- package/dist/lib/parsers/parse-shp-geometry.js +212 -265
- package/dist/lib/parsers/parse-shp-geometry.js.map +1 -0
- package/dist/lib/parsers/parse-shp-header.js +27 -38
- package/dist/lib/parsers/parse-shp-header.js.map +1 -0
- package/dist/lib/parsers/parse-shp.js +136 -152
- package/dist/lib/parsers/parse-shp.js.map +1 -0
- package/dist/lib/parsers/parse-shx.js +19 -25
- package/dist/lib/parsers/parse-shx.js.map +1 -0
- package/dist/lib/streaming/binary-chunk-reader.js +128 -152
- package/dist/lib/streaming/binary-chunk-reader.js.map +1 -0
- package/dist/lib/streaming/binary-reader.js +33 -50
- package/dist/lib/streaming/binary-reader.js.map +1 -0
- package/dist/lib/streaming/zip-batch-iterators.js +48 -57
- package/dist/lib/streaming/zip-batch-iterators.js.map +1 -0
- package/dist/shapefile-loader.js +22 -30
- package/dist/shapefile-loader.js.map +1 -0
- package/dist/shp-loader.js +22 -32
- package/dist/shp-loader.js.map +1 -0
- package/dist/shp-worker.js +1 -1
- package/dist/workers/dbf-worker.js +4 -5
- package/dist/workers/dbf-worker.js.map +1 -0
- package/dist/workers/shp-worker.js +4 -5
- package/dist/workers/shp-worker.js.map +1 -0
- package/package.json +9 -9
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/dbf-loader.js +0 -68
- package/dist/es5/dbf-loader.js.map +0 -1
- package/dist/es5/index.js +0 -42
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/parsers/parse-dbf.js +0 -454
- package/dist/es5/lib/parsers/parse-dbf.js.map +0 -1
- package/dist/es5/lib/parsers/parse-shapefile.js +0 -497
- package/dist/es5/lib/parsers/parse-shapefile.js.map +0 -1
- package/dist/es5/lib/parsers/parse-shp-geometry.js +0 -288
- package/dist/es5/lib/parsers/parse-shp-geometry.js.map +0 -1
- package/dist/es5/lib/parsers/parse-shp-header.js +0 -39
- package/dist/es5/lib/parsers/parse-shp-header.js.map +0 -1
- package/dist/es5/lib/parsers/parse-shp.js +0 -283
- package/dist/es5/lib/parsers/parse-shp.js.map +0 -1
- package/dist/es5/lib/parsers/parse-shx.js +0 -31
- package/dist/es5/lib/parsers/parse-shx.js.map +0 -1
- package/dist/es5/lib/streaming/binary-chunk-reader.js +0 -218
- package/dist/es5/lib/streaming/binary-chunk-reader.js.map +0 -1
- package/dist/es5/lib/streaming/binary-reader.js +0 -56
- package/dist/es5/lib/streaming/binary-reader.js.map +0 -1
- package/dist/es5/lib/streaming/zip-batch-iterators.js +0 -118
- package/dist/es5/lib/streaming/zip-batch-iterators.js.map +0 -1
- package/dist/es5/shapefile-loader.js +0 -34
- package/dist/es5/shapefile-loader.js.map +0 -1
- package/dist/es5/shp-loader.js +0 -71
- package/dist/es5/shp-loader.js.map +0 -1
- package/dist/es5/workers/dbf-worker.js +0 -8
- package/dist/es5/workers/dbf-worker.js.map +0 -1
- package/dist/es5/workers/shp-worker.js +0 -8
- package/dist/es5/workers/shp-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/dbf-loader.js +0 -23
- package/dist/esm/dbf-loader.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/parsers/parse-dbf.js +0 -299
- package/dist/esm/lib/parsers/parse-dbf.js.map +0 -1
- package/dist/esm/lib/parsers/parse-shapefile.js +0 -226
- package/dist/esm/lib/parsers/parse-shapefile.js.map +0 -1
- package/dist/esm/lib/parsers/parse-shp-geometry.js +0 -234
- package/dist/esm/lib/parsers/parse-shp-geometry.js.map +0 -1
- package/dist/esm/lib/parsers/parse-shp-header.js +0 -32
- package/dist/esm/lib/parsers/parse-shp-header.js.map +0 -1
- package/dist/esm/lib/parsers/parse-shp.js +0 -154
- package/dist/esm/lib/parsers/parse-shp.js.map +0 -1
- package/dist/esm/lib/parsers/parse-shx.js +0 -22
- package/dist/esm/lib/parsers/parse-shx.js.map +0 -1
- package/dist/esm/lib/streaming/binary-chunk-reader.js +0 -137
- package/dist/esm/lib/streaming/binary-chunk-reader.js.map +0 -1
- package/dist/esm/lib/streaming/binary-reader.js +0 -35
- package/dist/esm/lib/streaming/binary-reader.js.map +0 -1
- package/dist/esm/lib/streaming/zip-batch-iterators.js +0 -52
- package/dist/esm/lib/streaming/zip-batch-iterators.js.map +0 -1
- package/dist/esm/shapefile-loader.js +0 -23
- package/dist/esm/shapefile-loader.js.map +0 -1
- package/dist/esm/shp-loader.js +0 -25
- package/dist/esm/shp-loader.js.map +0 -1
- package/dist/esm/workers/dbf-worker.js +0 -4
- package/dist/esm/workers/dbf-worker.js.map +0 -1
- package/dist/esm/workers/shp-worker.js +0 -4
- package/dist/esm/workers/shp-worker.js.map +0 -1
|
@@ -1,161 +1,137 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
export default class BinaryChunkReader {
|
|
3
|
+
constructor(options) {
|
|
4
|
+
_defineProperty(this, "offset", void 0);
|
|
5
|
+
|
|
6
|
+
_defineProperty(this, "arrayBuffers", void 0);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "ended", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "maxRewindBytes", void 0);
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
maxRewindBytes = 0
|
|
14
|
+
} = options || {};
|
|
15
|
+
this.offset = 0;
|
|
16
|
+
this.arrayBuffers = [];
|
|
17
|
+
this.ended = false;
|
|
18
|
+
this.maxRewindBytes = maxRewindBytes;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
write(arrayBuffer) {
|
|
22
|
+
this.arrayBuffers.push(arrayBuffer);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
end() {
|
|
26
|
+
this.arrayBuffers = [];
|
|
27
|
+
this.ended = true;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
hasAvailableBytes(bytes) {
|
|
31
|
+
let bytesAvailable = -this.offset;
|
|
32
|
+
|
|
33
|
+
for (const arrayBuffer of this.arrayBuffers) {
|
|
34
|
+
bytesAvailable += arrayBuffer.byteLength;
|
|
35
|
+
|
|
36
|
+
if (bytesAvailable >= bytes) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
13
39
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
40
|
+
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
findBufferOffsets(bytes) {
|
|
45
|
+
let offset = -this.offset;
|
|
46
|
+
const selectedBuffers = [];
|
|
47
|
+
|
|
48
|
+
for (let i = 0; i < this.arrayBuffers.length; i++) {
|
|
49
|
+
const buf = this.arrayBuffers[i];
|
|
50
|
+
|
|
51
|
+
if (offset + buf.byteLength <= 0) {
|
|
52
|
+
offset += buf.byteLength;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const start = offset <= 0 ? Math.abs(offset) : 0;
|
|
57
|
+
let end;
|
|
58
|
+
|
|
59
|
+
if (start + bytes <= buf.byteLength) {
|
|
60
|
+
end = start + bytes;
|
|
61
|
+
selectedBuffers.push([i, [start, end]]);
|
|
62
|
+
return selectedBuffers;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
end = buf.byteLength;
|
|
66
|
+
selectedBuffers.push([i, [start, end]]);
|
|
67
|
+
bytes -= buf.byteLength - start;
|
|
68
|
+
offset += buf.byteLength;
|
|
19
69
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
70
|
+
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getDataView(bytes) {
|
|
75
|
+
const bufferOffsets = this.findBufferOffsets(bytes);
|
|
76
|
+
|
|
77
|
+
if (!bufferOffsets && this.ended) {
|
|
78
|
+
throw new Error('binary data exhausted');
|
|
23
79
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @param bytes Number of bytes
|
|
28
|
-
* @return boolean
|
|
29
|
-
*/
|
|
30
|
-
hasAvailableBytes(bytes) {
|
|
31
|
-
let bytesAvailable = -this.offset;
|
|
32
|
-
for (const arrayBuffer of this.arrayBuffers) {
|
|
33
|
-
bytesAvailable += arrayBuffer.byteLength;
|
|
34
|
-
if (bytesAvailable >= bytes) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
80
|
+
|
|
81
|
+
if (!bufferOffsets) {
|
|
82
|
+
return null;
|
|
39
83
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const selectedBuffers = [];
|
|
49
|
-
for (let i = 0; i < this.arrayBuffers.length; i++) {
|
|
50
|
-
const buf = this.arrayBuffers[i];
|
|
51
|
-
// Current buffer isn't long enough to reach global offset
|
|
52
|
-
if (offset + buf.byteLength <= 0) {
|
|
53
|
-
offset += buf.byteLength;
|
|
54
|
-
// eslint-disable-next-line no-continue
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
// Find start/end offsets for this buffer
|
|
58
|
-
// When offset < 0, need to skip over Math.abs(offset) bytes
|
|
59
|
-
// When offset > 0, implies bytes in previous buffer, start at 0
|
|
60
|
-
const start = offset <= 0 ? Math.abs(offset) : 0;
|
|
61
|
-
let end;
|
|
62
|
-
// Length of requested bytes is contained in current buffer
|
|
63
|
-
if (start + bytes <= buf.byteLength) {
|
|
64
|
-
end = start + bytes;
|
|
65
|
-
selectedBuffers.push([i, [start, end]]);
|
|
66
|
-
return selectedBuffers;
|
|
67
|
-
}
|
|
68
|
-
// Will need to look into next buffer
|
|
69
|
-
end = buf.byteLength;
|
|
70
|
-
selectedBuffers.push([i, [start, end]]);
|
|
71
|
-
// Need to read fewer bytes in next iter
|
|
72
|
-
bytes -= buf.byteLength - start;
|
|
73
|
-
offset += buf.byteLength;
|
|
74
|
-
}
|
|
75
|
-
// Should only finish loop if exhausted all arrays
|
|
76
|
-
return null;
|
|
84
|
+
|
|
85
|
+
if (bufferOffsets.length === 1) {
|
|
86
|
+
const [bufferIndex, [start, end]] = bufferOffsets[0];
|
|
87
|
+
const arrayBuffer = this.arrayBuffers[bufferIndex];
|
|
88
|
+
const view = new DataView(arrayBuffer, start, end - start);
|
|
89
|
+
this.offset += bytes;
|
|
90
|
+
this.disposeBuffers();
|
|
91
|
+
return view;
|
|
77
92
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
throw new Error('binary data exhausted');
|
|
90
|
-
}
|
|
91
|
-
if (!bufferOffsets) {
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
// If only one arrayBuffer needed, return DataView directly
|
|
96
|
-
if (bufferOffsets.length === 1) {
|
|
97
|
-
const [bufferIndex, [start, end]] = bufferOffsets[0];
|
|
98
|
-
const arrayBuffer = this.arrayBuffers[bufferIndex];
|
|
99
|
-
const view = new DataView(arrayBuffer, start, end - start);
|
|
100
|
-
this.offset += bytes;
|
|
101
|
-
this.disposeBuffers();
|
|
102
|
-
return view;
|
|
103
|
-
}
|
|
104
|
-
// Concatenate portions of multiple ArrayBuffers
|
|
105
|
-
const view = new DataView(this._combineArrayBuffers(bufferOffsets));
|
|
106
|
-
this.offset += bytes;
|
|
107
|
-
this.disposeBuffers();
|
|
108
|
-
return view;
|
|
93
|
+
|
|
94
|
+
const view = new DataView(this._combineArrayBuffers(bufferOffsets));
|
|
95
|
+
this.offset += bytes;
|
|
96
|
+
this.disposeBuffers();
|
|
97
|
+
return view;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
disposeBuffers() {
|
|
101
|
+
while (this.arrayBuffers.length > 0 && this.offset - this.maxRewindBytes >= this.arrayBuffers[0].byteLength) {
|
|
102
|
+
this.offset -= this.arrayBuffers[0].byteLength;
|
|
103
|
+
this.arrayBuffers.shift();
|
|
109
104
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_combineArrayBuffers(bufferOffsets) {
|
|
108
|
+
let byteLength = 0;
|
|
109
|
+
|
|
110
|
+
for (const bufferOffset of bufferOffsets) {
|
|
111
|
+
const [start, end] = bufferOffset[1];
|
|
112
|
+
byteLength += end - start;
|
|
119
113
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*/
|
|
130
|
-
_combineArrayBuffers(bufferOffsets) {
|
|
131
|
-
let byteLength = 0;
|
|
132
|
-
for (const bufferOffset of bufferOffsets) {
|
|
133
|
-
const [start, end] = bufferOffset[1];
|
|
134
|
-
byteLength += end - start;
|
|
135
|
-
}
|
|
136
|
-
const result = new Uint8Array(byteLength);
|
|
137
|
-
// Copy the subarrays
|
|
138
|
-
let resultOffset = 0;
|
|
139
|
-
for (const bufferOffset of bufferOffsets) {
|
|
140
|
-
const [bufferIndex, [start, end]] = bufferOffset;
|
|
141
|
-
const sourceArray = new Uint8Array(this.arrayBuffers[bufferIndex]);
|
|
142
|
-
result.set(sourceArray.subarray(start, end), resultOffset);
|
|
143
|
-
resultOffset += end - start;
|
|
144
|
-
}
|
|
145
|
-
return result.buffer;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* @param bytes
|
|
149
|
-
*/
|
|
150
|
-
skip(bytes) {
|
|
151
|
-
this.offset += bytes;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* @param bytes
|
|
155
|
-
*/
|
|
156
|
-
rewind(bytes) {
|
|
157
|
-
// TODO - only works if offset is already set
|
|
158
|
-
this.offset -= bytes;
|
|
114
|
+
|
|
115
|
+
const result = new Uint8Array(byteLength);
|
|
116
|
+
let resultOffset = 0;
|
|
117
|
+
|
|
118
|
+
for (const bufferOffset of bufferOffsets) {
|
|
119
|
+
const [bufferIndex, [start, end]] = bufferOffset;
|
|
120
|
+
const sourceArray = new Uint8Array(this.arrayBuffers[bufferIndex]);
|
|
121
|
+
result.set(sourceArray.subarray(start, end), resultOffset);
|
|
122
|
+
resultOffset += end - start;
|
|
159
123
|
}
|
|
124
|
+
|
|
125
|
+
return result.buffer;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
skip(bytes) {
|
|
129
|
+
this.offset += bytes;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
rewind(bytes) {
|
|
133
|
+
this.offset -= bytes;
|
|
134
|
+
}
|
|
135
|
+
|
|
160
136
|
}
|
|
161
|
-
|
|
137
|
+
//# sourceMappingURL=binary-chunk-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/streaming/binary-chunk-reader.ts"],"names":["BinaryChunkReader","constructor","options","maxRewindBytes","offset","arrayBuffers","ended","write","arrayBuffer","push","end","hasAvailableBytes","bytes","bytesAvailable","byteLength","findBufferOffsets","selectedBuffers","i","length","buf","start","Math","abs","getDataView","bufferOffsets","Error","bufferIndex","view","DataView","disposeBuffers","_combineArrayBuffers","shift","bufferOffset","result","Uint8Array","resultOffset","sourceArray","set","subarray","buffer","skip","rewind"],"mappings":"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","sourcesContent":["export default class BinaryChunkReader {\n offset: number;\n arrayBuffers: ArrayBuffer[];\n ended: boolean;\n maxRewindBytes: number;\n\n constructor(options?: {[key: string]: any}) {\n const {maxRewindBytes = 0} = options || {};\n\n /** current global offset into current array buffer*/\n this.offset = 0;\n /** current buffer from iterator */\n this.arrayBuffers = [];\n this.ended = false;\n\n /** bytes behind offset to hold on to */\n this.maxRewindBytes = maxRewindBytes;\n }\n /**\n * @param arrayBuffer\n */\n write(arrayBuffer: ArrayBuffer): void {\n this.arrayBuffers.push(arrayBuffer);\n }\n\n end(): void {\n this.arrayBuffers = [];\n this.ended = true;\n }\n\n /**\n * Has enough bytes available in array buffers\n *\n * @param bytes Number of bytes\n * @return boolean\n */\n hasAvailableBytes(bytes: number): boolean {\n let bytesAvailable = -this.offset;\n for (const arrayBuffer of this.arrayBuffers) {\n bytesAvailable += arrayBuffer.byteLength;\n if (bytesAvailable >= bytes) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Find offsets of byte ranges within this.arrayBuffers\n *\n * @param bytes Byte length to read\n * @return Arrays with byte ranges pointing to this.arrayBuffers, Output type is nested array, e.g. [ [0, [1, 2]], ...]\n */\n findBufferOffsets(bytes: number): any[] | null {\n let offset = -this.offset;\n const selectedBuffers: any = [];\n\n for (let i = 0; i < this.arrayBuffers.length; i++) {\n const buf = this.arrayBuffers[i];\n\n // Current buffer isn't long enough to reach global offset\n if (offset + buf.byteLength <= 0) {\n offset += buf.byteLength;\n // eslint-disable-next-line no-continue\n continue;\n }\n\n // Find start/end offsets for this buffer\n // When offset < 0, need to skip over Math.abs(offset) bytes\n // When offset > 0, implies bytes in previous buffer, start at 0\n const start = offset <= 0 ? Math.abs(offset) : 0;\n let end: number;\n\n // Length of requested bytes is contained in current buffer\n if (start + bytes <= buf.byteLength) {\n end = start + bytes;\n selectedBuffers.push([i, [start, end]]);\n return selectedBuffers;\n }\n\n // Will need to look into next buffer\n end = buf.byteLength;\n selectedBuffers.push([i, [start, end]]);\n\n // Need to read fewer bytes in next iter\n bytes -= buf.byteLength - start;\n offset += buf.byteLength;\n }\n\n // Should only finish loop if exhausted all arrays\n return null;\n }\n\n /**\n * Get the required number of bytes from the iterator\n *\n * @param bytes Number of bytes\n * @return DataView with data\n */\n getDataView(bytes: number): DataView | null {\n const bufferOffsets = this.findBufferOffsets(bytes);\n // return `null` if not enough data, except if end() already called, in\n // which case throw an error.\n if (!bufferOffsets && this.ended) {\n throw new Error('binary data exhausted');\n }\n\n if (!bufferOffsets) {\n // @ts-ignore\n return null;\n }\n\n // If only one arrayBuffer needed, return DataView directly\n if (bufferOffsets.length === 1) {\n const [bufferIndex, [start, end]] = bufferOffsets[0];\n const arrayBuffer = this.arrayBuffers[bufferIndex];\n const view = new DataView(arrayBuffer, start, end - start);\n\n this.offset += bytes;\n this.disposeBuffers();\n return view;\n }\n\n // Concatenate portions of multiple ArrayBuffers\n const view = new DataView(this._combineArrayBuffers(bufferOffsets));\n this.offset += bytes;\n this.disposeBuffers();\n return view;\n }\n\n /**\n * Dispose of old array buffers\n */\n disposeBuffers(): void {\n while (\n this.arrayBuffers.length > 0 &&\n this.offset - this.maxRewindBytes >= this.arrayBuffers[0].byteLength\n ) {\n this.offset -= this.arrayBuffers[0].byteLength;\n this.arrayBuffers.shift();\n }\n }\n\n /**\n * Copy multiple ArrayBuffers into one contiguous ArrayBuffer\n *\n * In contrast to concatenateArrayBuffers, this only copies the necessary\n * portions of the source arrays, rather than first copying the entire arrays\n * then taking a part of them.\n *\n * @param bufferOffsets List of internal array offsets\n * @return New contiguous ArrayBuffer\n */\n _combineArrayBuffers(bufferOffsets: any[]): ArrayBufferLike {\n let byteLength: number = 0;\n for (const bufferOffset of bufferOffsets) {\n const [start, end] = bufferOffset[1];\n byteLength += end - start;\n }\n\n const result = new Uint8Array(byteLength);\n\n // Copy the subarrays\n let resultOffset: number = 0;\n for (const bufferOffset of bufferOffsets) {\n const [bufferIndex, [start, end]] = bufferOffset;\n const sourceArray = new Uint8Array(this.arrayBuffers[bufferIndex]);\n result.set(sourceArray.subarray(start, end), resultOffset);\n resultOffset += end - start;\n }\n\n return result.buffer;\n }\n /**\n * @param bytes\n */\n skip(bytes: number): void {\n this.offset += bytes;\n }\n /**\n * @param bytes\n */\n rewind(bytes: number): void {\n // TODO - only works if offset is already set\n this.offset -= bytes;\n }\n}\n"],"file":"binary-chunk-reader.js"}
|
|
@@ -1,52 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get the required number of bytes from the iterator
|
|
21
|
-
*
|
|
22
|
-
* @param bytes
|
|
23
|
-
* @returns Dataview
|
|
24
|
-
*/
|
|
25
|
-
getDataView(bytes) {
|
|
26
|
-
if (bytes && !this.hasAvailableBytes(bytes)) {
|
|
27
|
-
throw new Error('binary data exhausted');
|
|
28
|
-
}
|
|
29
|
-
const dataView = bytes
|
|
30
|
-
? new DataView(this.arrayBuffer, this.offset, bytes)
|
|
31
|
-
: new DataView(this.arrayBuffer, this.offset);
|
|
32
|
-
this.offset += bytes;
|
|
33
|
-
return dataView;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Skipping
|
|
37
|
-
*
|
|
38
|
-
* @param bytes
|
|
39
|
-
*/
|
|
40
|
-
skip(bytes) {
|
|
41
|
-
this.offset += bytes;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Rewinding
|
|
45
|
-
*
|
|
46
|
-
* @param bytes
|
|
47
|
-
*/
|
|
48
|
-
rewind(bytes) {
|
|
49
|
-
this.offset -= bytes;
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
export default class BinaryReader {
|
|
3
|
+
constructor(arrayBuffer) {
|
|
4
|
+
_defineProperty(this, "offset", void 0);
|
|
5
|
+
|
|
6
|
+
_defineProperty(this, "arrayBuffer", void 0);
|
|
7
|
+
|
|
8
|
+
this.offset = 0;
|
|
9
|
+
this.arrayBuffer = arrayBuffer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
hasAvailableBytes(bytes) {
|
|
13
|
+
return this.arrayBuffer.byteLength - this.offset >= bytes;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getDataView(bytes) {
|
|
17
|
+
if (bytes && !this.hasAvailableBytes(bytes)) {
|
|
18
|
+
throw new Error('binary data exhausted');
|
|
50
19
|
}
|
|
20
|
+
|
|
21
|
+
const dataView = bytes ? new DataView(this.arrayBuffer, this.offset, bytes) : new DataView(this.arrayBuffer, this.offset);
|
|
22
|
+
this.offset += bytes;
|
|
23
|
+
return dataView;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
skip(bytes) {
|
|
27
|
+
this.offset += bytes;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
rewind(bytes) {
|
|
31
|
+
this.offset -= bytes;
|
|
32
|
+
}
|
|
33
|
+
|
|
51
34
|
}
|
|
52
|
-
|
|
35
|
+
//# sourceMappingURL=binary-reader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/streaming/binary-reader.ts"],"names":["BinaryReader","constructor","arrayBuffer","offset","hasAvailableBytes","bytes","byteLength","getDataView","Error","dataView","DataView","skip","rewind"],"mappings":";AAAA,eAAe,MAAMA,YAAN,CAAmB;AAIhCC,EAAAA,WAAW,CAACC,WAAD,EAA2B;AAAA;;AAAA;;AAEpC,SAAKC,MAAL,GAAc,CAAd;AAEA,SAAKD,WAAL,GAAmBA,WAAnB;AACD;;AAODE,EAAAA,iBAAiB,CAACC,KAAD,EAAyB;AACxC,WAAO,KAAKH,WAAL,CAAiBI,UAAjB,GAA8B,KAAKH,MAAnC,IAA6CE,KAApD;AACD;;AAQDE,EAAAA,WAAW,CAACF,KAAD,EAA0B;AACnC,QAAIA,KAAK,IAAI,CAAC,KAAKD,iBAAL,CAAuBC,KAAvB,CAAd,EAA6C;AAC3C,YAAM,IAAIG,KAAJ,CAAU,uBAAV,CAAN;AACD;;AAED,UAAMC,QAAQ,GAAGJ,KAAK,GAClB,IAAIK,QAAJ,CAAa,KAAKR,WAAlB,EAA+B,KAAKC,MAApC,EAA4CE,KAA5C,CADkB,GAElB,IAAIK,QAAJ,CAAa,KAAKR,WAAlB,EAA+B,KAAKC,MAApC,CAFJ;AAGA,SAAKA,MAAL,IAAeE,KAAf;AACA,WAAOI,QAAP;AACD;;AAODE,EAAAA,IAAI,CAACN,KAAD,EAAsB;AACxB,SAAKF,MAAL,IAAeE,KAAf;AACD;;AAODO,EAAAA,MAAM,CAACP,KAAD,EAAsB;AAC1B,SAAKF,MAAL,IAAeE,KAAf;AACD;;AAtD+B","sourcesContent":["export default class BinaryReader {\n offset: number;\n arrayBuffer: ArrayBuffer;\n\n constructor(arrayBuffer: ArrayBuffer) {\n /** current global (stream) offset */\n this.offset = 0;\n /** current buffer from iterator */\n this.arrayBuffer = arrayBuffer;\n }\n /**\n * Checks if there are available bytes in data\n *\n * @param bytes\n * @returns boolean\n */\n hasAvailableBytes(bytes: number): boolean {\n return this.arrayBuffer.byteLength - this.offset >= bytes;\n }\n\n /**\n * Get the required number of bytes from the iterator\n *\n * @param bytes\n * @returns Dataview\n */\n getDataView(bytes: number): DataView {\n if (bytes && !this.hasAvailableBytes(bytes)) {\n throw new Error('binary data exhausted');\n }\n\n const dataView = bytes\n ? new DataView(this.arrayBuffer, this.offset, bytes)\n : new DataView(this.arrayBuffer, this.offset);\n this.offset += bytes;\n return dataView;\n }\n\n /**\n * Skipping\n *\n * @param bytes\n */\n skip(bytes: number): void {\n this.offset += bytes;\n }\n\n /**\n * Rewinding\n *\n * @param bytes\n */\n rewind(bytes: number): void {\n this.offset -= bytes;\n }\n}\n"],"file":"binary-reader.js"}
|
|
@@ -1,61 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
iterator2Done = true;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
batch2 = value;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const batch = extractBatch(batch1, batch2);
|
|
37
|
-
if (batch) {
|
|
38
|
-
yield batch;
|
|
39
|
-
}
|
|
1
|
+
export async function* zipBatchIterators(iterator1, iterator2) {
|
|
2
|
+
let batch1 = [];
|
|
3
|
+
let batch2 = [];
|
|
4
|
+
let iterator1Done = false;
|
|
5
|
+
let iterator2Done = false;
|
|
6
|
+
|
|
7
|
+
while (!iterator1Done && !iterator2Done) {
|
|
8
|
+
if (batch1.length === 0 && !iterator1Done) {
|
|
9
|
+
const {
|
|
10
|
+
value,
|
|
11
|
+
done
|
|
12
|
+
} = await iterator1.next();
|
|
13
|
+
|
|
14
|
+
if (done) {
|
|
15
|
+
iterator1Done = true;
|
|
16
|
+
} else {
|
|
17
|
+
batch1 = value;
|
|
18
|
+
}
|
|
19
|
+
} else if (batch2.length === 0 && !iterator2Done) {
|
|
20
|
+
const {
|
|
21
|
+
value,
|
|
22
|
+
done
|
|
23
|
+
} = await iterator2.next();
|
|
24
|
+
|
|
25
|
+
if (done) {
|
|
26
|
+
iterator2Done = true;
|
|
27
|
+
} else {
|
|
28
|
+
batch2 = value;
|
|
29
|
+
}
|
|
40
30
|
}
|
|
31
|
+
|
|
32
|
+
const batch = extractBatch(batch1, batch2);
|
|
33
|
+
|
|
34
|
+
if (batch) {
|
|
35
|
+
yield batch;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Extract batch of same length from two batches
|
|
45
|
-
*
|
|
46
|
-
* @param batch1
|
|
47
|
-
* @param batch2
|
|
48
|
-
* @return array | null
|
|
49
|
-
*/
|
|
39
|
+
|
|
50
40
|
function extractBatch(batch1, batch2) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
const batchLength = Math.min(batch1.length, batch2.length);
|
|
42
|
+
|
|
43
|
+
if (batchLength === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const batch = [batch1.slice(0, batchLength), batch2.slice(0, batchLength)];
|
|
48
|
+
batch1.splice(0, batchLength);
|
|
49
|
+
batch2.splice(0, batchLength);
|
|
50
|
+
return batch;
|
|
61
51
|
}
|
|
52
|
+
//# sourceMappingURL=zip-batch-iterators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/streaming/zip-batch-iterators.ts"],"names":["zipBatchIterators","iterator1","iterator2","batch1","batch2","iterator1Done","iterator2Done","length","value","done","next","batch","extractBatch","batchLength","Math","min","slice","splice"],"mappings":"AAMA,OAAO,gBAAgBA,iBAAhB,CACLC,SADK,EAELC,SAFK,EAGsC;AAC3C,MAAIC,MAAM,GAAG,EAAb;AACA,MAAIC,MAAM,GAAG,EAAb;AACA,MAAIC,aAAsB,GAAG,KAA7B;AACA,MAAIC,aAAsB,GAAG,KAA7B;;AAIA,SAAO,CAACD,aAAD,IAAkB,CAACC,aAA1B,EAAyC;AACvC,QAAIH,MAAM,CAACI,MAAP,KAAkB,CAAlB,IAAuB,CAACF,aAA5B,EAA2C;AACzC,YAAM;AAACG,QAAAA,KAAD;AAAQC,QAAAA;AAAR,UAAgB,MAAMR,SAAS,CAACS,IAAV,EAA5B;;AACA,UAAID,IAAJ,EAAU;AACRJ,QAAAA,aAAa,GAAG,IAAhB;AACD,OAFD,MAEO;AACLF,QAAAA,MAAM,GAAGK,KAAT;AACD;AACF,KAPD,MAOO,IAAIJ,MAAM,CAACG,MAAP,KAAkB,CAAlB,IAAuB,CAACD,aAA5B,EAA2C;AAChD,YAAM;AAACE,QAAAA,KAAD;AAAQC,QAAAA;AAAR,UAAgB,MAAMP,SAAS,CAACQ,IAAV,EAA5B;;AACA,UAAID,IAAJ,EAAU;AACRH,QAAAA,aAAa,GAAG,IAAhB;AACD,OAFD,MAEO;AACLF,QAAAA,MAAM,GAAGI,KAAT;AACD;AACF;;AAED,UAAMG,KAAK,GAAGC,YAAY,CAACT,MAAD,EAASC,MAAT,CAA1B;;AACA,QAAIO,KAAJ,EAAW;AACT,YAAMA,KAAN;AACD;AACF;AACF;;AASD,SAASC,YAAT,CAAsBT,MAAtB,EAAwCC,MAAxC,EAA6E;AAC3E,QAAMS,WAAmB,GAAGC,IAAI,CAACC,GAAL,CAASZ,MAAM,CAACI,MAAhB,EAAwBH,MAAM,CAACG,MAA/B,CAA5B;;AACA,MAAIM,WAAW,KAAK,CAApB,EAAuB;AACrB,WAAO,IAAP;AACD;;AAGD,QAAMF,KAAiB,GAAG,CAACR,MAAM,CAACa,KAAP,CAAa,CAAb,EAAgBH,WAAhB,CAAD,EAA+BT,MAAM,CAACY,KAAP,CAAa,CAAb,EAAgBH,WAAhB,CAA/B,CAA1B;AAGAV,EAAAA,MAAM,CAACc,MAAP,CAAc,CAAd,EAAiBJ,WAAjB;AACAT,EAAAA,MAAM,CAACa,MAAP,CAAc,CAAd,EAAiBJ,WAAjB;AACA,SAAOF,KAAP;AACD","sourcesContent":["/**\n * Zip two iterators together\n *\n * @param iterator1\n * @param iterator2\n */\nexport async function* zipBatchIterators(\n iterator1: AsyncIterator<any[]>,\n iterator2: AsyncIterator<any[]>\n): AsyncGenerator<number[][], void, unknown> {\n let batch1 = [];\n let batch2 = [];\n let iterator1Done: boolean = false;\n let iterator2Done: boolean = false;\n\n // TODO - one could let all iterators flow at full speed using `Promise.race`\n // however we might end up with a big temporary buffer\n while (!iterator1Done && !iterator2Done) {\n if (batch1.length === 0 && !iterator1Done) {\n const {value, done} = await iterator1.next();\n if (done) {\n iterator1Done = true;\n } else {\n batch1 = value;\n }\n } else if (batch2.length === 0 && !iterator2Done) {\n const {value, done} = await iterator2.next();\n if (done) {\n iterator2Done = true;\n } else {\n batch2 = value;\n }\n }\n\n const batch = extractBatch(batch1, batch2);\n if (batch) {\n yield batch;\n }\n }\n}\n\n/**\n * Extract batch of same length from two batches\n *\n * @param batch1\n * @param batch2\n * @return array | null\n */\nfunction extractBatch(batch1: number[], batch2: number[]): number[][] | null {\n const batchLength: number = Math.min(batch1.length, batch2.length);\n if (batchLength === 0) {\n return null;\n }\n\n // Non interleaved arrays\n const batch: number[][] = [batch1.slice(0, batchLength), batch2.slice(0, batchLength)];\n\n // Modify the 2 batches\n batch1.splice(0, batchLength);\n batch2.splice(0, batchLength);\n return batch;\n}\n"],"file":"zip-batch-iterators.js"}
|
package/dist/shapefile-loader.js
CHANGED
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
tests: [new Uint8Array(shp_loader_1.SHP_MAGIC_NUMBER).buffer],
|
|
22
|
-
options: {
|
|
23
|
-
shapefile: {},
|
|
24
|
-
shp: {
|
|
25
|
-
_maxDimensions: 4
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
parse: parse_shapefile_1.parseShapefile,
|
|
29
|
-
parseInBatches: parse_shapefile_1.parseShapefileInBatches
|
|
1
|
+
import { SHP_MAGIC_NUMBER } from './shp-loader';
|
|
2
|
+
import { parseShapefile, parseShapefileInBatches } from './lib/parsers/parse-shapefile';
|
|
3
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
4
|
+
export const ShapefileLoader = {
|
|
5
|
+
name: 'Shapefile',
|
|
6
|
+
id: 'shapefile',
|
|
7
|
+
module: 'shapefile',
|
|
8
|
+
version: VERSION,
|
|
9
|
+
category: 'geometry',
|
|
10
|
+
extensions: ['shp'],
|
|
11
|
+
mimeTypes: ['application/octet-stream'],
|
|
12
|
+
tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],
|
|
13
|
+
options: {
|
|
14
|
+
shapefile: {},
|
|
15
|
+
shp: {
|
|
16
|
+
_maxDimensions: 4
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
parse: parseShapefile,
|
|
20
|
+
parseInBatches: parseShapefileInBatches
|
|
30
21
|
};
|
|
31
|
-
|
|
22
|
+
export const _typecheckShapefileLoader = ShapefileLoader;
|
|
23
|
+
//# sourceMappingURL=shapefile-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shapefile-loader.ts"],"names":["SHP_MAGIC_NUMBER","parseShapefile","parseShapefileInBatches","VERSION","ShapefileLoader","name","id","module","version","category","extensions","mimeTypes","tests","Uint8Array","buffer","options","shapefile","shp","_maxDimensions","parse","parseInBatches","_typecheckShapefileLoader"],"mappings":"AACA,SAAQA,gBAAR,QAA+B,cAA/B;AACA,SAAQC,cAAR,EAAwBC,uBAAxB,QAAsD,+BAAtD;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAMA,OAAO,MAAMC,eAAe,GAAG;AAC7BC,EAAAA,IAAI,EAAE,WADuB;AAE7BC,EAAAA,EAAE,EAAE,WAFyB;AAG7BC,EAAAA,MAAM,EAAE,WAHqB;AAI7BC,EAAAA,OAAO,EAAEL,OAJoB;AAK7BM,EAAAA,QAAQ,EAAE,UALmB;AAM7BC,EAAAA,UAAU,EAAE,CAAC,KAAD,CANiB;AAO7BC,EAAAA,SAAS,EAAE,CAAC,0BAAD,CAPkB;AAQ7BC,EAAAA,KAAK,EAAE,CAAC,IAAIC,UAAJ,CAAeb,gBAAf,EAAiCc,MAAlC,CARsB;AAS7BC,EAAAA,OAAO,EAAE;AACPC,IAAAA,SAAS,EAAE,EADJ;AAEPC,IAAAA,GAAG,EAAE;AACHC,MAAAA,cAAc,EAAE;AADb;AAFE,GAToB;AAe7BC,EAAAA,KAAK,EAAElB,cAfsB;AAgB7BmB,EAAAA,cAAc,EAAElB;AAhBa,CAAxB;AAmBP,OAAO,MAAMmB,yBAA2C,GAAGjB,eAApD","sourcesContent":["import type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport {SHP_MAGIC_NUMBER} from './shp-loader';\nimport {parseShapefile, parseShapefileInBatches} from './lib/parsers/parse-shapefile';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * Shapefile loader\n * @note Shapefile is multifile format and requires providing additional files\n */\nexport const ShapefileLoader = {\n name: 'Shapefile',\n id: 'shapefile',\n module: 'shapefile',\n version: VERSION,\n category: 'geometry',\n extensions: ['shp'],\n mimeTypes: ['application/octet-stream'],\n tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],\n options: {\n shapefile: {},\n shp: {\n _maxDimensions: 4\n }\n },\n parse: parseShapefile,\n parseInBatches: parseShapefileInBatches\n};\n\nexport const _typecheckShapefileLoader: LoaderWithParser = ShapefileLoader;\n"],"file":"shapefile-loader.js"}
|
package/dist/shp-loader.js
CHANGED
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
worker: true,
|
|
18
|
-
category: 'geometry',
|
|
19
|
-
extensions: ['shp'],
|
|
20
|
-
mimeTypes: ['application/octet-stream'],
|
|
21
|
-
// ISSUE: This also identifies SHX files, which are identical to SHP for the first 100 bytes...
|
|
22
|
-
tests: [new Uint8Array(exports.SHP_MAGIC_NUMBER).buffer],
|
|
23
|
-
options: {
|
|
24
|
-
shp: {
|
|
25
|
-
_maxDimensions: 4
|
|
26
|
-
}
|
|
1
|
+
import { parseSHP, parseSHPInBatches } from './lib/parsers/parse-shp';
|
|
2
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
3
|
+
export const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];
|
|
4
|
+
export const SHPWorkerLoader = {
|
|
5
|
+
name: 'SHP',
|
|
6
|
+
id: 'shp',
|
|
7
|
+
module: 'shapefile',
|
|
8
|
+
version: VERSION,
|
|
9
|
+
worker: true,
|
|
10
|
+
category: 'geometry',
|
|
11
|
+
extensions: ['shp'],
|
|
12
|
+
mimeTypes: ['application/octet-stream'],
|
|
13
|
+
tests: [new Uint8Array(SHP_MAGIC_NUMBER).buffer],
|
|
14
|
+
options: {
|
|
15
|
+
shp: {
|
|
16
|
+
_maxDimensions: 4
|
|
27
17
|
}
|
|
18
|
+
}
|
|
28
19
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
parseSync: parse_shp_1.parseSHP,
|
|
34
|
-
parseInBatches: parse_shp_1.parseSHPInBatches
|
|
20
|
+
export const SHPLoader = { ...SHPWorkerLoader,
|
|
21
|
+
parse: async (arrayBuffer, options) => parseSHP(arrayBuffer, options),
|
|
22
|
+
parseSync: parseSHP,
|
|
23
|
+
parseInBatches: parseSHPInBatches
|
|
35
24
|
};
|
|
25
|
+
//# sourceMappingURL=shp-loader.js.map
|