source: subversion/applications/utils/export/osmgarminmap/feature-list-csv2xml.pl @ 12483

Last change on this file since 12483 was 1797, checked in by jochen, 13 years ago

First release

  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/usr/bin/perl
2#
3#  garmin-features-csv2xml.pl
4#
5
6use XML::Generator;
7
8use strict;
9
10my $xml = XML::Generator->new(':pretty');
11
12my %features;
13
14<>; # read first line and discard it
15
16while(<>) {
17    chomp;
18 
19    my ($topo, $type, $subtype, $topo_id, $type_id, $subtype_id, $name) = split(/\|/);
20
21    next if ($type eq '');
22    next if ($subtype eq '') && ($topo eq 'point');
23
24    my %attributes = ( 'type' => $type, 'garmin_id' => $type_id );
25    $attributes{'subtype'} = $subtype if $subtype;
26    $attributes{'garmin_subid'} = $subtype_id if $subtype_id;
27
28    push(@{$features{$topo}}, $xml->feature( \%attributes ));
29}
30
31print $xml->xmldecl( 'version' => '1.0', 'encoding' => 'UTF-8' );
32print "<?xml-stylesheet type='text/xsl' href='../mpx2mp.xsl'?>\n";
33print $xml->xmlcmnt('This file was generated from a CSV file with the script garmin-features-csv2xml.pl. Do not change!'), "\n";
34print $xml->defs( { 'data' => 'map.mpx' },
35    $xml->point(    { 'id' => 'RGN10' }, @{$features{'point'}}),
36    $xml->city(     { 'id' => 'RGN20' }, @{$features{'city'}}),
37    $xml->polyline( { 'id' => 'RGN40' }, @{$features{'polyline'}}),
38    $xml->polygon(  { 'id' => 'RGN80' }, @{$features{'polygon'}}),
39), "\n";
40
Note: See TracBrowser for help on using the repository browser.