title: How to merge adjacent polygons
body: <p>I'm using a Javascript implementation of Fortune's algorithm to compute voronoi cells (<a href="https://github.com/gorhill/Javascript-Voronoi" rel="nofollow noreferrer">https://github.com/gorhill/Javascript-Voronoi</a>). My sites to compute are points on a map (so <code>(lat,lng)</code>). I first made the projection <code>(lat,lng) -&gt; (x,y)</code>, I then computed the voronoi cells and made the projection of the half edges the other way.<br>
  It works fine, I display the result using leaflet but I need to do one more thing. </p>
  
  <p>Each site I initially compute depends of an ID, I reclassify the voronoi cells by ID and I end up, for each ID with a standard  data structure looking like this : </p>
  
  <pre><code>{
    "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]
          ]]
        }
      }
    ]
  };
  </code></pre>
  
  <p>A set of polygons (made form the half edge of the voronoi cells) for a given ID. </p>
  
  <p>I need to merge those polygons by ID, I intended to use <code>turf.merge()</code>, but I have topology errors </p>
  
  <pre><code> turf.min.js:13 Uncaught TopologyError: side location conflict
  </code></pre>
  
  <p>Based on this post (<a href="http://lists.refractions.net/pipermail/jts-devel/2009-March/002939.html" rel="nofollow noreferrer">http://lists.refractions.net/pipermail/jts-devel/2009-March/002939.html</a>), I've tried to round the <code>(lat,lng)</code> couple from 10^-14 to 10^-7 but it didn't really worked. 
  Before looking for the kinks and trying to remove them, I printed some data sample and I'm know asking myself if I used the good data from Fortune's algorithm. When I display all the polygons for all IDs, I have the right diagram, but when I display all the polygons for one ID or some polygons for one ID I end up with incomplete diagrams : </p>
  
  <p><a href="https://i.stack.imgur.com/paXZI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/paXZI.png" alt="part of the  full diagram"></a></p>
  
  <p>Part of the full diagram </p>
  
  <p><a href="https://i.stack.imgur.com/oHB7H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oHB7H.png" alt="enter image description here"></a></p>
  
  <p>Part of the diagram for one ID</p>
  
  <p><a href="https://i.stack.imgur.com/rKWRQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rKWRQ.png" alt="enter image description here"></a></p>
  
  <p>Two "polygons" for a given ID </p>
  
  <p>Does anyone has an idea how to merge polygon that share at least one common vertex ? And why there is a topology error ? </p>
  
  <p><strong>Edit :</strong> The polygons are not "incomplete" (I was using polyline)</p>
  
  <p><a href="https://i.stack.imgur.com/sTLnr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sTLnr.png" alt="enter image description here"></a> </p>
  
  <p>I also tried on an easier sample :</p>
  
  <p><a href="https://i.stack.imgur.com/2xXV5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2xXV5.png" alt="enter image description here"></a></p>
  
  <p>And still got the error : </p>
  
  <pre><code>Uncaught TopologyError: side location conflict [ (44.8220601, -0.5869532) ]
  </code></pre>
  
  <p>So it's not (or at least not only) due to kinks</p>