#NEWLINE# def encode( locations ) : #NEWLINE# #INDENT# '\n    :param locations: locations list containig (lat, lon) two-tuples\n    :return: encoded polyline string\n    ' #NEWLINE# encoded = ( ( _encode_value ( lat , prev_lat ) , _encode_value ( lon , prev_lon ) ) for ( ( prev_lat , prev_lon ) , ( lat , lon ) ) in _iterate_with_previous ( lon , first = ( 0 , 0 ) ) ) #NEWLINE# encoded = chain . from_iterable ( encoded ) #NEWLINE# return '' . join ( ( c for r in encoded for c in r ) )