Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 0.49 KB | None | 0 0
  1. import sys
  2. import fileinput
  3. import time
  4. import re
  5. import math
  6.  
  7. def convertDegrees(degrees):
  8.     return '%02.0f'%math.modf(degrees)[1]+'%06.3f'%(math.modf(degrees)[0]*60)
  9.  
  10. lat=lon=0
  11. count=0
  12.  
  13. for line in sys.stdin:
  14.     strlat, strlon = line.split(",")
  15.     lat+=float(strlat)
  16.     lon+=float(strlon)
  17.     count+=1
  18.  
  19. lat/=count
  20. lon/=count
  21.  
  22. sentence="$GPGGA,"+time.strftime("%H%M%S", time.gmtime())+","+convertDegrees(lat)+"N,"+convertDegrees(lon)+"E,1,04,50,0,M,0,M,,*0"
  23. print sentence
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement