本文介绍了DbGeography 用圆心和半径做圆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我像这样创建了一个 DbGeography 点:

I create a DbGeography-point like this:

String selectedLocation = String.Format("POINT ({0} {1})", lon, lat).Replace(",", ".");
DbGeography selectedLocationGeo = DbGeography.FromText(selectedLocation, 4326);

我也有一个半径 R.

我想从点坐标创建一个具有指定半径的圆形的曲线多边形.请注意,我使用的是 DbGeography,而不是 DbGeometry.

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.

如何创建循环字符串?或者有没有比使用 CIRCULARSTRING 更好的方法?

How do I create the CIRCULARSTRING? Or is there a better way than using a 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 半径单位显示为公里.

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);

使用 adrian 中关于 DbGeography.DefaultCoordinateSystemId 的信息进行了编辑.

Edited with info from adrian about DbGeography.DefaultCoordinateSystemId.

这篇关于DbGeography 用圆心和半径做圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-12 01:46