EncodeLatLon() public static method

Encodes the given latitude and longitude into a geohash
public static EncodeLatLon ( double latitude, double longitude ) : String
latitude double Latitude to encode
longitude double Longitude to encode
return String
Beispiel #1
0
        public virtual void TestDecodePreciseLongitudeLatitude()
        {
            string hash = GeohashUtils.EncodeLatLon(52.3738007, 4.8909347);

            IPoint point = GeohashUtils.Decode(hash, ctx);

            CustomAssert.EqualWithDelta(52.3738007, point.Y, 0.00001D);
            CustomAssert.EqualWithDelta(4.8909347, point.X, 0.00001D);
        }
Beispiel #2
0
        public virtual void TestDecodeImpreciseLongitudeLatitude()
        {
            string hash = GeohashUtils.EncodeLatLon(84.6, 10.5);

            IPoint point = GeohashUtils.Decode(hash, ctx);

            CustomAssert.EqualWithDelta(84.6, point.Y, 0.00001D);
            CustomAssert.EqualWithDelta(10.5, point.X, 0.00001D);
        }
Beispiel #3
0
        public virtual void TestEncode()
        {
            string hash = GeohashUtils.EncodeLatLon(42.6, -5.6);

            Assert.Equal("ezs42e44yx96", hash);

            hash = GeohashUtils.EncodeLatLon(57.64911, 10.40744);
            Assert.Equal("u4pruydqqvj8", hash);
        }
Beispiel #4
0
        public virtual void TestDecodeEncode()
        {
            string geoHash = "u173zq37x014";

            Assert.Equal(geoHash, GeohashUtils.EncodeLatLon(52.3738007, 4.8909347));
            IPoint point = GeohashUtils.Decode(geoHash, ctx);

            CustomAssert.EqualWithDelta(52.37380061d, point.Y, 0.000001d);
            CustomAssert.EqualWithDelta(4.8909343d, point.X, 0.000001d);

            Assert.Equal(geoHash, GeohashUtils.EncodeLatLon(point.Y, point.X));

            geoHash = "u173";
            point   = GeohashUtils.Decode("u173", ctx);
            geoHash = GeohashUtils.EncodeLatLon(point.Y, point.X);
            IPoint point2 = GeohashUtils.Decode(geoHash, ctx);

            CustomAssert.EqualWithDelta(point.Y, point2.Y, 0.000001d);
            CustomAssert.EqualWithDelta(point.X, point2.X, 0.000001d);
        }