def encode(locations):
    encoded = (
        (_encode_value(lat, prev_lat), _encode_value(lon, prev_lon))
        for (prev_lat, prev_lon), (lat, lon)
        in _iterate_with_previous(locations, first=(0, 0))
    )
    encoded = chain.from_iterable(encoded)
    return ''.join(c for r in encoded for c in r)
:param locations: locations list containig (lat, lon) two-tuples
dataset/ETHPy150Open swistakm/python-gmaps/src/gmaps/polyline.py/encode