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); }
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); }
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); }
public virtual void TestHashLenToWidth() { //test odd & even len double[] boxOdd = GeohashUtils.LookupDegreesSizeForHashLen(3); CustomAssert.EqualWithDelta(1.40625, boxOdd[0], 0.0001); CustomAssert.EqualWithDelta(1.40625, boxOdd[1], 0.0001); double[] boxEven = GeohashUtils.LookupDegreesSizeForHashLen(4); CustomAssert.EqualWithDelta(0.1757, boxEven[0], 0.0001); CustomAssert.EqualWithDelta(0.3515, boxEven[1], 0.0001); }
public virtual void TestLookupHashLenForWidthHeight() { Assert.Equal(1, GeohashUtils.LookupHashLenForWidthHeight(999, 999)); Assert.Equal(1, GeohashUtils.LookupHashLenForWidthHeight(999, 46)); Assert.Equal(1, GeohashUtils.LookupHashLenForWidthHeight(46, 999)); Assert.Equal(2, GeohashUtils.LookupHashLenForWidthHeight(44, 999)); Assert.Equal(2, GeohashUtils.LookupHashLenForWidthHeight(999, 44)); Assert.Equal(2, GeohashUtils.LookupHashLenForWidthHeight(999, 5.7)); Assert.Equal(2, GeohashUtils.LookupHashLenForWidthHeight(11.3, 999)); Assert.Equal(3, GeohashUtils.LookupHashLenForWidthHeight(999, 5.5)); Assert.Equal(3, GeohashUtils.LookupHashLenForWidthHeight(11.1, 999)); Assert.Equal(GeohashUtils.MAX_PRECISION, GeohashUtils.LookupHashLenForWidthHeight(10e-20, 10e-20)); }
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); }