-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
658cb5f
commit a0867f6
Showing
2 changed files
with
29 additions
and
15 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,35 @@ | ||
#!/home/nik/github/try/python/latitude/bin/python | ||
|
||
import argparse | ||
import re | ||
|
||
# | ||
# Args | ||
# | ||
argParser = argparse.ArgumentParser() | ||
argParser.add_argument('--check', dest='check', help='String to check against known good') | ||
argParser = argparse.ArgumentParser(prog="convert.py", | ||
description="Convert street address to latitude/longitude.") | ||
|
||
argParser.add_argument('--debug', dest='debug', default=False, action='store_true', help='Debug mode for various things') | ||
argParser.add_argument('address') | ||
|
||
|
||
|
||
args = argParser.parse_args() | ||
|
||
print(f"You entered an address off >>>{args.address}<<<") | ||
address = args.address | ||
print(f"You entered an address off >>>{address}<<<") | ||
|
||
# Add in town/state if needed | ||
if (not re.search('natick', address)): | ||
address+= ", natick, ma" | ||
print(f"(Added in town) >>>{address}<<<") | ||
|
||
# importing geopy library and Nominatim class | ||
# Library to convert addresses | ||
from geopy.geocoders import Nominatim | ||
|
||
# calling the Nominatim tool and create Nominatim class | ||
loc = Nominatim(user_agent="Geopy Library") | ||
|
||
# entering the location name | ||
getLoc = loc.geocode(args.address) | ||
|
||
# printing address | ||
print(getLoc.address) | ||
# Convert address entered | ||
getLoc = loc.geocode(address) | ||
|
||
# printing latitude and longitude | ||
# Show information about the address | ||
print(f"Normalized address = {getLoc.address}") | ||
print(f"Latitude = {getLoc.latitude:.6f}") | ||
print(f"Longitude = {getLoc.longitude:.6f}") |
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