@dra2020/baseclient 1.0.163 → 1.0.165

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.
@@ -6633,12 +6633,14 @@ __exportStar(__webpack_require__(/*! ./blend */ "./lib/poly/blend.ts"), exports)
6633
6633
  __exportStar(__webpack_require__(/*! ./cartesian */ "./lib/poly/cartesian.ts"), exports);
6634
6634
  __exportStar(__webpack_require__(/*! ./minbound */ "./lib/poly/minbound.ts"), exports);
6635
6635
  __exportStar(__webpack_require__(/*! ./polyround */ "./lib/poly/polyround.ts"), exports);
6636
+ __exportStar(__webpack_require__(/*! ./polyconvert */ "./lib/poly/polyconvert.ts"), exports);
6636
6637
  __exportStar(__webpack_require__(/*! ./topo */ "./lib/poly/topo.ts"), exports);
6637
6638
  __exportStar(__webpack_require__(/*! ./selfintersect */ "./lib/poly/selfintersect.ts"), exports);
6638
6639
  __exportStar(__webpack_require__(/*! ./shamos */ "./lib/poly/shamos.ts"), exports);
6639
6640
  __exportStar(__webpack_require__(/*! ./pointinpoly */ "./lib/poly/pointinpoly.ts"), exports);
6640
6641
  __exportStar(__webpack_require__(/*! ./mapto */ "./lib/poly/mapto.ts"), exports);
6641
6642
  __exportStar(__webpack_require__(/*! ./featurecleanholes */ "./lib/poly/featurecleanholes.ts"), exports);
6643
+ __exportStar(__webpack_require__(/*! ./polyhash */ "./lib/poly/polyhash.ts"), exports);
6642
6644
 
6643
6645
 
6644
6646
  /***/ }),
@@ -9067,6 +9069,245 @@ function topoFromBuffer(coder, ab) {
9067
9069
  }
9068
9070
 
9069
9071
 
