2016-10-24 19:13:45 +00:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
my $filename = $ARGV[0];
|
|
|
|
my $fh;
|
2017-03-03 11:49:27 +00:00
|
|
|
if (defined $filename) {
|
|
|
|
open($fh, "<", $filename) or die "Could not open $filename: $!";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$fh = *STDIN;
|
|
|
|
}
|
2016-10-24 19:13:45 +00:00
|
|
|
|
|
|
|
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
|
|
|
|
print "<gpx version=\"1.1\" creator=\"me\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.topografix.com/GPX/1/1\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n";
|
|
|
|
|
|
|
|
my $line;
|
2016-11-02 15:01:07 +00:00
|
|
|
my $date;
|
2016-10-24 19:13:45 +00:00
|
|
|
my $hms;
|
|
|
|
my $lat; my $lon; my $alt;
|
|
|
|
|
|
|
|
print "<trk>\n";
|
|
|
|
print "<trkseg>\n";
|
|
|
|
|
|
|
|
while ($line = <$fh>) {
|
2016-11-02 15:01:07 +00:00
|
|
|
if ($line =~ /(\d\d:\d\d:\d\d\.?\d?\d?\d?).*\ +lat:\ *(-?\d*\.\d*)\ +lon:\ *(-?\d*\.\d*)\ +alt:\ *(-?\d*\.\d*).*/) {
|
|
|
|
|
2016-10-24 19:13:45 +00:00
|
|
|
$hms = $1;
|
|
|
|
$lat = $2;
|
|
|
|
$lon = $3;
|
|
|
|
$alt = $4;
|
2016-11-02 15:01:07 +00:00
|
|
|
|
|
|
|
$date = "";
|
|
|
|
if ($line =~ /(\d\d\d\d-\d\d-\d\d).*/) { $date = sprintf ("%sT", $1); }
|
|
|
|
#if ($line =~ /(\d\d\d\d)-(\d\d)-(\d\d).*/) { $date = sprintf ("%04d-%02d-%02dT", $1, $2, $3); }
|
|
|
|
|
2016-10-24 19:13:45 +00:00
|
|
|
print " <trkpt lat=\"$lat\" lon=\"$lon\">\n";
|
|
|
|
print " <ele>$alt<\/ele>\n";
|
2016-11-02 15:01:07 +00:00
|
|
|
printf(" <time>%s%sZ</time>\n", $date, $hms);
|
2016-10-24 19:13:45 +00:00
|
|
|
print " </trkpt>\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print "</trkseg>\n";
|
|
|
|
print "</trk>\n";
|
|
|
|
|
|
|
|
print "</gpx>\n";
|
|
|
|
|