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

Function normalize_lat_lng

googlemaps/convert.py:84–108  ·  view source on GitHub ↗

Take the various lat/lng representations and return a tuple. Accepts various representations: 1) dict with two entries - "lat" and "lng" 2) list or tuple - e.g. (-33, 151) or [-33, 151] :param arg: The lat/lng pair. :type arg: dict or list or tuple :rtype: tuple (lat, lng)

(arg)

Source from the content-addressed store, hash-verified

82
83
84def normalize_lat_lng(arg):
85 """Take the various lat/lng representations and return a tuple.
86
87 Accepts various representations:
88 1) dict with two entries - "lat" and "lng"
89 2) list or tuple - e.g. (-33, 151) or [-33, 151]
90
91 :param arg: The lat/lng pair.
92 :type arg: dict or list or tuple
93
94 :rtype: tuple (lat, lng)
95 """
96 if isinstance(arg, dict):
97 if "lat" in arg and "lng" in arg:
98 return arg["lat"], arg["lng"]
99 if "latitude" in arg and "longitude" in arg:
100 return arg["latitude"], arg["longitude"]
101
102 # List or tuple.
103 if _is_list(arg):
104 return arg[0], arg[1]
105
106 raise TypeError(
107 "Expected a lat/lng dict or tuple, "
108 "but got %s" % type(arg).__name__)
109
110
111def location_list(arg):

Callers 2

latlngFunction · 0.85
encode_polylineFunction · 0.85

Calls 1

_is_listFunction · 0.85

Tested by

no test coverage detected