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
import math | |
def haversine(lat1, lng1, lat2, lng2): | |
p = math.pi/180 | |
a = 0.5 - math.cos((lat2-lat1)*p)/2 + math.cos(lat1*p) * math.cos(lat2*p) * (1-math.cos((lng2-lng1)*p))/2 | |
return 12742 * math.asin(math.sqrt(a)) #2*R*asin... | |
def findIndex(my_list, prop, value): | |
return next((i for i, item in enumerate(my_list) if item[prop] == value), -1) |