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)
| 82 | |
| 83 | |
| 84 | def 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 | |
| 111 | def location_list(arg): |
no test coverage detected