@dra2020/baseclient 1.0.16 → 1.0.19
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 +88 -7
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +1 -0
- package/dist/poly/all.d.ts +1 -0
- package/dist/poly/pointinpoly.d.ts +1 -0
- package/lib/geo/geo.ts +15 -0
- package/lib/poly/all.ts +1 -0
- package/lib/poly/pointinpoly.ts +29 -0
- package/lib/poly/polybin.ts +5 -4
- package/lib/poly/polypack.ts +4 -2
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -1278,9 +1278,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1278
1278
|
return result;
|
|
1279
1279
|
};
|
|
1280
1280
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1281
|
-
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollection = exports.geoCollectionToTopo = exports.geoMapToCollection = exports.geoCollectionToMap = void 0;
|
|
1281
|
+
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollection = exports.geoCollectionToTopo = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoEnsureID = void 0;
|
|
1282
1282
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1283
1283
|
const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
|
|
1284
|
+
function geoEnsureID(col) {
|
|
1285
|
+
let prop;
|
|
1286
|
+
const props = ['id', 'GEOID', 'GEOID10', 'GEOID20', 'GEOID30'];
|
|
1287
|
+
if (col && col.features && col.features.length > 0) {
|
|
1288
|
+
let f = col.features[0];
|
|
1289
|
+
if (f.properties.id !== undefined)
|
|
1290
|
+
return;
|
|
1291
|
+
props.forEach(p => { if (prop === undefined && f.properties[p] !== undefined)
|
|
1292
|
+
prop = p; });
|
|
1293
|
+
if (prop)
|
|
1294
|
+
col.features.forEach(f => { f.properties.id = f.properties[prop]; });
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
exports.geoEnsureID = geoEnsureID;
|
|
1284
1298
|
function geoCollectionToMap(col) {
|
|
1285
1299
|
if (col == null)
|
|
1286
1300
|
return null;
|
|
@@ -4573,6 +4587,7 @@ __exportStar(__webpack_require__(/*! ./polyround */ "./lib/poly/polyround.ts"),
|
|
|
4573
4587
|
__exportStar(__webpack_require__(/*! ./topo */ "./lib/poly/topo.ts"), exports);
|
|
4574
4588
|
__exportStar(__webpack_require__(/*! ./selfintersect */ "./lib/poly/selfintersect.ts"), exports);
|
|
4575
4589
|
__exportStar(__webpack_require__(/*! ./shamos */ "./lib/poly/shamos.ts"), exports);
|
|
4590
|
+
__exportStar(__webpack_require__(/*! ./pointinpoly */ "./lib/poly/pointinpoly.ts"), exports);
|
|
4576
4591
|
|
|
4577
4592
|
|
|
4578
4593
|
/***/ }),
|
|
@@ -5654,6 +5669,66 @@ export function minimumBoundingRectangle(poly: any): any
|
|
|
5654
5669
|
*/
|
|
5655
5670
|
|
|
5656
5671
|
|
|
5672
|
+
/***/ }),
|
|
5673
|
+
|
|
5674
|
+
/***/ "./lib/poly/pointinpoly.ts":
|
|
5675
|
+
/*!*********************************!*\
|
|
5676
|
+
!*** ./lib/poly/pointinpoly.ts ***!
|
|
5677
|
+
\*********************************/
|
|
5678
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
5679
|
+
|
|
5680
|
+
|
|
5681
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5682
|
+
if (k2 === undefined) k2 = k;
|
|
5683
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5684
|
+
}) : (function(o, m, k, k2) {
|
|
5685
|
+
if (k2 === undefined) k2 = k;
|
|
5686
|
+
o[k2] = m[k];
|
|
5687
|
+
}));
|
|
5688
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
5689
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
5690
|
+
}) : function(o, v) {
|
|
5691
|
+
o["default"] = v;
|
|
5692
|
+
});
|
|
5693
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
5694
|
+
if (mod && mod.__esModule) return mod;
|
|
5695
|
+
var result = {};
|
|
5696
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
5697
|
+
__setModuleDefault(result, mod);
|
|
5698
|
+
return result;
|
|
5699
|
+
};
|
|
5700
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5701
|
+
exports.polyContainsPoint = void 0;
|
|
5702
|
+
const PP = __importStar(__webpack_require__(/*! ./polypack */ "./lib/poly/polypack.ts"));
|
|
5703
|
+
function polyContainsPoint(poly, x, y) {
|
|
5704
|
+
let pp = PP.polyPack(poly);
|
|
5705
|
+
if (pp == null)
|
|
5706
|
+
return false;
|
|
5707
|
+
let bFound = false;
|
|
5708
|
+
let bInside = false;
|
|
5709
|
+
PP.polyPackEachRing(pp, (b, iPoly, iRing, iOffset, nPoints) => {
|
|
5710
|
+
if (bFound)
|
|
5711
|
+
return;
|
|
5712
|
+
let inside = false;
|
|
5713
|
+
let iEnd = iOffset + (nPoints - 1) * 2;
|
|
5714
|
+
for (let i = iOffset, j = iEnd; i < iEnd; j = i, i += 2) {
|
|
5715
|
+
let xi = b[i], yi = b[i + 1];
|
|
5716
|
+
let xj = b[j], yj = b[j + 1];
|
|
5717
|
+
let intersect = ((yi > y) !== (yj > y))
|
|
5718
|
+
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
|
5719
|
+
if (intersect)
|
|
5720
|
+
inside = !inside;
|
|
5721
|
+
}
|
|
5722
|
+
if (inside) {
|
|
5723
|
+
bFound = iRing > 0; // if inside a hole, don't need to process further
|
|
5724
|
+
bInside = iRing == 0; // not inside if inside a hole
|
|
5725
|
+
}
|
|
5726
|
+
});
|
|
5727
|
+
return bInside;
|
|
5728
|
+
}
|
|
5729
|
+
exports.polyContainsPoint = polyContainsPoint;
|
|
5730
|
+
|
|
5731
|
+
|
|
5657
5732
|
/***/ }),
|
|
5658
5733
|
|
|
5659
5734
|
/***/ "./lib/poly/poly.ts":
|
|
@@ -6364,9 +6439,11 @@ function unpackString(coder, buf8, buf32, offset) {
|
|
|
6364
6439
|
function packCollection(coder, col) {
|
|
6365
6440
|
// Compute size
|
|
6366
6441
|
let pp = PP.featurePack(col);
|
|
6367
|
-
let
|
|
6442
|
+
let f = col.features.find((f) => { return f.geometry.packed ? f.geometry.packed.buffer : null; });
|
|
6443
|
+
let buffer = f ? f.geometry.packed.buffer : null;
|
|
6368
6444
|
let size = 16; // int endiness, offset to coordinates, float endiness
|
|
6369
|
-
col.features.forEach((f) => {
|
|
6445
|
+
col.features.forEach((f) => { if (f.geometry.packed)
|
|
6446
|
+
delete f.geometry.packed.buffer; }); // reconstructed when unpacking
|
|
6370
6447
|
let j = JSON.stringify(col);
|
|
6371
6448
|
size += sizeOfString(coder, j);
|
|
6372
6449
|
size += pad(size, 8);
|
|
@@ -6392,7 +6469,8 @@ function packCollection(coder, col) {
|
|
|
6392
6469
|
for (let i = 0; i < pp.length; i++)
|
|
6393
6470
|
buf64[foff++] = buf[i];
|
|
6394
6471
|
// Now restore
|
|
6395
|
-
col.features.forEach((f) => { f.geometry.packed
|
|
6472
|
+
col.features.forEach((f) => { if (f.geometry.packed)
|
|
6473
|
+
f.geometry.packed.buffer = buffer; });
|
|
6396
6474
|
PP.featureUnpack(col);
|
|
6397
6475
|
return ab;
|
|
6398
6476
|
}
|
|
@@ -6444,7 +6522,8 @@ function unpackCollection(coder, ab) {
|
|
|
6444
6522
|
let offset = 16;
|
|
6445
6523
|
let j = unpackString(coder, buf8, buf32, offset);
|
|
6446
6524
|
col = JSON.parse(j);
|
|
6447
|
-
col.features.forEach((f) => { f.geometry.packed
|
|
6525
|
+
col.features.forEach((f) => { if (f.geometry.packed)
|
|
6526
|
+
f.geometry.packed.buffer = buf64; });
|
|
6448
6527
|
return col;
|
|
6449
6528
|
}
|
|
6450
6529
|
exports.unpackCollection = unpackCollection;
|
|
@@ -7028,14 +7107,16 @@ function polyUnpack(prepack) {
|
|
|
7028
7107
|
}
|
|
7029
7108
|
exports.polyUnpack = polyUnpack;
|
|
7030
7109
|
function featurePackSize(f) {
|
|
7031
|
-
if (f && f.geometry && f.geometry.coordinates)
|
|
7110
|
+
if (f && f.geometry && f.geometry.coordinates && f.geometry.type !== 'Point')
|
|
7032
7111
|
return polyPackSize(f.geometry.coordinates);
|
|
7033
7112
|
return 0;
|
|
7034
7113
|
}
|
|
7035
7114
|
exports.featurePackSize = featurePackSize;
|
|
7036
7115
|
function featurePack(f, prepack) {
|
|
7037
7116
|
if (f && f.type === 'Feature') {
|
|
7038
|
-
if (f.geometry && f.geometry.
|
|
7117
|
+
if (f.geometry && f.geometry.type === 'Point')
|
|
7118
|
+
return prepack ? { offset: prepack.offset, length: 0, buffer: prepack.buffer } : { offset: 0, length: 0, buffer: null };
|
|
7119
|
+
else if (f.geometry && f.geometry.coordinates) {
|
|
7039
7120
|
f.geometry.packed = polyPack(f.geometry.coordinates, prepack);
|
|
7040
7121
|
delete f.geometry.coordinates;
|
|
7041
7122
|
}
|