1

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

Abhimanyu
  • 591
  • 1
  • 11
  • 22
  • is this to run on a phone or something? or a central server? or a pc? or an arduino board? how are you getting your values? could you just do a cron job or something? – Joran Beasley Sep 10 '12 at 05:36
  • i have just started planning my project .and I am planning to run it on a central server eventually but as of now i have got a OSX , and regarding the location information i have seen a few examples to connect to a GPS device via serial ports.I need to get the right information and direction to start , could you suggest me some tutorials regarding the same – Abhimanyu Sep 10 '12 at 05:46
  • if you are getting your data from a serial port you will have to just poll it contiuously so you are basically looking at an infinite loop... if its a phone app that will talk to a central server you will receive queries from the app and there will be no need for an infinite loop... once you get your points you can just plot them on google maps api or something – Joran Beasley Sep 10 '12 at 05:51
  • also I wouldnt necessarily make it a distance based thing ... rather update every few minutes that way you can show the actuall points – Joran Beasley Sep 10 '12 at 05:53
  • If you hook a GPS on the server how can the distance from your 10 fixed pos change? Is your server moving? –  Sep 10 '12 at 06:00

1 Answers1

0

If you are planning to constantly collect GPS data via a serial port, have a look at twisted server (it's reactor supports events from serial ports) http://twistedmatrix.com/trac/ There is an example that constantly gets the gps position over serial - see gpsfix.py on this page http://twistedmatrix.com/documents/current/core/examples/ . It may not be what you want, but it is a good starting point, and will allow you to evaluate that approach with some working code.

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29
  • what are the other ways to collect data , for instance what if i fix the gps into my car and want to track its location and if its ,say 5 km away from a fixed location , it will trigger some action , thanks – Abhimanyu Sep 10 '12 at 06:36