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.

Not sure why the first version of the code would not work - it *looks* functionally identical to the second version.

You shouldn't have to use the OverlayOp class directly - not the best JTS style (although supported by the API, might not be as stable as the Geometry method).

The reason a MultiPolygon is returned is exactly what you see in the image.  3 holes touch and surround a disconnected area, which creates an extra polygon when the final one is subtracted.

On Mon, Sep 19, 2016 at 8:14 PM, Phil Scadden <p.scadden@xxxxxxxxxx> wrote:
Hmm, this version works;

                Polygon op = geometryFactory.createPolygon(p.getExteriorRing().getCoordinates());
                Geometry g = op;
                for (k=0;k<p.getNumInteriorRing();k++) {
                   Polygon ip = geometryFactory.createPolygon(p.getInteriorRingN(k).getCoordinates());
                   g = OverlayOp.overlayOp(g, ip, OverlayOp.DIFFERENCE);
                }


Now just need to figure out why the output geometry is a multipolygon...

--
Phil Scadden, Senior Scientist GNS Science Ltd 764 Cumberland St, Private Bag 1930, Dunedin, New Zealand Ph +64 3 4799663, fax +64 3 477 5232

Notice: This email and any attachments are confidential.
If received in error please destroy and immediately notify us.
Do not copy or disclose the contents.

_______________________________________________
jts-dev mailing list
jts-dev@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.locationtech.org/mailman/listinfo/jts-dev


Back to the top