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 [...]

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

    • Hi,

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

      Cheers,

      //Daniel

Comments are closed.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: