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; // calculate latitude differences double phi1 = startCoords.Latitude.Radians; double phi2 = endCoords.Latitude.Radians; double phi12 = (phi1 + phi2) / 2.0; // calculate a new ellipsoid to accommodate average elevation double refA = refEllipsoid.SemiMajorAxisMeters; double f = refEllipsoid.Flattening; double a = refA + elev12 * (1.0 + f * Math.Sin(phi12)); Ellipsoid ellipsoid = Ellipsoid.FromAAndF(a, f); // calculate the curve at the average elevation GeodeticCurve averageCurve = CalculateGeodeticCurve(ellipsoid, startCoords, endCoords, tolerance); // return the measurement return(new GeodeticMeasurement(averageCurve, elev2 - elev1)); }
/// <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="elevationChange">the change in elevation, in meters, going from the starting point to the ending point</param> public GeodeticMeasurement(GeodeticCurve averageCurve, double elevationChange) { double ellDist = averageCurve.EllipsoidalDistance; mCurve = averageCurve; mElevationChange = elevationChange; mP2P = Math.Sqrt(ellDist * ellDist + mElevationChange * mElevationChange); }
/// <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 = Math.Sqrt((ellipsoidalDistanceMeters * ellipsoidalDistanceMeters) + (elevationChangeMeters * elevationChangeMeters)); }