PDA

View Full Version : Reformat GPS strings for Google Earth KML files



Paul_H
04-26-2008, 05:39 AM
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[value + index++ ])
SDwrite(string(" ")) '*** inserts the space between DD and MM.mmmm
repeat 7
SDwrite(byte[value + index++ ])
SDwrite(string(" "))
sdfat.pclose

tpw_man
04-26-2008, 05:54 AM
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!