Ejemplo n.º 1
0
        /// <summary>
        /// Calculates the initial azimuth (the angle measured clockwise from
        /// true north) at a point from that point to a second point.
        /// </summary>
        /// <param name="latitude1">The latitude of the first point.</param>
        /// <param name="longitude1">The longitude of the first point.</param>
        /// <param name="latitude2">The latitude of the second point.</param>
        /// <param name="longitude2">The longitude of the second point.</param>
        /// <returns>
        /// The initial azimuth of the first point to the second point.
        /// </returns>
        /// <example>
        /// The azimuth from 0,0 to 1,0 is 0 degrees. From 0,0 to 0,1 is 90
        /// degrees (due east). The range of the result is [-180, 180].
        /// </example>
        public static double Azimuth(double latitude1, double longitude1, double latitude2, double longitude2)
        {
            var measurement = Calculator.CalculateGeodeticMeasurement(
                new GlobalPosition(new GlobalCoordinates(new Angle(latitude1), new Angle(longitude1))),
                new GlobalPosition(new GlobalCoordinates(new Angle(latitude2), new Angle(longitude2))));

            return(measurement.Azimuth.Degrees);
        }
Ejemplo n.º 2
0
        public void TestCalculateGeodeticMeasurement()
        {
            // instantiate the calculator
            GeodeticCalculator geoCalc = new GeodeticCalculator();

            // select a reference elllipsoid
            Ellipsoid reference = Ellipsoid.WGS84;

            // set Pike's Peak position
            GlobalPosition pikesPeak;

            pikesPeak = new GlobalPosition(new GlobalCoordinates(new Angle(38.840511), new Angle(-105.0445896)), 4301.0);

            // set Alcatraz Island coordinates
            GlobalPosition alcatrazIsland;

            alcatrazIsland = new GlobalPosition(new GlobalCoordinates(new Angle(37.826389), new Angle(-122.4225)), 0.0);

            // calculate the geodetic measurement
            GeodeticMeasurement geoMeasurement;

            geoMeasurement = geoCalc.CalculateGeodeticMeasurement(reference, pikesPeak, alcatrazIsland);

            Assert.AreEqual(-4301.0, geoMeasurement.ElevationChange, 0.001);
            Assert.AreEqual(1521788.826, geoMeasurement.PointToPointDistance, 0.001);
            Assert.AreEqual(1521782.748, geoMeasurement.EllipsoidalDistance, 0.001);
            Assert.AreEqual(271.21039153, geoMeasurement.Azimuth.Degrees, 0.0000001);
            Assert.AreEqual(80.38029386, geoMeasurement.ReverseAzimuth.Degrees, 0.0000001);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Calculate the three-dimensional path from
        ///    Pike's Peak in Colorado --> 38.840511N, 105.0445896W, 4301 meters
        ///        to
        ///    Alcatraz Island --> 37.826389N, 122.4225W, sea level
        ///        using
        ///    WGS84 reference ellipsoid
        /// </summary>
        private static void ThreeDimensionalInverseCalculation()
        {
            // instantiate the calculator
            GeodeticCalculator geoCalc = new GeodeticCalculator();

            // select a reference elllipsoid
            Ellipsoid reference = Ellipsoid.WGS84;

            // set Pike's Peak position
            GlobalPosition pikesPeak = new GlobalPosition(new GlobalCoordinates(Angle.FromDegrees(38.840511), Angle.FromDegrees(-105.0445896)), 4301);

            // set Alcatraz Island coordinates
            GlobalPosition alcatrazIsland = new GlobalPosition(new GlobalCoordinates(Angle.FromDegrees(37.826389), Angle.FromDegrees(-122.4225)), 0);

            // calculate the geodetic measurement
            GeodeticMeasurement geoMeasurement;
            double p2pKilometers;
            double p2pMiles;
            double elevChangeMeters;
            double elevChangeFeet;

            geoMeasurement   = geoCalc.CalculateGeodeticMeasurement(reference, pikesPeak, alcatrazIsland);
            p2pKilometers    = geoMeasurement.PointToPointDistanceMeters / 1000;
            p2pMiles         = p2pKilometers * 0.621371192;
            elevChangeMeters = geoMeasurement.ElevationChangeMeters;
            elevChangeFeet   = elevChangeMeters * 3.2808399;

            Console.WriteLine("3-D path from Pike's Peak to Alcatraz Island using WGS84");
            Console.WriteLine("   Point-to-Point Distance: {0:0.00} kilometers ({1:0.00} miles)", p2pKilometers, p2pMiles);
            Console.WriteLine("   Elevation change:        {0:0.0} meters ({1:0.0} feet)", elevChangeMeters, elevChangeFeet);
            Console.WriteLine("   Azimuth:                 {0:0.00} degrees", geoMeasurement.Azimuth.Degrees);
            Console.WriteLine("   Reverse Azimuth:         {0:0.00} degrees", geoMeasurement.ReverseAzimuth.Degrees);
        }
Ejemplo n.º 4
0
        public IList <DerivedPointDto> CreateArc(double radius, SuppliedPointDto centerPoint, SuppliedPointDto startPoint, SuppliedPointDto endPoint)
        {
            Angle centerLatitude  = new Angle(centerPoint.Latitude);
            Angle centerLongitude = new Angle(centerPoint.Longitude);
            Angle startLatitude   = new Angle(startPoint.Latitude);
            Angle startLongitude  = new Angle(startPoint.Longitude);
            Angle endLatitude     = new Angle(endPoint.Latitude);
            Angle endLongitude    = new Angle(endPoint.Longitude);

            GlobalCoordinates centerCoordinate = new GlobalCoordinates(centerLatitude, centerLongitude);
            GlobalCoordinates startCoordinate  = new GlobalCoordinates(startLatitude, startLongitude);
            GlobalCoordinates endCoordinate    = new GlobalCoordinates(endLatitude, endLongitude);

            GlobalPosition centerPosition = new GlobalPosition(centerCoordinate);
            GlobalPosition startPosition  = new GlobalPosition(startCoordinate);
            GlobalPosition endPosition    = new GlobalPosition(endCoordinate);

            GeodeticMeasurement centerToStartMeasurement = calculator.CalculateGeodeticMeasurement(centerPosition, startPosition);
            GeodeticMeasurement centerToEndMeasurement   = calculator.CalculateGeodeticMeasurement(centerPosition, endPosition);

            // Radius should ensure that it is tolerable (we are going to ingore it in this implementation)
            double startDistance   = centerToStartMeasurement.PointToPointDistance;
            double endDistance     = centerToEndMeasurement.PointToPointDistance;
            double distanceDelta   = Math.Abs(startDistance - endDistance);
            double distanceEpsilon = distanceDelta / 10;

            Angle startBearing = centerToStartMeasurement.Azimuth;
            Angle endBearing   = centerToEndMeasurement.Azimuth;

            double degreesDelta   = Math.Abs(startBearing.Degrees - endBearing.Degrees);
            double degreesEpsilon = degreesDelta / 10;  // Our angular distribution

            IList <DerivedPointDto> arcPoints = new List <DerivedPointDto>();

            // We are going to assume that arc derivation is done in a clockwise position.
            for (int i = 0; i < 10; i++) // Such that the 10th increment should equate to the end point and the initial the start
            {
                Angle             nextBearing   = new Angle(startBearing.Degrees + (degreesEpsilon * (i + 1)));
                GlobalCoordinates thetaLocation = calculator.CalculateEndingGlobalCoordinates(centerCoordinate, nextBearing, startDistance + (distanceEpsilon * (i + 1)));
                DerivedPointDto   thetaPoint    = new DerivedPointDto(thetaLocation.Latitude.Degrees, thetaLocation.Longitude.Degrees);

                arcPoints.Add(thetaPoint);
            }

            return(arcPoints);
        }
Ejemplo n.º 5
0
        public void TestMeasurement()
        {
            var start = new GlobalPosition(Constants.MyHome, 200);
            var end   = new GlobalPosition(Constants.MyOffice, 240);
            var m     = calc.CalculateGeodeticMeasurement(start, end);
            var c     = calc.CalculateGeodeticCurve(Constants.MyHome, Constants.MyOffice);

            Assert.IsTrue(m.EllipsoidalDistance > c.EllipsoidalDistance);
        }
Ejemplo n.º 6
0
        public static GeodeticMeasurement CalculateDistance(double lat1, double lon1, double lat2, double lon2)
        {
            GlobalCoordinates   p1  = new GlobalCoordinates(new Angle(lat1), new Angle(lon1));
            GlobalCoordinates   p2  = new GlobalCoordinates(new Angle(lat2), new Angle(lon2));
            GeodeticCalculator  gc  = new GeodeticCalculator();
            GlobalPosition      gp1 = new GlobalPosition(p1);
            GlobalPosition      gp2 = new GlobalPosition(p2);
            GeodeticMeasurement gm  = gc.CalculateGeodeticMeasurement(Ellipsoid.WGS84, gp1, gp2);

            return(gm);
        }
Ejemplo n.º 7
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            // Store user inputs
            int maxRadius = (int)numRadius.Value;
            int minRWY    = (int)numRWYmin.Value;
            int minPCN    = (int)numPCNmin.Value;

            string[] mustHaveFields = txtIncludeFields.Text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            // Find home field
            AirfieldInformation home = airfieldInfo.Find(x => x.Airfield.ICAO == txtHome.Text);
            // instantiate the calculator
            GeodeticCalculator geoCalc = new GeodeticCalculator();
            // select a reference elllipsoid
            Ellipsoid reference = Ellipsoid.WGS84;

            foreach (AirfieldInformation alt in airfieldInfo)
            {
                // calculate the geodetic measurement
                GeodeticMeasurement geoMeasurement;
                geoMeasurement              = geoCalc.CalculateGeodeticMeasurement(reference, home.Airfield.Position, alt.Airfield.Position);
                alt.Airfield.RangeFromHome  = geoMeasurement.PointToPointDistance * 0.000539957;
                alt.Airfield.RadialFromHome = geoMeasurement.Azimuth.Degrees - home.Airfield.MagneticDeclination.Degrees;
            }
            airfieldInfo.Sort((x, y) => x.Airfield.RangeFromHome.CompareTo(y.Airfield.RangeFromHome));

            //Get suitable diverts
            List <AirfieldInformation> suitableDiverts = new List <AirfieldInformation>();

            for (int z = 0; z < airfieldInfo.Count; z++)
            {
                //Field is suitable until proven otherwise
                bool suitField = true;

                if (airfieldInfo[z].Airfield.RangeFromHome > maxRadius)
                {
                    suitField = false;
                }
                //Runway conditions
                bool suitRWY = false;
                foreach (Runway r in airfieldInfo[z].Runways)
                {
                    if (r.Length >= minRWY && (r.PCN >= minPCN || r.PCN == -1))
                    {
                        suitRWY = true;
                    }
                }
                if (!suitRWY)
                {
                    suitField = false;
                }
                //More options later


                if (mustHaveFields.Contains(airfieldInfo[z].Airfield.ICAO))
                {
                    suitField = true;
                }
                //Add to suitable fields as required
                if (suitField)
                {
                    suitableDiverts.Add(airfieldInfo[z]);
                }
            }
            suitableDiverts = import.addSuppAndTerminals(suitableDiverts, flipFileLocation);

            //Create pdf
            createDivertPDF(suitableDiverts);
        }