@dra2020/baseclient 1.0.34 → 1.0.35

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.
@@ -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 (map == null || Util.countKeys(map) == 0)
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.geoMapToCollection = geoMapToCollection;
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 = geoMapToCollection(e.map);
1500
+ e.col = geoMapToCollectionNonNull(e.map);
1487
1501
  else if (e.topo)
1488
- e.col = geoTopoToCollection(e.topo);
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 = geoTopoToCollection(e.topo);
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 = geoCollectionToTopo(e.col);
1524
+ e.topo = geoCollectionToTopoNonNull(e.col);
1511
1525
  else if (e.map) {
1512
- e.col = geoMapToCollection(e.map);
1513
- e.topo = geoCollectionToTopo(e.col);
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 = geoMapToCollection(this.allMap());
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 = geoCollectionToTopo(this.allCol());
1577
+ this.all.topo = geoCollectionToTopoNonNull(this.allCol());
1564
1578
  }
1565
1579
  return this.all.topo;
1566
1580
  }
@@ -8278,7 +8292,11 @@ function topoFromCollection(col) {
8278
8292
  let prop = getGEOID(col);
8279
8293
  let objects = {};
8280
8294
  col.features.forEach((f) => objects[f.properties[prop]] = f);
8281
- let topo = TopoServer.topology(objects);
8295
+ let topo;
8296
+ if (Util.isEmpty(objects))
8297
+ topo = { objects: objects };
8298
+ else
8299
+ topo = TopoServer.topology(objects);
8282
8300
  PP.featureRepack(col, save);
8283
8301
  if (col.datasets)
8284
8302
  topo.datasets = col.datasets;
@@ -8342,10 +8360,11 @@ function topoToFeature(topo, geoid) {
8342
8360
  exports.topoToFeature = topoToFeature;
8343
8361
  function topoToCollection(topo) {
8344
8362
  let col = { type: 'FeatureCollection', features: [] };
8345
- Object.keys(topo.objects).forEach((geoid) => {
8346
- col.features.push(topoToFeature(topo, geoid));
8347
- });
8348
- if (topo.datasets)
8363
+ if (topo)
8364
+ Object.keys(topo.objects).forEach((geoid) => {
8365
+ col.features.push(topoToFeature(topo, geoid));
8366
+ });
8367
+ if (topo && topo.datasets)
8349
8368
  col.datasets = topo.datasets;
8350
8369
  return col;
8351
8370
  }