lon2, lat2, zoom2 = ShortLink.decode(ShortLink.encode(lon, lat, zoom))
# zooms should be identical
assert_equal zoom, zoom2, "Decoding a encoded short link gives different zoom for (#{lat}, #{lon}, #{zoom})."
lon2, lat2, zoom2 = ShortLink.decode(ShortLink.encode(lon, lat, zoom))
# zooms should be identical
assert_equal zoom, zoom2, "Decoding a encoded short link gives different zoom for (#{lat}, #{lon}, #{zoom})."
- # but the location has a quantisation error introduced at roughly
- # one pixel (i.e: zoom + 8). the sqrt(5) is because each position
- # has an extra bit of accuracy in the lat coordinate, due to the
+ # but the location has a quantisation error introduced at roughly
+ # one pixel (i.e: zoom + 8). the sqrt(5) is because each position
+ # has an extra bit of accuracy in the lat coordinate, due to the
# smaller range.
distance = Math.sqrt((lat - lat2) ** 2 + (lon - lon2) ** 2)
max_distance = 360.0 / (1 << (zoom + 8)) * 0.5 * Math.sqrt(5)
# smaller range.
distance = Math.sqrt((lat - lat2) ** 2 + (lon - lon2) ** 2)
max_distance = 360.0 / (1 << (zoom + 8)) * 0.5 * Math.sqrt(5)
# the deprecated @ characters in them still work properly.
def test_deprecated_at_sign
cases = [["~v2juONc--", "@v2juONc--"],
# the deprecated @ characters in them still work properly.
def test_deprecated_at_sign
cases = [["~v2juONc--", "@v2juONc--"],
["CO0O~m8--", "CO0O@m8--"]]
cases.each do |new_code, old_code|
["CO0O~m8--", "CO0O@m8--"]]
cases.each do |new_code, old_code|