437,6 → 437,7 |
return dDistance; |
} |
|
|
public double GetDistanceInPixels(GPoint point1, GPoint point2) |
{ |
double a = (double)(point2.X - point1.X); |
445,6 → 446,30 |
return Math.Sqrt(a * a + b * b); |
} |
|
/// <summary> |
/// point from distance (in m) to point specified by latitude/longitude |
/// without bearing (bearing = 0°) |
/// for calculating radius of circle around a point |
/// The Haversine formula, http://www.movable-type.co.uk/scripts/latlong.html |
/// </summary> |
/// <param name="p1"></param> |
/// <param name="dDist"></param> |
/// <returns></returns> |
public static PointLatLng GetPointFromDistance(PointLatLng p1, double dDist) |
{ |
double R = 6378137; |
double dBearing = 0; |
double dLat1InRad = p1.Lat * (Math.PI / 180); |
double dLong1InRad = p1.Lng * (Math.PI / 180); |
|
double dLat2InRad = Math.Asin(Math.Sin(dLat1InRad) * Math.Cos(dDist / R) + Math.Cos(dLat1InRad) * Math.Sin(dDist / R)); |
double dLong2InRad = dLong1InRad + Math.Atan2(Math.Sin(dBearing) * Math.Sin(dDist / R) * Math.Cos(dLat1InRad), Math.Cos(dDist / R) - Math.Sin(dLat1InRad) * Math.Sin(dLat2InRad)); |
|
double dLatitude = dLat2InRad / (Math.PI / 180); |
double dLongitude = dLong2InRad / (Math.PI / 180); |
|
return new PointLatLng(dLatitude, dLongitude); |
} |
/// <summary> |
/// Accepts two coordinates in degrees. |
/// </summary> |