9072
+ /***/ }),
9073
+
9074
+ /***/ "./lib/poly/polyconvert.ts":
9075
+ /*!*********************************!*\
9076
+ !*** ./lib/poly/polyconvert.ts ***!
9077
+ \*********************************/
9078
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9079
+
9080
+
9081
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9082
+ if (k2 === undefined) k2 = k;
9083
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9084
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9085
+ desc = { enumerable: true, get: function() { return m[k]; } };
9086
+ }
9087
+ Object.defineProperty(o, k2, desc);
9088
+ }) : (function(o, m, k, k2) {
9089
+ if (k2 === undefined) k2 = k;
9090
+ o[k2] = m[k];
9091
+ }));
9092
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
9093
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
9094
+ }) : function(o, v) {
9095
+ o["default"] = v;
9096
+ });
9097
+ var __importStar = (this && this.__importStar) || (function () {
9098
+ var ownKeys = function(o) {
9099
+ ownKeys = Object.getOwnPropertyNames || function (o) {
9100
+ var ar = [];
9101
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
9102
+ return ar;
9103
+ };
9104
+ return ownKeys(o);
9105
+ };
9106
+ return function (mod) {
9107
+ if (mod && mod.__esModule) return mod;
9108
+ var result = {};
9109
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
9110
+ __setModuleDefault(result, mod);
9111
+ return result;
9112
+ };
9113
+ })();
9114
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
9115
+ exports.polyConvert = polyConvert;
9116
+ exports.polyFrom32614 = polyFrom32614;
9117
+ exports.colValidateCRS = colValidateCRS;
9118
+ exports.utm14ToLonLat = utm14ToLonLat;
9119
+ const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
9120
+ // Convert geometry given point conversion function. Takes any form of feature, collection or coordinate array(s)
9121
+ function polyConvert(o, cvt) {
9122
+ if (o) {
9123
+ if (Array.isArray(o)) {
9124
+ if (o.length && typeof o[0] === 'number') {
9125
+ for (let i = 0; i < o.length; i += 2) {
9126
+ const p = cvt([o[i], o[i + 1]]);
9127
+ o[i] = p[0];
9128
+ o[i + 1] = p[1];
9129
+ }
9130
+ }
9131
+ else
9132
+ o.forEach((e) => { polyConvert(e, cvt); });
9133
+ }
9134
+ else if (o.features !== undefined && Array.isArray(o.features))
9135
+ o.features.forEach((f) => { polyConvert(f, cvt); });
9136
+ else if (o.geometry !== undefined && o.geometry.coordinates !== undefined)
9137
+ polyConvert(o.geometry.coordinates, cvt);
9138
+ else if (o.geometry !== undefined && o.geometry.packed !== undefined)
9139
+ PP.polyPackEachPoint(o.geometry.packed, (b, iPoly, iRing, iOffset) => {
9140
+ const p = cvt([b[iOffset], b[iOffset + 1]]);
9141
+ b[iOffset] = p[0];
9142
+ b[iOffset + 1] = p[1];
9143
+ });
9144
+ }
9145
+ return o;
9146
+ }
9147
+ function polyFrom32614(o) {
9148
+ return polyConvert(o, utm14ToLonLat);
9149
+ }
9150
+ // If coordinates in 32614 format, convert to WGS84 (GeoJSON standard format)
9151
+ //
9152
+ function colValidateCRS(o) {
9153
+ // "crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::32614" } },
9154
+ var _a, _b;
9155
+ if (((_b = (_a = o === null || o === void 0 ? void 0 : o.crs) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.name) === 'urn:ogc:def:crs:EPSG::32614') {
9156
+ delete o.crs;
9157
+ return polyFrom32614(o);
9158
+ }
9159
+ return o;
9160
+ }
9161
+ /**
9162
+ * Convert UTM Zone 14N (EPSG:32614) coordinates to WGS84 lon/lat.
9163
+ * Input: [easting, northing] in meters
9164
+ * Output: [longitude, latitude] in degrees
9165
+ */
9166
+ function utm14ToLonLat([E, N]) {
9167
+ // WGS84 parameters
9168
+ const a = 6378137.0;
9169
+ const f = 1 / 298.257223563;
9170
+ const k0 = 0.9996;
9171
+ const e = Math.sqrt(f * (2 - f)); // eccentricity
9172
+ const e1sq = e * e / (1 - e * e);
9173
+ // UTM zone parameters
9174
+ const zone = 14;
9175
+ const lonOrigin = (zone - 1) * 6 - 180 + 3; // central meridian
9176
+ const falseEasting = 500000;
9177
+ // Remove false northing for northern hemisphere (EPSG:326xx always north)
9178
+ const x = E - falseEasting;
9179
+ const y = N;
9180
+ // Footpoint latitude
9181
+ const M = y / k0;
9182
+ const mu = M / (a * (1 - e * e / 4 - 3 * Math.pow(e, 4) / 64 - 5 * Math.pow(e, 6) / 256));
9183
+ const e1 = (1 - Math.sqrt(1 - e * e)) / (1 + Math.sqrt(1 - e * e));
9184
+ const J1 = (3 * e1 / 2 - 27 * Math.pow(e1, 3) / 32);
9185
+ const J2 = (21 * Math.pow(e1, 2) / 16 - 55 * Math.pow(e1, 4) / 32);
9186
+ const J3 = (151 * Math.pow(e1, 3) / 96);
9187
+ const J4 = (1097 * Math.pow(e1, 4) / 512);
9188
+ const fp = mu
9189
+ + J1 * Math.sin(2 * mu)
9190
+ + J2 * Math.sin(4 * mu)
9191
+ + J3 * Math.sin(6 * mu)
9192
+ + J4 * Math.sin(8 * mu);
9193
+ // Precompute trig functions
9194
+ const sinfp = Math.sin(fp);
9195
+ const cosfp = Math.cos(fp);
9196
+ const tanfp = Math.tan(fp);
9197
+ const C1 = e1sq * Math.pow(cosfp, 2);
9198
+ const T1 = Math.pow(tanfp, 2);
9199
+ const R1 = a * (1 - e * e) / Math.pow(1 - e * e * Math.pow(sinfp, 2), 3 / 2);
9200
+ const N1 = a / Math.sqrt(1 - e * e * Math.pow(sinfp, 2));
9201
+ const D = x / (N1 * k0);
9202
+ // Latitude (φ)
9203
+ const lat = fp
9204
+ - (N1 * tanfp / R1) *
9205
+ (Math.pow(D, 2) / 2
9206
+ - (5 + 3 * T1 + 10 * C1 - 4 * Math.pow(C1, 2) - 9 * e1sq) * Math.pow(D, 4) / 24
9207
+ + (61 + 90 * T1 + 298 * C1 + 45 * Math.pow(T1, 2) - 252 * e1sq - 3 * Math.pow(C1, 2)) * Math.pow(D, 6) / 720);
9208
+ // Longitude (λ)
9209
+ const lon = (D
9210
+ - (1 + 2 * T1 + C1) * Math.pow(D, 3) / 6
9211
+ + (5 - 2 * C1 + 28 * T1 - 3 * Math.pow(C1, 2) + 8 * e1sq + 24 * Math.pow(T1, 2)) * Math.pow(D, 5) / 120) / cosfp;
9212
+ // Convert to degrees and apply central meridian offset
9213
+ const latitude = lat * (180 / Math.PI);
9214
+ const longitude = lonOrigin + lon * (180 / Math.PI);
9215
+ return [longitude, latitude];
9216
+ }
9217
+
9218
+
9219
+ /***/ }),
9220
+
9221
+ /***/ "./lib/poly/polyhash.ts":
9222
+ /*!******************************!*\
9223
+ !*** ./lib/poly/polyhash.ts ***!
9224
+ \******************************/
9225
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
9226
+
9227
+
9228
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9229
+ if (k2 === undefined) k2 = k;
9230
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9231
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9232
+ desc = { enumerable: true, get: function() { return m[k]; } };
9233
+ }
9234
+ Object.defineProperty(o, k2, desc);
9235
+ }) : (function(o, m, k, k2) {
9236
+ if (k2 === undefined) k2 = k;
9237
+ o[k2] = m[k];
9238
+ }));
9239
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
9240
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
9241
+ }) : function(o, v) {
9242
+ o["default"] = v;
9243
+ });
9244
+ var __importStar = (this && this.__importStar) || (function () {
9245
+ var ownKeys = function(o) {
9246
+ ownKeys = Object.getOwnPropertyNames || function (o) {
9247
+ var ar = [];
9248
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
9249
+ return ar;
9250
+ };
9251
+ return ownKeys(o);
9252
+ };
9253
+ return function (mod) {
9254
+ if (mod && mod.__esModule) return mod;
9255
+ var result = {};
9256
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
9257
+ __setModuleDefault(result, mod);
9258
+ return result;
9259
+ };
9260
+ })();
9261
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
9262
+ exports.polyHash32 = polyHash32;
9263
+ const P = __importStar(__webpack_require__(/*! ./poly */ "./lib/poly/poly.ts"));
9264
+ const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
9265
+ // Hash coordinates to 32 bit number in order to produce a fast (and a little sloppy) equivalence test.
9266
+ // Note that this depends on ordering, so an equivalent polygon with different coordinate ordering would
9267
+ // not test as equivalent. As a 32 bit number, you can expect collisions when used for large numbers of
9268
+ // polygons (e.g. a 700k block set might expect ~57 collisions - TX at 660K gets 62 collisions, e.g.).
9269
+ //
9270
+ function polyHash32(poly, seed = 0) {
9271
+ let pp = P.polyNormalize(poly);
9272
+ if (!pp)
9273
+ return 0;
9274
+ let h = (seed | 0) ^ 0x9e3779b9;
9275
+ const buf = new ArrayBuffer(8);
9276
+ const dv = new DataView(buf);
9277
+ function mix32(x) {
9278
+ x ^= x >>> 16;
9279
+ x = Math.imul(x, 0x7feb352d);
9280
+ x ^= x >>> 15;
9281
+ x = Math.imul(x, 0x846ca68b);
9282
+ x ^= x >>> 16;
9283
+ return x | 0;
9284
+ }
9285
+ let l = 0;
9286
+ PP.polyPackEachRing(pp, (b, iPoly, iRing, iOffset, nPoints) => {
9287
+ let iEnd = iOffset + (nPoints * 2);
9288
+ for (; iOffset < iEnd; iOffset++) {
9289
+ const x = b[iOffset];
9290
+ if (Number.isNaN(x)) {
9291
+ dv.setUint32(0, 0x7ff80001, true);
9292
+ dv.setUint32(4, 0, true);
9293
+ }
9294
+ else
9295
+ dv.setFloat64(0, x, true);
9296
+ const lo = dv.getUint32(0, true) | 0;
9297
+ const hi = dv.getUint32(4, true) | 0;
9298
+ let z = mix32(lo ^ Math.imul(hi, 0x9e3779b9) ^ Math.imul(l + 1, 0x85ebca6b));
9299
+ h ^= z;
9300
+ h = mix32(h);
9301
+ l++;
9302
+ }
9303
+ });
9304
+ h ^= l | 0;
9305
+ h = mix32(h);
9306
+ // return as unsigned 32-bit in a JS number
9307
+ return h >>> 0;
9308
+ }
9309
+
9310
+
9070
9311
  /***/ }),
9071
9312
 
9072
9313
  /***/ "./lib/poly/polylabel.ts":