DbGeography make circle with center and radius
c#, entity-framework, geo, sql-server, sql-server-2012
Solution
Create a DbGeography Circle by creating a PointFromText and then Buffer that point by the radius. For the WGS84 coordinate system the DbGeography radius units appear to be in kilometers.
string textPoint = String.Format("POINT ({0} {1})", longitude, latitude);
DbGeography point = DbGeography.PointFromText(textPoint, DbGeography.DefaultCoordinateSystemId); //4326 = [WGS84]
DbGeography targetCircle = point.Buffer(radiusKilometers);
Edited with info from adrian about DbGeography.DefaultCoordinateSystemId.
Problem
I create a DbGeography-point like this: ``` String selectedLocation = String.Format("POINT ({0} {1})", lon, lat).Replace(",", "."); DbGeography selectedLocationGeo = DbGeography.FromText(selectedLocation, 4326); ``` I also have a radius R. I want to create a curvepolygon with the shape of a circle with the specified radius from the point-coordinate. Be aware that I am using DbGeography, and not DbGeometry. How do I create the CIRCULARSTRING? Or is there a better way than using a CIRCULARSTRING? Something like this perhaps? ``` String polyString = String.Format("CURVEPOLYGON(CIRCULARSTRING(xx yy, xx yy, xx yy, xx yy, xx yy))"); DbGeography polygon = DbGeography.FromText(polyString, 4326); ``` Thanks.