A View Inside My Head

Jason's Random Thoughts of Interest
posts - 86, comments - 178, trackbacks - 22

SqlGeography: Ring Orientation of Polygon Interior Rings (Holes)

I have mentioned before how the Ring Orientation for the exterior ring of a Polygon is significant when instantiating a SqlGeography object.  In this case, a Counter-Clockwise orientation is required so that as an observer walks along the path, the interior of the Polygon is always to their left.

Ring Orientation for SqlGeographyBut, what I have never really seen documented (or paid attention to, at least) is the fact that the interior rings, or holes, of a Polygon also have specific Ring Orientation requirements. 

In keeping with the "Left-handed" rule, interior rings must be defined in a Clockwise manner - the opposite orientation of the shape's exterior ring.  This is because holes within a Polygon are considered to be part of the exterior of the shape, so the observer walking in a Clockwise direction is still keeping the Polygon's interior to their left.

(I should note here that the Ring Orientation for SqlGeography is the exact opposite of ESRI's ShapeFile format, which is why Ring Orientation has been on my mind for the past few days).

 

Print | posted on Tuesday, November 25, 2008 9:14 AM | Filed Under [ Articles .NET SQL Spatial ]

Feedback

Gravatar

# re: SqlGeography: Ring Orientation of Polygon Interior Rings (Holes)

Hello Jason,
while currently working with a polygon having an exterior and an interior ring, I'm currently looking for how to decide, what is what... In the GML the things are clear: Both LinearRings are marked explicitely, either with "exterior" or "interior". But there is no indication in the SqlGeography object. Is there an implicit rule to specifiy the exterior first, followed by the interior?

Regards
12/20/2008 6:01 PM | neil
Gravatar

# re: SqlGeography: Ring Orientation of Polygon Interior Rings (Holes)

Neil:

The convention (and requirement) is to define the exterior ring first, followed by 0 or more interior rings (holes). This is true whether you're working with WKT, WKB, or the Builder API.

I realize that this is different than, say, what ESRI ShapeFiles require with their Polygon type (which happen to be "multi-polygons" in the Simple Features parlance). When writing my own SHP file converter, I had to examine each ring's orientation, and then see which "exterior" rings each "interior" ring belonged to before I could construct the SQL spatial object.
12/22/2008 12:05 AM | Jason
Gravatar

# re: SqlGeography: Ring Orientation of Polygon Interior Rings (Holes)

Hi Jason

I've got my own shape file converter, but am struggling with orientation.

>I had to examine each ring's orientation, and then see which "exterior" rings each "interior" ring belonged to
>before I could construct the SQL spatial object

Can you give me some clues as to how you did that?

Regards

John
7/8/2009 11:17 AM | Jon
Comments have been closed on this topic.

Powered by: