@dra2020/baseclient 1.0.33 → 1.0.36
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 +39 -17
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +3 -0
- package/lib/geo/geo.ts +25 -9
- package/lib/poly/polypack.ts +1 -1
- package/lib/poly/topo.ts +18 -8
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -1345,7 +1345,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
1345
1345
|
return result;
|
|
1346
1346
|
};
|
|
1347
1347
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1348
|
-
exports.geoIntersect = exports.geoIntersectOptions = exports.GeoMultiCollection = exports.geoMapEqual = exports.geoEqual = exports.geoTopoToCollection = exports.geoCollectionToTopo = exports.geoMapToCollection = exports.geoCollectionToMap = exports.geoEnsureID = void 0;
|
|
1348
|
+
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.geoEnsureID = void 0;
|
|
1349
1349
|
const Util = __importStar(__webpack_require__(/*! ../util/all */ "./lib/util/all.ts"));
|
|
1350
1350
|
const Poly = __importStar(__webpack_require__(/*! ../poly/all */ "./lib/poly/all.ts"));
|
|
1351
1351
|
function geoEnsureID(col) {
|
|
@@ -1375,25 +1375,39 @@ function geoCollectionToMap(col) {
|
|
|
1375
1375
|
}
|
|
1376
1376
|
exports.geoCollectionToMap = geoCollectionToMap;
|
|
1377
1377
|
function geoMapToCollection(map) {
|
|
1378
|
-
if (
|
|
1378
|
+
if (Util.countKeys(map) == 0)
|
|
1379
|
+
return null;
|
|
1380
|
+
return geoMapToCollectionNonNull(map);
|
|
1381
|
+
}
|
|
1382
|
+
exports.geoMapToCollection = geoMapToCollection;
|
|
1383
|
+
function geoMapToCollectionNonNull(map) {
|
|
1384
|
+
if (map == null)
|
|
1379
1385
|
return null;
|
|
1380
1386
|
let col = { type: 'FeatureCollection', features: [] };
|
|
1381
1387
|
Object.keys(map).forEach((geoid) => { col.features.push(map[geoid]); });
|
|
1382
1388
|
return col;
|
|
1383
1389
|
}
|
|
1384
|
-
exports.
|
|
1390
|
+
exports.geoMapToCollectionNonNull = geoMapToCollectionNonNull;
|
|
1385
1391
|
function geoCollectionToTopo(col) {
|
|
1386
1392
|
let topo = Poly.topoFromCollection(col);
|
|
1387
1393
|
Poly.topoPack(topo);
|
|
1388
1394
|
return topo;
|
|
1389
1395
|
}
|
|
1390
1396
|
exports.geoCollectionToTopo = geoCollectionToTopo;
|
|
1397
|
+
function geoCollectionToTopoNonNull(col) {
|
|
1398
|
+
return geoCollectionToTopo(col);
|
|
1399
|
+
}
|
|
1400
|
+
exports.geoCollectionToTopoNonNull = geoCollectionToTopoNonNull;
|
|
1391
1401
|
function geoTopoToCollection(topo) {
|
|
1392
1402
|
let col = Poly.topoToCollection(topo);
|
|
1393
1403
|
Poly.featurePack(col);
|
|
1394
1404
|
return col;
|
|
1395
1405
|
}
|
|
1396
1406
|
exports.geoTopoToCollection = geoTopoToCollection;
|
|
1407
|
+
function geoTopoToCollectionNonNull(topo) {
|
|
1408
|
+
return geoTopoToCollection(topo);
|
|
1409
|
+
}
|
|
1410
|
+
exports.geoTopoToCollectionNonNull = geoTopoToCollectionNonNull;
|
|
1397
1411
|
function geoEqual(m1, m2) {
|
|
1398
1412
|
let n1 = m1 ? m1.length : 0;
|
|
1399
1413
|
let n2 = m2 ? m2.length : 0;
|
|
@@ -1483,9 +1497,9 @@ class GeoMultiCollection {
|
|
|
1483
1497
|
return null;
|
|
1484
1498
|
if (!e.col) {
|
|
1485
1499
|
if (e.map)
|
|
1486
|
-
e.col =
|
|
1500
|
+
e.col = geoMapToCollectionNonNull(e.map);
|
|
1487
1501
|
else if (e.topo)
|
|
1488
|
-
e.col =
|
|
1502
|
+
e.col = geoTopoToCollectionNonNull(e.topo);
|
|
1489
1503
|
}
|
|
1490
1504
|
return e.col;
|
|
1491
1505
|
}
|
|
@@ -1496,7 +1510,7 @@ class GeoMultiCollection {
|
|
|
1496
1510
|
if (e.col)
|
|
1497
1511
|
e.map = geoCollectionToMap(e.col);
|
|
1498
1512
|
else if (e.topo) {
|
|
1499
|
-
e.col =
|
|
1513
|
+
e.col = geoTopoToCollectionNonNull(e.topo);
|
|
1500
1514
|
e.map = geoCollectionToMap(e.col);
|
|
1501
1515
|
}
|
|
1502
1516
|
}
|
|
@@ -1507,10 +1521,10 @@ class GeoMultiCollection {
|
|
|
1507
1521
|
return null;
|
|
1508
1522
|
if (!e.topo) {
|
|
1509
1523
|
if (e.col)
|
|
1510
|
-
e.topo =
|
|
1524
|
+
e.topo = geoCollectionToTopoNonNull(e.col);
|
|
1511
1525
|
else if (e.map) {
|
|
1512
|
-
e.col =
|
|
1513
|
-
e.topo =
|
|
1526
|
+
e.col = geoMapToCollectionNonNull(e.map);
|
|
1527
|
+
e.topo = geoCollectionToTopoNonNull(e.col);
|
|
1514
1528
|
}
|
|
1515
1529
|
}
|
|
1516
1530
|
return e.topo;
|
|
@@ -1531,7 +1545,7 @@ class GeoMultiCollection {
|
|
|
1531
1545
|
this.all.col = this._col(this.nthEntry(0));
|
|
1532
1546
|
else
|
|
1533
1547
|
// Going from map to collection guarantees that any duplicates are removed
|
|
1534
|
-
this.all.col =
|
|
1548
|
+
this.all.col = geoMapToCollectionNonNull(this.allMap());
|
|
1535
1549
|
}
|
|
1536
1550
|
return this.all.col;
|
|
1537
1551
|
}
|
|
@@ -1560,7 +1574,7 @@ class GeoMultiCollection {
|
|
|
1560
1574
|
if (n == 1)
|
|
1561
1575
|
this.all.topo = this._topo(this.nthEntry(0));
|
|
1562
1576
|
else
|
|
1563
|
-
this.all.topo =
|
|
1577
|
+
this.all.topo = geoCollectionToTopoNonNull(this.allCol());
|
|
1564
1578
|
}
|
|
1565
1579
|
return this.all.topo;
|
|
1566
1580
|
}
|
|
@@ -7314,7 +7328,7 @@ function featurePack(f, prepack) {
|
|
|
7314
7328
|
}
|
|
7315
7329
|
return f.geometry.packed;
|
|
7316
7330
|
}
|
|
7317
|
-
else if (f
|
|
7331
|
+
else if (f && f.type === 'FeatureCollection' && f.features) {
|
|
7318
7332
|
// Allocate one large buffer
|
|
7319
7333
|
let nFloats = 0;
|
|
7320
7334
|
let i;
|
|
@@ -8264,12 +8278,15 @@ function getGEOID(f) {
|
|
|
8264
8278
|
f = f.features[0];
|
|
8265
8279
|
else if (Array.isArray(f))
|
|
8266
8280
|
f = f[0];
|
|
8281
|
+
else
|
|
8282
|
+
return '';
|
|
8267
8283
|
if (f.properties.id !== undefined)
|
|
8268
8284
|
return 'id';
|
|
8269
8285
|
if (f.properties.GEOID !== undefined)
|
|
8270
8286
|
return 'GEOID';
|
|
8271
8287
|
if (f.properties.GEOID10 !== undefined)
|
|
8272
8288
|
return 'GEOID10';
|
|
8289
|
+
return '';
|
|
8273
8290
|
}
|
|
8274
8291
|
function topoFromCollection(col) {
|
|
8275
8292
|
if (col == null)
|
|
@@ -8278,7 +8295,11 @@ function topoFromCollection(col) {
|
|
|
8278
8295
|
let prop = getGEOID(col);
|
|
8279
8296
|
let objects = {};
|
|
8280
8297
|
col.features.forEach((f) => objects[f.properties[prop]] = f);
|
|
8281
|
-
let topo
|
|
8298
|
+
let topo;
|
|
8299
|
+
if (Util.isEmpty(objects))
|
|
8300
|
+
topo = { objects: objects };
|
|
8301
|
+
else
|
|
8302
|
+
topo = TopoServer.topology(objects);
|
|
8282
8303
|
PP.featureRepack(col, save);
|
|
8283
8304
|
if (col.datasets)
|
|
8284
8305
|
topo.datasets = col.datasets;
|
|
@@ -8342,10 +8363,11 @@ function topoToFeature(topo, geoid) {
|
|
|
8342
8363
|
exports.topoToFeature = topoToFeature;
|
|
8343
8364
|
function topoToCollection(topo) {
|
|
8344
8365
|
let col = { type: 'FeatureCollection', features: [] };
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8366
|
+
if (topo)
|
|
8367
|
+
Object.keys(topo.objects).forEach((geoid) => {
|
|
8368
|
+
col.features.push(topoToFeature(topo, geoid));
|
|
8369
|
+
});
|
|
8370
|
+
if (topo && topo.datasets)
|
|
8349
8371
|
col.datasets = topo.datasets;
|
|
8350
8372
|
return col;
|
|
8351
8373
|
}
|