Shop OBEX P1 Docs P2 Docs Learn Events
Reformat GPS strings for Google Earth KML files — Parallax Forums

Reformat GPS strings for Google Earth KML files

Paul_HPaul_H Posts: 85
edited 2008-04-25 22:54 in Propeller 1
Happy Friday All,

I'd like to build a routine to log NMEA GPS data into a Google Earth compatible KML file. This requires a reformat of the input String from GPS_mini

from:"-09647.4657" 
to:  "-096 47.4657"  The space makes the difference to Google.




I wrote this routine to write a byte at a time to the SD card with no success. Is it failing because there are no terminating Nulls on each character? Not sure how to correct that... I have been reading up on the FORMAT sprintf() command, but again am not sure if this is going in the right direction.
As always any help or suggestions are appreciated!
Paul


DAT
  gpslog     byte     "007.kml", 0                      ' Name of file that we will write to
 
PUB ForKML
' WRITE DATA TO SD CARD

sdfat.popen(@gpslog, "a")
  SDwrite(string("-"))  
  index := 0
  repeat 4                                                ' loop for the number of characters in the buffer location
    SDwrite(byte[noparse][[/noparse]value + index++ ])
  SDwrite(string(" "))                                    '*** inserts the space between DD and MM.mmmm
  repeat 7
    SDwrite(byte[noparse][[/noparse]value + index++ ])
    SDwrite(string(" "))
sdfat.pclose

Comments

  • tpw_mantpw_man Posts: 276
    edited 2008-04-25 22:54
    It is failing because you are writing a space after every MM.mmmm. It probably appears in the file as
    "-096 4 7 . 4 6 5 7"
    

    Sometimes the forum software messes the tabbing up, but I think that is your problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I am 1010, so be surprised!
Sign In or Register to comment.