class Location(DefaultLocation):
@staticmethod
def format_float(value, precision=10):
# If value is actually a string already, return unchanged
if isinstance(value, (str,)):
return value
# https://stackoverflow.com/questions/6416474/how-to-avoid-printing-scientific-notation-in-python-without-adding-extra-digits
if precision < 0:
f = "%f" % value
else:
f = "%.*f" % (precision, value)
p = f.partition(".")
s = "".join((p[0], p[1], p[2][0], p[2][1:].rstrip("0")))
return s
def __str__(self):
if self.ok:
return u'{0}, {1}'.format(self.format_float(self.lat), self.format_float(self.lng))
return u''
def _location_init(self, location, **kwargs):
return {
'latlng': str(Location(location)),
'sensor': 'false',
}
GoogleReverse._location_init = _location_init
Would do a PR but that Location class is used by every reverse geocoder, should be ok tho. Happy to do PR if this seems like a sensible solution.
Eg lat=51.1701954, lng=0.0000992
ends up as
https://maps.googleapis.com/maps/api/geocode/json?key=MY_KEY&sensor=false&latlng=51.1701954%2C+9.92e-05&language=
I have monkey patched temporarily with
Would do a PR but that Location class is used by every reverse geocoder, should be ok tho. Happy to do PR if this seems like a sensible solution.