public GeodeticMeasurement(GeodeticCurve averageCurve, double elevationChangeMeters)
        {
            double ellipsoidalDistanceMeters = averageCurve.EllipsoidalDistanceMeters;

            this.AverageCurve               = averageCurve;
            this.ElevationChangeMeters      = elevationChangeMeters;
            this.PointToPointDistanceMeters = Math.Sqrt((ellipsoidalDistanceMeters * ellipsoidalDistanceMeters) + (elevationChangeMeters * elevationChangeMeters));
        }
Beispiel #2
0
        public double CalculateDistance()
        {
            GeodeticCalculator geoCalc   = new GeodeticCalculator();
            Ellipsoid          reference = Ellipsoid.WGS84;
            double             lat1      = (double)_position1.Latitude;
            double             lon1      = (double)_position1.Longitude;

            GlobalCoordinates position1 = new GlobalCoordinates(Angle.FromDegrees(lat1), Angle.FromDegrees(lon1));

            double lat2 = (double)_position2.Latitude;
            double lon2 = (double)_position2.Longitude;

            GlobalCoordinates position2 = new GlobalCoordinates(Angle.FromDegrees(lat2), Angle.FromDegrees(lon2));

            GeodeticCurve geoCurve          = geoCalc.CalculateGeodeticCurve(reference, position1, position2);
            double        ellipseKilometers = geoCurve.EllipsoidalDistanceMeters / 1000;
            double        ellipseMiles      = ellipseKilometers * 0.621371192;

            return(ellipseMiles);
        }
        internal GeodeticMeasurement CalculateGeodeticMeasurement(Ellipsoid refEllipsoid, GlobalPosition start, GlobalPosition end, double tolerance)
        {
            // get the coordinates
            GlobalCoordinates startCoords = start.Coordinates;
            GlobalCoordinates endCoords   = end.Coordinates;

            // calculate elevation differences
            double elev1  = start.ElevationMeters;
            double elev2  = end.ElevationMeters;
            double elev12 = (elev1 + elev2) / 2.0;

            double phi1  = startCoords.Latitude.Radians;
            double phi2  = endCoords.Latitude.Radians;
            double phi12 = (phi1 + phi2) / 2.0;

            double    refA      = refEllipsoid.SemiMajorAxisMeters;
            double    f         = refEllipsoid.Flattening;
            double    a         = refA + elev12 * (1.0 + f * Math.Sin(phi12));
            Ellipsoid ellipsoid = Ellipsoid.FromAAndF(a, f);

            GeodeticCurve averageCurve = CalculateGeodeticCurve(ellipsoid, startCoords, endCoords, tolerance);

            return(new GeodeticMeasurement(averageCurve, elev2 - elev1));
        }