Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gps import *
- import matplotlib.pyplot as plt
- import time, inspect, os
- logPath = "/home/solergy/IBUZ/LOGS/"
- inputMapFilePath = logPath + "srcMap/" + "TBM-min.png"
- actualOutMapFilePath = logPath + "Map_GPS"
- TRX = -12.653 #top right longitude
- TRY = 41.8675 #top right latitude
- BLX = -12.6332 #bottom left longitude
- BLY = 41.8619 #bottom left latitude
- gpsd = gps(mode=WATCH_ENABLE|WATCH_NEWSTYLE)
- im = plt.imread(inputMapFilePath)
- try:
- while True:
- report = gpsd.next() #
- if report['class'] == 'TPV':
- GPStime = str(getattr(report,'time',''))
- lat = str(getattr(report,'lat',0.0))
- lon = str(getattr(report,'lon',0.0))
- speed = str(getattr(report,'speed','nan'))
- # Create Image File
- pos_y = float(lat)
- pos_x = -float(lon)
- actualTime = time.strftime("%H-%M-%S", time.localtime())
- plt.text(BLX, BLY, actualTime)
- plt.imshow(im, extent=[BLX, TRX, BLY, TRY], zorder=1)
- plt.scatter(x=[pos_x], y=[pos_y], s=3, c='r', zorder=2)
- cur_axes = plt.gca()
- cur_axes.axes.get_xaxis().set_visible(False)
- cur_axes.axes.get_yaxis().set_visible(False)
- plt.savefig(actualOutMapFilePath, dpi=150, type="png")
- plt.close('all')
- print (actualTime , GPStime)
- except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
- f.close()
- f_now.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement