-
Notifications
You must be signed in to change notification settings - Fork 26
/
geo2gpx
executable file
·57 lines (44 loc) · 1.41 KB
/
geo2gpx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
print "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\" ?>\n";
print "<gpx xmlns=\"http://www.topografix.com/GPX/1/1\" creator=\"\" version=\"1.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">\n";
sub endtrk {
($lat, $lon) = split(/,/, $b);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($when2);
$time = sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",
$year + 1900, $mon + 1, $mday, $hour, $min, $sec);
print " <trkpt lat=\"$lat\" lon=\"$lon\">\n";
print " <ele>$e2</ele>\n";
print " <time>$time</time>\n";
print " </trkpt>\n";
print " </trkseg>\n";
print " </trk>\n";
$within = 0;
}
while (<>) {
next if /#/;
if (/--/) {
if ($within) {
endtrk();
}
next;
}
($when, $a, $to, $b, $date, $time, $dur, $dist, $speed, $e1, $e2) = split(/ /);
$when2 = $when + $dur;
if (!$within) {
print " <trk>\n";
print " <trkseg>\n";
$within = 1;
}
($lat, $lon) = split(/,/, $a);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime($when);
$time = sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",
$year + 1900, $mon + 1, $mday, $hour, $min, $sec);
print " <trkpt lat=\"$lat\" lon=\"$lon\">\n";
print " <ele>$e1</ele>\n";
print " <time>$time</time>\n";
print " </trkpt>\n";
}
if ($within) {
endtrk();
}
print "</gpx>\n";