@dra2020/baseclient 1.0.153 → 1.0.155
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/LICENSE +1 -1
- package/dist/baseclient.js +75 -0
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/all.d.ts +1 -0
- package/dist/geo/ensurecentroid.d.ts +3 -0
- package/lib/geo/all.ts +1 -0
- package/lib/geo/ensurecentroid.ts +49 -0
- package/package.json +6 -4
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c) 2021-
|
|
1
|
+
Copyright (c) 2021-2025 Social Good Fund for Dave's Redistricting.
|
|
2
2
|
|
|
3
3
|
This software is openly licensed via the Creative Commons Attribution-ShareAlike 4.0 International License, which appears below.
|
|
4
4
|
(https://creativecommons.org/licenses/by-sa/4.0/)
|
package/dist/baseclient.js
CHANGED
|
@@ -2602,6 +2602,81 @@ __exportStar(__webpack_require__(/*! ./geo */ "./lib/geo/geo.ts"), exports);
|
|
|
2602
2602
|
__exportStar(__webpack_require__(/*! ./vfeature */ "./lib/geo/vfeature.ts"), exports);
|
|
2603
2603
|
__exportStar(__webpack_require__(/*! ./flexname */ "./lib/geo/flexname.ts"), exports);
|
|
2604
2604
|
__exportStar(__webpack_require__(/*! ./multiblockmapping */ "./lib/geo/multiblockmapping.ts"), exports);
|
|
2605
|
+
__exportStar(__webpack_require__(/*! ./ensurecentroid */ "./lib/geo/ensurecentroid.ts"), exports);
|
|
2606
|
+
|
|
2607
|
+
|
|
2608
|
+
/***/ }),
|
|
2609
|
+
|
|
2610
|
+
/***/ "./lib/geo/ensurecentroid.ts":
|
|
2611
|
+
/*!***********************************!*\
|
|
2612
|
+
!*** ./lib/geo/ensurecentroid.ts ***!
|
|
2613
|
+
\***********************************/
|
|
2614
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2615
|
+
|
|
2616
|
+
|
|
2617
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2618
|
+
if (k2 === undefined) k2 = k;
|
|
2619
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2620
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2621
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2622
|
+
}
|
|
2623
|
+
Object.defineProperty(o, k2, desc);
|
|
2624
|
+
}) : (function(o, m, k, k2) {
|
|
2625
|
+
if (k2 === undefined) k2 = k;
|
|
2626
|
+
o[k2] = m[k];
|
|
2627
|
+
}));
|
|
2628
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
2629
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
2630
|
+
}) : function(o, v) {
|
|
2631
|
+
o["default"] = v;
|
|
2632
|
+
});
|
|
2633
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
2634
|
+
if (mod && mod.__esModule) return mod;
|
|
2635
|
+
var result = {};
|
|
2636
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
2637
|
+
__setModuleDefault(result, mod);
|
|
2638
|
+
return result;
|
|
2639
|
+
};
|
|
2640
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2641
|
+
exports.ensureCentroidInCollection = exports.ensureCentroidInFeature = void 0;
|
|
2642
|
+
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
2643
|
+
const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
|
|
2644
|
+
function oneNumberOf(f, props) {
|
|
2645
|
+
for (let i = 0; i < props.length; i++)
|
|
2646
|
+
if (f.properties[props[i]])
|
|
2647
|
+
return Number(f.properties[props[i]]);
|
|
2648
|
+
return 0;
|
|
2649
|
+
}
|
|
2650
|
+
function ensureCentroidInFeature(f) {
|
|
2651
|
+
if (f.geometry && f.properties.labelx === undefined) {
|
|
2652
|
+
f.properties.labelx = oneNumberOf(f, ['INTPTLON30', 'INTPTLON20', 'INTPTLON10', 'INTPTLON']);
|
|
2653
|
+
f.properties.labely = oneNumberOf(f, ['INTPTLAT30', 'INTPTLAT20', 'INTPTLAT10', 'INTPTLAT']);
|
|
2654
|
+
if (f.properties.labelx && f.properties.labely)
|
|
2655
|
+
if (!Poly.polyContainsPoint(f, f.properties.labelx, f.properties.labely)) {
|
|
2656
|
+
delete f.properties.labelx;
|
|
2657
|
+
delete f.properties.labely;
|
|
2658
|
+
}
|
|
2659
|
+
// If internal point not specified, compute it
|
|
2660
|
+
if (!f.properties.labelx || !f.properties.labely) {
|
|
2661
|
+
let result = Poly.polyLabel(f);
|
|
2662
|
+
f.properties.labelx = Util.precisionRound(result.x, 6);
|
|
2663
|
+
f.properties.labely = Util.precisionRound(result.y, 6);
|
|
2664
|
+
}
|
|
2665
|
+
delete f.properties.INTPTLAT30;
|
|
2666
|
+
delete f.properties.INTPTLON30;
|
|
2667
|
+
delete f.properties.INTPTLAT20;
|
|
2668
|
+
delete f.properties.INTPTLON20;
|
|
2669
|
+
delete f.properties.INTPTLAT10;
|
|
2670
|
+
delete f.properties.INTPTLON10;
|
|
2671
|
+
delete f.properties.INTPTLAT;
|
|
2672
|
+
delete f.properties.INTPTLON;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
exports.ensureCentroidInFeature = ensureCentroidInFeature;
|
|
2676
|
+
function ensureCentroidInCollection(col) {
|
|
2677
|
+
col.features.forEach(ensureCentroidInFeature);
|
|
2678
|
+
}
|
|
2679
|
+
exports.ensureCentroidInCollection = ensureCentroidInCollection;
|
|
2605
2680
|
|
|
2606
2681
|
|
|
2607
2682
|
/***/ }),
|