@loaders.gl/shapefile 3.3.0-alpha.5 → 3.3.0-alpha.6

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 (67) hide show
  1. package/dist/dbf-worker.js +1 -1
  2. package/dist/dist.min.js +47 -11
  3. package/dist/es5/bundle.js +0 -1
  4. package/dist/es5/bundle.js.map +1 -1
  5. package/dist/es5/dbf-loader.js +5 -16
  6. package/dist/es5/dbf-loader.js.map +1 -1
  7. package/dist/es5/index.js +6 -9
  8. package/dist/es5/index.js.map +1 -1
  9. package/dist/es5/lib/parsers/parse-dbf.js +69 -154
  10. package/dist/es5/lib/parsers/parse-dbf.js.map +1 -1
  11. package/dist/es5/lib/parsers/parse-shapefile.js +34 -148
  12. package/dist/es5/lib/parsers/parse-shapefile.js.map +1 -1
  13. package/dist/es5/lib/parsers/parse-shp-geometry.js +4 -57
  14. package/dist/es5/lib/parsers/parse-shp-geometry.js.map +1 -1
  15. package/dist/es5/lib/parsers/parse-shp-header.js +0 -3
  16. package/dist/es5/lib/parsers/parse-shp-header.js.map +1 -1
  17. package/dist/es5/lib/parsers/parse-shp.js +39 -98
  18. package/dist/es5/lib/parsers/parse-shp.js.map +1 -1
  19. package/dist/es5/lib/parsers/parse-shx.js +0 -4
  20. package/dist/es5/lib/parsers/parse-shx.js.map +1 -1
  21. package/dist/es5/lib/parsers/types.js.map +1 -1
  22. package/dist/es5/lib/streaming/binary-chunk-reader.js +39 -55
  23. package/dist/es5/lib/streaming/binary-chunk-reader.js.map +1 -1
  24. package/dist/es5/lib/streaming/binary-reader.js +11 -12
  25. package/dist/es5/lib/streaming/binary-reader.js.map +1 -1
  26. package/dist/es5/lib/streaming/zip-batch-iterators.js +1 -24
  27. package/dist/es5/lib/streaming/zip-batch-iterators.js.map +1 -1
  28. package/dist/es5/shapefile-loader.js +1 -3
  29. package/dist/es5/shapefile-loader.js.map +1 -1
  30. package/dist/es5/shp-loader.js +6 -17
  31. package/dist/es5/shp-loader.js.map +1 -1
  32. package/dist/es5/workers/dbf-worker.js +0 -2
  33. package/dist/es5/workers/dbf-worker.js.map +1 -1
  34. package/dist/es5/workers/shp-worker.js +0 -2
  35. package/dist/es5/workers/shp-worker.js.map +1 -1
  36. package/dist/esm/bundle.js +1 -1
  37. package/dist/esm/bundle.js.map +1 -1
  38. package/dist/esm/dbf-loader.js +6 -2
  39. package/dist/esm/dbf-loader.js.map +1 -1
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/lib/parsers/parse-dbf.js +18 -58
  42. package/dist/esm/lib/parsers/parse-dbf.js.map +1 -1
  43. package/dist/esm/lib/parsers/parse-shapefile.js +12 -35
  44. package/dist/esm/lib/parsers/parse-shapefile.js.map +1 -1
  45. package/dist/esm/lib/parsers/parse-shp-geometry.js +3 -28
  46. package/dist/esm/lib/parsers/parse-shp-geometry.js.map +1 -1
  47. package/dist/esm/lib/parsers/parse-shp-header.js +1 -3
  48. package/dist/esm/lib/parsers/parse-shp-header.js.map +1 -1
  49. package/dist/esm/lib/parsers/parse-shp.js +2 -26
  50. package/dist/esm/lib/parsers/parse-shp.js.map +1 -1
  51. package/dist/esm/lib/parsers/parse-shx.js +1 -2
  52. package/dist/esm/lib/parsers/parse-shx.js.map +1 -1
  53. package/dist/esm/lib/parsers/types.js.map +1 -1
  54. package/dist/esm/lib/streaming/binary-chunk-reader.js +4 -19
  55. package/dist/esm/lib/streaming/binary-chunk-reader.js.map +1 -1
  56. package/dist/esm/lib/streaming/binary-reader.js +0 -5
  57. package/dist/esm/lib/streaming/binary-reader.js.map +1 -1
  58. package/dist/esm/lib/streaming/zip-batch-iterators.js +2 -5
  59. package/dist/esm/lib/streaming/zip-batch-iterators.js.map +1 -1
  60. package/dist/esm/shapefile-loader.js +3 -1
  61. package/dist/esm/shapefile-loader.js.map +1 -1
  62. package/dist/esm/shp-loader.js +6 -2
  63. package/dist/esm/shp-loader.js.map +1 -1
  64. package/dist/esm/workers/dbf-worker.js.map +1 -1
  65. package/dist/esm/workers/shp-worker.js.map +1 -1
  66. package/dist/shp-worker.js +1 -1
  67. package/package.json +5 -5
@@ -1,59 +1,38 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
- exports.parseShapefileInBatches = parseShapefileInBatches;
9
- exports.parseShapefile = parseShapefile;
10
7
  exports.loadShapefileSidecarFiles = loadShapefileSidecarFiles;
8
+ exports.parseShapefile = parseShapefile;
9
+ exports.parseShapefileInBatches = parseShapefileInBatches;
11
10
  exports.replaceExtension = replaceExtension;
12
-
13
11
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
14
-
15
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
16
-
17
13
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
18
-
19
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
-
21
15
  var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
22
-
23
16
  var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
24
-
25
- var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
26
-
27
17
  var _gis = require("@loaders.gl/gis");
