示例#1
0
        [Test] public void GeodeticDestination()
        {
            TestCoords(
                (idx, from, to) => {
                double kmApart = Geodetic.Kilometres(from, to);
                double bearing = Geodetic.BearingDegrees(from, to);

                var destination = Geodetic.Destination(start: from, distanceKm: kmApart, bearingDegrees: bearing);

                Assert.IsTrue(to.Equals(destination));
            });
        }
示例#2
0
        [Test] public void GeodeticDistances()
        {
            TestCoords(
                (idx, from, to) => {
                double metresApart   = Geodetic.Kilometres(from, to) * 1000;
                string distanceApart = Geodetic.DistanceBetween(from, to);

                Assert.AreEqual(expected: coords[idx, 2], actual: metresApart, delta: 5);

                Assert.AreEqual(expected: distances[idx / 2], actual: distanceApart);

                Assert.AreEqual(metresApart, Geodetic.Haversine(from, to) * 1000);
            });
        }
示例#3
0
        [Test] public void Example()
        {
            //- Generate coordinate structs in decimal degrees
            var from = Geodetic.Coords(latitude: -27.46850, longitude: 151.94379);
            //- or radians
            var to = Geodetic.Coords(latitude: -0.47941664, longitude: 2.65191906, radians: true);

            //- The calculations below don't need to know which form is used. We can always convert it ourselves
            from = from.ToRadians();
            to   = to.ToDegrees();
            //- Now we have two coordinates we can calculate how far apart they are
            double metresApart = Geodetic.Kilometres(from, to) * 1000;
            //- or use the human readable form which will use meters or km as needed
            string distanceApart = Geodetic.DistanceBetween(from, to);
            //- Now we have distance, what direction do we need to travel
            double bearing = Geodetic.BearingDegrees(from, to);
            //- and in radians
            double radians = Geodetic.BearingRadians(from, to);
            //- But what if we know the direction and distance to an object
            var destination = Geodetic.Destination(start: from, distanceKm: metresApart * 1000, bearingDegrees: bearing);
        }