1

特定の中心点の周りの緯度と経度の値を使用して、地図上に楕円を描くことができました。マップ上に形状が表示されますが、円ではなく楕円になり、指定された距離と一致しないと思います。これを使用して、その円内にオブジェクトを表示するつもりです(これは、円を適切に表示できるようになったら後で行います。これが、楕円ではなく円が完全に丸い必要がある理由です)。

Bing Maps API を使用しています。パラメーターを介して渡された中心から特定のマイル (距離) に円を描画したいのですが、マイルと呼ばれるパラメーターの他の変数は 1D の double 値を保持しています。問題は、数学の計算方法に関係していると思います。マイルをより適切に計算するためにこのコードを改良する方法についての手がかりを誰かが持っていますか?

private void drawPoly(SearchLocation center, Double miles)
{
//amount of vertex
double vertexCount = 100D;
         //used by the api to carried out searches
List<SearchLocation> vertices = new List<SearchLocation>();
double v = 0;
double radians = Math.PI / 180D;
double radiansPerDegree = Math.PI / 180D;
double degreePerVertex = 360D / vertexCount;
double radiansPerVertex = degreePerVertex * radiansPerDegree;
var centerOfMap = center;
const double degLatMiles = 68.68637156368D;
double degLonMiles = Math.Cos(center.Latitude.Value) * (68.68637156368D);
double milesLat = (miles * degLatMiles) / 3600;
double milesLon = (miles * degLonMiles) / 3600;
for (v = 0; v < vertexCount; v++)
{
    radians = v * radiansPerVertex;
               //adds the miles from the center point and draws a circle
    double centrLat = center.Latitude.Value + (milesLat * Math.Sin(radians));
    double centrLon = center.Longitude.Value + (milesLon * Math.Cos(radians));
    vertices.Add(new SearchLocation() { Latitude = centrLat, Longitude = centrLon });
}
4

2 に答える 2

1

わかりました、私はあなたの質問を誤解しました。これはうまくいくはずです:

    /// <summary>
    /// Calculates the end-point from a given source at a given range (meters) and bearing (degrees).
    /// This methods uses simple geometry equations to calculate the end-point.
    /// </summary>
    /// <param name="source">Point of origin</param>
    /// <param name="range">Range in meters</param>
    /// <param name="bearing">Bearing in degrees</param>
    /// <returns>End-point from the source given the desired range and bearing.</returns>
    public static PointLatLng CalculateDerivedPosition(PointLatLng source, double range, double bearing)
    {
        double latA = source.Lat * DEGREES_TO_RADIANS;
        double lonA = source.Lng * DEGREES_TO_RADIANS;
        double angularDistance = range / EARTH_RADIUS_M;
        double trueCourse = bearing * DEGREES_TO_RADIANS;

        double lat = Math.Asin(
            Math.Sin(latA) * Math.Cos(angularDistance) +
            Math.Cos(latA) * Math.Sin(angularDistance) * Math.Cos(trueCourse));

        double dlon = Math.Atan2(
            Math.Sin(trueCourse) * Math.Sin(angularDistance) * Math.Cos(latA),
            Math.Cos(angularDistance) - Math.Sin(latA) * Math.Sin(lat));

        double lon = ((lonA + dlon + Math.PI) % (Math.PI * 2)) - Math.PI;

        return new PointLatLng(
            lat / DEGREES_TO_RADIANS,
            lon / DEGREES_TO_RADIANS);
    }

あなたの中心をソースとしてください:

for (int i = 0; i < 360; i++)
{
  vertices.Add(CalculateDerivedPosition(center, circleRadius, i));
}
于 2012-10-15T09:24:01.703 に答える