@dra2020/baseclient 1.0.29 → 1.0.30
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 +16 -8
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +6 -0
- package/dist/poly/mapto.d.ts +1 -0
- package/lib/geo/geo.ts +1 -0
- package/lib/poly/mapto.ts +18 -9
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -5371,7 +5371,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
5371
5371
|
return result;
|
|
5372
5372
|
};
|
|
5373
5373
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
5374
|
-
exports.polyMapTo = void 0;
|
|
5374
|
+
exports.polyMapTo = exports.polyMapToByCentroid = void 0;
|
|
5375
5375
|
const PL = __importStar(__webpack_require__(/*! ./polylabel */ "./lib/poly/polylabel.ts"));
|
|
5376
5376
|
const BB = __importStar(__webpack_require__(/*! ./boundbox */ "./lib/poly/boundbox.ts"));
|
|
5377
5377
|
const pointinpoly_1 = __webpack_require__(/*! ./pointinpoly */ "./lib/poly/pointinpoly.ts");
|
|
@@ -5400,16 +5400,14 @@ function setLabels(c) {
|
|
|
5400
5400
|
//
|
|
5401
5401
|
// The return value is an object that maps the block feature ids to the district feature id.
|
|
5402
5402
|
//
|
|
5403
|
-
function
|
|
5403
|
+
function polyMapToByCentroid(districts, centroids) {
|
|
5404
5404
|
let map = {};
|
|
5405
|
-
// Cache labelx, labely if necessary
|
|
5406
|
-
setLabels(blocks);
|
|
5407
5405
|
// Cache district boundboxes for quick containment exclusion
|
|
5408
5406
|
let bbDistricts = districts.features.map(f => BB.boundbox(f));
|
|
5409
5407
|
// Walk over blocks, mapping centroid to district
|
|
5410
|
-
|
|
5411
|
-
let x =
|
|
5412
|
-
let y =
|
|
5408
|
+
Object.keys(centroids).forEach(blockid => {
|
|
5409
|
+
let x = centroids[blockid].x;
|
|
5410
|
+
let y = centroids[blockid].y;
|
|
5413
5411
|
let fIn = [];
|
|
5414
5412
|
districts.features.forEach((fDistrict, i) => {
|
|
5415
5413
|
if (BB.boundboxContains(bbDistricts[i], x, y))
|
|
@@ -5417,10 +5415,20 @@ function polyMapTo(districts, blocks) {
|
|
|
5417
5415
|
fIn.push(fDistrict);
|
|
5418
5416
|
});
|
|
5419
5417
|
if (fIn.length == 1)
|
|
5420
|
-
map[
|
|
5418
|
+
map[blockid] = fIn[0].properties.id;
|
|
5421
5419
|
});
|
|
5422
5420
|
return map;
|
|
5423
5421
|
}
|
|
5422
|
+
exports.polyMapToByCentroid = polyMapToByCentroid;
|
|
5423
|
+
function polyMapTo(districts, blocks) {
|
|
5424
|
+
// Cache labelx, labely if necessary
|
|
5425
|
+
setLabels(blocks);
|
|
5426
|
+
let centroids = {};
|
|
5427
|
+
blocks.features.forEach(f => {
|
|
5428
|
+
centroids[f.properties.id] = { x: f.properties.labelx, y: f.properties.labely };
|
|
5429
|
+
});
|
|
5430
|
+
return polyMapToByCentroid(districts, centroids);
|
|
5431
|
+
}
|
|
5424
5432
|
exports.polyMapTo = polyMapTo;
|
|
5425
5433
|
|
|
5426
5434
|
|