Converts a lat/lon pair to a comma-separated string. For example: sydney = { "lat" : -33.8674869, "lng" : 151.2069902 } convert.latlng(sydney) # '-33.8674869,151.2069902' For convenience, also accepts lat/lon pair as a string, in which case it's return
(arg)
| 56 | |
| 57 | |
| 58 | def latlng(arg): |
| 59 | """Converts a lat/lon pair to a comma-separated string. |
| 60 | |
| 61 | For example: |
| 62 | |
| 63 | sydney = { |
| 64 | "lat" : -33.8674869, |
| 65 | "lng" : 151.2069902 |
| 66 | } |
| 67 | |
| 68 | convert.latlng(sydney) |
| 69 | # '-33.8674869,151.2069902' |
| 70 | |
| 71 | For convenience, also accepts lat/lon pair as a string, in |
| 72 | which case it's returned unchanged. |
| 73 | |
| 74 | :param arg: The lat/lon pair. |
| 75 | :type arg: string or dict or list or tuple |
| 76 | """ |
| 77 | if is_string(arg): |
| 78 | return arg |
| 79 | |
| 80 | normalized = normalize_lat_lng(arg) |
| 81 | return "%s,%s" % (format_float(normalized[0]), format_float(normalized[1])) |
| 82 | |
| 83 | |
| 84 | def normalize_lat_lng(arg): |
no test coverage detected