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

Function bounds

googlemaps/convert.py:239–276  ·  view source on GitHub ↗

Converts a lat/lon bounds to a comma- and pipe-separated string. Accepts two representations: 1) string: pipe-separated pair of comma-separated lat/lon pairs. 2) dict with two entries - "southwest" and "northeast". See convert.latlng for information on how these can be represented.

(arg)

Source from the content-addressed store, hash-verified

237
238
239def bounds(arg):
240 """Converts a lat/lon bounds to a comma- and pipe-separated string.
241
242 Accepts two representations:
243 1) string: pipe-separated pair of comma-separated lat/lon pairs.
244 2) dict with two entries - "southwest" and "northeast". See convert.latlng
245 for information on how these can be represented.
246
247 For example:
248
249 sydney_bounds = {
250 "northeast" : {
251 "lat" : -33.4245981,
252 "lng" : 151.3426361
253 },
254 "southwest" : {
255 "lat" : -34.1692489,
256 "lng" : 150.502229
257 }
258 }
259
260 convert.bounds(sydney_bounds)
261 # '-34.169249,150.502229|-33.424598,151.342636'
262
263 :param arg: The bounds.
264 :type arg: dict
265 """
266
267 if is_string(arg) and arg.count("|") == 1 and arg.count(",") == 2:
268 return arg
269 elif isinstance(arg, dict):
270 if "southwest" in arg and "northeast" in arg:
271 return "%s|%s" % (latlng(arg["southwest"]),
272 latlng(arg["northeast"]))
273
274 raise TypeError(
275 "Expected a bounds (southwest/northeast) dict, "
276 "but got %s" % type(arg).__name__)
277
278
279def size(arg):

Callers

nothing calls this directly

Calls 2

is_stringFunction · 0.85
latlngFunction · 0.85

Tested by

no test coverage detected