Union call fails with complex polygon and line string intersection attempt
See original GitHub issueI have found what appears to be an issue with the union call crashing. The result is basically the node script I am running crashes and prints ‘debug’??. I have create a gist that replicates the issue https://gist.github.com/rheh/397308b280775ad70dedd140a27fd7ce.
The command and output I get follows:
ray@Pluto:~/badfir$ node bad.js
/home/ray/badfir/node_modules/turf-intersect/node_modules/jsts/dist/jsts.min.js:14
this.resultGeom=this.computeGeometry(this.resultPointList,this.resultLineList,this.resultPolyList,t)},labelIncompleteNode:function(t,e){var n=this.ptLocator.locate(t.getCoordinate(),this.arg[e].getGeometry());t.getLabel().setLocation(e,n)},copyPoints:function(t){for(var e=this.arg[t].getNodeIterator();e.hasNext();){var n=e.next(),i=this.graph.addNode(n.getCoordinate());i.setLabel(t,n.getLabel().getLocation(t))}},findResultAreaEdges:function(t){for(var e=this.graph.getEdgeEnds().iterator();e.hasNext();){var n=e.next(),i=n.getLabel();i.isArea()&&!n.isInteriorAreaEdge()&&ii.isResultOfOp(i.getLocation(0,cn.RIGHT),i.getLocation(1,cn.RIGHT),t)&&n.setInResult(!0)}},computeLabelsFromDepths:function(){for(var t=this.edgeList.iterator();t.hasNext();){var e=t.next(),n=e.getLabel(),i=e.getDepth();if(!i.isNull()){i.normalize();for(var r=0;2>r;r++)n.isNull(r)||!n.isArea()||i.isNull(r)||(0===i.getDelta(r)?n.toLine(r):(f.isTrue(!i.isNull(r,c
[object Object]
A work around I’ve used is to call turf.simplify on the polygon before passing this to union. Although, I would like to understand what the issue is so I can avoid it. Is my data malformed? I suspect not as the sample plots the various geojson tools online, such as google-developers.appspot.com/maps/documentation/utils/geojson/. The disadvantage of the simplify call is that my intersection may miss as the shape become ‘flatter’
To see the script working with the simplify in switch the variables on line 4489.
My node version is v4.2.6. The version of turf is 3.0.14.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (5 by maintainers)
@DenisCarriere thanks, that works just fine with the complex polygon - even without the simplify,
Hi @rheh
Unfortuantly the union module is a little unstable sometimes depending on the input geometries, we’re currently trying to remove the dependency on jsts which is the source for the union operation.
Odds are if simpliying works then your vertices are too dense for jsts to work for some reason… It might also be worth checking if your polygons contain self-intersections using turf/kinks
Hope that helps.
Cheers Rowan