Re: [Jts-topo-suite-user] TopologyException
Brought to you by:
dr_jts
From: Michaël M. <mic...@fr...> - 2012-08-27 18:53:31
|
Hi Jan Here is an answer issued from my user experience. Hopefully, Martin will give you the developper point of view > 1) If my input data #isValid(), should all Geometries calculated by #buffer, > #union, ..., be valid as well or do I have to recheck that? As far as I can say, JTS always produce valid geometries. But after complex processing, two valid geometries may be in a situation where it will create a TopologyExeption during an union, a difference... > 2) What do you consider the best way to prevent TopologyExeptions, catch > TopologyException whenever I do a geometry operation or call #isValid() > before? Checking IsValid is probably the first precaution, as processing invalid geometries generally fails immediately with JTS. But it will not always be enough. The second precaution is probably to "node" geometries together. In the following example, where AB is supposed to be "on" CD, it would mean inserting B into CD to avoid uncertainty due to floating point precision. x------x | G1 | A x------x B C x-------------x D | | | G2 | x-------------x Note that in your case, the exception is thrown by a class named FastNodingValidator which, according to its name, is probably doing a similar work. I can't explain why it fails in this particular case, but I know that with a well noded input dataset, a process has much more chance to succeed. Hope that helps, Michaël > > 3) What does this Exception mean for example: > > com.vividsolutions.jts.geom.TopologyException: found non-noded intersection > between LINESTRING ( 6.116429757706468 50.793713077775884, 6.116429757706471 > 50.793713077775884 ) and LINESTRING ( 6.116144996432054 50.793488893442145, > 6.1171063 50.79 > 42457 ) [ (6.11642975770647, 50.793713077775884, NaN) ] > at > com.vividsolutions.jts.noding.FastNodingValidator.checkValid(FastNodingValidator.java:109) > at > com.vividsolutions.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:94) > at > com.vividsolutions.jts.geomgraph.EdgeNodingValidator.checkValid(EdgeNodingValidator.java:59) > at > com.vividsolutions.jts.operation.overlay.OverlayOp.computeOverlay(OverlayOp.java:170) > at > com.vividsolutions.jts.operation.overlay.OverlayOp.getResultGeometry(OverlayOp.java:127) > at > com.vividsolutions.jts.operation.overlay.OverlayOp.overlayOp(OverlayOp.java:66) > at > com.vividsolutions.jts.operation.overlay.snap.SnapOverlayOp.getResultGeometry(SnapOverlayOp.java:67) > at > com.vividsolutions.jts.operation.overlay.snap.SnapOverlayOp.overlayOp(SnapOverlayOp.java:24) > at > com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp.getResultGeometry(SnapIfNeededOverlayOp.java:76) > at > com.vividsolutions.jts.operation.overlay.snap.SnapIfNeededOverlayOp.overlayOp(SnapIfNeededOverlayOp.java:25) > at com.vividsolutions.jts.geom.Geometry.difference(Geometry.java:1196) > > 4) Are there other reasons for TopologyExceptions? (float accuracy maybe?) > > Cheers > > |