DbGeography使圆与中心和半径 [英] DbGeography make circle with center and radius
问题描述
String selectedLocation = String.Format(POINT({0} { 1}),lon,lat)。替换(,,。);
DbGeography selectedLocationGeo = DbGeography.FromText(selectedLocation,4326);
我也有一个半径R。
我想创建一个具有圆点形状的曲线多边形,该圆弧具有从点坐标指定的半径。请注意,我使用DbGeography,而不是DbGeometry。
如何创建CIRCULARSTRING?或者比使用CIRCULARSTRING有更好的方法?
这样的东西可能吗?
String polyString = String.Format(CURVEPOLYGON(CIRCULARSTRING(xx yy,xx yy,xx yy,xx yy,xx yy)));
DbGeography polygon = DbGeography.FromText(polyString,4326);
谢谢。
创建一个 DbGeography 通过创建 PointFromText 然后缓冲区指向半径。对于WGS84坐标系,DbGeography半径单位似乎以公里为单位。
string textPoint = String.Format(POINT({0} {1}),经度,纬度)
DbGeography point = DbGeography.PointFromText(textPoint,DbGeography.DefaultCoordinateSystemId); // 4326 = [WGS84]
DbGeography targetCircle = point.Buffer(radiusKilometers);
使用 adrian 关于DbGeography.DefaultCoordinateSystemId。
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.
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.
这篇关于DbGeography使圆与中心和半径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!