첨부 소스 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170
using System;

#region 각도 구하기 - GetDegree(startLatitude, startLongitude, endLatitude, endLongitude)

/// <summary>
/// 각도 구하기
/// </summary>
/// <param name="startLatitude">시작 위도</param>
/// <param name="startLongitude">시작 경도</param>
/// <param name="endLatitude">종료 위도</param>
/// <param name="endLongitude">종료 경도</param>
/// <returns>각도</returns>
public double GetDegree(double startLatitude, double startLongitude, double endLatitude, double endLongitude)
{
    double startLatitudeRadian  = startLatitude  * Math.PI / 180d;
    double startLongitudeRadian = startLongitude * Math.PI / 180d;
    double endLatitudeRadian    = endLatitude    * Math.PI / 180d;
    double endLongitudeRadian   = endLongitude   * Math.PI / 180d;

    double distance = Math.Acos(Math.Sin(startLatitudeRadian) * Math.Sin(endLatitudeRadian) +
        Math.Cos(startLatitudeRadian) * Math.Cos(endLatitudeRadian) * Math.Cos(endLongitudeRadian - startLongitudeRadian));

    double degree = Math.Acos((Math.Sin(endLatitudeRadian) - Math.Sin(startLatitudeRadian) * Math.Cos(distance)) /
        (Math.Cos(startLatitudeRadian) * Math.Sin(distance))) * (180d / Math.PI);

    if((endLongitudeRadian - startLongitudeRadian) < 0d)
    {
        degree = 360 - degree;
    }

    return degree;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요