/[maps]/bin/nmea2kml.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/nmea2kml.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 17 - (show annotations)
Mon Dec 3 14:57:48 2007 UTC (16 years, 4 months ago) by dpavlin
File MIME type: text/plain
File size: 875 byte(s)
report number of points produced
1 #!/usr/bin/perl
2
3 # Convert GPS NMEA dump into Google's kml file
4
5 use strict;
6 use warnings;
7
8 use lib '../';
9 use NMEA;
10
11 my $path = shift @ARGV || die "usage: $0 nmea_dump.gps\n";
12
13 open(my $fh, '<', $path) || die "can't open $path: $!";
14
15 print qq{<?xml version="1.0" encoding="UTF-8"?>
16 <kml xmlns="http://earth.google.com/kml/2.2">
17 <Document>
18 <name>$path</name>
19 <Folder>
20 <name>NMEA trace</name>
21 };
22
23
24 my $point = 0;
25
26 while(<$fh>) {
27 my $hash = NMEA->line( $_ ) || next;
28
29 $point++;
30
31 print qq{
32 <Placemark>
33 <name>$point</name>
34 <description>
35 }, join(' ', map { ucfirst($_) . ':' . $hash->{$_} } ( qw/time lat lon speed course date var var_ew/ ) ), qq{
36 </description>
37 <Point>
38 <coordinates>}, $hash->{lon}, ',', $hash->{lat}, qq{,0</coordinates>
39 </Point>
40 </Placemark>
41 };
42 }
43
44 print qq{
45 </Folder>
46 </Document>
47 </kml>
48 };
49
50 warn "Produced $point points from $path\n";

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26