Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost.Geometry: Correct use of multi-part polygons
From: John Lilley (john.lilley_at_[hidden])
Date: 2013-02-20 17:03:38


Thanks, let me see if I understand. It sounds like if I want a set of islands, some with lakes, that I should make each island a separate polygon, and each lake an inner ring within the polygon. The overall set of islands would be a multipolygon, right?

Is multipolygon different than a vector of polygons like that returned by intersect()?

So if I just get a set of undifferentiated rings, it sounds like I need to determine which are contained by others and and combine them as inner/outer rings.

Once that is done can I intersect polygon against multipolygon or multipolygon against multipolygon easily?

--John Lilley

From: Barend Gehrels [mailto:barend_at_[hidden]]
Sent: Wednesday, February 20, 2013 1:37 PM
To: boost-users_at_[hidden]
Cc: John Lilley
Subject: Re: [Boost-users] Boost.Geometry: Correct use of multi-part polygons

Hi John,

On 20-2-2013 16:29, John Lilley wrote:
Greetings, I am looking for some guidance around the correct creation and use of multi-part polygons. I am a bit confused about when to use each of the following:

* Polygon with multiple rings

* Vector of polygons

* Polygon set

* Set/vector of polygons, each potentially containing multiple rings

I gather from this example picture:

http://geometrylibrary.geodan.nl/03__polygon__example_8cpp-example.html

Note that this documentation is VERY old. The correct docs are here:
http://www.boost.org/doc/libs/1_53_0/libs/geometry/doc/html/index.html

Examples like above are not included in the doc's, but they still exist in the SVN tree.

That if one wants holes to be opened as a result of intersection, they need to be rings as opposed to polygon sets or vectors of polygons?

Hmm, no... If two polygons, or multipolygons, do have the normal winding order, any holes are generated automatically. With normal I mean, w.r.t. to the specified clockwise order. If you use boost::geometry polygons, they are by default ordered clockwise.

In "normal" (multi)polygons, exterior rings are ordered clockwise, interior rings are ordered counter clockwise. This is an often-used convention.

If your polygons are not like that, just use boost::geometry::correct

An example would be polygon(s) representing an island chain. Some of the islands are atolls and as such have a hole in the middle. What would a representation of this set of islands look like?

This is a multi polygon.

And, what If I don't know if I have "real" rings (interior) vs just a collection of polygons (like I got this from an external source that doesn't have the same model). If I just throw a pile of points at a polygon and call clean(), will that magic everything up for me?

Not clean(). Where did you get that from?

Currently there is not a function like that, but dissolve in the extensions would target this functionality. Correct works only for the direction of rings, not to remove interior overlaps.

Regards, Barend



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net