Re: [Jts-topo-suite-user] Buffer TopologyException: depth mismatch
Brought to you by:
dr_jts
From: Martin D. <mtn...@gm...> - 2011-06-20 18:42:29
|
Mike, JTS has certainly been giving you a hard time recently.. or is it the other way around? Your model of what's going wrong isn't quite accurate. The buffer algorithm is fully capable of handling self-intersections. The real problem is likely a robustness error arising from the lower precision model. Lower precision tends to exacerbate robustness issues (as you've already noticed!) You may have noticed that this case works fine when run with full FLOATING precision. So this could be categorized as halfway between a bug and a design limitation. Unfortunately, these things tend to be very difficult to fix, so there probably won't be a fix in the short term. The best workaround I can offer at this point is to compute the buffer using FLOATING precision, and then use GeometryPrecisionReducer to reduce the precision back to your 1.0e9 FIXED precision model. I think this should be fairly robust, since buffers tend to have somewhat simplified geometry. Martin On Sun, Jun 19, 2011 at 4:52 PM, Mike Titov <ti...@gm...> wrote: > Hello, Martin. > > I need your advise again. I've got a valid simple polygon in precision > model=1e9 > > 1. POLYGON ((76489 76488, 76489 76488.999999999, 76491.000000001 > 76488.999999999, 76491.000000001 76491.000000001, 76489 > 76491.000000001, 76489 76492, 76493 76492, 76493 76488, 76489 76488)) > > polygon.buffer(-0.5) throws an > com.vividsolutions.jts.geom.TopologyException : > com.vividsolutions.jts.geom.TopologyException: depth mismatch at > (76491.000000006, 76491.500000001, NaN) > > As i understand it, an exception has been throwing because the result > of buffer operation has self-intersection. You can see it, if use > BufferOffsetCurve(). > > So what to do in such case ? > Surround every buffer(..) with try{}catch() and try to reduce > precision, or get buffer(value +\- precision.scale) or get > BufferOffsetCurve and remove self-intersection with another buffer or > with some algorithm and then polygonize? > > Or may be it's a bug of buffer() operation and possible it will be fixed? > > |