SHARE
TWEET

Untitled

a guest Jun 16th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from gps import *
  2. import matplotlib.pyplot as plt
  3. import time, inspect, os
  4.  
  5. logPath = "/home/solergy/IBUZ/LOGS/"
  6. inputMapFilePath = logPath + "srcMap/" + "TBM-min.png"
  7. actualOutMapFilePath = logPath + "Map_GPS"
  8.  
  9. TRX = -12.653          #top right longitude
  10. TRY = 41.8675            #top right latitude
  11. BLX = -12.6332          #bottom left longitude
  12. BLY = 41.8619             #bottom left latitude
  13.  
  14. gpsd = gps(mode=WATCH_ENABLE|WATCH_NEWSTYLE)
  15.  
  16. im = plt.imread(inputMapFilePath)
  17.  
  18. try:
  19.     while True:
  20.         report = gpsd.next() #
  21.         if report['class'] == 'TPV':
  22.             GPStime =  str(getattr(report,'time',''))
  23.             lat     = str(getattr(report,'lat',0.0))
  24.             lon     = str(getattr(report,'lon',0.0))
  25.             speed   =  str(getattr(report,'speed','nan'))
  26.  
  27.             # Create Image File
  28.             pos_y = float(lat)
  29.             pos_x = -float(lon)
  30.  
  31.             actualTime = time.strftime("%H-%M-%S", time.localtime())
  32.             plt.text(BLX, BLY, actualTime)
  33.             plt.imshow(im, extent=[BLX, TRX, BLY, TRY], zorder=1)
  34.             plt.scatter(x=[pos_x], y=[pos_y], s=3, c='r', zorder=2)
  35.             cur_axes = plt.gca()
  36.             cur_axes.axes.get_xaxis().set_visible(False)
  37.             cur_axes.axes.get_yaxis().set_visible(False)
  38.             plt.savefig(actualOutMapFilePath, dpi=150, type="png")
  39.             plt.close('all')
  40.             print (actualTime , GPStime)
  41.  
  42. except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
  43.     f.close()
  44.     f_now.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top