public void TestCalculateGeodeticCurve() { // instantiate the calculator GeodeticCalculator geoCalc = new GeodeticCalculator(); // select a reference elllipsoid Ellipsoid reference = Ellipsoid.WGS84; // set Lincoln Memorial coordinates GlobalCoordinates lincolnMemorial; lincolnMemorial = new GlobalCoordinates(38.88922, -77.04978); // set Eiffel Tower coordinates GlobalCoordinates eiffelTower; eiffelTower = new GlobalCoordinates(48.85889, 2.29583); // calculate the geodetic curve GeodeticCurve geoCurve = geoCalc.CalculateGeodeticCurve(reference, lincolnMemorial, eiffelTower); Assert.AreEqual(6179016.136, geoCurve.EllipsoidalDistance, 0.001); Assert.AreEqual(51.76792142, geoCurve.Azimuth.Degrees, 0.0000001); Assert.AreEqual(291.75529334, geoCurve.ReverseAzimuth.Degrees, 0.0000001); }
public static double CalculateBearing(GeoCoordinate startingLocation, GeoCoordinate destinationLocation) { GeodeticCurve result = _geodeticCalculator.CalculateGeodeticCurve(Ellipsoid.WGS84, startingLocation.ToGlobalCoordinates(), destinationLocation.ToGlobalCoordinates()); double bearing = result.Azimuth.Degrees; return(bearing); }
public void TestInverseWithDirect() { // instantiate the calculator GeodeticCalculator geoCalc = new GeodeticCalculator(); // select a reference elllipsoid Ellipsoid reference = Ellipsoid.WGS84; // set Lincoln Memorial coordinates GlobalCoordinates lincolnMemorial; lincolnMemorial = new GlobalCoordinates(new Angle(38.88922), new Angle(-77.04978)); // set Eiffel Tower coordinates GlobalCoordinates eiffelTower; eiffelTower = new GlobalCoordinates(48.85889, 2.29583); // calculate the geodetic curve GeodeticCurve geoCurve = geoCalc.CalculateGeodeticCurve(reference, lincolnMemorial, eiffelTower); // now, plug the result into to direct solution GlobalCoordinates dest; Angle endBearing = new Angle(); dest = geoCalc.CalculateEndingGlobalCoordinates(reference, lincolnMemorial, geoCurve.Azimuth, geoCurve.EllipsoidalDistance, out endBearing); Assert.AreEqual(eiffelTower.Latitude.Degrees, dest.Latitude.Degrees, 0.0000001); Assert.AreEqual(eiffelTower.Longitude.Degrees, dest.Longitude.Degrees, 0.0000001); }
/// <summary> /// Calculate the two-dimensional path from /// Lincoln Memorial in Washington, D.C --> 38.8892N, 77.04978W /// to /// Eiffel Tower in Paris --> 48.85889N, 2.29583E /// using /// WGS84 reference ellipsoid /// </summary> static void TwoDimensionalInverseCalculation() { // instantiate the calculator GeodeticCalculator geoCalc = new GeodeticCalculator(); // select a reference elllipsoid Ellipsoid reference = Ellipsoid.WGS84; // set Lincoln Memorial coordinates GlobalCoordinates lincolnMemorial; lincolnMemorial = new GlobalCoordinates( new Angle(38.88922), new Angle(-77.04978) ); // set Eiffel Tower coordinates GlobalCoordinates eiffelTower; eiffelTower = new GlobalCoordinates( new Angle(48.85889), new Angle(2.29583) ); // calculate the geodetic curve GeodeticCurve geoCurve = geoCalc.CalculateGeodeticCurve(reference, lincolnMemorial, eiffelTower); double ellipseKilometers = geoCurve.EllipsoidalDistance / 1000.0; double ellipseMiles = ellipseKilometers * 0.621371192; Console.WriteLine("2-D path from Lincoln Memorial to Eiffel Tower using WGS84"); Console.WriteLine(" Ellipsoidal Distance: {0:0.00} kilometers ({1:0.00} miles)", ellipseKilometers, ellipseMiles); Console.WriteLine(" Azimuth: {0:0.00} degrees", geoCurve.Azimuth.Degrees); Console.WriteLine(" Reverse Azimuth: {0:0.00} degrees", geoCurve.ReverseAzimuth.Degrees); }
public double Distance(String lat1, String lon1, String lat2, String lon2) { //The geodesy library calculates distance between two geo coordinates based on //Vincenty's Formula. This library class contains parameters to calculate the distance. //The Ellipsoid value is based on the geographic location. Australia follows GRS80 //Ellipsoid based on its demography. //The class was created by Gavaghan http://www.gavaghan.org/blog/free-source-code/geodesy-library-vincentys-formula/ Ellipsoid reference = Ellipsoid.GRS80; //Create new object for geodetic calculator. GeodeticCalculator geoCalc = new GeodeticCalculator(reference); //Set the coordinates for point A GlobalCoordinates pointA; pointA = new GlobalCoordinates( new Angle(Convert.ToDouble(lat1)), new Angle(Convert.ToDouble(lon1)) ); //Set the coordinates for point B GlobalCoordinates pointB; pointB = new GlobalCoordinates( new Angle(Convert.ToDouble(lat2)), new Angle(Convert.ToDouble(lon2)) ); //Calculate the curved distance between the two coordinates GeodeticCurve geoCurve = geoCalc.CalculateGeodeticCurve(pointA, pointB); double ellipseMeters = geoCurve.EllipsoidalDistance; return(ellipseMeters); // return the distance in meters }
/// <summary> /// Обратная геодезическая задача /// </summary> /// <param name="end_point"></param> /// <returns>Азимут точки</returns> double get_direction(GlobalCoordinates end_point) { GlobalCoordinates start = UserPosition; GlobalCoordinates end = new GlobalCoordinates(end_point.Latitude.Degrees, end_point.Longitude.Degrees); GeodeticCurve curve = geo_calc.CalculateGeodeticCurve(start, end); return(curve.Azimuth.Degrees); }
/// <summary> /// Обратная геодезическая задача /// </summary> /// <param name="end_point"></param> /// <returns>Азимут точки</returns> double get_direction(PointLatLng end_point) { GlobalCoordinates start = new GlobalCoordinates(UserPosition.Lat, UserPosition.Lng); GlobalCoordinates end = new GlobalCoordinates(end_point.Lat, end_point.Lng); GeodeticCurve curve = geo_calc.CalculateGeodeticCurve(start, end); return(curve.Azimuth.Degrees); }
/// <summary> /// Creates a new instance of GeodeticMeasurement. /// </summary> /// <param name="averageCurve">the geodetic curve as measured at the average elevation between two points</param> /// <param name="elevationChangeMeters">the change in elevation, in meters, going from the starting point to the ending point</param> public GeodeticMeasurement(GeodeticCurve averageCurve, double elevationChangeMeters) { double ellipsoidalDistanceMeters = averageCurve.EllipsoidalDistanceMeters; this.AverageCurve = averageCurve; this.ElevationChangeMeters = elevationChangeMeters; this.PointToPointDistanceMeters = System.Math.Sqrt((ellipsoidalDistanceMeters * ellipsoidalDistanceMeters) + (elevationChangeMeters * elevationChangeMeters)); }
public static double GetDistance(double txLat, double txLon, double rxLat, double rxLon) { GeodeticCalculator geoCalc = new GeodeticCalculator(); Ellipsoid reference = Ellipsoid.WGS84; GlobalCoordinates start = new GlobalCoordinates(new Angle(txLat), new Angle(txLon)); GlobalCoordinates end = new GlobalCoordinates(new Angle(rxLat), new Angle(rxLon)); GeodeticCurve path = geoCalc.CalculateGeodeticCurve(reference, start, end); return(path.EllipsoidalDistance); }
public static double ComputeDistance(Waypoint w1, Waypoint w2, out double elevationChange) { GlobalCoordinates startCoords = new GlobalCoordinates(w1.Latitude, w1.Longitude); GlobalCoordinates endCoords = new GlobalCoordinates(w2.Latitude, w2.Longitude); GeodeticCurve curve = geoCal.CalculateGeodeticCurve(Ellipsoid.WGS84, startCoords, endCoords); elevationChange = 0; if (!double.IsNaN(w1.Elevation) && !double.IsNaN(w2.Elevation)) { elevationChange = w2.Elevation - w1.Elevation; } GeodeticMeasurement measurement = new GeodeticMeasurement(curve, elevationChange); return(measurement.PointToPointDistance); }
// equation 53 protected double GetLargestIntermediateSlopeFromRx(List <Point> points, double RxAntennaeHeight) { // slope = m/km double?S_rim = null; // first point is Tx double h_rs = (points.Last().height ?? 0.0) + RxAntennaeHeight; double d = path.EllipsoidalDistance / 1000.0; double C_e = 1.0 / effectiveEarthRadius; // intermediate points are 1 .. n-2, 0 is Tx and n-1 is Rx for (int i = 1; i < points.Count - 1; i++) { double h_i = (points[i].height ?? 0.0); // d_(n-2) will likely be less than distanceBetweenPoints from Rx double d_i; if (i == points.Count - 2) { if (mode == LibraryMode.Normal) { GeodeticCurve subPath = geoCalc.CalculateGeodeticCurve(ellipsoid, points[i].coordinate, points.Last().coordinate); d_i = subPath.EllipsoidalDistance / 1000.0; } else { d_i = distanceBetweenLastPoints / 1000.0; } } else { d_i = i * distanceBetweenPoints / 1000.0; } double S_i = GetSlope(h_rs, h_i, C_e, d_i, d, (d - d_i)); S_rim = (S_i > S_rim || S_rim == null) ? S_i : S_rim; } return(S_rim ?? 0); }
public void TestAntiPodal2() { // instantiate the calculator GeodeticCalculator geoCalc = new GeodeticCalculator(); // select a reference elllipsoid Ellipsoid reference = Ellipsoid.WGS84; // set position 1 GlobalCoordinates p1 = new GlobalCoordinates(Angle.FromDegrees(11), Angle.FromDegrees(80)); // set position 2 GlobalCoordinates p2 = new GlobalCoordinates(Angle.FromDegrees(-10), Angle.FromDegrees(-100)); // calculate the geodetic measurement GeodeticCurve geoCurve = geoCalc.CalculateGeodeticCurve(reference, p1, p2); Assert.AreEqual(19893320.272061437, geoCurve.EllipsoidalDistanceMeters, 0.001); Assert.AreEqual(360, geoCurve.Azimuth.Degrees, StandardTolerance); Assert.AreEqual(0, geoCurve.ReverseAzimuth.Degrees, StandardTolerance); }
private void SetupLibrary(double gap, double earthRadius, string data, ref List <Point> points) { UseDefaultValues(); mode = LibraryMode.Test; geoCalc = new GeodeticCalculator(); distanceBetweenPoints = gap; effectiveEarthRadius = earthRadius; var csv = File.ReadAllLines(data); points = csv .Skip(1) .Select(p => newPointFromCsv(p)) .ToList(); double d = Convert.ToDouble(csv.Last().Split(',')[0]) * 1000.0; path = new GeodeticCurve(d, new Angle(0.0), new Angle(180.0)); double d_secondLast = Convert.ToDouble(csv[csv.Length - 2].Split(',')[0]) * 1000.0; distanceBetweenLastPoints = d - d_secondLast; }
public List <Point> GenerateIntermediateProfilePoints(GlobalCoordinates start, GlobalCoordinates end) { List <Point> points = new List <Point>(); int?startHeight = srtmData.GetElevation(start.Latitude.Degrees, start.Longitude.Degrees); points.Add(new Point(start, startHeight)); path = geoCalc.CalculateGeodeticCurve(ellipsoid, start, end); Angle azimuth = path.Azimuth.Degrees; double totalDistance = path.EllipsoidalDistance; int numberOfPoints = (Convert.ToInt32(Math.Floor(totalDistance / distanceBetweenPoints))); for (int i = 0; i < numberOfPoints; i++) { GlobalCoordinates nextPoint = geoCalc.CalculateEndingGlobalCoordinates(ellipsoid, points[i].coordinate, azimuth, distanceBetweenPoints, out azimuth); int?height = srtmData.GetElevation(nextPoint.Latitude.Degrees, nextPoint.Longitude.Degrees); points.Add(new Point(nextPoint, height)); } int?endHeight = srtmData.GetElevation(end.Latitude.Degrees, end.Longitude.Degrees); points.Add(new Point(end, endHeight)); /* * Perform a sanity check * Occasionally the SRTM library throws up odd values like 65,535 so if we detect values above mount everest (about 8900m) we use the average height between the next points */ FixHeights(ref points); return(points); }
/// <summary> /// Азимут до точки в градусах /// </summary> /// <param name="pointEnd">Точка до которой рассчитывается азимут</param> /// <returns></returns> public int AngleToPoint(Point pointEnd) { GeodeticCurve curve = geoCalc.CalculateGeodeticCurve(LatLon, pointEnd.LatLon); return((int)curve.Azimuth.Degrees); }
/// <summary> /// Дистанция до Точки в метрах /// </summary> /// <param name="pointEnd">Точка до которой считается дистанция</param> /// <returns></returns> public double DistToPoint(Point pointEnd) { GeodeticCurve curve = geoCalc.CalculateGeodeticCurve(LatLon, pointEnd.LatLon); return(curve.EllipsoidalDistance); }