Created
October 23, 2022 18:34
-
-
Save natyrix/c77c3909a805ca90fb7497437c19cbb0 to your computer and use it in GitHub Desktop.
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
def calculate_distances(self, starting_coordinates, ending_coordinates): | |
calculated_distances = [] | |
for i in range(len(starting_coordinates)): | |
val = str(starting_coordinates[i]).split(',') | |
starting_tuple = (val[0], val[1]) | |
val_end = str(ending_coordinates[i]).split(',') | |
ending_tuple = (val_end[0], val_end[1]) | |
if val_end[0] == "0.0" or val_end[1] == "0.0": | |
calculated_distances.append(-1) | |
elif val_end[0] == "0.5" or val_end[1] == "0.5": | |
calculated_distances.append(-2) | |
else: | |
calculated_distances.append(distance.distance(starting_tuple, ending_tuple).km) | |
return calculated_distances |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment