Beispiel #1
0
        public void EqualTest2()
        {
            GeoHash hash  = GeoHash.EncodeWithCharacterPrecision(120, 30, 10);
            GeoHash hash2 = GeoHash.EncodeWithCharacterPrecision(120, 30, 10);

            Assert.True(hash.Equals(hash2));
        }
Beispiel #2
0
        public void BridNestTest()
        {
            GeoHash hash   = GeoHash.EncodeWithCharacterPrecision(116.402843, 39.999375, 8);
            string  result = hash.ToBase32();

            Assert.Equal("wx4g8c9v", result);
        }
Beispiel #3
0
        public void EightDirectionTest(double longitude, double latitude, int length, string[] hashCodes)
        {
            GeoHash hash = GeoHash.EncodeWithCharacterPrecision(longitude, latitude, length);

            string[] eights = hash.GetEightDirectionBase32();
            foreach (string code in eights)
            {
                Assert.Contains(code, hashCodes);
            }
        }
        public void RectangleTest()
        {
            double        lon = 121.805809020996, lat = 30.0665111541748;
            int           length = 10;
            List <string> hashes = new List <string>();
            GeoHash       gh     = GeoHash.EncodeWithCharacterPrecision(lon, lat, length);

            hashes.Add(gh.ToBase32());
            hashes.AddRange(gh.GetEightDirectionBase32());
            RectangleD       rect   = RectangleD.FromLTRB(lon - gh.Bound.Width, lat - gh.Bound.Height, lon + gh.Bound.Width, lat + gh.Bound.Height);
            GeoHashRectangle ghRect = new GeoHashRectangle(rect, length);

            string[] strs = ghRect.ToBase32();
            Assert.Equal(hashes.Count, strs.Length);
            foreach (string str in strs)
            {
                Assert.Contains(str, hashes);
            }
        }
Beispiel #5
0
 public void StringOverlengthTest()
 {
     Assert.Throws <NotSupportedException>(() => GeoHash.EncodeWithCharacterPrecision(120, 30, GeoHash.MaxCharacterLength + 1));
 }
Beispiel #6
0
        public void MultiTest(double longitude, double latitude, int length, string hashCode)
        {
            GeoHash hash = GeoHash.EncodeWithCharacterPrecision(longitude, latitude, length);

            Assert.Equal(hashCode, hash.ToBase32());
        }