Skip to content

Instantly share code, notes, and snippets.

@rtt
Created November 28, 2012 16:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtt/4162266 to your computer and use it in GitHub Desktop.
Save rtt/4162266 to your computer and use it in GitHub Desktop.
def valid_loc(loc):
'''Validates a lat,lng string value to ensure both lat and lng are within their correct bounds'''
try:
lng, lat = loc.split(',')
lng = float(lng)
lat = float(lat)
except:
pass
else:
return (-180.0 <= lng <= 180.0) and (-90.0 <= lat <= 90)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment