@stampgis/webrtc 1.0.2 → 1.0.3
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/README.md +15 -9
- package/assets/config/stamp_core_config.js +25 -7
- package/dist/index.cjs +156 -23
- package/dist/index.d.mts +310 -17
- package/dist/index.d.ts +310 -17
- package/dist/index.js +156 -23
- package/package.json +1 -1
- package/assets/core/EmergencyPlotting.symlib +0 -0
- package/assets/core/default.symlib +0 -0
- package/assets/core/gbk.js +0 -201
- package/assets/core/shapefile.js +0 -509
- package/assets/core/spark-md5.min.js +0 -1
- package/assets/core/widgetConfig.js +0 -307
- package/assets/core/worker.js +0 -24
- package/assets/core/workerEx.js +0 -24
package/assets/core/shapefile.js
DELETED
|
@@ -1,509 +0,0 @@
|
|
|
1
|
-
// https://github.com/mbostock/shapefile Version 0.6.6. Copyright 2017 Mike Bostock.
|
|
2
|
-
(function (global, factory) {
|
|
3
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
4
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
5
|
-
(factory((global.shapefile = {})));
|
|
6
|
-
}(this, (function (exports) { 'use strict';
|
|
7
|
-
|
|
8
|
-
var array_cancel = function() {
|
|
9
|
-
this._array = null;
|
|
10
|
-
return Promise.resolve();
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
var array_read = function() {
|
|
14
|
-
var array = this._array;
|
|
15
|
-
this._array = null;
|
|
16
|
-
return Promise.resolve(array ? {done: false, value: array} : {done: true, value: undefined});
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function array(array) {
|
|
20
|
-
return new ArraySource(array instanceof Uint8Array ? array : new Uint8Array(array));
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function ArraySource(array) {
|
|
24
|
-
this._array = array;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
ArraySource.prototype.read = array_read;
|
|
28
|
-
ArraySource.prototype.cancel = array_cancel;
|
|
29
|
-
|
|
30
|
-
var fetchPath = function(url) {
|
|
31
|
-
return fetch(url).then(function(response) {
|
|
32
|
-
return response.body && response.body.getReader
|
|
33
|
-
? response.body.getReader()
|
|
34
|
-
: response.arrayBuffer().then(array);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
var requestPath = function(url) {
|
|
39
|
-
return new Promise(function(resolve, reject) {
|
|
40
|
-
var request = new XMLHttpRequest;
|
|
41
|
-
request.responseType = "arraybuffer";
|
|
42
|
-
request.onload = function() { resolve(array(request.response)); };
|
|
43
|
-
request.onerror = reject;
|
|
44
|
-
request.ontimeout = reject;
|
|
45
|
-
request.open("GET", url, true);
|
|
46
|
-
request.send();
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
function path(path) {
|
|
51
|
-
return (typeof fetch === "function" ? fetchPath : requestPath)(path);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function stream(source) {
|
|
55
|
-
return typeof source.read === "function" ? source : source.getReader();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var empty = new Uint8Array(0);
|
|
59
|
-
|
|
60
|
-
var slice_cancel = function() {
|
|
61
|
-
return this._source.cancel();
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function concat(a, b) {
|
|
65
|
-
if (!a.length) return b;
|
|
66
|
-
if (!b.length) return a;
|
|
67
|
-
var c = new Uint8Array(a.length + b.length);
|
|
68
|
-
c.set(a);
|
|
69
|
-
c.set(b, a.length);
|
|
70
|
-
return c;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
var slice_read = function() {
|
|
74
|
-
var that = this, array = that._array.subarray(that._index);
|
|
75
|
-
return that._source.read().then(function(result) {
|
|
76
|
-
that._array = empty;
|
|
77
|
-
that._index = 0;
|
|
78
|
-
return result.done ? (array.length > 0
|
|
79
|
-
? {done: false, value: array}
|
|
80
|
-
: {done: true, value: undefined})
|
|
81
|
-
: {done: false, value: concat(array, result.value)};
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
var slice_slice = function(length) {
|
|
86
|
-
if ((length |= 0) < 0) throw new Error("invalid length");
|
|
87
|
-
var that = this, index = this._array.length - this._index;
|
|
88
|
-
|
|
89
|
-
// If the request fits within the remaining buffer, resolve it immediately.
|
|
90
|
-
if (this._index + length <= this._array.length) {
|
|
91
|
-
return Promise.resolve(this._array.subarray(this._index, this._index += length));
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// Otherwise, read chunks repeatedly until the request is fulfilled.
|
|
95
|
-
var array = new Uint8Array(length);
|
|
96
|
-
array.set(this._array.subarray(this._index));
|
|
97
|
-
return (function read() {
|
|
98
|
-
return that._source.read().then(function(result) {
|
|
99
|
-
|
|
100
|
-
// When done, it’s possible the request wasn’t fully fullfilled!
|
|
101
|
-
// If so, the pre-allocated array is too big and needs slicing.
|
|
102
|
-
if (result.done) {
|
|
103
|
-
that._array = empty;
|
|
104
|
-
that._index = 0;
|
|
105
|
-
return index > 0 ? array.subarray(0, index) : null;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// If this chunk fulfills the request, return the resulting array.
|
|
109
|
-
if (index + result.value.length >= length) {
|
|
110
|
-
that._array = result.value;
|
|
111
|
-
that._index = length - index;
|
|
112
|
-
array.set(result.value.subarray(0, length - index), index);
|
|
113
|
-
return array;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Otherwise copy this chunk into the array, then read the next chunk.
|
|
117
|
-
array.set(result.value, index);
|
|
118
|
-
index += result.value.length;
|
|
119
|
-
return read();
|
|
120
|
-
});
|
|
121
|
-
})();
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
function slice(source) {
|
|
125
|
-
return typeof source.slice === "function" ? source :
|
|
126
|
-
new SliceSource(typeof source.read === "function" ? source
|
|
127
|
-
: source.getReader());
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function SliceSource(source) {
|
|
131
|
-
this._source = source;
|
|
132
|
-
this._array = empty;
|
|
133
|
-
this._index = 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
SliceSource.prototype.read = slice_read;
|
|
137
|
-
SliceSource.prototype.slice = slice_slice;
|
|
138
|
-
SliceSource.prototype.cancel = slice_cancel;
|
|
139
|
-
|
|
140
|
-
var dbf_cancel = function() {
|
|
141
|
-
return this._source.cancel();
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
var readBoolean = function(value) {
|
|
145
|
-
return /^[nf]$/i.test(value) ? false
|
|
146
|
-
: /^[yt]$/i.test(value) ? true
|
|
147
|
-
: null;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
var readDate = function(value) {
|
|
151
|
-
return new Date(+value.substring(0, 4), value.substring(4, 6) - 1, +value.substring(6, 8));
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
var readNumber = function(value) {
|
|
155
|
-
return !(value = value.trim()) || isNaN(value = +value) ? null : value;
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
var readString = function(value) {
|
|
159
|
-
return value.trim() || null;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
var types = {
|
|
163
|
-
B: readNumber,
|
|
164
|
-
C: readString,
|
|
165
|
-
D: readDate,
|
|
166
|
-
F: readNumber,
|
|
167
|
-
L: readBoolean,
|
|
168
|
-
M: readNumber,
|
|
169
|
-
N: readNumber
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
var dbf_read = function() {
|
|
173
|
-
var that = this, i = 1;
|
|
174
|
-
return that._source.slice(that._recordLength).then(function(value) {
|
|
175
|
-
return value && (value[0] !== 0x1a) ? {done: false, value: that._fields.reduce(function(p, f) {
|
|
176
|
-
p[f.name] = types[f.type](that._decode(value.subarray(i, i += f.length)));
|
|
177
|
-
return p;
|
|
178
|
-
}, {}), fields: that._fields} : {done: true, value: undefined};
|
|
179
|
-
});
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
var view = function(array) {
|
|
183
|
-
return new DataView(array.buffer, array.byteOffset, array.byteLength);
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
var dbf = function(source, decoder) {
|
|
187
|
-
source = slice(source);
|
|
188
|
-
return source.slice(32).then(function(array) {
|
|
189
|
-
var head = view(array);
|
|
190
|
-
return source.slice(head.getUint16(8, true) - 32).then(function(array) {
|
|
191
|
-
return new Dbf(source, decoder, head, view(array));
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
function Dbf(source, decoder, head, body) {
|
|
197
|
-
this._source = source;
|
|
198
|
-
this._decode = decoder.decode.bind(decoder);
|
|
199
|
-
this._recordLength = head.getUint16(10, true);
|
|
200
|
-
this._fields = [];
|
|
201
|
-
for (var n = 0; body.getUint8(n) !== 0x0d; n += 32) {
|
|
202
|
-
for (var j = 0; j < 11; ++j) if (body.getUint8(n + j) === 0) break;
|
|
203
|
-
this._fields.push({
|
|
204
|
-
name: this._decode(new Uint8Array(body.buffer, body.byteOffset + n, j)),
|
|
205
|
-
type: String.fromCharCode(body.getUint8(n + 11)),
|
|
206
|
-
length: body.getUint8(n + 16),
|
|
207
|
-
precision: body.getUint8(n + 17),
|
|
208
|
-
});
|
|
209
|
-
if (this._fields[this._fields.length - 1].precision > 0 && this._fields[this._fields.length - 1].type == "N") {
|
|
210
|
-
this._fields[this._fields.length - 1].type = "F";
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
var prototype = Dbf.prototype;
|
|
216
|
-
prototype.read = dbf_read;
|
|
217
|
-
prototype.cancel = dbf_cancel;
|
|
218
|
-
|
|
219
|
-
function cancel() {
|
|
220
|
-
return this._source.cancel();
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
var parseMultiPoint = function(record) {
|
|
224
|
-
var i = 40, j, n = record.getInt32(36, true), coordinates = new Array(n);
|
|
225
|
-
for (j = 0; j < n; ++j, i += 16) coordinates[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
|
|
226
|
-
return {type: "MultiPoint", coordinates: coordinates};
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
var parseNull = function() {
|
|
230
|
-
return null;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
var parsePoint = function(record) {
|
|
234
|
-
return {type: "Point", coordinates: [record.getFloat64(4, true), record.getFloat64(12, true)]};
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
var parsePolygon = function(record) {
|
|
238
|
-
var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m), polygons = [], holes = [];
|
|
239
|
-
for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true);
|
|
240
|
-
for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
|
|
241
|
-
|
|
242
|
-
parts.forEach(function(i, j) {
|
|
243
|
-
var ring = points.slice(i, parts[j + 1]);
|
|
244
|
-
if (ringClockwise(ring)) polygons.push([ring]);
|
|
245
|
-
else holes.push(ring);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
holes.forEach(function(hole) {
|
|
249
|
-
polygons.some(function(polygon) {
|
|
250
|
-
if (ringContainsSome(polygon[0], hole)) {
|
|
251
|
-
polygon.push(hole);
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
}) || polygons.push([hole]);
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
return polygons.length === 1
|
|
258
|
-
? {type: "Polygon", coordinates: polygons[0]}
|
|
259
|
-
: {type: "MultiPolygon", coordinates: polygons};
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
function ringClockwise(ring) {
|
|
263
|
-
if ((n = ring.length) < 4) return false;
|
|
264
|
-
var i = 0, n, area = ring[n - 1][1] * ring[0][0] - ring[n - 1][0] * ring[0][1];
|
|
265
|
-
while (++i < n) area += ring[i - 1][1] * ring[i][0] - ring[i - 1][0] * ring[i][1];
|
|
266
|
-
return area >= 0;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
function ringContainsSome(ring, hole) {
|
|
270
|
-
var i = -1, n = hole.length, c;
|
|
271
|
-
while (++i < n) {
|
|
272
|
-
if (c = ringContains(ring, hole[i])) {
|
|
273
|
-
return c > 0;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
function ringContains(ring, point) {
|
|
280
|
-
var x = point[0], y = point[1], contains = -1;
|
|
281
|
-
for (var i = 0, n = ring.length, j = n - 1; i < n; j = i++) {
|
|
282
|
-
var pi = ring[i], xi = pi[0], yi = pi[1],
|
|
283
|
-
pj = ring[j], xj = pj[0], yj = pj[1];
|
|
284
|
-
if (segmentContains(pi, pj, point)) {
|
|
285
|
-
return 0;
|
|
286
|
-
}
|
|
287
|
-
if (((yi > y) !== (yj > y)) && ((x < (xj - xi) * (y - yi) / (yj - yi) + xi))) {
|
|
288
|
-
contains = -contains;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return contains;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function segmentContains(p0, p1, p2) {
|
|
295
|
-
var x20 = p2[0] - p0[0], y20 = p2[1] - p0[1];
|
|
296
|
-
if (x20 === 0 && y20 === 0) return true;
|
|
297
|
-
var x10 = p1[0] - p0[0], y10 = p1[1] - p0[1];
|
|
298
|
-
if (x10 === 0 && y10 === 0) return false;
|
|
299
|
-
var t = (x20 * x10 + y20 * y10) / (x10 * x10 + y10 * y10);
|
|
300
|
-
return t < 0 || t > 1 ? false : t === 0 || t === 1 ? true : t * x10 === x20 && t * y10 === y20;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
var parsePolyLine = function(record) {
|
|
304
|
-
var i = 44, j, n = record.getInt32(36, true), m = record.getInt32(40, true), parts = new Array(n), points = new Array(m);
|
|
305
|
-
for (j = 0; j < n; ++j, i += 4) parts[j] = record.getInt32(i, true);
|
|
306
|
-
for (j = 0; j < m; ++j, i += 16) points[j] = [record.getFloat64(i, true), record.getFloat64(i + 8, true)];
|
|
307
|
-
return n === 1
|
|
308
|
-
? {type: "LineString", coordinates: points}
|
|
309
|
-
: {type: "MultiLineString", coordinates: parts.map(function(i, j) { return points.slice(i, parts[j + 1]); })};
|
|
310
|
-
};
|
|
311
|
-
|
|
312
|
-
var concat$1 = function(a, b) {
|
|
313
|
-
var ab = new Uint8Array(a.length + b.length);
|
|
314
|
-
ab.set(a, 0);
|
|
315
|
-
ab.set(b, a.length);
|
|
316
|
-
return ab;
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
var shp_read = function() {
|
|
320
|
-
var that = this;
|
|
321
|
-
++that._index;
|
|
322
|
-
return that._source.slice(12).then(function(array) {
|
|
323
|
-
if (array == null) return {done: true, value: undefined};
|
|
324
|
-
var header = view(array);
|
|
325
|
-
|
|
326
|
-
// If the record starts with an invalid shape type (see #36), scan ahead in
|
|
327
|
-
// four-byte increments to find the next valid record, identified by the
|
|
328
|
-
// expected index, a non-empty content length and a valid shape type.
|
|
329
|
-
function skip() {
|
|
330
|
-
return that._source.slice(4).then(function(chunk) {
|
|
331
|
-
if (chunk == null) return {done: true, value: undefined};
|
|
332
|
-
header = view(array = concat$1(array.slice(4), chunk));
|
|
333
|
-
return header.getInt32(0, false) !== that._index ? skip() : read();
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// All records should have at least four bytes (for the record shape type),
|
|
338
|
-
// so an invalid content length indicates corruption.
|
|
339
|
-
function read() {
|
|
340
|
-
var length = header.getInt32(4, false) * 2 - 4, type = header.getInt32(8, true);
|
|
341
|
-
return length < 0 || (type && type !== that._type) ? skip() : that._source.slice(length).then(function(chunk) {
|
|
342
|
-
return {done: false, value: type ? that._parse(view(concat$1(array.slice(8), chunk))) : null};
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return read();
|
|
347
|
-
});
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
var parsers = {
|
|
351
|
-
0: parseNull,
|
|
352
|
-
1: parsePoint,
|
|
353
|
-
3: parsePolyLine,
|
|
354
|
-
5: parsePolygon,
|
|
355
|
-
8: parseMultiPoint,
|
|
356
|
-
11: parsePoint, // PointZ
|
|
357
|
-
13: parsePolyLine, // PolyLineZ
|
|
358
|
-
15: parsePolygon, // PolygonZ
|
|
359
|
-
18: parseMultiPoint, // MultiPointZ
|
|
360
|
-
21: parsePoint, // PointM
|
|
361
|
-
23: parsePolyLine, // PolyLineM
|
|
362
|
-
25: parsePolygon, // PolygonM
|
|
363
|
-
28: parseMultiPoint // MultiPointM
|
|
364
|
-
};
|
|
365
|
-
|
|
366
|
-
var shp = function(source) {
|
|
367
|
-
source = slice(source);
|
|
368
|
-
return source.slice(100).then(function(array) {
|
|
369
|
-
return new Shp(source, view(array));
|
|
370
|
-
});
|
|
371
|
-
};
|
|
372
|
-
|
|
373
|
-
function Shp(source, header) {
|
|
374
|
-
var type = header.getInt32(32, true);
|
|
375
|
-
if (!(type in parsers)) throw new Error("unsupported shape type: " + type);
|
|
376
|
-
this._source = source;
|
|
377
|
-
this._type = type;
|
|
378
|
-
this._index = 0;
|
|
379
|
-
this._parse = parsers[type];
|
|
380
|
-
this.bbox = [header.getFloat64(36, true), header.getFloat64(44, true), header.getFloat64(52, true), header.getFloat64(60, true)];
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
var prototype$2 = Shp.prototype;
|
|
384
|
-
prototype$2.read = shp_read;
|
|
385
|
-
prototype$2.cancel = cancel;
|
|
386
|
-
|
|
387
|
-
function noop() {}
|
|
388
|
-
|
|
389
|
-
var shapefile_cancel = function() {
|
|
390
|
-
return Promise.all([
|
|
391
|
-
this._dbf && this._dbf.cancel(),
|
|
392
|
-
this._shp.cancel()
|
|
393
|
-
]).then(noop);
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
var shapefile_read = function() {
|
|
397
|
-
var that = this;
|
|
398
|
-
return Promise.all([
|
|
399
|
-
that._dbf ? that._dbf.read() : {value: {}},
|
|
400
|
-
that._dbf ? that._dbf._fields : undefined,
|
|
401
|
-
that._shp.read(),
|
|
402
|
-
that._shp.bbox,
|
|
403
|
-
]).then(function(results) {
|
|
404
|
-
var dbf = results[0], fields = results[1], shp = results[2];
|
|
405
|
-
return shp.done ? shp : {
|
|
406
|
-
done: false,
|
|
407
|
-
value: {
|
|
408
|
-
type: "Feature",
|
|
409
|
-
properties: dbf.value,
|
|
410
|
-
geometry: shp.value,
|
|
411
|
-
fields : fields,
|
|
412
|
-
bbox : results[3],
|
|
413
|
-
}
|
|
414
|
-
};
|
|
415
|
-
});
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
var shapefile = function(shpSource, dbfSource, decoder) {
|
|
419
|
-
return Promise.all([
|
|
420
|
-
shp(shpSource),
|
|
421
|
-
dbfSource && dbf(dbfSource, decoder)
|
|
422
|
-
]).then(function(sources) {
|
|
423
|
-
return new Shapefile(sources[0], sources[1]);
|
|
424
|
-
});
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
function Shapefile(shp$$1, dbf$$1) {
|
|
428
|
-
this._shp = shp$$1;
|
|
429
|
-
this._dbf = dbf$$1;
|
|
430
|
-
this.bbox = shp$$1.bbox;
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
var prototype$1 = Shapefile.prototype;
|
|
434
|
-
prototype$1.read = shapefile_read;
|
|
435
|
-
prototype$1.cancel = shapefile_cancel;
|
|
436
|
-
|
|
437
|
-
function open(shp$$1, dbf$$1, options) {
|
|
438
|
-
if (typeof dbf$$1 === "string") {
|
|
439
|
-
if (!/\.dbf$/.test(dbf$$1)) dbf$$1 += ".dbf";
|
|
440
|
-
dbf$$1 = path(dbf$$1, options);
|
|
441
|
-
} else if (dbf$$1 instanceof ArrayBuffer || dbf$$1 instanceof Uint8Array) {
|
|
442
|
-
dbf$$1 = array(dbf$$1);
|
|
443
|
-
} else if (dbf$$1 != null) {
|
|
444
|
-
dbf$$1 = stream(dbf$$1);
|
|
445
|
-
}
|
|
446
|
-
if (typeof shp$$1 === "string") {
|
|
447
|
-
if (!/\.shp$/.test(shp$$1)) shp$$1 += ".shp";
|
|
448
|
-
if (dbf$$1 === undefined) dbf$$1 = path(shp$$1.substring(0, shp$$1.length - 4) + ".dbf", options).catch(function() {});
|
|
449
|
-
shp$$1 = path(shp$$1, options);
|
|
450
|
-
} else if (shp$$1 instanceof ArrayBuffer || shp$$1 instanceof Uint8Array) {
|
|
451
|
-
shp$$1 = array(shp$$1);
|
|
452
|
-
} else {
|
|
453
|
-
shp$$1 = stream(shp$$1);
|
|
454
|
-
}
|
|
455
|
-
return Promise.all([shp$$1, dbf$$1]).then(function(sources) {
|
|
456
|
-
var shp$$1 = sources[0], dbf$$1 = sources[1], encoding = "windows-1252";
|
|
457
|
-
if (options && options.encoding != null) encoding = options.encoding;
|
|
458
|
-
return shapefile(shp$$1, dbf$$1, dbf$$1 && new TextDecoder(encoding));
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function openShp(source, options) {
|
|
463
|
-
if (typeof source === "string") {
|
|
464
|
-
if (!/\.shp$/.test(source)) source += ".shp";
|
|
465
|
-
source = path(source, options);
|
|
466
|
-
} else if (source instanceof ArrayBuffer || source instanceof Uint8Array) {
|
|
467
|
-
source = array(source);
|
|
468
|
-
} else {
|
|
469
|
-
source = stream(source);
|
|
470
|
-
}
|
|
471
|
-
return Promise.resolve(source).then(shp);
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function openDbf(source, options) {
|
|
475
|
-
var encoding = "windows-1252";
|
|
476
|
-
if (options && options.encoding != null) encoding = options.encoding;
|
|
477
|
-
encoding = new TextDecoder(encoding);
|
|
478
|
-
if (typeof source === "string") {
|
|
479
|
-
if (!/\.dbf$/.test(source)) source += ".dbf";
|
|
480
|
-
source = path(source, options);
|
|
481
|
-
} else if (source instanceof ArrayBuffer || source instanceof Uint8Array) {
|
|
482
|
-
source = array(source);
|
|
483
|
-
} else {
|
|
484
|
-
source = stream(source);
|
|
485
|
-
}
|
|
486
|
-
return Promise.resolve(source).then(function(source) {
|
|
487
|
-
return dbf(source, encoding);
|
|
488
|
-
});
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
function read(shp$$1, dbf$$1, options) {
|
|
492
|
-
return open(shp$$1, dbf$$1, options).then(function(source) {
|
|
493
|
-
var features = [], collection = {type: "FeatureCollection", features: features, bbox: source.bbox};
|
|
494
|
-
return source.read().then(function read(result) {
|
|
495
|
-
if (result.done) return collection;
|
|
496
|
-
features.push(result.value);
|
|
497
|
-
return source.read().then(read);
|
|
498
|
-
});
|
|
499
|
-
});
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
exports.open = open;
|
|
503
|
-
exports.openShp = openShp;
|
|
504
|
-
exports.openDbf = openDbf;
|
|
505
|
-
exports.read = read;
|
|
506
|
-
|
|
507
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
508
|
-
|
|
509
|
-
})));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},hex_chr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<<s|a>>>32-s,b)}function md5cycle(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a+=(b&c|~b&d)+k[0]-680876936|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[1]-389564586|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[2]+606105819|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[3]-1044525330|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[4]-176418897|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[5]+1200080426|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[6]-1473231341|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[7]-45705983|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[8]+1770035416|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[9]-1958414417|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[10]-42063|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[11]-1990404162|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[12]+1804603682|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[13]-40341101|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[14]-1502002290|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[15]+1236535329|0;b=(b<<22|b>>>10)+c|0;a+=(b&d|c&~d)+k[1]-165796510|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[6]-1069501632|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[11]+643717713|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[0]-373897302|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[5]-701558691|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[10]+38016083|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[15]-660478335|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[4]-405537848|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[9]+568446438|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[14]-1019803690|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[3]-187363961|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[8]+1163531501|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[13]-1444681467|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[2]-51403784|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[7]+1735328473|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[12]-1926607734|0;b=(b<<20|b>>>12)+c|0;a+=(b^c^d)+k[5]-378558|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[8]-2022574463|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[11]+1839030562|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[14]-35309556|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[1]-1530992060|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[4]+1272893353|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[7]-155497632|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[10]-1094730640|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[13]+681279174|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[0]-358537222|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[3]-722521979|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[6]+76029189|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[9]-640364487|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[12]-421815835|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[15]+530742520|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[2]-995338651|0;b=(b<<23|b>>>9)+c|0;a+=(c^(b|~d))+k[0]-198630844|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[7]+1126891415|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[14]-1416354905|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[5]-57434055|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[12]+1700485571|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[3]-1894986606|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[10]-1051523|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[1]-2054922799|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[8]+1873313359|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[15]-30611744|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[6]-1560198380|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[13]+1309151649|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[4]-145523070|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[11]-1120210379|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[2]+718787259|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[9]-343485551|0;b=(b<<21|b>>>11)+c|0;x[0]=a+x[0]|0;x[1]=b+x[1]|0;x[2]=c+x[2]|0;x[3]=d+x[3]|0}function md5blk(s){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=s.charCodeAt(i)+(s.charCodeAt(i+1)<<8)+(s.charCodeAt(i+2)<<16)+(s.charCodeAt(i+3)<<24)}return md5blks}function md5blk_array(a){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=a[i]+(a[i+1]<<8)+(a[i+2]<<16)+(a[i+3]<<24)}return md5blks}function md51(s){var n=s.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk(s.substring(i-64,i)))}s=s.substring(i-64);length=s.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<length;i+=1){tail[i>>2]|=s.charCodeAt(i)<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function md51_array(a){var n=a.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk_array(a.subarray(i-64,i)))}a=i-64<n?a.subarray(i-64):new Uint8Array(0);length=a.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i<length;i+=1){tail[i>>2]|=a[i]<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function rhex(n){var s="",j;for(j=0;j<4;j+=1){s+=hex_chr[n>>j*8+4&15]+hex_chr[n>>j*8&15]}return s}function hex(x){var i;for(i=0;i<x.length;i+=1){x[i]=rhex(x[i])}return x.join("")}if(hex(md51("hello"))!=="5d41402abc4b2a76b9719d911017c592"){add32=function(x,y){var lsw=(x&65535)+(y&65535),msw=(x>>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}}if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice){(function(){function clamp(val,length){val=val|0||0;if(val<0){return Math.max(val+length,0)}return Math.min(val,length)}ArrayBuffer.prototype.slice=function(from,to){var length=this.byteLength,begin=clamp(from,length),end=length,num,target,targetArray,sourceArray;if(to!==undefined){end=clamp(to,length)}if(begin>end){return new ArrayBuffer(0)}num=end-begin;target=new ArrayBuffer(num);targetArray=new Uint8Array(target);sourceArray=new Uint8Array(this,begin,num);targetArray.set(sourceArray);return target}})()}function toUtf8(str){if(/[\u0080-\uFFFF]/.test(str)){str=unescape(encodeURIComponent(str))}return str}function utf8Str2ArrayBuffer(str,returnUInt8Array){var length=str.length,buff=new ArrayBuffer(length),arr=new Uint8Array(buff),i;for(i=0;i<length;i+=1){arr[i]=str.charCodeAt(i)}return returnUInt8Array?arr:buff}function arrayBuffer2Utf8Str(buff){return String.fromCharCode.apply(null,new Uint8Array(buff))}function concatenateArrayBuffers(first,second,returnUInt8Array){var result=new Uint8Array(first.byteLength+second.byteLength);result.set(new Uint8Array(first));result.set(new Uint8Array(second),first.byteLength);return returnUInt8Array?result:result.buffer}function hexToBinaryString(hex){var bytes=[],length=hex.length,x;for(x=0;x<length-1;x+=2){bytes.push(parseInt(hex.substr(x,2),16))}return String.fromCharCode.apply(String,bytes)}function SparkMD5(){this.reset()}SparkMD5.prototype.append=function(str){this.appendBinary(toUtf8(str));return this};SparkMD5.prototype.appendBinary=function(contents){this._buff+=contents;this._length+=contents.length;var length=this._buff.length,i;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk(this._buff.substring(i-64,i)))}this._buff=this._buff.substring(i-64);return this};SparkMD5.prototype.end=function(raw){var buff=this._buff,length=buff.length,i,tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ret;for(i=0;i<length;i+=1){tail[i>>2]|=buff.charCodeAt(i)<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash}};SparkMD5.prototype.setState=function(state){this._buff=state.buff;this._length=state.length;this._hash=state.hash;return this};SparkMD5.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};SparkMD5.prototype._finish=function(tail,length){var i=length,tmp,lo,hi;tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(this._hash,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=this._length*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(this._hash,tail)};SparkMD5.hash=function(str,raw){return SparkMD5.hashBinary(toUtf8(str),raw)};SparkMD5.hashBinary=function(content,raw){var hash=md51(content),ret=hex(hash);return raw?hexToBinaryString(ret):ret};SparkMD5.ArrayBuffer=function(){this.reset()};SparkMD5.ArrayBuffer.prototype.append=function(arr){var buff=concatenateArrayBuffers(this._buff.buffer,arr,true),length=buff.length,i;this._length+=arr.byteLength;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk_array(buff.subarray(i-64,i)))}this._buff=i-64<length?new Uint8Array(buff.buffer.slice(i-64)):new Uint8Array(0);return this};SparkMD5.ArrayBuffer.prototype.end=function(raw){var buff=this._buff,length=buff.length,tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i,ret;for(i=0;i<length;i+=1){tail[i>>2]|=buff[i]<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.ArrayBuffer.prototype.getState=function(){var state=SparkMD5.prototype.getState.call(this);state.buff=arrayBuffer2Utf8Str(state.buff);return state};SparkMD5.ArrayBuffer.prototype.setState=function(state){state.buff=utf8Str2ArrayBuffer(state.buff,true);return SparkMD5.prototype.setState.call(this,state)};SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy;SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish;SparkMD5.ArrayBuffer.hash=function(arr,raw){var hash=md51_array(new Uint8Array(arr)),ret=hex(hash);return raw?hexToBinaryString(ret):ret};return SparkMD5});
|