21 my @opt = <<'=back' =~ /B<--(\S+)>/g;
37 use lib
"$FindBin::Bin/../lib";
43 use File
::Basename
qw(dirname);
44 use File
::Path
qw(mkpath);
49 use Hash
::Util
qw(lock_keys);
52 lock_keys
%Opt, map { /([^=|!]+)/ } @opt;
61 my $xml = do { open my $fh, 'mwiese141117.osm' or die; local $/; <$fh> };
62 my $dom = XML
::LibXML
->load_xml(string
=> $xml);
64 <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
65 <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">
67 <name>ACTIVE LOG221114</name>
70 for my $e ($dom->findnodes('/osm/node')) {
71 my $id = $e->getAttribute('id');
72 $N{$id}{lat
} = $e->getAttribute('lat');
73 $N{$id}{lon
} = $e->getAttribute('lon');
75 for my $e ($dom->findnodes('/osm/way')) {
76 my $w = $e->getAttribute('id');
78 for my $e2 ($e->findnodes('nd')) {
79 my $ref = $e2->getAttribute('ref');
80 printf qq{<trkpt lat
="%s" lon
="%s"/>\n}, $N{$ref}{lat
}, $N{$ref}{lon
};
84 print "</trk></gpx>\n";
87 # cperl-indent-level: 4