def encode_polyline(points):
 last_lat = last_lng = 0
 result = ''
 for point in points:
  ll = normalize_lat_lng(point)
  lat = int(round((ll[0] * 100000.0)))
  lng = int(round((ll[1] * 100000.0)))
  d_lat = (lat - last_lat)
  d_lng = (lng - last_lng)
  for v in [d_lat, d_lng]:
   v = ((~ (v << 1)) if (v < 0) else (v << 1))
   while (v >= 32):
    result += chr(((32 | (v & 31)) + 63))
    v >>= 5
   result += chr((v + 63))
  last_lat = lat
  last_lng = lng
 return result

def encode_polyline ( points ) : last_lat = last_lng = 0 result = '' for point in points : ll = normalize_lat_lng ( point ) lat = int ( round ( ( ll [ 0 ] * 100000.0 ) ) ) lng = int ( round ( ( ll [ 1 ] * 100000.0 ) ) ) d_lat = ( lat - last_lat ) d_lng = ( lng - last_lng ) for v in [ d_lat , d_lng ] : v = ( ( ~ ( v << 1 ) ) if ( v < 0 ) else ( v << 1 ) ) while ( v >= 32 ) : result += chr ( ( ( 32 | ( v & 31 ) ) + 63 ) ) v >>= 5 result += chr ( ( v + 63 ) ) last_lat = lat last_lng = lng return result
encodes a list of points into a polyline string .