I\'m using SQL Server 2012, geography.STContains
(documentation) and I don\'t get why the code below fails.
If I switch to geometry
it wor
Now I found the issue. The user drew the polygon starting lower-right and went clockwise. If I reorder the points from biggest latitude and then go counterwise by sorting on long, lat it works. Found a helper for it, but that only works if you "know it's wrong":
if(sqlGeography.EnvelopeAngle() > 90)
sqlGeography ? sqlGeography.ReorientObject();
Just put together a small solution that will fix my values: https://github.com/danielwertheim/GeographyFactory
and a blogpost about it: http://danielwertheim.se/sqlgeography-in-sql-server-2012-polygon-must-start-on-correct-position/
and a follow up about the real "issue", the left-hand rule:
http://danielwertheim.se/sqlgeography-in-sql-server-2012-polygon-must-start-on-correct-position-no/