@dra2020/baseclient 1.0.2 → 1.0.5
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 +35 -35
- package/dist/baseclient.js.map +1 -1
- package/dist/geo/geo.d.ts +2 -0
- package/lib/geo/geo.ts +39 -2
- package/lib/poly/topo.ts +4 -35
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -1468,11 +1468,31 @@ class GeoMultiCollection {
|
|
|
1468
1468
|
});
|
|
1469
1469
|
return found;
|
|
1470
1470
|
}
|
|
1471
|
-
|
|
1471
|
+
nthFilteredFeature(n, cb) {
|
|
1472
|
+
let found;
|
|
1472
1473
|
this.forEachEntry(e => {
|
|
1474
|
+
if (found)
|
|
1475
|
+
return;
|
|
1473
1476
|
let col = this._col(e);
|
|
1474
1477
|
if (col)
|
|
1475
|
-
|
|
1478
|
+
for (let i = 0; !found && i < col.features.length; i++) {
|
|
1479
|
+
let f = col.features[i];
|
|
1480
|
+
if (this.hidden[f.properties.id] === undefined && cb(f)) {
|
|
1481
|
+
if (n === 0) {
|
|
1482
|
+
found = f;
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
n--;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
return found;
|
|
1490
|
+
}
|
|
1491
|
+
forEach(cb) {
|
|
1492
|
+
this.forEachEntry(e => {
|
|
1493
|
+
let col = this._col(e);
|
|
1494
|
+
if (e.col)
|
|
1495
|
+
e.col.features.forEach(f => { if (this.hidden[f.properties.id] === undefined)
|
|
1476
1496
|
cb(f); });
|
|
1477
1497
|
});
|
|
1478
1498
|
}
|
|
@@ -1495,6 +1515,16 @@ class GeoMultiCollection {
|
|
|
1495
1515
|
}
|
|
1496
1516
|
return undefined;
|
|
1497
1517
|
}
|
|
1518
|
+
filter(test) {
|
|
1519
|
+
let m = new GeoMultiCollection();
|
|
1520
|
+
this.forEachEntry(e => {
|
|
1521
|
+
let col = this._col(e);
|
|
1522
|
+
let features = col ? col.features.filter(test) : null;
|
|
1523
|
+
if (features && features.length)
|
|
1524
|
+
m.add(e.tag, null, { type: 'FeatureCollection', features: features }, null);
|
|
1525
|
+
});
|
|
1526
|
+
return m;
|
|
1527
|
+
}
|
|
1498
1528
|
}
|
|
1499
1529
|
exports.GeoMultiCollection = GeoMultiCollection;
|
|
1500
1530
|
var geoIntersectOptions;
|
|
@@ -7919,24 +7949,14 @@ function ringsCancel(outerPoly, innerRing) {
|
|
|
7919
7949
|
function correctGeometry(f) {
|
|
7920
7950
|
if (f && f.geometry && f.geometry.type === 'MultiPolygon' && f.geometry.coordinates) {
|
|
7921
7951
|
let multiPoly = f.geometry.coordinates;
|
|
7922
|
-
/* Comment this out right now - might have been do to not rewinding merge output
|
|
7923
|
-
// topojson will under certain circumstances return a MultiPolygon with the first Polygon containing holes
|
|
7924
|
-
// that are precisely filled by a subsequent polygon. We make a secondary union pass to try to correct for this.
|
|
7925
|
-
// If we have a really degenerate multipolygon (test above some number of polygons) omit this expensive pass
|
|
7926
|
-
// since cleanup is unlikely.
|
|
7927
|
-
if (multiPoly.length > 1 && multiPoly.length < 50)
|
|
7928
|
-
{
|
|
7929
|
-
let result = Q.unionPolys(multiPoly);
|
|
7930
|
-
if (Util.depthof(result) == 4) result = [ result ];
|
|
7931
|
-
multiPoly = result;
|
|
7932
|
-
}
|
|
7933
|
-
*/
|
|
7934
7952
|
// Convert degenerate MultiPolygon to Polygon
|
|
7935
7953
|
if (multiPoly.length == 1) {
|
|
7936
7954
|
f.geometry.type = 'Polygon';
|
|
7937
7955
|
f.geometry.coordinates = multiPoly[0];
|
|
7938
7956
|
}
|
|
7939
7957
|
}
|
|
7958
|
+
// TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
|
|
7959
|
+
P.featureRewind(f);
|
|
7940
7960
|
return f;
|
|
7941
7961
|
}
|
|
7942
7962
|
function topoContiguity(topo) {
|
|
@@ -8136,27 +8156,7 @@ function topoMerge(topo, geoids) {
|
|
|
8136
8156
|
return null;
|
|
8137
8157
|
let objects = [];
|
|
8138
8158
|
geoids.forEach((geoid) => objects.push(topo.objects[geoid]));
|
|
8139
|
-
|
|
8140
|
-
P.featureRewind(f);
|
|
8141
|
-
/* Comment out for now - may be due to merge output needing to be rewound
|
|
8142
|
-
// If I get a bad output from topoMerge, just do more expensive poly union. This can happen if input polygons
|
|
8143
|
-
// are a little funky (in particular, if they double back along the same edge.
|
|
8144
|
-
if (selfIntersectFast(f))
|
|
8145
|
-
{
|
|
8146
|
-
//console.log('topoMerge: patching selfIntersect');
|
|
8147
|
-
let polys: any[] = [];
|
|
8148
|
-
geoids.forEach((geoid) => polys.push(topoToFeature(topo, geoid).geometry.coordinates));
|
|
8149
|
-
let result = Q.unionPolys(polys);
|
|
8150
|
-
let depth = Util.depthof(result);
|
|
8151
|
-
if (depth === 5 && result.length === 1)
|
|
8152
|
-
{
|
|
8153
|
-
depth = 4;
|
|
8154
|
-
result = result[0];
|
|
8155
|
-
}
|
|
8156
|
-
f = { type: 'feature', properties: {}, geometry: { type: depth == 4 ? 'Polygon' : 'MultiPolygon', coordinates: result } };
|
|
8157
|
-
}
|
|
8158
|
-
*/
|
|
8159
|
-
return f;
|
|
8159
|
+
return correctGeometry({ type: 'Feature', properties: {}, geometry: TopoClient.merge(topo, objects) });
|
|
8160
8160
|
}
|
|
8161
8161
|
exports.topoMerge = topoMerge;
|
|
8162
8162
|
function topoMergeFeatures(topo, features) {
|