コード例 #1
0
        public void ToGeoHashTest3()
        {
            var geo01       = new GeoCoordinate(new Latitude(-38.897), new Longitude(-77.036));
            var geo01hash   = geo01.ToGeoHash(20);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("6314xp00e1ej140gw3hz", geo01hash.Value);
            Assert.AreEqual(817991144U, geo01hash32.Value);
            Assert.AreEqual(3513245211907368736UL, geo01hash64.Value);

            var geo01rev   = geo01hash.ToGeoCoordinate(3);
            var geo01rev32 = geo01hash.ToGeoCoordinate(3);
            var geo01rev64 = geo01hash.ToGeoCoordinate(3);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev32.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev64.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
コード例 #2
0
        public void ToGeoHashTest2()
        {
            var geo01       = new GeoCoordinate(new Latitude(38.897), new Longitude(-77.036));
            var geo01hash   = geo01.ToGeoHash(20);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("dqcjr0bp7n74cjbuqqub", geo01hash.Value);
            Assert.AreEqual(2590713666U, geo01hash32.Value);
            Assert.AreEqual(11127030471626460554UL, geo01hash64.Value);

            var geo01rev   = geo01hash.ToGeoCoordinate(3);
            var geo01rev32 = geo01hash.ToGeoCoordinate(3);
            var geo01rev64 = geo01hash.ToGeoCoordinate(3);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev32.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev64.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
コード例 #3
0
        public void ToGeoHashTest1()
        {
            var geo01       = new GeoCoordinate(new Latitude(57.64911), new Longitude(10.40744));
            var geo01hash   = geo01.ToGeoHash(11);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("u4pruydqqvj", geo01hash.Value);
            Assert.AreEqual(3793206966U, geo01hash32.Value);
            Assert.AreEqual(16291699867698975045UL, geo01hash64.Value);

            var geo01rev   = geo01hash.ToGeoCoordinate(5);
            var geo01rev32 = geo01hash.ToGeoCoordinate(5);
            var geo01rev64 = geo01hash.ToGeoCoordinate(5);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev32.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value, geo01rev64.Latitude.Value, 0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
コード例 #4
0
        public void GeoCoordinate_Equal_Tests()
        {
            GeoCoordinate c1 = null, c2 = null;

            var c3 = new GeoCoordinate
            {
                Latitude  = 1.1m,
                Longitude = -100m,
            };
            var c4 = new GeoCoordinate
            {
                Latitude  = 1.1m,
                Longitude = -100m,
            };
            var c5 = new GeoCoordinate
            {
                Latitude = 1.1m
            };

            object o1 = "a string";
            object o2 = c5;

            Assert.AreEqual(true, c1 == c2);
            Assert.AreEqual(true, c3 == c4);
            Assert.AreEqual(true, c1 != c3);
            Assert.AreEqual(true, c4 != c2);
            Assert.AreEqual(true, c5 == null);
            Assert.AreEqual(true, null == c5);
            Assert.AreEqual(false, c5.Equals(o1));
            Assert.AreEqual(true, c5.Equals(o2));
        }
コード例 #5
0
        public void GeoCoordinate_EqualsTwoInstancesWithSameValues_ReturnsTrue()
        {
            var first  = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
            var second = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);

            Assert.IsTrue(first.Equals(second));
        }
コード例 #6
0
        public void GeoCoordinate_EqualsTwoInstancesWithDifferentValuesExceptLongitudeAndLatitude_ReturnsTrue()
        {
            var first  = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
            var second = new GeoCoordinate(11, 12, 14, 15, 16, 17, 18);

            Assert.IsTrue(first.Equals(second));
        }
コード例 #7
0
    public void EqualsTest1()
    {
        var geo = new GeoCoordinate(1, 1);

        Assert.IsFalse(geo.Equals(null));
        Assert.IsFalse(geo !.Equals(new object()));
    }
コード例 #8
0
        public void GeoCoordinate_EqualsTwoInstancesWithDifferentValuesExceptLongitudeAndLatitude_ReturnsTrue()
        {
            var first = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
            var second = new GeoCoordinate(11, 12, 14, 15, 16, 17, 18);

            Assert.IsTrue(first.Equals(second));
        }
コード例 #9
0
            public void ShouldReturnProperValue(number lat1, number lon1, number lat2, number lon2, bool expectedResult)
            {
                // arrange
                var sut = new GeoCoordinate(lat1, lon1);

                // act
                bool result = sut.Equals(new GeoCoordinate(lat2, lon2));

                // assert
                result.Should().Be(expectedResult);
            }
コード例 #10
0
    public void EqualsTest(double latitude1, double longitude1, double latitude2, double longitude2, bool expected)
    {
        var geo1 = new GeoCoordinate(latitude1, longitude1);
        var geo2 = new GeoCoordinate(latitude2, longitude2);

        Assert.AreEqual(expected, geo1.Equals(geo2));

        if (expected)
        {
            Assert.AreEqual(geo1.GetHashCode(), geo2.GetHashCode());
        }
    }
コード例 #11
0
        //returns the flight time between two coordinates with a given speed
        public static TimeSpan GetFlightTime(GeoCoordinate coordinate1, GeoCoordinate coordinate2, double speed)
        {
            if (coordinate1.Equals(coordinate2))
            {
                return(new TimeSpan());
            }

            double dist = GetDistance(coordinate1, coordinate2);

            double dtime = dist / speed;

            int hours = Convert.ToInt16(Math.Floor(dtime));

            double dMinutes = (dtime - hours) * 60;

            int minutes = Convert.ToInt16(Math.Floor(dMinutes));

            return(new TimeSpan(hours, minutes, 0));
        }
コード例 #12
0
ファイル: GeoTriangle.cs プロジェクト: Vanaheimr/Aegir
        /// <summary>
        /// Create a triangle of type T.
        /// </summary>
        /// <param name="Pixel1">The first pixel of the triangle.</param>
        /// <param name="Pixel2">The second pixel of the triangle.</param>
        /// <param name="Pixel3">The third pixel of the triangle.</param>
        public GeoTriangle(GeoCoordinate Pixel1, GeoCoordinate Pixel2, GeoCoordinate Pixel3)
        {
            #region Initial Checks

            if (Pixel1 == null)
                throw new ArgumentNullException("The given first pixel must not be null!");

            if (Pixel2 == null)
                throw new ArgumentNullException("The given second pixel must not be null!");

            if (Pixel3 == null)
                throw new ArgumentNullException("The given third pixel must not be null!");

            #endregion

            #region Math Checks

            if (Pixel1.Equals(Pixel2) ||
                Pixel1.Equals(Pixel3) ||
                Pixel2.Equals(Pixel3))
                throw new ArgumentException("All distances between the pixels must be larger than zero!");

            //if (Pixel1.Longitude.Equals(Pixel2.Longitude) &&
            //    Pixel2.Longitude.Equals(Pixel3.Longitude))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            //if (Pixel1.Latitude.Equals(Pixel2.Latitude) &&
            //    Pixel2.Latitude.Equals(Pixel3.Latitude))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            #endregion

            #region Sort Pixels

            // Sort by x-coordinate.
            while (true)
            {

                if (Pixel1.Longitude > Pixel2.Longitude)
                {
                    GeoCoordinate.Swap(ref Pixel1, ref Pixel2);
                    continue;
                }

                if (Pixel1.Longitude > Pixel3.Longitude)
                {
                    GeoCoordinate.Swap(ref Pixel1, ref Pixel3);
                    continue;
                }

                if (Pixel2.Longitude > Pixel3.Longitude)
                {
                    GeoCoordinate.Swap(ref Pixel2, ref Pixel3);
                    continue;
                }

                break;

            }

            // Sort by y-coordinate if x-coordinates are the same
            if (Pixel1.Longitude.Equals(Pixel2.Longitude))
                if (Pixel1.Latitude > Pixel2.Latitude)
                    GeoCoordinate.Swap(ref Pixel1, ref Pixel2);

            if (Pixel2.Longitude.Equals(Pixel3.Longitude))
                if (Pixel2.Latitude > Pixel3.Latitude)
                    GeoCoordinate.Swap(ref Pixel1, ref Pixel2);

            #endregion

            this.P1         = Pixel1;
            this.P2         = Pixel2;
            this.P3         = Pixel3;

            this.E12        = new GeoLine(P1, P2);
            this.E23        = new GeoLine(P2, P3);
            this.E31        = new GeoLine(P3, P1);

            this._Borders   = new GeoLine[3] { E12, E23, E31 };

            this.Tags       = new List<String>();
        }
コード例 #13
0
ファイル: GeoCircle.cs プロジェクト: Vanaheimr/Aegir
        /// <summary>
        /// Creates a circumcircle of type T based on three pixels.
        /// </summary>
        /// <param name="Pixel1">The first pixel of the triangle.</param>
        /// <param name="Pixel2">The second pixel of the triangle.</param>
        /// <param name="Pixel3">The third pixel of the triangle.</param>
        public GeoCircle(GeoCoordinate Pixel1, GeoCoordinate Pixel2, GeoCoordinate Pixel3)
        {
            #region Initial Checks

            if (Pixel1 == null)
                throw new ArgumentNullException("The given first pixel must not be null!");

            if (Pixel2 == null)
                throw new ArgumentNullException("The given second pixel must not be null!");

            if (Pixel3 == null)
                throw new ArgumentNullException("The given third pixel must not be null!");

            #endregion

            #region Math Checks

            if (Pixel1.Equals(Pixel2) ||
                Pixel1.Equals(Pixel3) ||
                Pixel2.Equals(Pixel3))
                throw new ArgumentException("All distances between the pixels must be larger than zero!");

            //if (Pixel1.Longitude.Value.Equals(Pixel2.Longitude.Value) &&
            //    Pixel2.Longitude.Value.Equals(Pixel3.Longitude.Value))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            //if (Pixel1.Latitude.Value.Equals(Pixel2.Latitude.Value) &&
            //    Pixel2.Latitude.Value.Equals(Pixel3.Latitude.Value))
            //    throw new ArgumentException("All three pixels must not be on a single line!");

            #endregion

            var _Line12     = new GeoLine(Pixel1, Pixel2);
            var _Line23     = new GeoLine(Pixel2, Pixel3);

            this.Center     = new GeoLine(_Line12.Center, _Line12.Normale).
                                  Intersection(
                              new GeoLine(_Line23.Center, _Line23.Normale));

            this.Radius     = (Center != null) ? Center.DistanceTo(Pixel1) : 0;
        }
コード例 #14
0
ファイル: GeoCoordinateTests.cs プロジェクト: cegreer/Common
        public void GeoCoordinate_Unit_Equals1_ObjIsNull()
        {
            Double latitude = -32;
            Double longitude = 32;
            GeoCoordinate target = new GeoCoordinate(latitude, longitude);
            Object obj = null;

            Boolean actual = target.Equals(obj);
            Assert.AreEqual(false, actual);
        }
コード例 #15
0
ファイル: GeoCoordinateTests.cs プロジェクト: cegreer/Common
        public void GeoCoordinate_Unit_Equals2_ObjIsUnequivalent()
        {
            Double latitude = -32;
            Double longitude = 32;
            GeoCoordinate target = new GeoCoordinate(latitude, longitude);
            GeoCoordinate other = new GeoCoordinate();

            Boolean actual = target.Equals(other);
            Assert.AreEqual(false, actual);
        }
コード例 #16
0
ファイル: GeoCircle.cs プロジェクト: Vanaheimr/Aegir
        /// <summary>
        /// Checks if the given first pixel is within the circle
        /// defined by the remaining three edge pixels.
        /// </summary>
        /// <param name="Pixel">The pixel to be checked.</param>
        /// <param name="EdgePixel1">The first edge pixel defining a circle.</param>
        /// <param name="EdgePixel2">The second edge pixel defining a circle.</param>
        /// <param name="EdgePixel3">The third edge pixel defining a circle.</param>
        public static Boolean IsInCircle(GeoCoordinate Pixel, GeoCoordinate EdgePixel1, GeoCoordinate EdgePixel2, GeoCoordinate EdgePixel3)
        {
            #region Initial Checks

            if (Pixel == null)
                throw new ArgumentNullException("The given first pixel must not be null!");

            if (EdgePixel1 == null)
                throw new ArgumentNullException("The given first edgepixel must not be null!");

            if (EdgePixel2 == null)
                throw new ArgumentNullException("The given second edgepixel must not be null!");

            if (EdgePixel3 == null)
                throw new ArgumentNullException("The given third edgepixel must not be null!");

            #endregion

            #region Math Checks

            if (EdgePixel1.Equals(EdgePixel2) ||
                EdgePixel1.Equals(EdgePixel3) ||
                EdgePixel2.Equals(EdgePixel3))
                throw new ArgumentException("All distances between the pixels must be larger than zero!");

            if (EdgePixel1.Longitude.Value.Equals(EdgePixel2.Longitude.Value) &&
                EdgePixel2.Longitude.Value.Equals(EdgePixel3.Longitude.Value))
                throw new ArgumentException("All three pixels must not be on a single line!");

            if (EdgePixel1.Latitude.Value.Equals(EdgePixel2.Latitude.Value) &&
                EdgePixel2.Latitude.Value.Equals(EdgePixel3.Latitude.Value))
                throw new ArgumentException("All three pixels must not be on a single line!");

            #endregion

            var _Line12     = new GeoLine(EdgePixel1, EdgePixel2);
            var _Line23     = new GeoLine(EdgePixel2, EdgePixel3);

            var Center      = new GeoLine(_Line12.Center, _Line12.Normale).
                                  Intersection(
                              new GeoLine(_Line23.Center, _Line23.Normale));

            return Center.DistanceTo(Pixel) <= Center.DistanceTo(EdgePixel1);
        }
コード例 #17
0
        /// <summary>
        /// Determines a geodetic vector between source and destination coordinates.
        /// </summary>
        /// <param name="ellipsoid">The ellipsoid.</param>
        /// <param name="source">The source coordinate.</param>
        /// <param name="dest">The destination coordinate.</param>
        /// <returns>The geodetic vector between source and destination coordinates.</returns>
        public static GeoVector GetVector(this Ellipsoid ellipsoid, GeoCoordinate source, GeoCoordinate dest)
        {
            if (ellipsoid == null)
            {
                throw new ArgumentNullException("ellipsoid", "The ellipsoid is null.");
            }

            if (!source.IsValid)
            {
                throw new ArgumentException("Source coordinate must be valid.", "source");
            }

            if (!dest.IsValid)
            {
                throw new ArgumentException("Destination coordinate must be valid.", "dest");
            }

            if (source.Equals(dest))
            {
                return(GeoVector.NullVector);
            }

            if (ellipsoid.IsSphere)
            {
                Double deltaLambda, omega, dist, azimuth;

                // case the destination is a pole
                if (Math.Abs(source.Latitude.BaseValue - Constants.PI / 2) <= Calculator.Tolerance)
                {
                    azimuth = Constants.PI;
                    dist    = LengthOfVerticalCurvature(ellipsoid, source.Latitude.BaseValue, dest.Latitude.BaseValue);
                }
                if (Math.Abs(source.Latitude.BaseValue - 3 * Constants.PI / 2) <= Calculator.Tolerance)
                {
                    azimuth = 0;
                    dist    = LengthOfVerticalCurvature(ellipsoid, source.Latitude.BaseValue, dest.Latitude.BaseValue);
                }
                else
                {
                    deltaLambda = dest.Longitude.BaseValue - source.Longitude.BaseValue;
                    dist        = Math.Acos(Math.Sin(source.Latitude.BaseValue) * Math.Sin(dest.Latitude.BaseValue) + Math.Cos(source.Latitude.BaseValue) * Math.Cos(dest.Latitude.BaseValue) * Math.Cos(deltaLambda)) * ellipsoid.SemiMajorAxis.BaseValue;

                    // case the vector is north or sourth oriented
                    if (Math.Sin(deltaLambda) == 0)
                    {
                        if (Math.Abs(dist - LengthOfVerticalCurvature(ellipsoid, source.Latitude.BaseValue, dest.Latitude.BaseValue)) <= Calculator.Tolerance)
                        {
                            deltaLambda = 0;
                        }
                        else
                        {
                            deltaLambda = Constants.PI;
                        }
                    }

                    omega = Math.Acos((Math.Sin(dest.Latitude.BaseValue) - Math.Sin(source.Latitude.BaseValue) * Math.Cos(dist / ellipsoid.SemiMajorAxis.BaseValue)) / Math.Cos(source.Latitude.BaseValue) / Math.Sin(dist / ellipsoid.SemiMajorAxis.BaseValue)) * Math.Sin(deltaLambda) / Math.Abs(Math.Sin(deltaLambda));

                    azimuth = deltaLambda > 0 ? omega : 2 * Constants.PI - omega;
                }

                return(new GeoVector(azimuth, dist));
            }
            else
            {
                // TODO
                throw new NotImplementedException();
            }
        }
コード例 #18
0
        public void GeoCoordinate_EqualsWithOtherTypes_ReturnsFalse()
        {
            dynamic something = 42;

            UnitTesting.Assert.IsFalse(_unitUnderTest.Equals(something));
        }
コード例 #19
0
ファイル: GeoPositionTests.cs プロジェクト: Vanaheimr/Aegir
        public void ToGeoHashTest3()
        {
            var geo01       = new GeoCoordinate(new Latitude(-38.897), new Longitude(-77.036));
            var geo01hash   = geo01.ToGeoHash(20);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("6314xp00e1ej140gw3hz", geo01hash.Value);
            Assert.AreEqual(817991144U,             geo01hash32.Value);
            Assert.AreEqual(3513245211907368736UL,  geo01hash64.Value);

            var geo01rev    = geo01hash.ToGeoCoordinate(3);
            var geo01rev32  = geo01hash.ToGeoCoordinate(3);
            var geo01rev64  = geo01hash.ToGeoCoordinate(3);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev.Latitude.Value,    0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value,   0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev32.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev64.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
コード例 #20
0
ファイル: GeoPositionTests.cs プロジェクト: Vanaheimr/Aegir
        public void ToGeoHashTest2()
        {
            var geo01       = new GeoCoordinate(new Latitude(38.897), new Longitude(-77.036));
            var geo01hash   = geo01.ToGeoHash(20);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("dqcjr0bp7n74cjbuqqub", geo01hash.Value);
            Assert.AreEqual(2590713666U,            geo01hash32.Value);
            Assert.AreEqual(11127030471626460554UL, geo01hash64.Value);

            var geo01rev    = geo01hash.ToGeoCoordinate(3);
            var geo01rev32  = geo01hash.ToGeoCoordinate(3);
            var geo01rev64  = geo01hash.ToGeoCoordinate(3);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev.Latitude.Value,    0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value,   0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev32.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev64.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
コード例 #21
0
ファイル: GeoPositionTests.cs プロジェクト: Vanaheimr/Aegir
        public void ToGeoHashTest1()
        {
            var geo01       = new GeoCoordinate(new Latitude(57.64911), new Longitude(10.40744));
            var geo01hash   = geo01.ToGeoHash(11);
            var geo01hash32 = geo01.ToGeoHash32(16);
            var geo01hash64 = geo01.ToGeoHash64(32);

            Assert.AreEqual("u4pruydqqvj",          geo01hash.Value);
            Assert.AreEqual(3793206966U,            geo01hash32.Value);
            Assert.AreEqual(16291699867698975045UL, geo01hash64.Value);

            var geo01rev    = geo01hash.ToGeoCoordinate(5);
            var geo01rev32  = geo01hash.ToGeoCoordinate(5);
            var geo01rev64  = geo01hash.ToGeoCoordinate(5);

            Assert.IsTrue(geo01.Equals(geo01rev));
            Assert.IsTrue(geo01 == geo01rev);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev.Latitude.Value,    0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev.Longitude.Value,   0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev32));
            Assert.IsTrue(geo01 == geo01rev32);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev32.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev32.Longitude.Value, 0.000001);

            Assert.IsTrue(geo01.Equals(geo01rev64));
            Assert.IsTrue(geo01 == geo01rev64);
            Assert.AreEqual(geo01.Latitude.Value,  geo01rev64.Latitude.Value,  0.000001);
            Assert.AreEqual(geo01.Longitude.Value, geo01rev64.Longitude.Value, 0.000001);
        }
コード例 #22
0
        public void GeoCoordinate_EqualsTwoInstancesWithSameValues_ReturnsTrue()
        {
            var first = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);
            var second = new GeoCoordinate(11, 12, 13, 14, 15, 16, 17);

            Assert.IsTrue(first.Equals(second));
        }
コード例 #23
0
        public void GeoCoordinate_EqualsWithOtherTypes_ReturnsFalse()
        {
            var something = new Nullable <Int32>(42);

            Assert.IsFalse(_UnitUnderTest.Equals(something));
        }