c# - Reverse orientation of points in a Multipoligon -


There is no specific criteria such as country state and city you find famous text defining a polygon or multiply Area.

You can have an example.

Now I am trying to insert this data into a SQL Server database using C # and EF 6.1.

> code will be something like this:

Take a polygon string from the service 1 and add it to a variable:

  var polygon = GetPolygonFromService (country, state, city ​​);  

and then use it to insert in DB: using

  (datacentext data = new dativientx ()) {var location = New location {country = country, state = state, town = city, geography = dbgoffograph Formtext (polygon)}; Data.Locations.Add (location); Data.SaveChanges (); }  

Now when I do this, I get an error:

The forthcoming Data Data Stream (TDS) Remote Process Call (RPC) Protocol Stream That's wrong . Parameter 4 ("@ 3"): The supply value data type is not a valid example of geography Check the source data for invalid values ​​An example of an invalid value is the numerical type of data with a more accurate scale

< / Blockquote>

After some research and some tests, I came to the conclusion that this is because the order of each point is defined by the polygon such that the polygon has the outer space rather than the outer space R has defined, instead of trying to get the New York area, it gets the rest of the Earth except New York.

Is there any way to convert it in the right direction?

edit: Does

Fixed DbGeography CreatePolygon (string wktString) {var sqlGeography = SqlGeography.STGeomFromText (new SqlChars (wktString), 4326) .MakeValid (); Var Inverted SQLGraphography = sql GOG Reorient object (); If (sql geographical. STArea ()> reverse SqlGeography.STArea ()) {sqlGeography = invertedSqlGeography; } Return DbGeography.FromText (sqlGeography.ToString ()); }

then use the function

  var polygon = GetPolygonFromService (country, state, city); (Using datacentext data = new dataVientoText ()) {var location = new location {country = country, state = state, town = city, geography = create polygon (polygon)}; Data.Locations.Add (location); Data.SaveChanges (); }  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -