-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcoords.py
38 lines (29 loc) · 1.15 KB
/
coords.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
import json
def get_coordinates(facility_id):
# Prompt user for facility_id, longitude, and latitude
longitude = input("Enter longitude: ")
latitude = input("Enter latitude: ")
# Create a dictionary to store the input values
coordinates = {
'facility_id': facility_id,
'longitude': longitude,
'latitude': latitude
}
return coordinates
def main():
# Get the range of facility_ids
start_id = int(input("Enter the starting facility ID: "))
end_id = int(input("Enter the ending facility ID: "))
# Initialize a list to store the coordinates
coordinates_list = []
# Loop through the range of facility_ids and get coordinates
for facility_id in range(start_id, end_id + 1):
print(f"\nCoordinates for facility ID {facility_id}:")
coordinates = get_coordinates(facility_id)
coordinates_list.append(coordinates)
# Write the coordinates list to a JSON file
with open('coords.json', 'w') as json_file:
json.dump(coordinates_list, json_file, indent=4)
print("Coordinates saved to coords.json")
if __name__ == "__main__":
main()