def decode(polyline)
      points = []
      index = lat = lng = 0

      while index < polyline.length
        result = 1
        shift = 0
        while true
          b = polyline[index].ord - 63 - 1
          index += 1
          result += b << shift
          shift += 5
          break if b < 0x1f
        end
        lat += (result & 1) != 0 ? (~result >> 1) : (result >> 1)

        result = 1
        shift = 0
        while true
          b = polyline[index].ord - 63 - 1
          index += 1
          result += b << shift
          shift += 5
          break if b < 0x1f
        end
        lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1)

        points << {lat: lat * 1e-5, lng: lng * 1e-5}
      end

      points
    end
def decode(polyline)
      points = []
      index = lat = lng = 0

      while index < polyline.length
        result = 1
        shift = 0
        while true
          b = polyline[index].ord - 63 - 1
          index += 1
          result += b << shift
          shift += 5
          break if b < 0x1f
        end
        lat += (result & 1) != 0 ? (~result >> 1) : (result >> 1)

        result = 1
        shift = 0
        while true
          b = polyline[index].ord - 63 - 1
          index += 1
          result += b << shift
          shift += 5
          break if b < 0x1f
        end
        lng += (result & 1) != 0 ? ~(result >> 1) : (result >> 1)

        points << {lat: lat * 1e-5, lng: lng * 1e-5}
      end

      points
    end
Decodes a Polyline string into a list of lat/lng hash.

 See the developer docs for a detailed description of this encoding:
 https://developers.google.com/maps/documentation/utilities/polylinealgorithm

 @example
   encoded_path = '_p~iF~ps|U_ulLnnqC_mqNvxq`@'
   path = GoogleMapsService::Polyline.decode(encoded_path)
   #=> [{:lat=>38.5, :lng=>-120.2}, {:lat=>40.7, :lng=>-120.95}, {:lat=>43.252, :lng=>-126.45300000000002}]

 @param [String] polyline An encoded polyline

 @return [Array] Array of hash with lat/lng keys