MCPcopy Index your code
hub / github.com/googlemaps/google-maps-services-python / shortest_path

Function shortest_path

googlemaps/convert.py:366–386  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

364
365
366def 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

Callers

nothing calls this directly

Calls 2

encode_polylineFunction · 0.85
location_listFunction · 0.85

Tested by

no test coverage detected