@dra2020/baseclient 1.0.164 → 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.
- package/dist/baseclient.js +148 -0
- package/dist/baseclient.js.map +1 -1
- package/dist/poly/all.d.ts +1 -0
- package/dist/poly/polyconvert.d.ts +10 -0
- package/lib/poly/all.ts +1 -0
- package/lib/poly/polyconvert.ts +128 -0
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -6633,6 +6633,7 @@ __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);
|
|
@@ -9068,6 +9069,153 @@ function topoFromBuffer(coder, ab) {
|
|
|
9068
9069
|
}
|
|
9069
9070
|
|
|
9070
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
|
+
|
|
9071
9219
|
/***/ }),
|
|
9072
9220
|
|
|
9073
9221
|
/***/ "./lib/poly/polyhash.ts":
|