28
-
29
18
  var _proj = require("@math.gl/proj4");
30
-
31
19
  var _parseShx = require("./parse-shx");
32
-
33
20
  var _zipBatchIterators = require("../streaming/zip-batch-iterators");
34
-
35
21
  var _shpLoader = require("../../shp-loader");
36
-
37
22
  var _dbfLoader = require("../../dbf-loader");
38
-
39
23
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
40
-
41
24
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
42
-
43
25
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
44
-
45
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
46
-
47
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
48
-
26
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
28
+ function _asyncIterator(iterable) { var method, async, sync, retry = 2; for ("undefined" != typeof Symbol && (async = Symbol.asyncIterator, sync = Symbol.iterator); retry--;) { if (async && null != (method = iterable[async])) return method.call(iterable); if (sync && null != (method = iterable[sync])) return new AsyncFromSyncIterator(method.call(iterable)); async = "@@asyncIterator", sync = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
29
+ function AsyncFromSyncIterator(s) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var done = r.done; return Promise.resolve(r.value).then(function (value) { return { value: value, done: done }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(s) { this.s = s, this.n = s.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, return: function _return(value) { var ret = this.s.return; return void 0 === ret ? Promise.resolve({ value: value, done: !0 }) : AsyncFromSyncIteratorContinuation(ret.apply(this.s, arguments)); }, throw: function _throw(value) { var thr = this.s.return; return void 0 === thr ? Promise.reject(value) : AsyncFromSyncIteratorContinuation(thr.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(s); }
49
30
  function parseShapefileInBatches(_x, _x2, _x3) {
50
31
  return _parseShapefileInBatches.apply(this, arguments);
51
32
  }
52
-
53
33
  function _parseShapefileInBatches() {
54
34
  _parseShapefileInBatches = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee(asyncIterator, options, context) {
55
- var _ref, _ref$reproject, reproject, _ref$_targetCrs, _targetCrs, _yield$_awaitAsyncGen, shx, cpg, prj, shapeIterable, propertyIterable, dbfResponse, shapeHeader, dbfHeader, iterator, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, item, geometries, properties, _item, geojsonGeometries, features;
56
-
35
+ var _ref, _ref$reproject, reproject, _ref$_targetCrs, _targetCrs, _yield$_awaitAsyncGen, shx, cpg, prj, shapeIterable, propertyIterable, dbfResponse, shapeHeader, dbfHeader, iterator, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, geometries, properties, _item, geojsonGeometries, features;
57
36
  return _regenerator.default.wrap(function _callee$(_context) {
58
37
  while (1) {
59
38
  switch (_context.prev = _context.next) {
@@ -61,7 +40,6 @@ function _parseShapefileInBatches() {
61
40
  _ref = (options === null || options === void 0 ? void 0 : options.gis) || {}, _ref$reproject = _ref.reproject, reproject = _ref$reproject === void 0 ? false : _ref$reproject, _ref$_targetCrs = _ref._targetCrs, _targetCrs = _ref$_targetCrs === void 0 ? 'WGS84' : _ref$_targetCrs;
62
41
  _context.next = 3;
63
42
  return (0, _awaitAsyncGenerator2.default)(loadShapefileSidecarFiles(options, context));
64
-
65
43
  case 3:
66
44
  _yield$_awaitAsyncGen = _context.sent;
67
45
  shx = _yield$_awaitAsyncGen.shx;
@@ -69,107 +47,76 @@ function _parseShapefileInBatches() {
69
47
  prj = _yield$_awaitAsyncGen.prj;
70
48
  _context.next = 9;
71
49
  return (0, _awaitAsyncGenerator2.default)(context.parseInBatches(asyncIterator, _shpLoader.SHPLoader, options));
72
-
73
50
  case 9:
74
51
  shapeIterable = _context.sent;
75
52
  _context.next = 12;
76
53
  return (0, _awaitAsyncGenerator2.default)(context.fetch(replaceExtension((context === null || context === void 0 ? void 0 : context.url) || '', 'dbf')));
77
-
78
54
  case 12:
79
55
  dbfResponse = _context.sent;
80
-
81
56
  if (!dbfResponse.ok) {
82
57
  _context.next = 17;
83
58
  break;
84
59
  }
85
-
86
60
  _context.next = 16;
87
61
  return (0, _awaitAsyncGenerator2.default)(context.parseInBatches(dbfResponse, _dbfLoader.DBFLoader, _objectSpread(_objectSpread({}, options), {}, {
88
62
  dbf: {
89
63
  encoding: cpg || 'latin1'
90
64
  }
91
65
  })));
92
-
93
66
  case 16:
94
67
  propertyIterable = _context.sent;
95
-
96
68
  case 17:
97
69
  _context.next = 19;
98
70
  return (0, _awaitAsyncGenerator2.default)(shapeIterable.next());
99
-
100
71
  case 19:
101
72
  shapeHeader = _context.sent.value;
102
-
103
73
  if (!(shapeHeader && shapeHeader.batchType === 'metadata')) {
104
74
  _context.next = 24;
105
75
  break;
106
76
  }
107
-
108
77
  _context.next = 23;
109
78
  return (0, _awaitAsyncGenerator2.default)(shapeIterable.next());
110
-
111
79
  case 23:
112
80
  shapeHeader = _context.sent.value;
113
-
114
81
  case 24:
115
82
  dbfHeader = {};
116
-
117
83
  if (!propertyIterable) {
118
84
  _context.next = 33;
119
85
  break;
120
86
  }
121
-
122
87
  _context.next = 28;
123
88
  return (0, _awaitAsyncGenerator2.default)(propertyIterable.next());
124
-
125
89
  case 28:
126
90
  dbfHeader = _context.sent.value;
127
-
128
91
  if (!(dbfHeader && dbfHeader.batchType === 'metadata')) {
129
92
  _context.next = 33;
130
93
  break;
131
94
  }
132
-
133
95
  _context.next = 32;
134
96
  return (0, _awaitAsyncGenerator2.default)(propertyIterable.next());
135
-
136
97
  case 32:
137
98
  dbfHeader = _context.sent.value;
138
-
139
99
  case 33:
140
100
  if (propertyIterable) {
141
101
  iterator = (0, _zipBatchIterators.zipBatchIterators)(shapeIterable, propertyIterable);
142
102
  } else {
143
103
  iterator = shapeIterable;
144
104
  }
145
-
146
- _iteratorNormalCompletion = true;
105
+ _iteratorAbruptCompletion = false;
147
106
  _didIteratorError = false;
148
107
  _context.prev = 36;
149
- _iterator = (0, _asyncIterator2.default)(iterator);
150
-
108
+ _iterator = _asyncIterator(iterator);
151
109
  case 38:
152
110
  _context.next = 40;
153
111
  return (0, _awaitAsyncGenerator2.default)(_iterator.next());
154
-
155
112
  case 40:
156
- _step = _context.sent;
157
- _iteratorNormalCompletion = _step.done;
158
- _context.next = 44;
159
- return (0, _awaitAsyncGenerator2.default)(_step.value);
160
-
161
- case 44:
162
- _value = _context.sent;
163
-
164
- if (_iteratorNormalCompletion) {
165
- _context.next = 58;
113
+ if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
114
+ _context.next = 53;
166
115
  break;
167
116
  }
168
-
169
- item = _value;
117
+ item = _step.value;
170
118
  geometries = void 0;
171
119
  properties = void 0;
172
-
173
120
  if (!propertyIterable) {
174
121
  geometries = item;
175
122
  } else {
@@ -177,15 +124,12 @@ function _parseShapefileInBatches() {
177
124
  geometries = _item[0];
178
125
  properties = _item[1];
179
126
  }
180
-
181
127
  geojsonGeometries = parseGeometries(geometries);
182
128
  features = joinProperties(geojsonGeometries, properties);
183
-
184
129
  if (reproject) {
185
130
  features = reprojectFeatures(features, prj, _targetCrs);
186
131
  }
187
-
188
- _context.next = 55;
132
+ _context.next = 50;
189
133
  return {
190
134
  encoding: cpg,
191
135
  prj: prj,
@@ -193,68 +137,53 @@ function _parseShapefileInBatches() {
193
137
  header: shapeHeader,
194
138
  data: features
195
139
  };
196
-
197
- case 55:
198
- _iteratorNormalCompletion = true;
140
+ case 50:
141
+ _iteratorAbruptCompletion = false;
199
142
  _context.next = 38;
200
143
  break;
201
-
202
- case 58:
203
- _context.next = 64;
144
+ case 53:
145
+ _context.next = 59;
204
146
  break;
205
-
206
- case 60:
207
- _context.prev = 60;
147
+ case 55:
148
+ _context.prev = 55;
208
149
  _context.t0 = _context["catch"](36);
209
150
  _didIteratorError = true;
210
151
  _iteratorError = _context.t0;
211
-
212
- case 64:
213
- _context.prev = 64;
214
- _context.prev = 65;
215
-
216
- if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
217
- _context.next = 69;
152
+ case 59:
153
+ _context.prev = 59;
154
+ _context.prev = 60;
155
+ if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
156
+ _context.next = 64;
218
157
  break;
219
158
  }
220
-
221
- _context.next = 69;
159
+ _context.next = 64;
222
160
  return (0, _awaitAsyncGenerator2.default)(_iterator.return());
223
-
224
- case 69:
225
- _context.prev = 69;
226
-
161
+ case 64:
162
+ _context.prev = 64;
227
163
  if (!_didIteratorError) {
228
- _context.next = 72;
164
+ _context.next = 67;
229
165
  break;
230
166
  }
231
-
232
167
  throw _iteratorError;
233
-
234
- case 72:
235
- return _context.finish(69);
236
-
237
- case 73:
168
+ case 67:
238
169
  return _context.finish(64);
239
-
240
- case 74:
170
+ case 68:
171
+ return _context.finish(59);
172
+ case 69:
241
173
  case "end":
242
174
  return _context.stop();
243
175
  }
244
176
  }
245
- }, _callee, null, [[36, 60, 64, 74], [65,, 69, 73]]);
177
+ }, _callee, null, [[36, 55, 59, 69], [60,, 64, 68]]);
246
178
  }));
247
179
  return _parseShapefileInBatches.apply(this, arguments);
248
180
  }
249
-
250
181
  function parseShapefile(_x4, _x5, _x6) {
251
182
  return _parseShapefile.apply(this, arguments);
252
183
  }
253
-
254
184
  function _parseShapefile() {
255
185
  _parseShapefile = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, options, context) {
256
186
  var _ref2, _ref2$reproject, reproject, _ref2$_targetCrs, _targetCrs, _yield$loadShapefileS, shx, cpg, prj, _yield$context$parse, header, geometries, geojsonGeometries, properties, dbfResponse, features;
257
-
258
187
  return _regenerator.default.wrap(function _callee2$(_context2) {
259
188
  while (1) {
260
189
  switch (_context2.prev = _context2.next) {
@@ -262,7 +191,6 @@ function _parseShapefile() {
262
191
  _ref2 = (options === null || options === void 0 ? void 0 : options.gis) || {}, _ref2$reproject = _ref2.reproject, reproject = _ref2$reproject === void 0 ? false : _ref2$reproject, _ref2$_targetCrs = _ref2._targetCrs, _targetCrs = _ref2$_targetCrs === void 0 ? 'WGS84' : _ref2$_targetCrs;
263
192
  _context2.next = 3;
264
193
  return loadShapefileSidecarFiles(options, context);
265
-
266
194
  case 3:
267
195
  _yield$loadShapefileS = _context2.sent;
268
196
  shx = _yield$loadShapefileS.shx;
@@ -270,7 +198,6 @@ function _parseShapefile() {
270
198
  prj = _yield$loadShapefileS.prj;
271
199
  _context2.next = 9;
272
200
  return context.parse(arrayBuffer, _shpLoader.SHPLoader, options);
273
-
274
201
  case 9:
275
202
  _yield$context$parse = _context2.sent;
276
203
  header = _yield$context$parse.header;
@@ -279,32 +206,25 @@ function _parseShapefile() {
279
206
  properties = [];
280
207
  _context2.next = 16;
281
208
  return context.fetch(replaceExtension(context.url, 'dbf'));
282
-
283
209
  case 16:
284
210
  dbfResponse = _context2.sent;
285
-
286
211
  if (!dbfResponse.ok) {
287
212
  _context2.next = 21;
288
213
  break;
289
214
  }
290
-
291
215
  _context2.next = 20;
292
216
  return context.parse(dbfResponse, _dbfLoader.DBFLoader, {
293
217
  dbf: {
294
218
  encoding: cpg || 'latin1'
295
219
  }
296
220
  });
297
-
298
221
  case 20:
299
222
  properties = _context2.sent;
300
-
301
223
  case 21:
302
224
  features = joinProperties(geojsonGeometries, properties);
303
-
304
225
  if (reproject) {
305
226
  features = reprojectFeatures(features, prj, _targetCrs);
306
227
  }
307
-
308
228
  return _context2.abrupt("return", {
309
229
  encoding: cpg,
310
230
  prj: prj,
@@ -312,7 +232,6 @@ function _parseShapefile() {
312
232
  header: header,
313
233
  data: features
314
234
  });
315
-
316
235
  case 24:
317
236
  case "end":
318
237
  return _context2.stop();
@@ -322,13 +241,10 @@ function _parseShapefile() {
322
241
  }));
323
242
  return _parseShapefile.apply(this, arguments);
324
243
  }
325
-
326
244
  function parseGeometries(geometries) {
327
245
  var geojsonGeometries = [];
328
-
329
246
  var _iterator2 = _createForOfIteratorHelper(geometries),
330
- _step2;
331
-
247
+ _step2;
332
248
  try {
333
249
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
334
250
  var geom = _step2.value;
@@ -339,13 +255,11 @@ function parseGeometries(geometries) {
339
255
  } finally {
340
256
  _iterator2.f();
341
257
  }
342
-
343
258
  return geojsonGeometries;
344
259
  }
345
260
 
346
261
  function joinProperties(geometries, properties) {
347
262
  var features = [];
348
-
349
263
  for (var i = 0; i < geometries.length; i++) {
350
264
  var geometry = geometries[i];
351
265
  var feature = {
@@ -355,7 +269,6 @@ function joinProperties(geometries, properties) {
355
269
  };
356
270
  features.push(feature);
357
271
  }
358
-
359
272
  return features;
360
273
  }
361
274
 
@@ -363,7 +276,6 @@ function reprojectFeatures(features, sourceCrs, targetCrs) {
363
276
  if (!sourceCrs && !targetCrs) {
364
277
  return features;
365
278
  }
366
-
367
279
  var projection = new _proj.Proj4Projection({
368
280
  from: sourceCrs || 'WGS84',
369
281
  to: targetCrs || 'WGS84'
@@ -376,7 +288,6 @@ function reprojectFeatures(features, sourceCrs, targetCrs) {
376
288
  function loadShapefileSidecarFiles(_x7, _x8) {
377
289
  return _loadShapefileSidecarFiles.apply(this, arguments);
378
290
  }
379
-
380
291
  function _loadShapefileSidecarFiles() {
381
292
  _loadShapefileSidecarFiles = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(options, context) {
382
293
  var url, fetch, shxPromise, cpgPromise, prjPromise, shx, cpg, prj, shxResponse, arrayBuffer, cpgResponse, prjResponse;
@@ -390,69 +301,52 @@ function _loadShapefileSidecarFiles() {
390
301
  prjPromise = fetch(replaceExtension(url, 'prj'));
391
302
  _context3.next = 6;
392
303
  return Promise.all([shxPromise, cpgPromise, prjPromise]);
393
-
394
304
  case 6:
395
305
  _context3.next = 8;
396
306
  return shxPromise;
397
-
398
307
  case 8:
399
308
  shxResponse = _context3.sent;
400
-
401
309
  if (!shxResponse.ok) {
402
310
  _context3.next = 14;
403
311
  break;
404
312
  }
405
-
406
313
  _context3.next = 12;
407
314
  return shxResponse.arrayBuffer();
408
-
409
315
  case 12:
410
316
  arrayBuffer = _context3.sent;
411
317
  shx = (0, _parseShx.parseShx)(arrayBuffer);
412
-
413
318
  case 14:
414
319
  _context3.next = 16;
415
320
  return cpgPromise;
416
-
417
321
  case 16:
418
322
  cpgResponse = _context3.sent;
419
-
420
323
  if (!cpgResponse.ok) {
421
324
  _context3.next = 21;
422
325
  break;
423
326
  }
424
-
425
327
  _context3.next = 20;
426
328
  return cpgResponse.text();
427
-
428
329
  case 20:
429
330
  cpg = _context3.sent;
430
-
431
331
  case 21:
432
332
  _context3.next = 23;
433
333
  return prjPromise;
434
-
435
334
  case 23:
436
335
  prjResponse = _context3.sent;
437
-
438
336
  if (!prjResponse.ok) {
439
337
  _context3.next = 28;
440
338
  break;
441
339
  }
442
-
443
340
  _context3.next = 27;
444
341
  return prjResponse.text();
445
-
446
342
  case 27:
447
343
  prj = _context3.sent;
448
-
449
344
  case 28:
450
345
  return _context3.abrupt("return", {
451
346
  shx: shx,
452
347
  cpg: cpg,
453
348
  prj: prj
454
349
  });
455
-
456
350
  case 29:
457
351
  case "end":
458
352
  return _context3.stop();
@@ -462,36 +356,28 @@ function _loadShapefileSidecarFiles() {
462
356
  }));
463
357
  return _loadShapefileSidecarFiles.apply(this, arguments);
464
358
  }
465
-
466
359
  function replaceExtension(url, newExtension) {
467
360
  var baseName = basename(url);
468
361
  var extension = extname(url);
469
362
  var isUpperCase = extension === extension.toUpperCase();
470
-
471
363
  if (isUpperCase) {
472
364
  newExtension = newExtension.toUpperCase();
473
365
  }
474
-
475
366
  return "".concat(baseName, ".").concat(newExtension);
476
367
  }
477
368
 
478
369
  function basename(url) {
479
370
  var extIndex = url && url.lastIndexOf('.');
480
-
481
371
  if (typeof extIndex === 'number') {
482
372
  return extIndex >= 0 ? url.substr(0, extIndex) : '';
483
373
  }
484
-
485
374
  return extIndex;
486
375
  }
487
-
488
376
  function extname(url) {
489
377
  var extIndex = url && url.lastIndexOf('.');
490
-
491
378
  if (typeof extIndex === 'number') {
492
379
  return extIndex >= 0 ? url.substr(extIndex + 1) : '';
493
380
  }
494
-
495
381
  return extIndex;
496
382
  }
497
383
  //# sourceMappingURL=parse-shapefile.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/parsers/parse-shapefile.ts"],"names":["parseShapefileInBatches","asyncIterator","options","context","gis","reproject","_targetCrs","loadShapefileSidecarFiles","shx","cpg","prj","parseInBatches","SHPLoader","shapeIterable","fetch","replaceExtension","url","dbfResponse","ok","DBFLoader","dbf","encoding","propertyIterable","next","shapeHeader","value","batchType","dbfHeader","iterator","item","geometries","properties","geojsonGeometries","parseGeometries","features","joinProperties","reprojectFeatures","header","data","parseShapefile","arrayBuffer","parse","geom","push","i","length","geometry","feature","type","sourceCrs","targetCrs","projection","Proj4Projection","from","to","coord","project","shxPromise","cpgPromise","prjPromise","Promise","all","shxResponse","cpgResponse","text","prjResponse","newExtension","baseName","basename","extension","extname","isUpperCase","toUpperCase","extIndex","lastIndexOf","substr"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;SAcuBA,uB;;;;;yFAAhB,iBACLC,aADK,EAELC,OAFK,EAGLC,OAHK;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,mBAK6C,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,GAAT,KAAgB,EAL7D,wBAKEC,SALF,EAKEA,SALF,+BAKc,KALd,0CAKqBC,UALrB,EAKqBA,UALrB,gCAKkC,OALlC;AAAA;AAAA,sDAMyBC,yBAAyB,CAACL,OAAD,EAAUC,OAAV,CANlD;;AAAA;AAAA;AAMEK,YAAAA,GANF,yBAMEA,GANF;AAMOC,YAAAA,GANP,yBAMOA,GANP;AAMYC,YAAAA,GANZ,yBAMYA,GANZ;AAAA;AAAA,sDAU4BP,OAAO,CAACQ,cAAR,CAAuBV,aAAvB,EAA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B,CAAxB;;AACA,MAAI,OAAOD,QAAP,KAAoB,QAAxB,EAAkC;AAChC,WAAOA,QAAQ,IAAI,CAAZ,GAAgBzD,GAAG,CAAC2D,MAAJ,CAAWF,QAAQ,GAAG,CAAtB,CAAhB,GAA2C,EAAlD;AACD;;AACD,SAAOA,QAAP;AACD","sourcesContent":["// import type {Feature} from '@loaders.gl/gis';\nimport type {SHXOutput} from './parse-shx';\nimport type {SHPHeader} from './parse-shp-header';\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport type {ShapefileLoaderOptions} from './types';\n\nimport {binaryToGeometry, transformGeoJsonCoords} from '@loaders.gl/gis';\nimport {Proj4Projection} from '@math.gl/proj4';\nimport {parseShx} from './parse-shx';\nimport {zipBatchIterators} from '../streaming/zip-batch-iterators';\nimport {SHPLoader} from '../../shp-loader';\nimport {DBFLoader} from '../../dbf-loader';\n\ntype Feature = any;\ninterface ShapefileOutput {\n encoding?: string;\n prj?: string;\n shx?: SHXOutput;\n header: SHPHeader;\n data: object[];\n}\n/**\n * Parsing of file in batches\n */\n// eslint-disable-next-line max-statements, complexity\nexport async function* parseShapefileInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: ShapefileLoaderOptions,\n context?: LoaderContext\n): AsyncIterable<ShapefileOutput> {\n const {reproject = false, _targetCrs = 'WGS84'} = options?.gis || {};\n const {shx, cpg, prj} = await loadShapefileSidecarFiles(options, context);\n\n // parse geometries\n // @ts-ignore context must be defined\n const shapeIterable: any = await context.parseInBatches(asyncIterator, SHPLoader, options);\n\n // parse properties\n let propertyIterable: any;\n // @ts-ignore context must be defined\n const dbfResponse = await context.fetch(replaceExtension(context?.url || '', 'dbf'));\n if (dbfResponse.ok) {\n // @ts-ignore context must be defined\n propertyIterable = await context.parseInBatches(dbfResponse, DBFLoader, {\n ...options,\n dbf: {encoding: cpg || 'latin1'}\n });\n }\n\n // When `options.metadata` is `true`, there's an extra initial `metadata`\n // object before the iterator starts. zipBatchIterators expects to receive\n // batches of Array objects, and will fail with non-iterable batches, so it's\n // important to skip over the first batch.\n let shapeHeader = (await shapeIterable.next()).value;\n if (shapeHeader && shapeHeader.batchType === 'metadata') {\n shapeHeader = (await shapeIterable.next()).value;\n }\n\n let dbfHeader: {batchType?: string} = {};\n if (propertyIterable) {\n dbfHeader = (await propertyIterable.next()).value;\n if (dbfHeader && dbfHeader.batchType === 'metadata') {\n dbfHeader = (await propertyIterable.next()).value;\n }\n }\n\n let iterator: any;\n if (propertyIterable) {\n iterator = zipBatchIterators(shapeIterable, propertyIterable);\n } else {\n iterator = shapeIterable;\n }\n\n for await (const item of iterator) {\n let geometries: any;\n let properties: any;\n if (!propertyIterable) {\n geometries = item;\n } else {\n [geometries, properties] = item;\n }\n\n const geojsonGeometries = parseGeometries(geometries);\n let features = joinProperties(geojsonGeometries, properties);\n if (reproject) {\n // @ts-ignore\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n yield {\n encoding: cpg,\n prj,\n shx,\n header: shapeHeader,\n data: features\n };\n }\n}\n\n/**\n * Parse shapefile\n *\n * @param arrayBuffer\n * @param options\n * @param context\n * @returns output of shapefile\n */\nexport async function parseShapefile(\n arrayBuffer: ArrayBuffer,\n options?: ShapefileLoaderOptions,\n context?: LoaderContext\n): Promise<ShapefileOutput> {\n const {reproject = false, _targetCrs = 'WGS84'} = options?.gis || {};\n const {shx, cpg, prj} = await loadShapefileSidecarFiles(options, context);\n\n // parse geometries\n // @ts-ignore context must be defined\n const {header, geometries} = await context.parse(arrayBuffer, SHPLoader, options); // {shp: shx}\n\n const geojsonGeometries = parseGeometries(geometries);\n\n // parse properties\n let properties = [];\n\n // @ts-ignore context must be defined\n const dbfResponse = await context.fetch(replaceExtension(context.url, 'dbf'));\n if (dbfResponse.ok) {\n // @ts-ignore context must be defined\n properties = await context.parse(dbfResponse, DBFLoader, {dbf: {encoding: cpg || 'latin1'}});\n }\n\n let features = joinProperties(geojsonGeometries, properties);\n if (reproject) {\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n\n return {\n encoding: cpg,\n prj,\n shx,\n header,\n data: features\n };\n}\n\n/**\n * Parse geometries\n *\n * @param geometries\n * @returns geometries as an array\n */\nfunction parseGeometries(geometries: any[]): any[] {\n const geojsonGeometries: any[] = [];\n for (const geom of geometries) {\n geojsonGeometries.push(binaryToGeometry(geom));\n }\n return geojsonGeometries;\n}\n\n/**\n * Join properties and geometries into features\n *\n * @param geometries [description]\n * @param properties [description]\n * @return [description]\n */\nfunction joinProperties(geometries: object[], properties: object[]): Feature[] {\n const features: Feature[] = [];\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n const feature: Feature = {\n type: 'Feature',\n geometry,\n // properties can be undefined if dbfResponse above was empty\n properties: (properties && properties[i]) || {}\n };\n features.push(feature);\n }\n\n return features;\n}\n\n/**\n * Reproject GeoJSON features to output CRS\n *\n * @param features parsed GeoJSON features\n * @param sourceCrs source coordinate reference system\n * @param targetCrs †arget coordinate reference system\n * @return Reprojected Features\n */\nfunction reprojectFeatures(features: Feature[], sourceCrs?: string, targetCrs?: string): Feature[] {\n if (!sourceCrs && !targetCrs) {\n return features;\n }\n\n const projection = new Proj4Projection({from: sourceCrs || 'WGS84', to: targetCrs || 'WGS84'});\n return transformGeoJsonCoords(features, (coord) => projection.project(coord));\n}\n\n/**\n *\n * @param options\n * @param context\n * @returns Promise\n */\n// eslint-disable-next-line max-statements\nexport async function loadShapefileSidecarFiles(\n options?: object,\n context?: LoaderContext\n): Promise<{\n shx?: SHXOutput;\n cpg?: string;\n prj?: string;\n}> {\n // Attempt a parallel load of the small sidecar files\n // @ts-ignore context must be defined\n const {url, fetch} = context;\n const shxPromise = fetch(replaceExtension(url, 'shx'));\n const cpgPromise = fetch(replaceExtension(url, 'cpg'));\n const prjPromise = fetch(replaceExtension(url, 'prj'));\n await Promise.all([shxPromise, cpgPromise, prjPromise]);\n\n let shx: SHXOutput | undefined;\n let cpg: string | undefined;\n let prj: string | undefined;\n\n const shxResponse = await shxPromise;\n if (shxResponse.ok) {\n const arrayBuffer = await shxResponse.arrayBuffer();\n shx = parseShx(arrayBuffer);\n }\n\n const cpgResponse = await cpgPromise;\n if (cpgResponse.ok) {\n cpg = await cpgResponse.text();\n }\n\n const prjResponse = await prjPromise;\n if (prjResponse.ok) {\n prj = await prjResponse.text();\n }\n\n return {\n shx,\n cpg,\n prj\n };\n}\n\n/**\n * Replace the extension at the end of a path.\n *\n * Matches the case of new extension with the case of the original file extension,\n * to increase the chance of finding files without firing off a request storm looking for various case combinations\n *\n * NOTE: Extensions can be both lower and uppercase\n * per spec, extensions should be lower case, but that doesn't mean they always are. See:\n * calvinmetcalf/shapefile-js#64, mapserver/mapserver#4712\n * https://trac.osgeo.org/mapserver/ticket/166\n */\nexport function replaceExtension(url: string, newExtension: string): string {\n const baseName = basename(url);\n const extension = extname(url);\n const isUpperCase = extension === extension.toUpperCase();\n if (isUpperCase) {\n newExtension = newExtension.toUpperCase();\n }\n return `${baseName}.${newExtension}`;\n}\n\n// NOTE - this gives the entire path minus extension (i.e. NOT same as path.basename)\n/**\n * @param url\n * @returns string\n */\nfunction basename(url: string): string {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(0, extIndex) : '';\n }\n return extIndex;\n}\n/**\n * @param url\n * @returns string\n */\nfunction extname(url: string): string {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(extIndex + 1) : '';\n }\n return extIndex;\n}\n"],"file":"parse-shapefile.js"}
1
+ {"version":3,"file":"parse-shapefile.js","names":["parseShapefileInBatches","asyncIterator","options","context","gis","reproject","_targetCrs","loadShapefileSidecarFiles","shx","cpg","prj","parseInBatches","SHPLoader","shapeIterable","fetch","replaceExtension","url","dbfResponse","ok","DBFLoader","dbf","encoding","propertyIterable","next","shapeHeader","value","batchType","dbfHeader","iterator","zipBatchIterators","item","geometries","properties","geojsonGeometries","parseGeometries","features","joinProperties","reprojectFeatures","header","data","parseShapefile","arrayBuffer","parse","geom","push","binaryToGeometry","i","length","geometry","feature","type","sourceCrs","targetCrs","projection","Proj4Projection","from","to","transformGeoJsonCoords","coord","project","shxPromise","cpgPromise","prjPromise","Promise","all","shxResponse","parseShx","cpgResponse","text","prjResponse","newExtension","baseName","basename","extension","extname","isUpperCase","toUpperCase","extIndex","lastIndexOf","substr"],"sources":["../../../../src/lib/parsers/parse-shapefile.ts"],"sourcesContent":["// import type {Feature} from '@loaders.gl/gis';\nimport type {SHXOutput} from './parse-shx';\nimport type {SHPHeader} from './parse-shp-header';\nimport type {LoaderContext} from '@loaders.gl/loader-utils';\nimport type {ShapefileLoaderOptions} from './types';\n\nimport {binaryToGeometry, transformGeoJsonCoords} from '@loaders.gl/gis';\nimport {Proj4Projection} from '@math.gl/proj4';\nimport {parseShx} from './parse-shx';\nimport {zipBatchIterators} from '../streaming/zip-batch-iterators';\nimport {SHPLoader} from '../../shp-loader';\nimport {DBFLoader} from '../../dbf-loader';\n\ntype Feature = any;\ninterface ShapefileOutput {\n encoding?: string;\n prj?: string;\n shx?: SHXOutput;\n header: SHPHeader;\n data: object[];\n}\n/**\n * Parsing of file in batches\n */\n// eslint-disable-next-line max-statements, complexity\nexport async function* parseShapefileInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: ShapefileLoaderOptions,\n context?: LoaderContext\n): AsyncIterable<ShapefileOutput> {\n const {reproject = false, _targetCrs = 'WGS84'} = options?.gis || {};\n const {shx, cpg, prj} = await loadShapefileSidecarFiles(options, context);\n\n // parse geometries\n // @ts-ignore context must be defined\n const shapeIterable: any = await context.parseInBatches(asyncIterator, SHPLoader, options);\n\n // parse properties\n let propertyIterable: any;\n // @ts-ignore context must be defined\n const dbfResponse = await context.fetch(replaceExtension(context?.url || '', 'dbf'));\n if (dbfResponse.ok) {\n // @ts-ignore context must be defined\n propertyIterable = await context.parseInBatches(dbfResponse, DBFLoader, {\n ...options,\n dbf: {encoding: cpg || 'latin1'}\n });\n }\n\n // When `options.metadata` is `true`, there's an extra initial `metadata`\n // object before the iterator starts. zipBatchIterators expects to receive\n // batches of Array objects, and will fail with non-iterable batches, so it's\n // important to skip over the first batch.\n let shapeHeader = (await shapeIterable.next()).value;\n if (shapeHeader && shapeHeader.batchType === 'metadata') {\n shapeHeader = (await shapeIterable.next()).value;\n }\n\n let dbfHeader: {batchType?: string} = {};\n if (propertyIterable) {\n dbfHeader = (await propertyIterable.next()).value;\n if (dbfHeader && dbfHeader.batchType === 'metadata') {\n dbfHeader = (await propertyIterable.next()).value;\n }\n }\n\n let iterator: any;\n if (propertyIterable) {\n iterator = zipBatchIterators(shapeIterable, propertyIterable);\n } else {\n iterator = shapeIterable;\n }\n\n for await (const item of iterator) {\n let geometries: any;\n let properties: any;\n if (!propertyIterable) {\n geometries = item;\n } else {\n [geometries, properties] = item;\n }\n\n const geojsonGeometries = parseGeometries(geometries);\n let features = joinProperties(geojsonGeometries, properties);\n if (reproject) {\n // @ts-ignore\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n yield {\n encoding: cpg,\n prj,\n shx,\n header: shapeHeader,\n data: features\n };\n }\n}\n\n/**\n * Parse shapefile\n *\n * @param arrayBuffer\n * @param options\n * @param context\n * @returns output of shapefile\n */\nexport async function parseShapefile(\n arrayBuffer: ArrayBuffer,\n options?: ShapefileLoaderOptions,\n context?: LoaderContext\n): Promise<ShapefileOutput> {\n const {reproject = false, _targetCrs = 'WGS84'} = options?.gis || {};\n const {shx, cpg, prj} = await loadShapefileSidecarFiles(options, context);\n\n // parse geometries\n // @ts-ignore context must be defined\n const {header, geometries} = await context.parse(arrayBuffer, SHPLoader, options); // {shp: shx}\n\n const geojsonGeometries = parseGeometries(geometries);\n\n // parse properties\n let properties = [];\n\n // @ts-ignore context must be defined\n const dbfResponse = await context.fetch(replaceExtension(context.url, 'dbf'));\n if (dbfResponse.ok) {\n // @ts-ignore context must be defined\n properties = await context.parse(dbfResponse, DBFLoader, {dbf: {encoding: cpg || 'latin1'}});\n }\n\n let features = joinProperties(geojsonGeometries, properties);\n if (reproject) {\n features = reprojectFeatures(features, prj, _targetCrs);\n }\n\n return {\n encoding: cpg,\n prj,\n shx,\n header,\n data: features\n };\n}\n\n/**\n * Parse geometries\n *\n * @param geometries\n * @returns geometries as an array\n */\nfunction parseGeometries(geometries: any[]): any[] {\n const geojsonGeometries: any[] = [];\n for (const geom of geometries) {\n geojsonGeometries.push(binaryToGeometry(geom));\n }\n return geojsonGeometries;\n}\n\n/**\n * Join properties and geometries into features\n *\n * @param geometries [description]\n * @param properties [description]\n * @return [description]\n */\nfunction joinProperties(geometries: object[], properties: object[]): Feature[] {\n const features: Feature[] = [];\n for (let i = 0; i < geometries.length; i++) {\n const geometry = geometries[i];\n const feature: Feature = {\n type: 'Feature',\n geometry,\n // properties can be undefined if dbfResponse above was empty\n properties: (properties && properties[i]) || {}\n };\n features.push(feature);\n }\n\n return features;\n}\n\n/**\n * Reproject GeoJSON features to output CRS\n *\n * @param features parsed GeoJSON features\n * @param sourceCrs source coordinate reference system\n * @param targetCrs †arget coordinate reference system\n * @return Reprojected Features\n */\nfunction reprojectFeatures(features: Feature[], sourceCrs?: string, targetCrs?: string): Feature[] {\n if (!sourceCrs && !targetCrs) {\n return features;\n }\n\n const projection = new Proj4Projection({from: sourceCrs || 'WGS84', to: targetCrs || 'WGS84'});\n return transformGeoJsonCoords(features, (coord) => projection.project(coord));\n}\n\n/**\n *\n * @param options\n * @param context\n * @returns Promise\n */\n// eslint-disable-next-line max-statements\nexport async function loadShapefileSidecarFiles(\n options?: object,\n context?: LoaderContext\n): Promise<{\n shx?: SHXOutput;\n cpg?: string;\n prj?: string;\n}> {\n // Attempt a parallel load of the small sidecar files\n // @ts-ignore context must be defined\n const {url, fetch} = context;\n const shxPromise = fetch(replaceExtension(url, 'shx'));\n const cpgPromise = fetch(replaceExtension(url, 'cpg'));\n const prjPromise = fetch(replaceExtension(url, 'prj'));\n await Promise.all([shxPromise, cpgPromise, prjPromise]);\n\n let shx: SHXOutput | undefined;\n let cpg: string | undefined;\n let prj: string | undefined;\n\n const shxResponse = await shxPromise;\n if (shxResponse.ok) {\n const arrayBuffer = await shxResponse.arrayBuffer();\n shx = parseShx(arrayBuffer);\n }\n\n const cpgResponse = await cpgPromise;\n if (cpgResponse.ok) {\n cpg = await cpgResponse.text();\n }\n\n const prjResponse = await prjPromise;\n if (prjResponse.ok) {\n prj = await prjResponse.text();\n }\n\n return {\n shx,\n cpg,\n prj\n };\n}\n\n/**\n * Replace the extension at the end of a path.\n *\n * Matches the case of new extension with the case of the original file extension,\n * to increase the chance of finding files without firing off a request storm looking for various case combinations\n *\n * NOTE: Extensions can be both lower and uppercase\n * per spec, extensions should be lower case, but that doesn't mean they always are. See:\n * calvinmetcalf/shapefile-js#64, mapserver/mapserver#4712\n * https://trac.osgeo.org/mapserver/ticket/166\n */\nexport function replaceExtension(url: string, newExtension: string): string {\n const baseName = basename(url);\n const extension = extname(url);\n const isUpperCase = extension === extension.toUpperCase();\n if (isUpperCase) {\n newExtension = newExtension.toUpperCase();\n }\n return `${baseName}.${newExtension}`;\n}\n\n// NOTE - this gives the entire path minus extension (i.e. NOT same as path.basename)\n/**\n * @param url\n * @returns string\n */\nfunction basename(url: string): string {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(0, extIndex) : '';\n }\n return extIndex;\n}\n/**\n * @param url\n * @returns string\n */\nfunction extname(url: string): string {\n const extIndex = url && url.lastIndexOf('.');\n if (typeof extIndex === 'number') {\n return extIndex >= 0 ? url.substr(extIndex + 1) : '';\n }\n return extIndex;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAMA;AACA;AACA;AACA;AACA;AACA;AAA2C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAcpBA,uBAAuB;EAAA;AAAA;AAAA;EAAA,uFAAvC,iBACLC,aAAiE,EACjEC,OAAgC,EACh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