Created
January 8, 2024 22:23
-
-
Save f5-rahm/e10e03b0666bf9f93fd8cd450fe38627 to your computer and use it in GitHub Desktop.
Get Lat/Lon coordinates by address for F5 Distributed Cloud CE devices
This file contains 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
""" | |
Usage: | |
~/testlab/venv/bin/python ~/testlab/ce_coords.py | |
Enter the installation address for your F5 Distributed Cloud CE device: | |
801 5th Ave, Seattle WA 98104 | |
Latitude: 47.60518879999999, Longitude: -122.33104424785958 | |
""" | |
from geopy.geocoders import Nominatim | |
def get_coordinates(addr): | |
coordinates = Nominatim(user_agent="Jason's F5XC coord generator") | |
loc = coordinates.geocode(addr) | |
if loc: | |
return loc.latitude, loc.longitude | |
else: | |
return None, None | |
if __name__ == '__main__': | |
addr = input('\n\n\tEnter the installation address for your F5 Distributed Cloud CE device: \n\n\t') | |
lat, lon = get_coordinates(addr) | |
if lat and lon: | |
print(f'\n\tLatitude: {lat}, Longitude: {lon}') | |
else: | |
print('\n\tNo location found') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment