dr-jts / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
22 stars 6 forks source link

Add Snap-Rounding Overlay option #2

Open dr-jts opened 6 years ago

dr-jts commented 6 years ago

Using Snap-Rounding for noding in Overlay should provide full robustness. TopologyExceptions will never be thrown!

Design Aspects

Design Issues

The code is in branch https://github.com/dr-jts/jts/tree/overlay-sr-classic

dr-jts commented 6 years ago

@strk I'm wondering if the global rounding caused by using SR will be an issue for users? It seems like a small price to pay for robustness, but I can imagine some situations where changing every coordinate might not be desirable.

strk commented 6 years ago

Yes it may be an issue. At least I know a person who complained about this specific drift, he reported, is also enforced by some known proprietary tool.

Me I think a global grid may be defined by a specific authority for a specific bounding box and be done with it, but as I said I've heard someone complain. Will try to have him comment here to know more :)

strk commented 6 years ago

@dr-jts so the global rounding issue is that different bodies may opt for different grids and this would result in data passed around to add small changes could result in global coordinates drift to adapt to this or that grid. This is what I'm hearing from govt users. I understand a global govt-driven grid would solve this issue but evidently it is easier to said that done..

dr-jts commented 6 years ago

@strk That's a good point. However, this should not create issues when using SR for internal computation, as long as the SR grid is finer than all the "external" grids being used. (All that is needed for SR to prevent robustness errors is a few digits of precision, so the grid can be quite fine.)

Another alternative is to use the finest grid of all the ones which will be used (assuming the others are multiples of it).

It's worth noting that snapping to grids itself may introduce topology invalidity (collapses, self-intersection), unless it is done using SR. Is this handled appropriately?

strk commented 6 years ago

It's not a matter of how much things are moved, even a single bit can be a problem when you move datasets from a center to another for a specific computation.

But maybe I'm being over paranoid. Note GEOS can already do precision reduction as a possible workaround to topology exceptions, so snaprounding wouldn't be worst than that.

dr-jts commented 6 years ago

Yes, I've seen this kind of constraint before as well. It's going to be difficult or impossible to provide full robustness while maintaining full precision, I think. Maybe the best that can be done is to not change the coordinates during an overlay op if there is no interaction between the inputs. This will require a special check, though.

And yes, SR should be basically the same impact as precision reduction. At least that's my working hypothesis - will need to be confirmed by testing.