Returns the shortest representation of the given locations. The Elevations API limits requests to 2000 characters, and accepts multiple locations either as pipe-delimited lat/lng values, or an encoded polyline, so we determine which is shortest and use it. :param locations: The lat
(locations)
| 364 | |
| 365 | |
| 366 | def shortest_path(locations): |
| 367 | """Returns the shortest representation of the given locations. |
| 368 | |
| 369 | The Elevations API limits requests to 2000 characters, and accepts |
| 370 | multiple locations either as pipe-delimited lat/lng values, or |
| 371 | an encoded polyline, so we determine which is shortest and use it. |
| 372 | |
| 373 | :param locations: The lat/lng list. |
| 374 | :type locations: list |
| 375 | |
| 376 | :rtype: string |
| 377 | """ |
| 378 | if isinstance(locations, tuple): |
| 379 | # Handle the single-tuple lat/lng case. |
| 380 | locations = [locations] |
| 381 | encoded = "enc:%s" % encode_polyline(locations) |
| 382 | unencoded = location_list(locations) |
| 383 | if len(encoded) < len(unencoded): |
| 384 | return encoded |
| 385 | else: |
| 386 | return unencoded |
nothing calls this directly
no test coverage detected