@dra2020/baseclient 1.0.36 → 1.0.39
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 +20 -4
- package/dist/baseclient.js.map +1 -1
- package/dist/util/util.d.ts +2 -1
- package/lib/poly/mapto.ts +18 -5
- package/lib/poly/poly.ts +1 -0
- package/lib/util/util.ts +3 -1
- package/package.json +4 -1
package/dist/baseclient.js
CHANGED
|
@@ -5390,6 +5390,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
5390
5390
|
};
|
|
5391
5391
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5392
5392
|
exports.polyMapTo = exports.polyMapToByCentroid = void 0;
|
|
5393
|
+
const P = __importStar(__webpack_require__(/*! ./poly */ "./lib/poly/poly.ts"));
|
|
5393
5394
|
const PL = __importStar(__webpack_require__(/*! ./polylabel */ "./lib/poly/polylabel.ts"));
|
|
5394
5395
|
const BB = __importStar(__webpack_require__(/*! ./boundbox */ "./lib/poly/boundbox.ts"));
|
|
5395
5396
|
const pointinpoly_1 = __webpack_require__(/*! ./pointinpoly */ "./lib/poly/pointinpoly.ts");
|
|
@@ -5421,19 +5422,31 @@ function setLabels(c) {
|
|
|
5421
5422
|
function polyMapToByCentroid(districts, centroids) {
|
|
5422
5423
|
let map = {};
|
|
5423
5424
|
// Cache district boundboxes for quick containment exclusion
|
|
5424
|
-
let
|
|
5425
|
+
let fs = districts.features;
|
|
5426
|
+
let bbDistricts = fs.map(f => BB.boundbox(f));
|
|
5427
|
+
let aDistricts = fs.map(f => P.polyArea(f));
|
|
5425
5428
|
// Walk over blocks, mapping centroid to district
|
|
5426
5429
|
Object.keys(centroids).forEach(blockid => {
|
|
5427
5430
|
let x = centroids[blockid].x;
|
|
5428
5431
|
let y = centroids[blockid].y;
|
|
5429
5432
|
let fIn = [];
|
|
5430
|
-
|
|
5433
|
+
fs.forEach((fDistrict, i) => {
|
|
5431
5434
|
if (BB.boundboxContains(bbDistricts[i], x, y))
|
|
5432
5435
|
if (pointinpoly_1.polyContainsPoint(fDistrict, x, y))
|
|
5433
|
-
fIn.push(
|
|
5436
|
+
fIn.push(i);
|
|
5434
5437
|
});
|
|
5435
5438
|
if (fIn.length == 1)
|
|
5436
|
-
map[blockid] = fIn[0].properties.id;
|
|
5439
|
+
map[blockid] = fs[fIn[0]].properties.id;
|
|
5440
|
+
else if (fIn.length > 1) {
|
|
5441
|
+
// Pick district with smallest area since some times we get malformed content that doesn't
|
|
5442
|
+
// reflect holes in districts when one is nested in another. So theory is smaller district
|
|
5443
|
+
// is a hole in containing larger one(s).
|
|
5444
|
+
let iLow = fIn[0];
|
|
5445
|
+
for (let i = 1; i < fIn.length; i++)
|
|
5446
|
+
if (aDistricts[fIn[i]] < aDistricts[iLow])
|
|
5447
|
+
iLow = fIn[i];
|
|
5448
|
+
map[blockid] = fs[iLow].properties.id;
|
|
5449
|
+
}
|
|
5437
5450
|
});
|
|
5438
5451
|
return map;
|
|
5439
5452
|
}
|
|
@@ -6496,6 +6509,7 @@ function featureRewind(poly) {
|
|
|
6496
6509
|
closePoly(poly.geometry.coordinates);
|
|
6497
6510
|
else if (d === 5)
|
|
6498
6511
|
poly.geometry.coordinates.forEach(closePoly);
|
|
6512
|
+
poly.geometry.type = d === 4 ? 'Polygon' : 'MultiPolygon';
|
|
6499
6513
|
}
|
|
6500
6514
|
return poly;
|
|
6501
6515
|
}
|
|
@@ -9947,6 +9961,8 @@ exports.partialEqual = partialEqual;
|
|
|
9947
9961
|
function exactEqual(o1, o2, options) {
|
|
9948
9962
|
if (o1 === o2)
|
|
9949
9963
|
return true;
|
|
9964
|
+
if (options && options.epsilon && typeof o1 === 'number' && typeof o2 === 'number' && Math.abs(o1 - o2) < options.epsilon)
|
|
9965
|
+
return true;
|
|
9950
9966
|
if (options && options.emptyStringIsNull)
|
|
9951
9967
|
if ((o1 == null && o2 == '') || (o2 == null && o1 == ''))
|
|
9952
9968
|
return true;
|