Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- the_dictionary = {}
- new_list = []
- depot_list = []
- dest_id = []
- horiz_dist = []
- bearing = []
- new_dictionary = []
- longitude = []
- latitude = []
- final_list = []
- dictionary_list = observatory_read_csv()
- depot_dictionary_list = depot_read_csv()
- for line in dictionary_list:
- depot_ID = line[1:]
- if depot_ID[0][0] == "D":
- new_list.append(depot_ID)
- new_list.sort()
- for line in depot_dictionary_list:
- lat_lon = line[0:][0:]
- depot_list.append(lat_lon)
- depot_list.sort()
- for line in new_list:
- dest_id.append(line[0])
- horiz_dist.append(line[1])
- bearing.append(line[2])
- dest_id.pop(-1)
- horiz_dist.pop(-1)
- bearing.pop(-1)
- for line in depot_list:
- latitude.append(line[1])
- longitude.append(line[2])
- longitude.pop(-1)
- latitude.pop(-1)
- final_list = [dest_id, horiz_dist, bearing, latitude, longitude]
- def get_values():
- d = float(final_list[1][0])
- brng = float(final_list[2][0])
- lat1 = float(final_list[3][0])
- lon1 = float(final_list[4][0])
- get_lat_lon(lat1, lon1, d, brng)
- get_values()
- def get_lat_lon(lat1, lon1, d, brng):
- R = 6371.0 #Radius of the Earth
- lat1 = math.radians(lat1)
- lon1 = math.radians(lon1)
- brng = math.radians(brng)
- lat2 = math.asin( math.sin(lat1)*math.cos(d/R) + math.cos(lat1)*math.sin(d/R)*math.cos(brng))
- lon2 = lon1 + math.atan2(math.sin(brng)*math.sin(d/R)*math.cos(lat1), math.cos(d/R)-math.sin(lat1)*math.sin(lat2))
- lat2 = math.degrees(lat2)
- lon2 = math.degrees(lon2)
- return lat2, lon2
- def depot_read_csv():
- my_data = open("depot_data.csv", 'rU', newline='')
- csv_data = csv.reader(my_data)
- depot_dictionary_list = list(csv_data)
- my_data.close()
- return depot_dictionary_list
- def observatory_read_csv():
- my_data = open("observatory_data.csv", 'rU', newline='')
- csv_data = csv.reader(my_data)
- dictionary_list = list(csv_data)
- my_data.close()
- return dictionary_list
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement