I am trying to make a RealTime GPS tracking device using python().
features
i have got 10 fixed locations
loc0 = (lat0,lon0)
loc1 = (lat1,lon1)
loc2 = (lat2,lon2)
loc3 = (lat3,lon3)
loc4 = (lat4,lon4)
loc5 = (lat5,lon5)
loc6 = (lat6,lon6)
loc7 = (lat7,lon7)
loc8 = (lat8,lon8)
loc9 = (lat9,lon9)
my current position
locCurrent = (latCurrent,lonCurrent)
code to calculate distances
def haversine(lon1, lat1, lon2, lat2):
"""
Calculate the great circle distance between two points
on the earth (specified in decimal degrees)
"""
# convert decimal degrees to radians
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2
c = 2 * asin(sqrt(a))
km = 6367 * c
return km
doubt
1.)how am i supposed to trigger a function ,such as send an Email or SMS , efficiently when distance is less than say 5 kms (one possible way is to run an infinite while loop and check it against the distance(here 5kms) , but thats not very efficient , )
2.)which is the most preferred language other than python to accomplish the same
please suggest some documented tutorials regarding the same ,thanks in advance