I am working with the new Entity-Framework 5, using the Spatial data type DbGeography as part of my model to store in one instance, POINT and in another POLYGON instance.
When setting the value of my POLYGON everything saves without errors, however this is only if I draw a polygon on the map clockwise. If I draw POLGON counterclockwise, I get an error, sql level, indicating that the data is an invalid type of geography.
Now, after my own research into the problem, it seems that the geography data type is pretty strict in terms of the orientation of the Polygons ring. The most common solution is to create a polygon as a geometry, and then convert it to a geography type.
I am looking for a solution in C # that can be applied to data before it is sent to sql. Basically something that will automatically fix the annular orientation of the coordinate array.
I tried to catch the error and then rebuilt the line by changing the array. This works in some cases, but, firstly, it is not reliable, and secondly, catching an error is a big hit in performance.
Thank you, Chris
source share