This is a follow up on my post that I wrote this weekend: “SQLGeography in SQL Server 2012 – Polygon must start on correct position?“, you probably want to go and skim it through and then come back. But basically after my first tests I got the feeling that the starting position was the issue, but it turns out it’s not. It’s the “left hand rule”. Let my try and explain with two pictures.

sqlgeography-polygon-clockwise

If you draw the polygon walking “clockwise” and imagine your self looking to the left. Then you are looking away from the shape being constructed, hence we will get the area outside of the shape.

If you instead walk counter-clockwise, you will be looking into the shape, hence we will get the polygon we desired. At least for my use-case.

sqlgeography-polygon-counter-clockwise

Sorry,

//Daniel

Category:
ADO.NET, Development, SQL-Server
Tags:
,

Join the conversation! 3 Comments

  1. [...] I’ve written a followup on this post, explaining the issue and the “left hand rule”. Again feel free to educate [...]

    Reply
  2. So any ideas how to detect if the polygon is drawn counter- or clock wise?

    Reply
    • Hi,

      there’s a link to the first post in this series with T-SQL and C# code. Hope that helps,

      Cheers,

      //Daniel

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: