@dra2020/baseclient 1.0.147 → 1.0.149
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 +32 -8
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +2 -0
- package/dist/util/util.d.ts +1 -0
- package/lib/geo/geo.ts +26 -5
- package/lib/util/util.ts +7 -0
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -2602,7 +2602,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
2602
2602
|
return result;
|
|
2603
2603
|
};
|
|
2604
2604
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2605
|
-
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollectionNonNull = exports.geoTopoToCollection = exports.geoCollectionToTopoNonNull = exports.geoCollectionToTopo = exports.geoMapToCollectionNonNull = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoNormalizeCollection = exports.geoNormalizeFeature = exports.geoEnsureID = exports.hidemapConcat = exports.dumpMetrics = void 0;
|
|
2605
|
+
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollectionNonNull = exports.geoTopoToCollection = exports.geoCollectionToTopoNonNull = exports.geoCollectionToTopo = exports.geoMapToCollectionNonNull = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoNormalizeCollection = exports.geoNormalizeFeature = exports.geoEnsureID = exports.isValidId = exports.applyCanonicalID = exports.hidemapConcat = exports.dumpMetrics = void 0;
|
|
2606
2606
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
2607
2607
|
const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
|
|
2608
2608
|
// Tracing/debugging aid
|
|
@@ -2628,6 +2628,26 @@ function hidemapConcat(...args) {
|
|
|
2628
2628
|
}
|
|
2629
2629
|
exports.hidemapConcat = hidemapConcat;
|
|
2630
2630
|
const NormalizeAll = { joinPolygons: true, checkRewind: true, ensureID: true };
|
|
2631
|
+
function applyCanonicalID(col) {
|
|
2632
|
+
if (col && Array.isArray(col.features))
|
|
2633
|
+
col.features.forEach((f, n) => { f.properties.id = String(n + 1); });
|
|
2634
|
+
}
|
|
2635
|
+
exports.applyCanonicalID = applyCanonicalID;
|
|
2636
|
+
function isValidId(col) {
|
|
2637
|
+
if (!col || !Array.isArray(col.features))
|
|
2638
|
+
return true;
|
|
2639
|
+
let set = new Set();
|
|
2640
|
+
for (let i = 0; i < col.features.length; i++) {
|
|
2641
|
+
let f = col.features[i];
|
|
2642
|
+
if (typeof f.properties.id !== 'string')
|
|
2643
|
+
return false; // id must be string
|
|
2644
|
+
if (set.has(f.properties.id))
|
|
2645
|
+
return false; // id must be unique
|
|
2646
|
+
set.add(f.properties.id);
|
|
2647
|
+
}
|
|
2648
|
+
return true;
|
|
2649
|
+
}
|
|
2650
|
+
exports.isValidId = isValidId;
|
|
2631
2651
|
// set the canonical 'id' property from the best property value.
|
|
2632
2652
|
// if joinPolygons is true, we do not enforce uniqueness.
|
|
2633
2653
|
//
|
|
@@ -2637,8 +2657,6 @@ function geoEnsureID(col, options) {
|
|
|
2637
2657
|
const props = ['id', 'GEOID', 'GEOID10', 'GEOID20', 'GEOID30', 'DISTRICT', 'DISTRICTNO', 'DISTRICTNAME'];
|
|
2638
2658
|
if (col && col.features && col.features.length > 0) {
|
|
2639
2659
|
let f = col.features[0];
|
|
2640
|
-
if (f.properties.id !== undefined)
|
|
2641
|
-
return; // short-cut - assume if 'id' is set, we're all good.
|
|
2642
2660
|
props.forEach(p => {
|
|
2643
2661
|
if (prop === undefined)
|
|
2644
2662
|
if (f.properties[p] !== undefined)
|
|
@@ -2649,12 +2667,13 @@ function geoEnsureID(col, options) {
|
|
|
2649
2667
|
prop = p;
|
|
2650
2668
|
}
|
|
2651
2669
|
});
|
|
2652
|
-
if (prop)
|
|
2670
|
+
if (prop) {
|
|
2653
2671
|
col.features.forEach(f => { f.properties.id = f.properties[prop]; });
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
col.features.forEach(f => { f.properties.id = String(n++); });
|
|
2672
|
+
if (!isValidId(col))
|
|
2673
|
+
applyCanonicalID(col);
|
|
2657
2674
|
}
|
|
2675
|
+
else
|
|
2676
|
+
applyCanonicalID(col);
|
|
2658
2677
|
}
|
|
2659
2678
|
}
|
|
2660
2679
|
exports.geoEnsureID = geoEnsureID;
|
|
@@ -11778,7 +11797,7 @@ exports.IndexedArray = IndexedArray;
|
|
|
11778
11797
|
|
|
11779
11798
|
|
|
11780
11799
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
11781
|
-
exports.toSafeNumber = exports.toNumber = exports.isNumber = exports.wrapLon = exports.rad2deg = exports.deg2rad = exports.distance = exports.toRGBAIntensity = exports.toRGBA = exports.toHex = exports.hashObject = exports.hash = exports.percentString = exports.precisionRound = exports.deepAccum = exports.deepCopy = exports.shallowEqual = exports.shallowAssignImmutable = exports.shallowDelete = exports.shallowAssign = exports.shallowCopy = exports.textToHtml = exports.recentDate = exports.relativeDate = exports.prettyDate = exports.deepEqual = exports.partialEqual = exports.nthKey = exports.nthProperty = exports.countKeys = exports.isEmpty = exports.depthof = exports.sizeof = exports.guidKey = exports.createKeyedGuid = exports.createGuid = exports.Deadline = exports.MultiTimer = exports.Elapsed = exports.Now = void 0;
|
|
11800
|
+
exports.toSafeNumber = exports.toNumber = exports.isNumber = exports.wrapLon = exports.rad2deg = exports.deg2rad = exports.distance = exports.toRGBAIntensity = exports.toRGBA = exports.toHex = exports.hashObject = exports.hash = exports.percentString = exports.precisionRound = exports.deepAccum = exports.deepCopy = exports.shallowEqual = exports.shallowAssignImmutable = exports.shallowDelete = exports.shallowAssign = exports.shallowCopy = exports.textToHtml = exports.recentDate = exports.relativeDate = exports.prettyDate = exports.deepEqual = exports.partialEqual = exports.nthKey = exports.nthProperty = exports.countKeys = exports.isEmpty = exports.depthof = exports.sizeof = exports.guidKey = exports.createKeyedGuid = exports.isGuid = exports.createGuid = exports.Deadline = exports.MultiTimer = exports.Elapsed = exports.Now = void 0;
|
|
11782
11801
|
function Now() { return (new Date()).toJSON(); }
|
|
11783
11802
|
exports.Now = Now;
|
|
11784
11803
|
// polyfill
|
|
@@ -11877,6 +11896,11 @@ function createGuid() {
|
|
|
11877
11896
|
});
|
|
11878
11897
|
}
|
|
11879
11898
|
exports.createGuid = createGuid;
|
|
11899
|
+
const reGuid = /.*-.*-.*-.*-/;
|
|
11900
|
+
function isGuid(s) {
|
|
11901
|
+
return reGuid.test(s) && s.length >= 36;
|
|
11902
|
+
}
|
|
11903
|
+
exports.isGuid = isGuid;
|
|
11880
11904
|
function createKeyedGuid(key) {
|
|
11881
11905
|
return `xxxxxxxx-xxxx-${key}xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g, function (c) {
|
|
11882
11906
|
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|