X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/e15a92a30213d87e10e000a240a7dcab66c208b4..2de26d54ef22c5653f830d0ce4938df78d0ca0fd:/lib/short_link.rb?ds=inline diff --git a/lib/short_link.rb b/lib/short_link.rb index 8983f3bd3..eb73d6029 100644 --- a/lib/short_link.rb +++ b/lib/short_link.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + ## # Encodes and decodes locations from Morton-coded "quad tile" strings. Each # variable-length string encodes to a precision of one pixel per tile (roughly, @@ -23,7 +25,7 @@ module ShortLink # keep support for old shortlinks which use the @ character, now # replaced by the ~ character because twitter is horribly broken # and we can't have that. - str.tr!("@", "~") + str = str.tr("@", "~") str.each_char do |c| t = ARRAY.index c @@ -57,7 +59,7 @@ module ShortLink def encode(lon, lat, z) code = interleave_bits(((lon + 180.0) * (2**32) / 360.0).to_i, ((lat + 90.0) * (2**32) / 180.0).to_i) - str = "" + str = +"" # add eight to the zoom level, which approximates an accuracy of # one pixel in a tile. ((z + 8) / 3.0).ceil.times do |i|