I am using Fortune's Javascript implementation to compute voronoi cells ( https://github.com/gorhill/Javascript-Voronoi ). My sites for calculation are points on the map (therefore (lat,lng)
). First I made a projection (lat,lng) -> (x,y)
, then I calculated the voronoi cells and made a half-edge projection in another way.
It works great, I show the result using the flyer, but I need to do one more thing.
Each site that I initially compute depends on the identifier, I reclassify voronoi cells by ID, and I end up with each identifier with a standard data structure that looks like this:
{ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [[ [9.994812, 53.549487], [10.046997, 53.598209], [10.117721, 53.531737], [9.994812, 53.549487] ]] } }, { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [[ [10.000991, 53.50418], [10.03807, 53.562539], [9.926834, 53.551731], [10.000991, 53.50418] ]] } } ] };
The set of polygons (made from a half-edge in voronoi cells) for a given ID.
I need to combine these polygons by ID, I intended to use turf.merge()
, but I have topology errors
turf.min.js:13 Uncaught TopologyError: side location conflict
Based on this post ( http://lists.refractions.net/pipermail/jts-devel/2009-March/002939.html ), I tried to get around a pair (lat,lng)
from 10 ^ -14 to 10 ^ -7, but it really didn't work. Before searching for the kinks and trying to delete them, I printed a few examples of the data, and I know, I ask myself if I used good data from the Fortune algorithm. When I display all polygons for all identifiers, I have the correct diagram, but when I show all polygons for one ID or several polygons for one ID, I end up with incomplete diagrams:

Part of the complete diagram

Part of the diagram for a single identifier

Two "polygons" for a given ID
Does anyone have an idea how to combine a polygon that has at least one common vertex? And why is there a topology error?
Edit: Polygons are not "incomplete" (I used a polyline)

I also tried a simpler example:

And still got the error:
Uncaught TopologyError: side location conflict [ (44.8220601, -0.5869532) ]
So itβs not (or at least not only) because of kinks