Author Topic: Querying a Region body  (Read 2542 times)

0 Members and 1 Guest are viewing this topic.

MaksimS

  • Guest
Querying a Region body
« on: May 07, 2007, 12:32:14 PM »
Dear all,

I'm stuck with a very simple problem of converting a Region to MPolygon. My experiences with Region bodies are very shallow. How do I query a Region to find out geometry of it's shells (outer boundaries) and holes (inner boundaries)?

Regards,
Maksim Sestic

MaksimS

  • Guest
Re: Querying a Region body
« Reply #1 on: May 08, 2007, 04:13:41 AM »
I mean, except for exploding a Region, of course :-) I'm primarily working with MPolygons still they lack important geometric operations (i.e. Union) therefor I need to convert them to Regions. That one was prettly straighforward. Alas, converting resulting Region back to MPolygon seems to be a bit more difficult task since there's no way (?) of qerying a Region for it's loops using .NET.

I guess I'll be forced to explode a Region and consequently deal with resulting primitives... bah...

Regards,
Maksim Sestic

MaksimS

  • Guest
Re: Querying a Region body
« Reply #2 on: May 09, 2007, 05:19:13 AM »
Yap, it seems to me that exploding a Region down to primitives (Lines and Arcs) is the only solution I can think of. Nevermind, here're the steps for reverting a Region back to MPolygon:

1) Explode Region
2) Merge resulting geometries, converting them to closed polylines
3) If there's only one polyline then there's no holes - skip to step 6)
4) Iterate through resulting set of polylines and find the one with largest area (this is a shell, outer boundary)
5) The rest of polylines are, therefor, holes (inner boundaries)
6) Construe a MPolygon knowing loop types and associated geometries (polylines)

Now, this works only if associated Region geometries form a Polygon (see OGC specs), not a MultiPolygon.

Regards,
Maksim Sestic