@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/lib/poly/topo.ts
CHANGED
|
@@ -59,19 +59,6 @@ function correctGeometry(f: any): any
|
|
|
59
59
|
{
|
|
60
60
|
let multiPoly = f.geometry.coordinates;
|
|
61
61
|
|
|
62
|
-
/* Comment this out right now - might have been do to not rewinding merge output
|
|
63
|
-
// topojson will under certain circumstances return a MultiPolygon with the first Polygon containing holes
|
|
64
|
-
// that are precisely filled by a subsequent polygon. We make a secondary union pass to try to correct for this.
|
|
65
|
-
// If we have a really degenerate multipolygon (test above some number of polygons) omit this expensive pass
|
|
66
|
-
// since cleanup is unlikely.
|
|
67
|
-
if (multiPoly.length > 1 && multiPoly.length < 50)
|
|
68
|
-
{
|
|
69
|
-
let result = Q.unionPolys(multiPoly);
|
|
70
|
-
if (Util.depthof(result) == 4) result = [ result ];
|
|
71
|
-
multiPoly = result;
|
|
72
|
-
}
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
62
|
// Convert degenerate MultiPolygon to Polygon
|
|
76
63
|
if (multiPoly.length == 1)
|
|
77
64
|
{
|
|
@@ -80,6 +67,9 @@ function correctGeometry(f: any): any
|
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
69
|
|
|
70
|
+
// TopoJSON does not guarantee proper winding order which messes up later processing. Fix it.
|
|
71
|
+
P.featureRewind(f);
|
|
72
|
+
|
|
83
73
|
return f;
|
|
84
74
|
}
|
|
85
75
|
|
|
@@ -318,28 +308,7 @@ export function topoMerge(topo: Topo, geoids: string[]): any
|
|
|
318
308
|
if (geoids == null || geoids.length == 0) return null;
|
|
319
309
|
let objects: any[] = [];
|
|
320
310
|
geoids.forEach((geoid) => objects.push(topo.objects[geoid]));
|
|
321
|
-
|
|
322
|
-
P.featureRewind(f);
|
|
323
|
-
|
|
324
|
-
/* Comment out for now - may be due to merge output needing to be rewound
|
|
325
|
-
// If I get a bad output from topoMerge, just do more expensive poly union. This can happen if input polygons
|
|
326
|
-
// are a little funky (in particular, if they double back along the same edge.
|
|
327
|
-
if (selfIntersectFast(f))
|
|
328
|
-
{
|
|
329
|
-
//console.log('topoMerge: patching selfIntersect');
|
|
330
|
-
let polys: any[] = [];
|
|
331
|
-
geoids.forEach((geoid) => polys.push(topoToFeature(topo, geoid).geometry.coordinates));
|
|
332
|
-
let result = Q.unionPolys(polys);
|
|
333
|
-
let depth = Util.depthof(result);
|
|
334
|
-
if (depth === 5 && result.length === 1)
|
|
335
|
-
{
|
|
336
|
-
depth = 4;
|
|
337
|
-
result = result[0];
|
|
338
|
-
}
|
|
339
|
-
f = { type: 'feature', properties: {}, geometry: { type: depth == 4 ? 'Polygon' : 'MultiPolygon', coordinates: result } };
|
|
340
|
-
}
|
|
341
|
-
*/
|
|
342
|
-
return f;
|
|
311
|
+
return correctGeometry({ type: 'Feature', properties: {}, geometry: TopoClient.merge(topo, objects) });
|
|
343
312
|
}
|
|
344
313
|
|
|
345
314
|
export function topoMergeFeatures(topo: Topo, features: any[]): any
|