05.05.2014, 22:57
(This post was last modified: 07.05.2014, 18:40 by GPSVisualizer.)
Here's an abridged/simplified version of GPS Visualizer's perl code anyway, in case it's useful for someone:
Code:
open(BTK,$file_path);
seek(BTK,24,0); # skip mysterious file header
while (!eof(BTK)) {
read(BTK,my $type,1); $type = unpack("C",$type);
if ($type == 3) { # track header
read(BTK,my $trk_info,8); my ($unknown,$y,$mo,$d,$h,$m,$s) = unpack("c SCC CCC",$trk_info);
seek(BTK,15,1);
# [do something here with the time info from the header and start a new track]
} else { # type 4 = end of track; type 2 = normal point
read(BTK,my $temp,1); $temp = unpack("c",$temp)/2 + 20;
read(BTK,my $number,2); $number = unpack("S",$number);
read(BTK,my $alt,4); $alt = unpack("l",$alt)/10;
read(BTK,my $lat,8); $lat = unpack("d",$lat);
read(BTK,my $lon,8); $lon = unpack("d",$lon);
# [do something here with the point data]
}
}
close(BTK);
