13 return sprintf("%d%09.6f %s", $degi, $deg, $dir);
18 return deg($lat{$id}, "N") . " " . deg($lon{$id}, "E");
25 if ($line =~ /<node id="(.*?)" lat="(.*?)" lon="(.*?)"/) {
29 } elsif ($line =~ /<segment id="(.*?)" from="(.*?)" to="(.*?)"/) {
34 } elsif ($line =~ /<tag k="(.*?)" v="(.*?)"/) {
35 if ($1 ne "created_by" && $1 ne "converted_by") {
38 } elsif ($line =~ /<way id="(.*?)"/) {
45 } elsif ($line =~ /<seg id="(.*?)"/) {
47 $from=coord($from{ $1 });
53 $coords="$start\n$end\n";
57 if ($start == $from) {
58 $coords="$to\n" . $coords;
60 } elsif ($start == $to) {
61 $coords="$from\n" . $coords;
63 } elsif ($end == $from) {
66 } elsif ($end == $to) {
67 $coords.=$from . "\n";
70 push(@coords,$coords);
73 $coords="$start\n$end\n";
76 # print STDERR "not connected from=$from to=$to coords=$coords \n";
80 } elsif ($line =~ /<osm /) {
81 } elsif ($line =~ /<?xml /) {
82 } elsif ($line =~ /<\/node/) {
84 #print STDERR Dumper(\%tag);
86 } elsif ($line =~ /<\/segment/) {
88 #print STDERR Dumper(\%tag);
90 } elsif ($line =~ /<\/segment/) {
91 } elsif ($line =~ /<\/way/) {
93 if ($tag{'highway'} ne '') {
94 for ($tag{'highway'}) {
95 if (/cycleway/ || /footway/ || /steps/ || /cyclepath/ || /track/ || /service/ || /pedestrian/) {
96 $type='street_nopass';
97 } elsif (/residential/ || /unclassified/) {
98 $type='street_1_city';
99 } elsif (/tertiary/) {
100 $type='street_2_city';
101 } elsif (/secondary/) {
102 $type='street_3_city';
103 } elsif (/primary/) {
104 $type='street_4_city';
105 } elsif (/motorway/) {
106 $type='highway_city';
108 print STDERR "Unknown highway $_\n";
113 if ($tag{'natural'} ne '') {
114 for ($tag{'natural'}) {
118 print STDERR "Unknown natural $_\n";
123 if ($tag{'railway'} ne '') {
124 for ($tag{'railway'}) {
128 print STDERR "Unknown railway $_\n";
133 if ($tag{'waterway'} ne '') {
134 for ($tag{'waterway'}) {
138 print STDERR "Unknown waterway $_\n";
143 if ($tag{'amenity'} ne '') {
144 for ($tag{'amenity'}) {
146 $type='hospital_poly';
147 } elsif (/parking/) {
148 $type='parking_lot_poly';
150 print STDERR "Unknown amenity $_\n";
155 if ($tag{'landuse'} ne '') {
156 for ($tag{'landuse'}) {
158 $type='cemetery_poly';
159 } elsif (/forest/||/village_green/||/greenfield/||/farm/) {
161 } elsif (/industrial/ || /residential/) {
162 $type='industry_poly';
163 } elsif (/parking/) {
164 $type='parking_lot_poly';
168 print STDERR "Unknown landuse $_\n";
174 if ($tag{'name'} ne '') {
175 $oline.=' label="' . $tag{'name'} . '"';
177 $oline .= ' debug="way_id=' . $way_id . ' ';
178 while (($key,$value)=each(%tag)) {
179 $oline .= "$key='$value' ";
182 push(@coords,$coords);
183 foreach $coords (@coords) {
188 } elsif ($line =~ /<\/osm/) {
196 while (($key,$value)=each(%reference)) {
198 print STDERR "$key $value\n";