-
-
Save jordotech/16c980cdecaa7ab15ec83454720bb68c to your computer and use it in GitHub Desktop.
geocoder.google()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geocoder | |
def get_shop_coordinates(shop): | |
if len(shop.postalcode) and len(shop.street) > 1: | |
address_to_check = '%s %s' % (shop.street, shop.postalcode) | |
g = geocoder.google(address_to_check) | |
ret = {} | |
if g.lat <> 0 and g.lng <> 0: | |
ret['latitude'] = g.lat | |
ret['longitude'] = g.lng | |
return ret | |
else: | |
message = 'Failed to get lat/lon of shop: %s id: %s' % (shop.name, shop.id) | |
shop_url = '%s/storelocator/shops/%s' % (settings.SITE_DOMAIN, shop.id) | |
if settings.DEBUG: | |
client.http_context({'url': shop_url}) | |
client.captureMessage(message) | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment