samedi 29 octobre 2016

how to take specific(range) data from gps using pyhton

I am using adafruit ultimate GPS module connected to raspberry pi 3 B,I want to take a specific data from gps for example,if in range ( 103.467 E, 104.467 E) for longitude and latitude (1.556 N, 1.656 N) the program should print/run something,please help im very new to python and programming.

Here the current code that ive used to straight print coordinates without any range :)

import gps

session = gps.gps("localhost", "2947")

session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)

while True:

     try:

          report = session.next()

          if report['class'] == 'TPV':
              if hasattr(report,'lon'):
                  if hasattr(report,'lat'):
                      print 'latitude=',report.lat,'N','longitude=',report.lon,'E'


    except KeyError:
    pass
except KeyboardInterrupt:
    quit()
except StopIteration:
    session = None
    print "GPSD has terminated"

Aucun commentaire:

Enregistrer un commentaire