-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
69 lines (52 loc) · 1.79 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# star = '*'*100
# print(star)
# print('\n First GPS current cordinates')
# import geocoder
# def get_current_gps_coordinates():
# g = geocoder.ip('me')
# if g.latlng is not None:
# latitude = "{:.8f}".format(g.latlng[0])
# longitude = "{:.8f}".format(g.latlng[1])
# return latitude, longitude
# else:
# return None
# if __name__ == "__main__":
# coordinates = get_current_gps_coordinates()
# if coordinates is not None:
# latitude, longitude = coordinates
# # print("Your current GPS coordinates are:")
# print(f"Latitude: {latitude}")
# print(f"Longitude: {longitude}")
# else:
# print("Unable to retrieve your GPS coordinates.")
# from datetime import datetime
# now = datetime.now()
# # Print the day of the week
# day_of_week = now.strftime("%A")
# print(day_of_week)
star = '*'*100
print(star)
print('My GPS location cordinates')
import asyncio
import winsdk.windows.devices.geolocation as wdg
async def getCoords():
locator = wdg.Geolocator()
pos = await locator.get_geoposition_async()
return [round(pos.coordinate.latitude, 8), round(pos.coordinate.longitude, 8)]
def getLoc():
try:
return asyncio.run(getCoords())
except PermissionError:
print("ERROR: You need to allow applications to access your location in Windows settings")
if __name__ == "__main__":
coordinates = getLoc()
if coordinates:
print("Latitude:", coordinates[0])
print("Longitude:", coordinates[1])
star = '*'*100
print(star)
print('Location name')
from geopy.geocoders import Nominatim
geoLoc = Nominatim(user_agent="GetLoc")
locname = geoLoc.reverse((coordinates[0], coordinates[1]))
print(locname.address)