@dra2020/baseclient 1.0.4 → 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 +3 -33
- package/dist/baseclient.js.map +1 -1
- package/lib/poly/topo.ts +4 -35
- package/package.json +1 -1
package/dist/baseclient.js
CHANGED
|
@@ -7949,24 +7949,14 @@ function ringsCancel(outerPoly, innerRing) {
|
|
|
7949
7949
|
function correctGeometry(f) {
|
|
7950
7950
|
if (f && f.geometry && f.geometry.type === 'MultiPolygon' && f.geometry.coordinates) {
|
|
7951
7951
|
let multiPoly = f.geometry.coordinates;
|
|
7952
|
-
/* Comment this out right now - might have been do to not rewinding merge output
|
|
7953
|
-
// topojson will under certain circumstances return a MultiPolygon with the first Polygon containing holes
|
|
7954
|
-
// that are precisely filled by a subsequent polygon. We make a secondary union pass to try to correct for this.
|
|
7955
|
-
// If we have a really degenerate multipolygon (test above some number of polygons) omit this expensive pass
|
|
7956
|
-
// since cleanup is unlikely.
|
|
7957
|
-
if (multiPoly.length > 1 && multiPoly.length < 50)
|
|
7958
|
-
{
|
|
7959
|
-
let result = Q.unionPolys(multiPoly);
|
|
7960
|
-
if (Util.depthof(result) == 4) result = [ result ];
|
|
7961
|
-
multiPoly = result;
|
|
7962
|
-
}
|
|
7963
|
-
*/
|
|
7964
7952
|
// Convert degenerate MultiPolygon to Polygon
|
|
7965
7953
|
if (multiPoly.length == 1) {
|
|
7966
7954
|
f.geometry.type = 'Polygon';
|
|
7967
7955
|
f.geometry.coordinates = multiPoly[0];
|
|
7968
7956
|
}
|
|
7969
7957
|
}
|
|
7958
|
+
// TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
|
|
7959
|
+
P.featureRewind(f);
|
|
7970
7960
|
return f;
|
|
7971
7961
|
}
|
|
7972
7962
|
function topoContiguity(topo) {
|
|
@@ -8166,27 +8156,7 @@ function topoMerge(topo, geoids) {
|
|
|
8166
8156
|
return null;
|
|
8167
8157
|
let objects = [];
|
|
8168
8158
|
geoids.forEach((geoid) => objects.push(topo.objects[geoid]));
|
|
8169
|
-
|
|
8170
|
-
P.featureRewind(f);
|
|
8171
|
-
/* Comment out for now - may be due to merge output needing to be rewound
|
|
8172
|
-
// If I get a bad output from topoMerge, just do more expensive poly union. This can happen if input polygons
|
|
8173
|
-
// are a little funky (in particular, if they double back along the same edge.
|
|
8174
|
-
if (selfIntersectFast(f))
|
|
8175
|
-
{
|
|
8176
|
-
//console.log('topoMerge: patching selfIntersect');
|
|
8177
|
-
let polys: any[] = [];
|
|
8178
|
-
geoids.forEach((geoid) => polys.push(topoToFeature(topo, geoid).geometry.coordinates));
|
|
8179
|
-
let result = Q.unionPolys(polys);
|
|
8180
|
-
let depth = Util.depthof(result);
|
|
8181
|
-
if (depth === 5 && result.length === 1)
|
|
8182
|
-
{
|
|
8183
|
-
depth = 4;
|
|
8184
|
-
result = result[0];
|
|
8185
|
-
}
|
|
8186
|
-
f = { type: 'feature', properties: {}, geometry: { type: depth == 4 ? 'Polygon' : 'MultiPolygon', coordinates: result } };
|
|
8187
|
-
}
|
|
8188
|
-
*/
|
|
8189
|
-
return f;
|
|
8159
|
+
return correctGeometry({ type: 'Feature', properties: {}, geometry: TopoClient.merge(topo, objects) });
|
|
8190
8160
|
}
|
|
8191
8161
|
exports.topoMerge = topoMerge;
|
|
8192
8162
|
function topoMergeFeatures(topo, features) {
|