/[maps]/bin/nmea2gpx.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/nmea2gpx.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 22 - (show annotations)
Wed Dec 5 21:20:54 2007 UTC (16 years, 4 months ago) by dpavlin
File MIME type: text/plain
File size: 883 byte(s)
first try to conversion tool from NMEA to GPX
1 #!/usr/bin/perl
2
3 # Convert GPS NMEA dump into GPX
4
5 use strict;
6 use warnings;
7
8 use Getopt::Long;
9 use Geo::Gpx;
10
11 my $placemarks = 1;
12 my $line = 1;
13
14 GetOptions(
15 'placemarks!' => \$placemarks,
16 'line!' => \$line,
17 );
18
19 use lib '../';
20 use NMEA;
21
22 my $path = shift @ARGV || die "usage: $0 nmea_dump.gps\n";
23
24 open(my $fh, '<', $path) || die "can't open $path: $!";
25
26 my $out_path = $path;
27 $out_path =~ s!^.*?([^/]+)$!$1!; #!
28 $out_path .= '.gpx';
29
30 my $gpx = Geo::Gpx->new();
31 my $point = 0;
32
33 while(<$fh>) {
34 my $hash = NMEA->line( $_ ) || next;
35
36 $point++;
37
38 # time lat lon speed course date
39
40 $gpx->add_waypoint({
41 lat => $hash->{lat},
42 lon => $hash->{lon},
43 name => $point,
44 });
45 }
46 close($fh);
47
48 open(my $out, '>', $out_path) || die "can't open $out_path: $!";
49 print $out $gpx->xml || die "can't write to $out_path: $!";
50 close($out);
51
52 warn "Produced $point points from $path -> $out_path\n";

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26