@loaders.gl/shapefile 3.4.0-alpha.2 → 3.4.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dbf-worker.js +1 -1
- package/dist/dist.min.js +47 -0
- package/dist/es5/dbf-loader.js +7 -11
- package/dist/es5/dbf-loader.js.map +1 -1
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parsers/parse-dbf.js +47 -75
- package/dist/es5/lib/parsers/parse-dbf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-shapefile.js +239 -249
- package/dist/es5/lib/parsers/parse-shapefile.js.map +1 -1
- package/dist/es5/lib/parsers/parse-shp-geometry.js +0 -16
- package/dist/es5/lib/parsers/parse-shp-geometry.js.map +1 -1
- package/dist/es5/lib/parsers/parse-shp-header.js +0 -1
- package/dist/es5/lib/parsers/parse-shp-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-shp.js +74 -79
- package/dist/es5/lib/parsers/parse-shp.js.map +1 -1
- package/dist/es5/lib/parsers/parse-shx.js +0 -1
- package/dist/es5/lib/parsers/parse-shx.js.map +1 -1
- package/dist/es5/lib/streaming/binary-chunk-reader.js +9 -33
- package/dist/es5/lib/streaming/binary-chunk-reader.js.map +1 -1
- package/dist/es5/lib/streaming/binary-reader.js +4 -11
- package/dist/es5/lib/streaming/binary-reader.js.map +1 -1
- package/dist/es5/lib/streaming/zip-batch-iterators.js +54 -58
- package/dist/es5/lib/streaming/zip-batch-iterators.js.map +1 -1
- package/dist/es5/shapefile-loader.js +1 -2
- package/dist/es5/shapefile-loader.js.map +1 -1
- package/dist/es5/shp-loader.js +7 -11
- package/dist/es5/shp-loader.js.map +1 -1
- package/dist/es5/workers/dbf-worker.js.map +1 -1
- package/dist/es5/workers/shp-worker.js.map +1 -1
- package/dist/esm/bundle.js +0 -1
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/dbf-loader.js +1 -4
- package/dist/esm/dbf-loader.js.map +1 -1
- package/dist/esm/lib/parsers/parse-dbf.js +34 -45
- package/dist/esm/lib/parsers/parse-dbf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-shapefile.js +0 -16
- package/dist/esm/lib/parsers/parse-shapefile.js.map +1 -1
- package/dist/esm/lib/parsers/parse-shp-geometry.js +0 -18
- package/dist/esm/lib/parsers/parse-shp-geometry.js.map +1 -1
- package/dist/esm/lib/parsers/parse-shp-header.js +0 -1
- package/dist/esm/lib/parsers/parse-shp-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-shp.js +0 -4
- package/dist/esm/lib/parsers/parse-shp.js.map +1 -1
- package/dist/esm/lib/parsers/parse-shx.js +0 -1
- package/dist/esm/lib/parsers/parse-shx.js.map +1 -1
- package/dist/esm/lib/streaming/binary-chunk-reader.js +0 -16
- package/dist/esm/lib/streaming/binary-chunk-reader.js.map +1 -1
- package/dist/esm/lib/streaming/binary-reader.js +0 -3
- package/dist/esm/lib/streaming/binary-reader.js.map +1 -1
- package/dist/esm/lib/streaming/zip-batch-iterators.js +0 -5
- package/dist/esm/lib/streaming/zip-batch-iterators.js.map +1 -1
- package/dist/esm/shapefile-loader.js +1 -3
- package/dist/esm/shapefile-loader.js.map +1 -1
- package/dist/esm/shp-loader.js +1 -4
- package/dist/esm/shp-loader.js.map +1 -1
- package/dist/shp-worker.js +1 -1
- package/package.json +5 -5
|
@@ -22,7 +22,7 @@ var _shpLoader = require("../../shp-loader");
|
|
|
22
22
|
var _dbfLoader = require("../../dbf-loader");
|
|
23
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; } } }; }
|
|
24
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); }
|
|
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++)
|
|
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; }
|
|
26
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
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
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"); }
|
|
@@ -34,145 +34,143 @@ function _parseShapefileInBatches() {
|
|
|
34
34
|
_parseShapefileInBatches = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee(asyncIterator, options, context) {
|
|
35
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;
|
|
36
36
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
37
|
-
while (1) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
encoding: cpg || 'latin1'
|
|
64
|
-
}
|
|
65
|
-
})));
|
|
66
|
-
case 16:
|
|
67
|
-
propertyIterable = _context.sent;
|
|
68
|
-
case 17:
|
|
69
|
-
_context.next = 19;
|
|
70
|
-
return (0, _awaitAsyncGenerator2.default)(shapeIterable.next());
|
|
71
|
-
case 19:
|
|
72
|
-
shapeHeader = _context.sent.value;
|
|
73
|
-
if (!(shapeHeader && shapeHeader.batchType === 'metadata')) {
|
|
74
|
-
_context.next = 24;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
_context.next = 23;
|
|
78
|
-
return (0, _awaitAsyncGenerator2.default)(shapeIterable.next());
|
|
79
|
-
case 23:
|
|
80
|
-
shapeHeader = _context.sent.value;
|
|
81
|
-
case 24:
|
|
82
|
-
dbfHeader = {};
|
|
83
|
-
if (!propertyIterable) {
|
|
84
|
-
_context.next = 33;
|
|
85
|
-
break;
|
|
86
|
-
}
|
|
87
|
-
_context.next = 28;
|
|
88
|
-
return (0, _awaitAsyncGenerator2.default)(propertyIterable.next());
|
|
89
|
-
case 28:
|
|
90
|
-
dbfHeader = _context.sent.value;
|
|
91
|
-
if (!(dbfHeader && dbfHeader.batchType === 'metadata')) {
|
|
92
|
-
_context.next = 33;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
_context.next = 32;
|
|
96
|
-
return (0, _awaitAsyncGenerator2.default)(propertyIterable.next());
|
|
97
|
-
case 32:
|
|
98
|
-
dbfHeader = _context.sent.value;
|
|
99
|
-
case 33:
|
|
100
|
-
if (propertyIterable) {
|
|
101
|
-
iterator = (0, _zipBatchIterators.zipBatchIterators)(shapeIterable, propertyIterable);
|
|
102
|
-
} else {
|
|
103
|
-
iterator = shapeIterable;
|
|
104
|
-
}
|
|
105
|
-
_iteratorAbruptCompletion = false;
|
|
106
|
-
_didIteratorError = false;
|
|
107
|
-
_context.prev = 36;
|
|
108
|
-
_iterator = _asyncIterator(iterator);
|
|
109
|
-
case 38:
|
|
110
|
-
_context.next = 40;
|
|
111
|
-
return (0, _awaitAsyncGenerator2.default)(_iterator.next());
|
|
112
|
-
case 40:
|
|
113
|
-
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
114
|
-
_context.next = 53;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
item = _step.value;
|
|
118
|
-
geometries = void 0;
|
|
119
|
-
properties = void 0;
|
|
120
|
-
if (!propertyIterable) {
|
|
121
|
-
geometries = item;
|
|
122
|
-
} else {
|
|
123
|
-
_item = (0, _slicedToArray2.default)(item, 2);
|
|
124
|
-
geometries = _item[0];
|
|
125
|
-
properties = _item[1];
|
|
126
|
-
}
|
|
127
|
-
geojsonGeometries = parseGeometries(geometries);
|
|
128
|
-
features = joinProperties(geojsonGeometries, properties);
|
|
129
|
-
if (reproject) {
|
|
130
|
-
features = reprojectFeatures(features, prj, _targetCrs);
|
|
37
|
+
while (1) switch (_context.prev = _context.next) {
|
|
38
|
+
case 0:
|
|
39
|
+
_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;
|
|
40
|
+
_context.next = 3;
|
|
41
|
+
return (0, _awaitAsyncGenerator2.default)(loadShapefileSidecarFiles(options, context));
|
|
42
|
+
case 3:
|
|
43
|
+
_yield$_awaitAsyncGen = _context.sent;
|
|
44
|
+
shx = _yield$_awaitAsyncGen.shx;
|
|
45
|
+
cpg = _yield$_awaitAsyncGen.cpg;
|
|
46
|
+
prj = _yield$_awaitAsyncGen.prj;
|
|
47
|
+
_context.next = 9;
|
|
48
|
+
return (0, _awaitAsyncGenerator2.default)(context.parseInBatches(asyncIterator, _shpLoader.SHPLoader, options));
|
|
49
|
+
case 9:
|
|
50
|
+
shapeIterable = _context.sent;
|
|
51
|
+
_context.next = 12;
|
|
52
|
+
return (0, _awaitAsyncGenerator2.default)(context.fetch(replaceExtension((context === null || context === void 0 ? void 0 : context.url) || '', 'dbf')));
|
|
53
|
+
case 12:
|
|
54
|
+
dbfResponse = _context.sent;
|
|
55
|
+
if (!dbfResponse.ok) {
|
|
56
|
+
_context.next = 17;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
_context.next = 16;
|
|
60
|
+
return (0, _awaitAsyncGenerator2.default)(context.parseInBatches(dbfResponse, _dbfLoader.DBFLoader, _objectSpread(_objectSpread({}, options), {}, {
|
|
61
|
+
dbf: {
|
|
62
|
+
encoding: cpg || 'latin1'
|
|
131
63
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
_context.next = 38;
|
|
64
|
+
})));
|
|
65
|
+
case 16:
|
|
66
|
+
propertyIterable = _context.sent;
|
|
67
|
+
case 17:
|
|
68
|
+
_context.next = 19;
|
|
69
|
+
return (0, _awaitAsyncGenerator2.default)(shapeIterable.next());
|
|
70
|
+
case 19:
|
|
71
|
+
shapeHeader = _context.sent.value;
|
|
72
|
+
if (!(shapeHeader && shapeHeader.batchType === 'metadata')) {
|
|
73
|
+
_context.next = 24;
|
|
143
74
|
break;
|
|
144
|
-
|
|
145
|
-
|
|
75
|
+
}
|
|
76
|
+
_context.next = 23;
|
|
77
|
+
return (0, _awaitAsyncGenerator2.default)(shapeIterable.next());
|
|
78
|
+
case 23:
|
|
79
|
+
shapeHeader = _context.sent.value;
|
|
80
|
+
case 24:
|
|
81
|
+
dbfHeader = {};
|
|
82
|
+
if (!propertyIterable) {
|
|
83
|
+
_context.next = 33;
|
|
146
84
|
break;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
_context.
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
85
|
+
}
|
|
86
|
+
_context.next = 28;
|
|
87
|
+
return (0, _awaitAsyncGenerator2.default)(propertyIterable.next());
|
|
88
|
+
case 28:
|
|
89
|
+
dbfHeader = _context.sent.value;
|
|
90
|
+
if (!(dbfHeader && dbfHeader.batchType === 'metadata')) {
|
|
91
|
+
_context.next = 33;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
_context.next = 32;
|
|
95
|
+
return (0, _awaitAsyncGenerator2.default)(propertyIterable.next());
|
|
96
|
+
case 32:
|
|
97
|
+
dbfHeader = _context.sent.value;
|
|
98
|
+
case 33:
|
|
99
|
+
if (propertyIterable) {
|
|
100
|
+
iterator = (0, _zipBatchIterators.zipBatchIterators)(shapeIterable, propertyIterable);
|
|
101
|
+
} else {
|
|
102
|
+
iterator = shapeIterable;
|
|
103
|
+
}
|
|
104
|
+
_iteratorAbruptCompletion = false;
|
|
105
|
+
_didIteratorError = false;
|
|
106
|
+
_context.prev = 36;
|
|
107
|
+
_iterator = _asyncIterator(iterator);
|
|
108
|
+
case 38:
|
|
109
|
+
_context.next = 40;
|
|
110
|
+
return (0, _awaitAsyncGenerator2.default)(_iterator.next());
|
|
111
|
+
case 40:
|
|
112
|
+
if (!(_iteratorAbruptCompletion = !(_step = _context.sent).done)) {
|
|
113
|
+
_context.next = 53;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
item = _step.value;
|
|
117
|
+
geometries = void 0;
|
|
118
|
+
properties = void 0;
|
|
119
|
+
if (!propertyIterable) {
|
|
120
|
+
geometries = item;
|
|
121
|
+
} else {
|
|
122
|
+
_item = (0, _slicedToArray2.default)(item, 2);
|
|
123
|
+
geometries = _item[0];
|
|
124
|
+
properties = _item[1];
|
|
125
|
+
}
|
|
126
|
+
geojsonGeometries = parseGeometries(geometries);
|
|
127
|
+
features = joinProperties(geojsonGeometries, properties);
|
|
128
|
+
if (reproject) {
|
|
129
|
+
features = reprojectFeatures(features, prj, _targetCrs);
|
|
130
|
+
}
|
|
131
|
+
_context.next = 50;
|
|
132
|
+
return {
|
|
133
|
+
encoding: cpg,
|
|
134
|
+
prj: prj,
|
|
135
|
+
shx: shx,
|
|
136
|
+
header: shapeHeader,
|
|
137
|
+
data: features
|
|
138
|
+
};
|
|
139
|
+
case 50:
|
|
140
|
+
_iteratorAbruptCompletion = false;
|
|
141
|
+
_context.next = 38;
|
|
142
|
+
break;
|
|
143
|
+
case 53:
|
|
144
|
+
_context.next = 59;
|
|
145
|
+
break;
|
|
146
|
+
case 55:
|
|
147
|
+
_context.prev = 55;
|
|
148
|
+
_context.t0 = _context["catch"](36);
|
|
149
|
+
_didIteratorError = true;
|
|
150
|
+
_iteratorError = _context.t0;
|
|
151
|
+
case 59:
|
|
152
|
+
_context.prev = 59;
|
|
153
|
+
_context.prev = 60;
|
|
154
|
+
if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
|
|
159
155
|
_context.next = 64;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
_context.next = 64;
|
|
159
|
+
return (0, _awaitAsyncGenerator2.default)(_iterator.return());
|
|
160
|
+
case 64:
|
|
161
|
+
_context.prev = 64;
|
|
162
|
+
if (!_didIteratorError) {
|
|
163
|
+
_context.next = 67;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
throw _iteratorError;
|
|
167
|
+
case 67:
|
|
168
|
+
return _context.finish(64);
|
|
169
|
+
case 68:
|
|
170
|
+
return _context.finish(59);
|
|
171
|
+
case 69:
|
|
172
|
+
case "end":
|
|
173
|
+
return _context.stop();
|
|
176
174
|
}
|
|
177
175
|
}, _callee, null, [[36, 55, 59, 69], [60,, 64, 68]]);
|
|
178
176
|
}));
|
|
@@ -185,57 +183,55 @@ function _parseShapefile() {
|
|
|
185
183
|
_parseShapefile = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, options, context) {
|
|
186
184
|
var _ref2, _ref2$reproject, reproject, _ref2$_targetCrs, _targetCrs, _yield$loadShapefileS, shx, cpg, prj, _yield$context$parse, header, geometries, geojsonGeometries, properties, dbfResponse, features;
|
|
187
185
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
188
|
-
while (1) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
encoding: cpg || 'latin1'
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
case 20:
|
|
222
|
-
properties = _context2.sent;
|
|
223
|
-
case 21:
|
|
224
|
-
features = joinProperties(geojsonGeometries, properties);
|
|
225
|
-
if (reproject) {
|
|
226
|
-
features = reprojectFeatures(features, prj, _targetCrs);
|
|
186
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
187
|
+
case 0:
|
|
188
|
+
_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;
|
|
189
|
+
_context2.next = 3;
|
|
190
|
+
return loadShapefileSidecarFiles(options, context);
|
|
191
|
+
case 3:
|
|
192
|
+
_yield$loadShapefileS = _context2.sent;
|
|
193
|
+
shx = _yield$loadShapefileS.shx;
|
|
194
|
+
cpg = _yield$loadShapefileS.cpg;
|
|
195
|
+
prj = _yield$loadShapefileS.prj;
|
|
196
|
+
_context2.next = 9;
|
|
197
|
+
return context.parse(arrayBuffer, _shpLoader.SHPLoader, options);
|
|
198
|
+
case 9:
|
|
199
|
+
_yield$context$parse = _context2.sent;
|
|
200
|
+
header = _yield$context$parse.header;
|
|
201
|
+
geometries = _yield$context$parse.geometries;
|
|
202
|
+
geojsonGeometries = parseGeometries(geometries);
|
|
203
|
+
properties = [];
|
|
204
|
+
_context2.next = 16;
|
|
205
|
+
return context.fetch(replaceExtension(context.url, 'dbf'));
|
|
206
|
+
case 16:
|
|
207
|
+
dbfResponse = _context2.sent;
|
|
208
|
+
if (!dbfResponse.ok) {
|
|
209
|
+
_context2.next = 21;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
_context2.next = 20;
|
|
213
|
+
return context.parse(dbfResponse, _dbfLoader.DBFLoader, {
|
|
214
|
+
dbf: {
|
|
215
|
+
encoding: cpg || 'latin1'
|
|
227
216
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
217
|
+
});
|
|
218
|
+
case 20:
|
|
219
|
+
properties = _context2.sent;
|
|
220
|
+
case 21:
|
|
221
|
+
features = joinProperties(geojsonGeometries, properties);
|
|
222
|
+
if (reproject) {
|
|
223
|
+
features = reprojectFeatures(features, prj, _targetCrs);
|
|
224
|
+
}
|
|
225
|
+
return _context2.abrupt("return", {
|
|
226
|
+
encoding: cpg,
|
|
227
|
+
prj: prj,
|
|
228
|
+
shx: shx,
|
|
229
|
+
header: header,
|
|
230
|
+
data: features
|
|
231
|
+
});
|
|
232
|
+
case 24:
|
|
233
|
+
case "end":
|
|
234
|
+
return _context2.stop();
|
|
239
235
|
}
|
|
240
236
|
}, _callee2);
|
|
241
237
|
}));
|
|
@@ -257,7 +253,6 @@ function parseGeometries(geometries) {
|
|
|
257
253
|
}
|
|
258
254
|
return geojsonGeometries;
|
|
259
255
|
}
|
|
260
|
-
|
|
261
256
|
function joinProperties(geometries, properties) {
|
|
262
257
|
var features = [];
|
|
263
258
|
for (var i = 0; i < geometries.length; i++) {
|
|
@@ -271,7 +266,6 @@ function joinProperties(geometries, properties) {
|
|
|
271
266
|
}
|
|
272
267
|
return features;
|
|
273
268
|
}
|
|
274
|
-
|
|
275
269
|
function reprojectFeatures(features, sourceCrs, targetCrs) {
|
|
276
270
|
if (!sourceCrs && !targetCrs) {
|
|
277
271
|
return features;
|
|
@@ -284,7 +278,6 @@ function reprojectFeatures(features, sourceCrs, targetCrs) {
|
|
|
284
278
|
return projection.project(coord);
|
|
285
279
|
});
|
|
286
280
|
}
|
|
287
|
-
|
|
288
281
|
function loadShapefileSidecarFiles(_x7, _x8) {
|
|
289
282
|
return _loadShapefileSidecarFiles.apply(this, arguments);
|
|
290
283
|
}
|
|
@@ -292,65 +285,63 @@ function _loadShapefileSidecarFiles() {
|
|
|
292
285
|
_loadShapefileSidecarFiles = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(options, context) {
|
|
293
286
|
var url, fetch, shxPromise, cpgPromise, prjPromise, shx, cpg, prj, shxResponse, arrayBuffer, cpgResponse, prjResponse;
|
|
294
287
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
295
|
-
while (1) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
return _context3.stop();
|
|
353
|
-
}
|
|
288
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
289
|
+
case 0:
|
|
290
|
+
url = context.url, fetch = context.fetch;
|
|
291
|
+
shxPromise = fetch(replaceExtension(url, 'shx'));
|
|
292
|
+
cpgPromise = fetch(replaceExtension(url, 'cpg'));
|
|
293
|
+
prjPromise = fetch(replaceExtension(url, 'prj'));
|
|
294
|
+
_context3.next = 6;
|
|
295
|
+
return Promise.all([shxPromise, cpgPromise, prjPromise]);
|
|
296
|
+
case 6:
|
|
297
|
+
_context3.next = 8;
|
|
298
|
+
return shxPromise;
|
|
299
|
+
case 8:
|
|
300
|
+
shxResponse = _context3.sent;
|
|
301
|
+
if (!shxResponse.ok) {
|
|
302
|
+
_context3.next = 14;
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
_context3.next = 12;
|
|
306
|
+
return shxResponse.arrayBuffer();
|
|
307
|
+
case 12:
|
|
308
|
+
arrayBuffer = _context3.sent;
|
|
309
|
+
shx = (0, _parseShx.parseShx)(arrayBuffer);
|
|
310
|
+
case 14:
|
|
311
|
+
_context3.next = 16;
|
|
312
|
+
return cpgPromise;
|
|
313
|
+
case 16:
|
|
314
|
+
cpgResponse = _context3.sent;
|
|
315
|
+
if (!cpgResponse.ok) {
|
|
316
|
+
_context3.next = 21;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
_context3.next = 20;
|
|
320
|
+
return cpgResponse.text();
|
|
321
|
+
case 20:
|
|
322
|
+
cpg = _context3.sent;
|
|
323
|
+
case 21:
|
|
324
|
+
_context3.next = 23;
|
|
325
|
+
return prjPromise;
|
|
326
|
+
case 23:
|
|
327
|
+
prjResponse = _context3.sent;
|
|
328
|
+
if (!prjResponse.ok) {
|
|
329
|
+
_context3.next = 28;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
_context3.next = 27;
|
|
333
|
+
return prjResponse.text();
|
|
334
|
+
case 27:
|
|
335
|
+
prj = _context3.sent;
|
|
336
|
+
case 28:
|
|
337
|
+
return _context3.abrupt("return", {
|
|
338
|
+
shx: shx,
|
|
339
|
+
cpg: cpg,
|
|
340
|
+
prj: prj
|
|
341
|
+
});
|
|
342
|
+
case 29:
|
|
343
|
+
case "end":
|
|
344
|
+
return _context3.stop();
|
|
354
345
|
}
|
|
355
346
|
}, _callee3);
|
|
356
347
|
}));
|
|
@@ -365,7 +356,6 @@ function replaceExtension(url, newExtension) {
|
|
|
365
356
|
}
|
|
366
357
|
return "".concat(baseName, ".").concat(newExtension);
|
|
367
358
|
}
|
|
368
|
-
|
|
369
359
|
function basename(url) {
|
|
370
360
|
var extIndex = url && url.lastIndexOf('.');
|
|
371
361
|
if (typeof extIndex === 'number') {
|