Esempio n. 1
0
        /// <summary>
        /// Calculates the distance between two points on the ellipsoid given elevations.
        ///
        /// First finded a new ellipsoid which radius is greater (or less) than the radius of the original ellipsoid
        /// by the difference between the elevations. Then calculated the length of a geodesic on this ellipsoid. The
        /// distance between two points is calculated as the hypotenuse of a triangle, which cathetus are geodesic
        /// length and height difference.
        /// </summary>
        /// <param name="refEllipsoid">Ellipsoid</param>
        /// <param name="start">A start point</param>
        /// <param name="end">An end point</param>
        /// <returns>An object that represents the result</returns>
        public GeodeticMeasurement CalculateGeodeticMeasurement(Ellipsoid refEllipsoid, GlobalPosition start, GlobalPosition end)
        {
            GlobalCoordinates startCoords = start.Coordinates;
            GlobalCoordinates endCoords   = end.Coordinates;

            // calculate the average elevation
            double elev1  = start.Elevation;
            double elev2  = end.Elevation;
            double elev12 = (elev1 + elev2) / 2.0;

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

            // Calculate new ellipsoid
            double refA = refEllipsoid.SemiMajorAxis;
            double f    = refEllipsoid.IsInvFDefinitive ? 1 / refEllipsoid.InverseFlattening : 0;
            double a    = refA + elev12 * (1.0 + f * Math.Sin(phi12));

            Ellipsoid ellipsoid = new Ellipsoid(a, f == 0 ? a : 0, f == 0 ? 0 : 1 / f, f != 0, LinearUnit.Metre, string.Empty, string.Empty, 0, string.Empty, string.Empty, string.Empty);

            // calculate the geodesic on an average elevation
            GeodeticCurve averageCurve = CalculateGeodeticCurve(ellipsoid, startCoords, endCoords);

            return(new GeodeticMeasurement(averageCurve, elev2 - elev1));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the MapAround.Geography.GeodeticMeasurement.
        /// </summary>
        /// <param name="averageCurve">A segment of a geodesic line at the average elevation</param>
        /// <param name="elevationChange">A change of the elevation in units of the ellipsoid's axes</param>
        public GeodeticMeasurement(GeodeticCurve averageCurve, double elevationChange)
        {
            double ellDist = averageCurve.EllipsoidalDistance;

            _curve           = averageCurve;
            _elevationChange = elevationChange;
            _P2P             = Math.Sqrt(ellDist * ellDist + _elevationChange * _elevationChange);
        }