Esempio n. 1
0
        public void TestConstructorFromDegrees()
        {
            var loc = GeoLocation.FromDegrees(1, 1);

            Assert.AreEqual(1, loc.Latitude);
            Assert.AreEqual(1, loc.Longitude);
        }
Esempio n. 2
0
        public void TestGetDistanceTo()
        {
            //Math.Acos(Math.Sin(0.ToRadians()) * Math.Sin(20.ToRadians()) +
            //          Math.Cos(0.ToRadians()) * Math.Cos(20.ToRadians()) *
            //          Math.Cos(0.ToRadians() - 20.ToRadians())) * 6371.01;

            //Math.Acos(Math.Sin(0) * Math.Sin(0.34906585) +
            //          Math.Cos(0) * Math.Cos(0.34906585) *
            //          Math.Cos(0 - 0.34906585)) * 6371.01;

            //Math.Acos(0 * 0.342020143 +
            //          1 * 0.939692621 *
            //          Math.Cos(-0.34906585)) * 6371.01;

            //Math.Acos(0 * 0.342020143 +
            //          1 * 0.939692621 *
            //          0.939692621) * 6371.01;

            //Math.Acos(0.883022222) * 6371.01;

            //0.488533203 * 6371.01;

            //3112.44992

            var toLocation = GeoLocation.FromDegrees(20, 20);

            var distance = location.GetDistanceTo(toLocation);

            Assert.AreEqual(3112.44992, distance, 0.0001);
        }
Esempio n. 3
0
        public void TestGetBoundingBoxRadiusNearPoles()
        {
            //angularDistance = 1000 / 6371.01
            //angularDistance = 0.156960984

            //minLat = 88.ToRadians() - 0.156960984
            //maxLat = 88.ToRadians() + 0.156960984

            //minLat = 1.53588974 - 0.156960984
            //maxLat = 1.53588974 + 0.156960984

            //minLat = 1.37892876
            //maxLat = 1.69285072

            var loc = GeoLocation.FromDegrees(88, 178);

            var box = loc.GetBoundingBox(1000);

            Assert.AreEqual(79.0067982, box[0], 0.0001);
            Assert.AreEqual(-180, box[1], 0.0001);
            Assert.AreEqual(90, box[2], 0.0001);
            Assert.AreEqual(180, box[3], 0.0001);
        }
Esempio n. 4
0
        public void TestGetDistanceToRadiusLessThanZero()
        {
            var toLocation = GeoLocation.FromDegrees(20, 20);

            Assert.Throws <ArgumentException>(() => location.GetDistanceTo(toLocation, -1), "Radius must be greater than zero");
        }
Esempio n. 5
0
        public void TestConstructorFromDegreesLongitudeTooLarge()
        {
            var exception = Assert.Throws <ArgumentException>(() => GeoLocation.FromDegrees(1, 185));

            Assert.AreEqual(exception.Message, "Longitude must not be greater than the maximum value. (180)");
        }
Esempio n. 6
0
        public void TestConstructorFromDegreesLongitudeTooSmall()
        {
            var exception = Assert.Throws <ArgumentException>(() => GeoLocation.FromDegrees(1, -185));

            Assert.AreEqual(exception.Message, "Longitude must not be less than the minimum value. (-180)");
        }
Esempio n. 7
0
 public void Setup()
 {
     location = GeoLocation.FromDegrees(0, 0);
 }