geo icon indicating copy to clipboard operation
geo copied to clipboard

Single Polygon (or MultiPolygon) from Polygon with interiors

Open flaport opened this issue 2 years ago • 2 comments

Hi,

Is there a way to create a single polygon without any interiors from a polygon with interiors?

Something like this?

image

I'm trying to use your library for processing of GDSII shapes, which does not support polygons with holes.

flaport avatar Aug 23 '22 21:08 flaport

Just to make sure I understand your situation, in the example you're showing, you ultimately want to create a polygon whose exterior will have overlapping segments, and is thus "invalid" (in terms of OGC validity anyway).

Am I understanding the desired result correctly?

I don't know of an off the shelf way to do that, but maybe using:

https://docs.rs/geo/latest/geo/algorithm/closest_point/trait.ClosestPoint.html you could stitch each interior ring into the exterior.

And beware of winding order. See https://docs.rs/geo/latest/geo/algorithm/winding_order/trait.Winding.html if you need to do any re-winding.

michaelkirk avatar Aug 23 '22 21:08 michaelkirk

Indeed, it's such an 'invalid' polygon I want.

In fact, it's a common operation we do after processing GDS Files. Tools like KLayout (with Ruby and Python bindings) implement it by default on write. But I'm experimenting with Rust to hopefully improve some of the performance of my algorithms, so I I'm looking if there are any options out there. So far GeoRust has been filling in the gap pretty well!

I will try your suggestion! Thanks :)

flaport avatar Aug 23 '22 22:08 flaport