コード例 #1
0
        /// <summary>
        /// Calculate the three dimensional geodetic measurement between two positions
        /// measured in reference to a specified ellipsoid.
        /// This calculation is performed by first computing a new ellipsoid by expanding or contracting
        /// the reference ellipsoid such that the new ellipsoid passes through the average elevation
        /// of the two positions.  A geodetic curve across the new ellisoid is calculated.  The
        /// point-to-point distance is calculated as the hypotenuse of a right triangle where the length
        /// of one side is the ellipsoidal distance and the other is the difference in elevation.
        /// </summary>
        /// <param name="start">starting position</param>
        /// <param name="end">ending position</param>
        /// <returns>The geodetic measurement information to get from start to end</returns>
        public GeodeticMeasurement CalculateGeodeticMeasurement(
            GlobalPosition start,
            GlobalPosition end)
        {
            // get the coordinates
            var startCoords = start.Coordinates;
            var endCoords   = end.Coordinates;

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

            // calculate latitude differences
            var phi1  = startCoords.Latitude.Radians;
            var phi2  = endCoords.Latitude.Radians;
            var phi12 = (phi1 + phi2) / 2.0;

            // calculate a new ellipsoid to accommodate average elevation
            var refA      = ReferenceGlobe.SemiMajorAxis;
            var f         = ReferenceGlobe.Flattening;
            var a         = refA + elev12 * (1.0 + f * Math.Sin(phi12));
            var ellipsoid = Ellipsoid.FromAAndF(a, f);
            var geoCalc   = new GeodeticCalculator(ellipsoid);

            // calculate the curve at the average elevation
            var averageCurve =
                geoCalc.CalculateGeodeticCurve(startCoords, endCoords);

            // return the measurement
            return(new GeodeticMeasurement(averageCurve, elev2 - elev1));
        }
コード例 #2
0
        public void TestFactory1()
        {
            var e = Ellipsoid.FromAAndF(100000, 0.01);

            Assert.AreEqual(e.SemiMinorAxis, (1 - 0.01) * 100000);
            Assert.AreEqual(100, e.InverseFlattening);
            Assert.AreEqual(100000, e.SemiMajorAxis);
            Assert.AreEqual(e.Ratio, 1.0 - 0.01);
        }