@dra2020/baseclient 1.0.58 → 1.0.61
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/all/all.d.ts +2 -0
- package/dist/baseclient.js +259 -24
- package/dist/baseclient.js.map +1 -1
- package/dist/csv/all.d.ts +1 -0
- package/dist/csv/csv.d.ts +18 -0
- package/dist/poly/poly.d.ts +13 -1
- package/lib/all/all.ts +2 -0
- package/lib/csv/all.ts +1 -0
- package/lib/csv/csv.ts +121 -0
- package/lib/poly/poly.ts +143 -17
- package/lib/poly/topo.ts +1 -1
- package/package.json +1 -1
package/dist/all/all.d.ts
CHANGED
package/dist/baseclient.js
CHANGED
|
@@ -39,7 +39,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
39
39
|
return result;
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
42
|
-
exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
|
|
42
|
+
exports.CSV = exports.Emit = exports.G = exports.FilterExpr = exports.OTE = exports.OT = exports.LogClient = exports.LogAbstract = exports.Poly = exports.FSM = exports.Context = exports.Util = void 0;
|
|
43
43
|
// Client and Server
|
|
44
44
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
45
45
|
exports.Util = Util;
|
|
@@ -63,6 +63,8 @@ const G = __importStar(__webpack_require__(/*! ../geo/all */ "./lib/geo/all.ts")
|
|
|
63
63
|
exports.G = G;
|
|
64
64
|
const Emit = __importStar(__webpack_require__(/*! ../emit/all */ "./lib/emit/all.ts"));
|
|
65
65
|
exports.Emit = Emit;
|
|
66
|
+
const CSV = __importStar(__webpack_require__(/*! ../csv/all */ "./lib/csv/all.ts"));
|
|
67
|
+
exports.CSV = CSV;
|
|
66
68
|
|
|
67
69
|
|
|
68
70
|
/***/ }),
|
|
@@ -169,6 +171,150 @@ function create() {
|
|
|
169
171
|
exports.create = create;
|
|
170
172
|
|
|
171
173
|
|
|
174
|
+
/***/ }),
|
|
175
|
+
|
|
176
|
+
/***/ "./lib/csv/all.ts":
|
|
177
|
+
/*!************************!*\
|
|
178
|
+
!*** ./lib/csv/all.ts ***!
|
|
179
|
+
\************************/
|
|
180
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
184
|
+
if (k2 === undefined) k2 = k;
|
|
185
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
186
|
+
}) : (function(o, m, k, k2) {
|
|
187
|
+
if (k2 === undefined) k2 = k;
|
|
188
|
+
o[k2] = m[k];
|
|
189
|
+
}));
|
|
190
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
191
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
192
|
+
};
|
|
193
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
194
|
+
__exportStar(__webpack_require__(/*! ./csv */ "./lib/csv/csv.ts"), exports);
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
/***/ }),
|
|
198
|
+
|
|
199
|
+
/***/ "./lib/csv/csv.ts":
|
|
200
|
+
/*!************************!*\
|
|
201
|
+
!*** ./lib/csv/csv.ts ***!
|
|
202
|
+
\************************/
|
|
203
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
207
|
+
if (k2 === undefined) k2 = k;
|
|
208
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
209
|
+
}) : (function(o, m, k, k2) {
|
|
210
|
+
if (k2 === undefined) k2 = k;
|
|
211
|
+
o[k2] = m[k];
|
|
212
|
+
}));
|
|
213
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
214
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
215
|
+
}) : function(o, v) {
|
|
216
|
+
o["default"] = v;
|
|
217
|
+
});
|
|
218
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
219
|
+
if (mod && mod.__esModule) return mod;
|
|
220
|
+
var result = {};
|
|
221
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
222
|
+
__setModuleDefault(result, mod);
|
|
223
|
+
return result;
|
|
224
|
+
};
|
|
225
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
226
|
+
exports.ParseOne = void 0;
|
|
227
|
+
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
228
|
+
// Parse CSV.
|
|
229
|
+
// Fields are separated by commas or pipe symbol (census uses pipe separators.
|
|
230
|
+
// Quoted fields may contain commas or pipes.
|
|
231
|
+
// Either single quotes or double quotes may be used to surround field value.
|
|
232
|
+
// Spaces at the beginning and end of fields are ignored.
|
|
233
|
+
// Quotes must be the first non-space character in the field (otherwise they are part of the field value).
|
|
234
|
+
//
|
|
235
|
+
const Space = 32;
|
|
236
|
+
const Tab = 9;
|
|
237
|
+
const Newline = 10;
|
|
238
|
+
const CR = 13;
|
|
239
|
+
const Comma = 44;
|
|
240
|
+
const SingleQuote = 39;
|
|
241
|
+
const DoubleQuote = 34;
|
|
242
|
+
const BackSlash = 92;
|
|
243
|
+
const Pipe = 124;
|
|
244
|
+
function isWhite(c) {
|
|
245
|
+
return c === Space || c === Newline || c === Tab || c == CR;
|
|
246
|
+
}
|
|
247
|
+
class ParseOne {
|
|
248
|
+
constructor(coder, line) {
|
|
249
|
+
this.coder = coder;
|
|
250
|
+
if (line)
|
|
251
|
+
this.set(line);
|
|
252
|
+
else
|
|
253
|
+
this.fields = [];
|
|
254
|
+
}
|
|
255
|
+
set(line) {
|
|
256
|
+
this.fields = [];
|
|
257
|
+
this.buf = Util.s2u8(this.coder, line);
|
|
258
|
+
this.tok = new Uint8Array(new ArrayBuffer(this.buf.length));
|
|
259
|
+
this.n = 0;
|
|
260
|
+
this.toklen = 0;
|
|
261
|
+
this.infield = false;
|
|
262
|
+
this.nwhite = 0;
|
|
263
|
+
this.quote = 0;
|
|
264
|
+
this.force = false;
|
|
265
|
+
this.parse();
|
|
266
|
+
}
|
|
267
|
+
get length() { return this.fields.length; }
|
|
268
|
+
pushtok() {
|
|
269
|
+
// Trim trailing whitespace
|
|
270
|
+
this.toklen -= this.nwhite;
|
|
271
|
+
if (this.toklen || this.force) {
|
|
272
|
+
this.fields.push(Util.u82s(this.coder, this.tok, 0, this.toklen));
|
|
273
|
+
this.toklen = 0;
|
|
274
|
+
}
|
|
275
|
+
this.infield = false;
|
|
276
|
+
this.nwhite = 0;
|
|
277
|
+
this.quote = 0;
|
|
278
|
+
this.force = false;
|
|
279
|
+
}
|
|
280
|
+
parse() {
|
|
281
|
+
while (this.n < this.buf.length) {
|
|
282
|
+
let c = this.buf[this.n++];
|
|
283
|
+
if (this.quote && c === this.quote) {
|
|
284
|
+
this.quote = 0;
|
|
285
|
+
this.nwhite = 0;
|
|
286
|
+
}
|
|
287
|
+
else if (c === Comma || c === Pipe) {
|
|
288
|
+
this.force = true;
|
|
289
|
+
this.pushtok();
|
|
290
|
+
this.force = true;
|
|
291
|
+
}
|
|
292
|
+
else if (this.infield) {
|
|
293
|
+
this.tok[this.toklen++] = c;
|
|
294
|
+
if (!this.quote && isWhite(c))
|
|
295
|
+
this.nwhite++;
|
|
296
|
+
else
|
|
297
|
+
this.nwhite = 0;
|
|
298
|
+
}
|
|
299
|
+
else if (isWhite(c))
|
|
300
|
+
continue;
|
|
301
|
+
else if (c === SingleQuote || c === DoubleQuote) {
|
|
302
|
+
this.quote = c;
|
|
303
|
+
this.infield = true;
|
|
304
|
+
this.force = true;
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
this.infield = true;
|
|
308
|
+
this.tok[this.toklen++] = c;
|
|
309
|
+
this.force = true;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
this.pushtok();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
exports.ParseOne = ParseOne;
|
|
316
|
+
|
|
317
|
+
|
|
172
318
|
/***/ }),
|
|
173
319
|
|
|
174
320
|
/***/ "./lib/emit/all.ts":
|
|
@@ -6096,7 +6242,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
6096
6242
|
return result;
|
|
6097
6243
|
};
|
|
6098
6244
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
6099
|
-
exports.polyBadCoordinates = exports.polyRewindRings = exports.featureRewind = exports.polyTransform = exports.npoints = exports.polyDescribe = exports.polyCompactness = exports.makeConvexHullMonotoneChain2D = exports.polyConvexHull = exports.polyToExteriorPoints = exports.polyFromCircle = exports.polyToPolsbyPopperCircle = exports.polyToCircle = exports.Circle = exports.polyPerimeter = exports.polyDiameter = exports.polyArea = exports.polyNull = exports.polyNormalize = exports.polySimpleArea = exports.DefaultOptions = exports.EARTH_RADIUS = exports.DefaultTickOptions = void 0;
|
|
6245
|
+
exports.polyBadCoordinates = exports.polyRewindRings = exports.featureRewind = exports.polyRingWindings = exports.polyTransform = exports.npoints = exports.polyDescribe = exports.polyCompactness = exports.makeConvexHullMonotoneChain2D = exports.polyConvexHull = exports.polyToExteriorPoints = exports.polyFromCircle = exports.polyToPolsbyPopperCircle = exports.polyToCircle = exports.Circle = exports.polyPerimeter = exports.polyDiameter = exports.polyArea = exports.polyNull = exports.polyNormalize = exports.polySimpleArea = exports.DefaultOptions = exports.EARTH_RADIUS = exports.DefaultTickOptions = void 0;
|
|
6100
6246
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
6101
6247
|
const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
|
|
6102
6248
|
const graham_scan_1 = __webpack_require__(/*! ./graham-scan */ "./lib/poly/graham-scan.ts");
|
|
@@ -6616,30 +6762,119 @@ function closePoly(poly) {
|
|
|
6616
6762
|
poly.forEach(closeRing);
|
|
6617
6763
|
return poly;
|
|
6618
6764
|
}
|
|
6765
|
+
function closeFeature(f) {
|
|
6766
|
+
let d = Util.depthof(f.geometry.coordinates);
|
|
6767
|
+
if (d === 4)
|
|
6768
|
+
closePoly(f.geometry.coordinates);
|
|
6769
|
+
if (d === 5)
|
|
6770
|
+
f.geometry.coordinates.forEach(closePoly);
|
|
6771
|
+
}
|
|
6772
|
+
function canonicalPoint(f, options) {
|
|
6773
|
+
if (options.canonical)
|
|
6774
|
+
if (f && f.geometry && f.geometry.type === 'Point' && f.geometry.coordinates)
|
|
6775
|
+
while (Array.isArray(f.geometry.coordinates[0]))
|
|
6776
|
+
f.geometry.coordinates = f.geometry.coordinates[0];
|
|
6777
|
+
return f;
|
|
6778
|
+
}
|
|
6779
|
+
;
|
|
6780
|
+
function misWound(w) {
|
|
6781
|
+
return (((w.iRing == 0) && (w.direction > 0)) || ((w.iRing > 0) && (w.direction < 0)));
|
|
6782
|
+
}
|
|
6783
|
+
function polyRingWindings(poly) {
|
|
6784
|
+
let windings = [];
|
|
6785
|
+
let pp = polyNormalize(poly);
|
|
6786
|
+
if (pp == null || pp.buffer == null)
|
|
6787
|
+
return windings;
|
|
6788
|
+
PP.polyPackEachRing(pp, (b, iPoly, iRing, iOffset, nPoints) => {
|
|
6789
|
+
const iStart = iOffset;
|
|
6790
|
+
const iEnd = iStart + (nPoints * 2) - 2;
|
|
6791
|
+
// Determine the winding order of the ring
|
|
6792
|
+
let direction = 0;
|
|
6793
|
+
// Start at the second point
|
|
6794
|
+
iOffset += 2;
|
|
6795
|
+
for (; iOffset <= iEnd; iOffset += 2) {
|
|
6796
|
+
// The previous point
|
|
6797
|
+
let jOffset = iOffset - 2;
|
|
6798
|
+
// Sum over the edges
|
|
6799
|
+
direction += twoTimesArea(b[iOffset], b[jOffset], b[iOffset + 1], b[jOffset + 1]);
|
|
6800
|
+
}
|
|
6801
|
+
// Implicitly close the ring, if necessary
|
|
6802
|
+
if (nPoints > 2 && (b[iStart] != b[iEnd] || b[iStart + 1] != b[iEnd + 1]))
|
|
6803
|
+
direction += twoTimesArea(b[iStart], b[iEnd], b[iStart + 1], b[iEnd + 1]);
|
|
6804
|
+
windings.push({ iPoly: iPoly, iRing: iRing, direction: direction });
|
|
6805
|
+
});
|
|
6806
|
+
return windings;
|
|
6807
|
+
}
|
|
6808
|
+
exports.polyRingWindings = polyRingWindings;
|
|
6619
6809
|
// This mutates the passed in feature to ensure it is correctly wound
|
|
6620
6810
|
// For convenience, passed back the value provided.
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6811
|
+
//
|
|
6812
|
+
function featureRewind(f, options) {
|
|
6813
|
+
options = Util.shallowAssignImmutable({ validateHoles: true, validateClose: true, canonical: true }, options);
|
|
6814
|
+
if (!f)
|
|
6624
6815
|
return null;
|
|
6625
|
-
|
|
6626
|
-
if (
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6816
|
+
// Has to be an unpacked feature
|
|
6817
|
+
if (f.type !== 'Feature')
|
|
6818
|
+
throw 'featureRewind: must be a valid GeoJSON feature';
|
|
6819
|
+
if (!f.geometry || f.geometry.packed)
|
|
6820
|
+
throw 'featureRewind: only valid on unpacked features';
|
|
6821
|
+
// Non polygons are simpler
|
|
6822
|
+
if (f.geometry.type !== 'Polygon' && f.geometry.type !== 'MultiPolygon')
|
|
6823
|
+
return canonicalPoint(f, options);
|
|
6824
|
+
// Make sure polygon is closed (first === last)
|
|
6825
|
+
if (options.validateClose)
|
|
6826
|
+
closeFeature(f);
|
|
6827
|
+
// Check if multi-polygon is really polygon with holes
|
|
6828
|
+
// Only applies to multi-polygons with no holes
|
|
6829
|
+
let d = Util.depthof(f.geometry.coordinates);
|
|
6830
|
+
let windings = polyRingWindings(f);
|
|
6831
|
+
if (options.validateHoles && d === 5 && windings.length) {
|
|
6832
|
+
// If there are explicit holes, don't look for implicit ones
|
|
6833
|
+
let nHoles = 0;
|
|
6834
|
+
windings.forEach(w => { if (w.iRing)
|
|
6835
|
+
nHoles++; });
|
|
6836
|
+
if (nHoles == 0 && !misWound(windings[0])) {
|
|
6837
|
+
// Looking for pattern: of (G (B*))*
|
|
6838
|
+
// To convert to ((GH*))*
|
|
6839
|
+
let iWinding = 0;
|
|
6840
|
+
let polys = f.geometry.coordinates;
|
|
6841
|
+
let iPoly;
|
|
6842
|
+
for (; iWinding < windings.length; iWinding++) {
|
|
6843
|
+
let good = misWound(windings[iWinding]);
|
|
6844
|
+
if (!good && iWinding == 0) // First is miswound - no good
|
|
6845
|
+
break;
|
|
6846
|
+
if (good)
|
|
6847
|
+
iPoly = iWinding;
|
|
6848
|
+
else {
|
|
6849
|
+
polys[iPoly].push(polys[iWinding][0]);
|
|
6850
|
+
polys[iWinding] = null;
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6853
|
+
f.geometry.coordinates = polys.filter((p) => p != null);
|
|
6854
|
+
}
|
|
6855
|
+
// Degenerate multi-polygon
|
|
6856
|
+
if (f.geometry.coordinates.length == 1) {
|
|
6857
|
+
f.geometry.type = 'Polygon';
|
|
6858
|
+
f.geometry.coordinates = f.geometry.coordinates[0];
|
|
6859
|
+
}
|
|
6860
|
+
}
|
|
6861
|
+
// OK, now go through each ring
|
|
6862
|
+
let polys = f.geometry.coordinates;
|
|
6863
|
+
windings = polyRingWindings(f);
|
|
6864
|
+
windings.forEach((w) => {
|
|
6865
|
+
let good = misWound(w);
|
|
6866
|
+
if (!good) {
|
|
6867
|
+
let ring = polys[w.iPoly][w.iRing];
|
|
6868
|
+
let iFront = 0;
|
|
6869
|
+
let iBack = ring.length - 1;
|
|
6870
|
+
for (; iFront < iBack; iFront++, iBack--) {
|
|
6871
|
+
let tmp = ring[iFront];
|
|
6872
|
+
ring[iFront] = ring[iBack];
|
|
6873
|
+
ring[iBack] = tmp;
|
|
6874
|
+
}
|
|
6875
|
+
}
|
|
6876
|
+
});
|
|
6877
|
+
return f;
|
|
6643
6878
|
}
|
|
6644
6879
|
exports.featureRewind = featureRewind;
|
|
6645
6880
|
//
|
|
@@ -8565,7 +8800,7 @@ function correctGeometry(f) {
|
|
|
8565
8800
|
}
|
|
8566
8801
|
else
|
|
8567
8802
|
// TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
|
|
8568
|
-
P.featureRewind(f);
|
|
8803
|
+
P.featureRewind(f, { validateHoles: false });
|
|
8569
8804
|
return f;
|
|
8570
8805
|
}
|
|
8571
8806
|
function topoContiguity(topo) {
|