Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jts-dev] Struggling with polygon topology again. Overlapping inner polygons.



On Tue, Sep 20, 2016 at 7:05 PM, Phil Scadden <p.scadden@xxxxxxxxxx> wrote:

In TestBuilder are you working with LinearRings or Polygons? If you are using rings then yes, subtracting one ring from another outside it is just going to return the outer ring.  (Rings don't have area).
Outer was definitely polygon, but inner may have been rings.

Subtracting rings from a polygon also has no effect. 


When I subtract the first hole polygon from the shell polygon I get a polygon with one hole, as expected.  I'm not sure why the original code doesn't work, however.  Probably something obvious that neither of us is seeing.  Are the intermediate results at all correct?
No. The difference was having no effect. I will have another look at it. Should probably fetch the jts source and have a closer look.
Another way to do this is to form the polygon with the holes (which will be invalid), and then run buffer(0) on it. That has the effect of fixing the topology.  It's quite fast. Not 100% robust, but should be fine if the polygon geometry is "relatively clean" (which is hard to define more precisely!)
 
I have avoided this because I found I could have a small self-crossing with it keeping the small polygon and destroying the main geometry.Because I am bulk processing, it can be hard to detect this happening. Hadnt tried it for issue of crossing inner polygon though. Speed doesnt worry me so much ( I dont care if runs all night), but maximizing the accuracy of the reconstruction does.

Yes, that is one of the unfortunate issues that can happen when using buffer(0) to clean invalid geometry. In this case however it's less likely to happen (because the topology is "almost" valid - it only needs noding and having rings assigned correctly.)

Back to the top