diff options
author | Joseph Herlant <herlantj@gmail.com> | 2018-05-25 22:07:07 -0700 |
---|---|---|
committer | Joseph Herlant <aerostitch@users.noreply.github.com> | 2018-05-25 22:17:50 -0700 |
commit | 41a1264cdd43a11695de85eab0bd3c941abf2b70 (patch) | |
tree | 3da1ef3bebc674807258ae824ff9156a64adf370 /navit/script | |
parent | 8a76acb966f7059caf9d72c853175bd923b1e9d7 (diff) | |
download | navit-41a1264cdd43a11695de85eab0bd3c941abf2b70.tar.gz |
cleanup:cmake:remove trailing spaces
Diffstat (limited to 'navit/script')
30 files changed, 360 insertions, 360 deletions
diff --git a/navit/script/cabify.sh b/navit/script/cabify.sh index 4536ff330..0364e8f7f 100755 --- a/navit/script/cabify.sh +++ b/navit/script/cabify.sh @@ -27,8 +27,8 @@ else fi [ "$2" != "" ] && SRCDIR="$2" [ "$3" != "" ] && BASEDIR="$3" -if [ "$4" != "" ]; -then +if [ "$4" != "" ]; +then NAVITXML="$4" else NAVITXML="" diff --git a/navit/script/download_index.html b/navit/script/download_index.html index 7439f4b6a..ca5a7d48f 100644 --- a/navit/script/download_index.html +++ b/navit/script/download_index.html @@ -34,45 +34,45 @@ } #controls { float: left; - + } </style> <script src="http://openlayers.org/dev/lib/OpenLayers.js"></script> <script type="text/javascript"> var map, polygonControl, polygonLayer, bbox_set; - + OpenLayers.Util.onImageLoadErrorColor = "transparent"; function init(){ map = new OpenLayers.Map('map'); - - var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS", - "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); - + + var wmsLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS", + "http://labs.metacarta.com/wms/vmap0?", {layers: 'basic'}); + polygonLayer = new OpenLayers.Layer.Vector("Polygon Layer"); - + map.addLayers([wmsLayer, polygonLayer]); map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.MousePosition()); - + polyOptions = {sides: 4, irregular: true}; polygonControl = new OpenLayers.Control.DrawFeature(polygonLayer, OpenLayers.Handler.RegularPolygon, {handlerOptions: polyOptions}); //alert(polygonControl); - + map.addControl(polygonControl); - + polygonControl.featureAdded=featureInsert; - + map.setCenter(new OpenLayers.LonLat(0, 0), 3); - + document.getElementById('noneToggle').checked = true; //document.getElementById('irregularToggle').checked = false; - + //var polyOptions = {sides: 4, irregular: true}; //polygonControl.handler.setOptions(polyOptions); } - + function featureInsert(feature){ var old=[]; for (var i = 0; i < polygonLayer.features.length; i++) { @@ -81,9 +81,9 @@ } } polygonLayer.destroyFeatures(old); - + var bounds = feature.geometry.getBounds(); - + document.form.bounds_top.value = bounds.top; document.form.bounds_right.value = bounds.right; document.form.bounds_btm.value = bounds.bottom; diff --git a/navit/script/gensvg b/navit/script/gensvg index b7a4241c9..6225051d8 100755 --- a/navit/script/gensvg +++ b/navit/script/gensvg @@ -2,7 +2,7 @@ makearrow() { -cat <<EOT +cat <<EOT <?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:svg="http://www.w3.org/2000/svg" @@ -233,14 +233,14 @@ do xl2=14 yl2=32 long1=$longa - ;; + ;; 315) xa0=23.54 ya0=23.54 xl2=19.3 yl2=19.3 long1=$longa - ;; + ;; esac long2=$((1-long1)) filename="nav_roundabout_${letter}${st}_$col.svg" @@ -249,7 +249,7 @@ do done filename="nav_straight_$col.svg" xl0=32 - xl1=32 + xl1=32 yl1=32 xcc0=32 ycc0=10 diff --git a/navit/script/geotag b/navit/script/geotag index e025cbc61..608f6c269 100755 --- a/navit/script/geotag +++ b/navit/script/geotag @@ -9,10 +9,10 @@ case $order in ;; 12|13) size=4000 - ;; + ;; 14|15) size=16000 - ;; + ;; 16|17|18|19) size=64000 ;; diff --git a/navit/script/gps_emu b/navit/script/gps_emu index f2eef3e50..73ddbc54f 100755 --- a/navit/script/gps_emu +++ b/navit/script/gps_emu @@ -1,15 +1,15 @@ #! /bin/bash function send_data { - trap send_data SIGPIPE + trap send_data SIGPIPE while read line do case $line in \$GPVTG*) echo "$line" - sleep 1 + sleep 1 ;; - *) + *) echo "$line" ;; esac diff --git a/navit/script/gps_emu2 b/navit/script/gps_emu2 index e9e79b42a..b4a66e526 100755 --- a/navit/script/gps_emu2 +++ b/navit/script/gps_emu2 @@ -21,8 +21,8 @@ while (read(FILE,$record,64)) if ($mode == 3) { - ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($timestampl); - $datestring=sprintf("%02d.%02d.%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime($timestampl); + $datestring=sprintf("%02d.%02d.%d %02d:%02d:%02d",$mday,$mon+1,$year+1900,$hour,$min,$sec); $long_dir="E"; $lat_dir="N"; if ($longitude < 0) { @@ -42,5 +42,5 @@ while (read(FILE,$record,64)) printf("\$GPVTG,%s,T,,M,,N,%s,K,*6A\n",$direction,$speed*1.852); printf(STDERR "\$GPGGA,%02d%02d%02d,%s,%s,%s,%s,1,%d,%s,%s,M,,,,0000*0C\n",$hour,$min,$sec,$lat_gps,$lat_dir,$long_gps,$long_dir,$sats,$hdop,$altitude); sleep(1); - } + } } diff --git a/navit/script/mapExtract.class.php b/navit/script/mapExtract.class.php index f5c4bbbc3..8d96ec76f 100644 --- a/navit/script/mapExtract.class.php +++ b/navit/script/mapExtract.class.php @@ -1,22 +1,22 @@ <?php class mapExtract { - + var $input_fd; var $output_fd; var $fetchBbox; - + var $formats; var $worldBbox; - + function mapExtract() { $formats = array(); - + $formats['ziphpack'] = "lssssslLLSS"; $formats['zipheader'] = "l" . "ziplocsig"; # Signature (is always the same) $formats['zipheader'] .= "/s" . "zipver"; # zip version needed $formats['zipheader'] .= "/s" . "zipgenfld";# type of os that generated the file - $formats['zipheader'] .= "/s" . "zipmthd"; # + $formats['zipheader'] .= "/s" . "zipmthd"; # $formats['zipheader'] .= "/s" . "ziptime"; # time $formats['zipheader'] .= "/s" . "zipdate"; # date $formats['zipheader'] .= "/l" . "zipcrc"; # crc checksum @@ -24,7 +24,7 @@ class mapExtract { $formats['zipheader'] .= "/L" . "zipuncmp"; # uncompressed size $formats['zipheader'] .= "/S" . "zipfnln"; # length of filename $formats['zipheader'] .= "/S" . "zipxtraln";# length of extra data (always 0) - + $formats['zipcdpack'] = "iccccssssiIISSSSSII"; $formats['zipcd'] = "". "i" . "zipcensig/". @@ -46,7 +46,7 @@ class mapExtract { "S" . "zipint/". "I" . "zipext/". "I" . "zipofst"; - + $formats['zipeocpack'] = "iSSSSIIs"; $formats['zipeoc'] = "". "i" . "zipesig/". @@ -57,20 +57,20 @@ class mapExtract { "I" . "zipecsz/". "I" . "zipeofst/". "s" . "zipecoml/". - + $world_bbox = array(); $world_bbox['l']['x'] = -20000000; $world_bbox['l']['y'] = -20000000; $world_bbox['h']['x'] = 20000000; $world_bbox['h']['y'] = 20000000; - + $this->formats = $formats; $this->worldBbox = $world_bbox; } - - + + function process() { - + if (!is_array($this->fetchBbox)) { return "Fetch box not set"; } @@ -85,10 +85,10 @@ class mapExtract { $offset = 0; $zipcd_data = ''; $report = array(); - + /** * Read through zipheaders - * + * */ for(;;) { $buffer = fread($this->input_fd, 30); @@ -98,20 +98,20 @@ class mapExtract { if ($tileinfo['ziplocsig'] != 0x4034b50) break; - + if ($tileinfo['zipfnln'] <= 0) break; - + $filename = fread($this->input_fd, $tileinfo['zipfnln']); $done=false; - + $r = $this->worldBbox; - - $len=strlen($filename); + + $len=strlen($filename); for ($i=0 ; $i < $len ; $i++) { $c['x'] = floor( ($r['l']['x'] + $r['h']['x'])/2 ); $c['y'] = floor( ($r['l']['y'] + $r['h']['y'])/2 ); - + switch($filename[$i]) { case 'a': $r['l']['x'] = $c['x']; @@ -135,27 +135,27 @@ class mapExtract { if ($done) break; } - # print "zipsize=" . $tileinfo['zipsize']; + # print "zipsize=" . $tileinfo['zipsize']; $tilecontent = fread($this->input_fd, $tileinfo['zipsize']); - - # print "tile $filename"; + + # print "tile $filename"; /* Area inside box, save it! */ if ($this->contains_bbox($r)) { $report['added_areas']++; - + $zipheader = $buffer; # print " in\n"; - + /* Area outside of box, set zipcontent=0 */ } else { # print " out\n"; $report['excluded_areas']++; - + $tileinfo['zipmthd'] = $tileinfo['zipcrc'] = $tileinfo ['zipsize'] = $tileinfo['zipuncmp'] = 0; $zipheader = $tileinfo; $tilecontent = ''; - $zipheader = pack($this->formats['ziphpack'], + $zipheader = pack($this->formats['ziphpack'], $tileinfo['ziplocsig'], $tileinfo['zipver'], $tileinfo['zipgenfld'], @@ -169,9 +169,9 @@ class mapExtract { $tileinfo['zipxtraln'] ); } - + $put = $zipheader.$filename.$tilecontent; - + /* Zip directory */ $zipcd_data .= pack($this->formats['zipcdpack'], 0x02014b50, @@ -194,17 +194,17 @@ class mapExtract { 0x00, $offset ) . $filename; - + fwrite($this->output_fd, $put); $offset += strlen($put); $filecount += 1; } - + fwrite($this->output_fd, $zipcd_data); $ecsz = strlen($zipcd_data); - + /* Zip central directory */ - $zip_eoc = pack($this->formats['zipeocpack'], + $zip_eoc = pack($this->formats['zipeocpack'], 0x06054b50, #zipesig; 0, #zipedsk; 0, #zipecen; @@ -215,11 +215,11 @@ class mapExtract { 0 #zipecoml; ); fwrite($this->output_fd, $zip_eoc); - - + + return null; } - + function setBbox($sx,$sy,$ex,$ey) { if ($ex<$sx) return false; @@ -235,7 +235,7 @@ class mapExtract { function setInputFD($fd) { $this->input_fd=$fd; } - + function setOutput($file) { $this->output_fd=fopen($file,'w'); } @@ -243,8 +243,8 @@ class mapExtract { function setOutputFD($fd) { $this->output_fd=$fd; } - - + + function contains_bbox(&$r) { $c =& $this->fetchBbox; if ($c['l']['x'] > $r['h']['x']) @@ -255,14 +255,14 @@ class mapExtract { return false; elseif ($c['h']['y'] < $r['l']['y']) return false; - else + else return true; } - + function getmercator($sx,$sy,$ex,$ey) { $sx = $sx*6371000.0*M_PI/180; $sy = log(tan(M_PI_4+$sy*M_PI/360))*6371000.0; - + $ex = $ex*6371000.0*M_PI/180; $ey = log(tan(M_PI_4+$ey*M_PI/360))*6371000.0; return array( @@ -276,7 +276,7 @@ class mapExtract { ) ); } - + } diff --git a/navit/script/map_index.php b/navit/script/map_index.php index 57fd0d054..050d5fc76 100644 --- a/navit/script/map_index.php +++ b/navit/script/map_index.php @@ -4,7 +4,7 @@ $bbox=split(',',urldecode($HTTP_GET_VARS['bbox'])); if (count($bbox) == 4) { $mapextract = new mapExtract(); - $mapextract->setBbox($bbox[0], $bbox[1], $bbox[2], $bbox[3]); + $mapextract->setBbox($bbox[0], $bbox[1], $bbox[2], $bbox[3]); $fp=fopen('php://output','w'); $mapextract->setInput('../../planet.bin'); $mapextract->setOutputFD($fp); @@ -13,7 +13,7 @@ else header('Content-Type: application/octet-stream'); $name='osm_bbox_'; - $name.=round($bbox[0],1) . ',' . round($bbox[1],1) . ','; + $name.=round($bbox[0],1) . ',' . round($bbox[1],1) . ','; $name.=round($bbox[2],1) . ',' . round($bbox[3],1); $name.='.bin'; header("Content-disposition: attachment; filename=\"$name\""); @@ -37,6 +37,6 @@ $urlf=$url . "?bbox=$bbox"; echo "$area <a href='$urlf'>$urlf</a><br />\n"; } - + } ?> diff --git a/navit/script/mapextract.php b/navit/script/mapextract.php index 33441ba95..0e114c746 100644 --- a/navit/script/mapextract.php +++ b/navit/script/mapextract.php @@ -1,13 +1,13 @@ #!/usr/local/bin/php –q <?php function getmercator($sx,$sy,$ex,$ey) { - + $sx = $sx*6371000.0*M_PI/180; $sy = log(tan(M_PI_4+$sy*M_PI/360))*6371000.0; - + $ex = $ex*6371000.0*M_PI/180; $ey = log(tan(M_PI_4+$ey*M_PI/360))*6371000.0; - + return array( 'l' => array( 'x' => $sx, @@ -18,7 +18,7 @@ function getmercator($sx,$sy,$ex,$ey) { 'y' => $ey ) ); - + } function contains_bbox($c, &$r) { if ($c['l']['x'] > $r['h']['x']) @@ -29,7 +29,7 @@ function contains_bbox($c, &$r) { return false; elseif ($c['h']['y'] < $r['l']['y']) return false; - else + else return true; } @@ -44,7 +44,7 @@ $formats['ziphpack'] = "lssssslLLSS"; $formats['zipheader'] = "l" . "ziplocsig"; # Signature (is always the same) $formats['zipheader'] .= "/s" . "zipver"; # zip version needed $formats['zipheader'] .= "/s" . "zipgenfld";# type of os that generated the file -$formats['zipheader'] .= "/s" . "zipmthd"; # +$formats['zipheader'] .= "/s" . "zipmthd"; # $formats['zipheader'] .= "/s" . "ziptime"; # time $formats['zipheader'] .= "/s" . "zipdate"; # date $formats['zipheader'] .= "/l" . "zipcrc"; # crc checksum @@ -91,26 +91,26 @@ $offset = 0; /** * Read through zipheaders - * + * */ while (!feof($fp)) { - + $buffer = fread($fp, 30); $tileinfo = unpack($formats['zipheader'], $buffer); - + if ($tileinfo['zipfnln'] <= 0) break; - + $filename = fread($fp, $tileinfo['zipfnln']); $x=0; $done=false; - + $r = $world_bbox; - + while (!$done) { $c['x'] = floor( ($r['l']['x'] + $r['h']['x'])/2 ); $c['y'] = floor( ($r['l']['y'] + $r['h']['y'])/2 ); - + switch($filename[$x]) { case 'a': $r['l']['x'] = $c['x']; @@ -133,23 +133,23 @@ while (!feof($fp)) { } $x++; } - + $tilecontent = fread($fp, $tileinfo['zipsize']); - + /* Area inside box, save it! */ if (contains_bbox($fetch_bbox, $r)) { #echo "In box. "; #echo $filename . " "; $zipheader = $buffer; #echo "\n"; - + /* Area outside of box, set zipcontent=0 */ } else { $tileinfo['zipmthd'] = $tileinfo['zipcrc'] = $tileinfo['zipsize'] = $tileinfo['zipuncmp'] = 0; #echo "Out of box"; $zipheader = $tileinfo; $tilecontent = ''; - $zipheader = pack($formats['ziphpack'], + $zipheader = pack($formats['ziphpack'], $tileinfo['ziplocsig'], $tileinfo['zipver'], $tileinfo['zipgenfld'], @@ -163,11 +163,11 @@ while (!feof($fp)) { $tileinfo['zipxtraln'] ); } - + $put = $zipheader.$filename.$tilecontent; $files[$filename]['header'] = $tileinfo; $files[$filename]['size'] = strlen($put); - + $zipcd = array(); $zipcd['zipcensig'] = 0x02014b50; $zipcd['zipcver'] = $tileinfo['zipver']; @@ -210,11 +210,11 @@ while (!feof($fp)) { $zipcd['zipext'], $zipcd['zipofst'] ) . $filename; - - + + fwrite($sp, $put); $offset += strlen($put); - + } fwrite($sp, $zipcd_data); diff --git a/navit/script/osm/Geo/OSM/APIClientV4.pm b/navit/script/osm/Geo/OSM/APIClientV4.pm index 26b8ec5fc..d5a267e1c 100644 --- a/navit/script/osm/Geo/OSM/APIClientV4.pm +++ b/navit/script/osm/Geo/OSM/APIClientV4.pm @@ -22,10 +22,10 @@ use POSIX qw(sigprocmask); sub new { my( $class, %attr ) = @_; - + my $obj = bless {}, $class; - my $url = $attr{api}; + my $url = $attr{api}; if( not defined $url ) { croak "Did not specify aip url"; @@ -34,7 +34,7 @@ sub new $url =~ s,/$,,; # Strip trailing slash $obj->{url} = $url; $obj->{client} = new LWP::UserAgent(agent => 'Geo::OSM::APIClientV4', timeout => 1200); - + if( defined $attr{username} and defined $attr{password} ) { if( $obj->{url} =~ m,http://([\w.]+)/, ) @@ -44,7 +44,7 @@ sub new my $encoded = MIME::Base64::encode_base64("$attr{username}:$attr{password}",""); $obj->{client}->default_header( "Authorization", "Basic $encoded" ); } - + $obj->{reader} = init Geo::OSM::OsmReader( sub { _process($obj,@_) } ); return $obj; } @@ -62,7 +62,7 @@ sub _process if( ref $obj->{buffer} eq "CODE" ) { $obj->{buffer}->($ent); return } die "Internal error: don't know what to do with buffer $obj->{buffer}"; -} +} # Utility function to handle the temporary blocking of signals in a way that # works with exception handling. @@ -104,18 +104,18 @@ sub create $ent->set_id($oldid); my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/create"; $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + # print $res->as_string; if( $res->code == 200 ) { return $res->content } - + $self->{last_error} = $res; return undef; } @@ -126,11 +126,11 @@ sub modify my $content = encode("utf-8", $ent->full_xml); my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/".$ent->id(); $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + return $ent->id() if $res->code == 200; $self->{last_error} = $res; return undef; @@ -142,11 +142,11 @@ sub delete my $content = encode("utf-8", $ent->full_xml); my $req = new HTTP::Request DELETE => $self->{url}."/".$ent->type()."/".$ent->id(); # $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + return $ent->id() if $res->code == 200; $self->{last_error} = $res; return undef; @@ -157,9 +157,9 @@ sub get($$) my $self = shift; my $type = shift; my $id = shift; - + my $req = new HTTP::Request GET => $self->{url}."/$type/$id"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -167,7 +167,7 @@ sub get($$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); @@ -176,7 +176,7 @@ sub get($$) { die "Unexpected response for get_$type [".$res->content()."]\n"; } - + return $res[0]; } @@ -203,9 +203,9 @@ sub map($$$$) { my $self = shift; my @bbox = @_; - + my $req = new HTTP::Request GET => $self->{url}."/map?bbox=$bbox[0],$bbox[1],$bbox[2],$bbox[3]"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -213,12 +213,12 @@ sub map($$$$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); undef $self->{buffer}; - + return \@res; } diff --git a/navit/script/osm/Geo/OSM/APIClientV5.pm b/navit/script/osm/Geo/OSM/APIClientV5.pm index 5bee097de..39cc124d9 100644 --- a/navit/script/osm/Geo/OSM/APIClientV5.pm +++ b/navit/script/osm/Geo/OSM/APIClientV5.pm @@ -24,10 +24,10 @@ use Socket qw(inet_ntoa); sub new { my( $class, %attr ) = @_; - + my $obj = bless {}, $class; - my $url = $attr{api}; + my $url = $attr{api}; if( not defined $url ) { croak "Did not specify api url"; @@ -36,13 +36,13 @@ sub new $url =~ s,/$,,; # Strip trailing slash $obj->{url} = URI->new($url); $obj->{client} = new LWP::UserAgent(agent => 'Geo::OSM::APIClientV5', timeout => 1200); - + if( defined $attr{username} and defined $attr{password} ) { my $encoded = MIME::Base64::encode_base64("$attr{username}:$attr{password}",""); $obj->{client}->default_header( "Authorization", "Basic $encoded" ); } - + # We had the problem of the client doing a DNS lookup each request. To # solve this we do a gethostbyname now and store that in the URI. { @@ -57,7 +57,7 @@ sub new } # Hack to avoid protocol lookups each time @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( 'Proto' => 6 ); - + $obj->{reader} = init Geo::OSM::OsmReader( sub { _process($obj,@_) } ); return $obj; } @@ -75,7 +75,7 @@ sub _process if( ref $obj->{buffer} eq "CODE" ) { $obj->{buffer}->($ent); return } die "Internal error: don't know what to do with buffer $obj->{buffer}"; -} +} # Utility function to handle the temporary blocking of signals in a way that # works with exception handling. @@ -121,18 +121,18 @@ sub create($) $ent->set_id($oldid); my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/create"; $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + # print $res->as_string; if( $res->code == 200 ) { return $res->content } - + $self->{last_error} = $res; return undef; } @@ -143,11 +143,11 @@ sub modify($) my $content = encode("utf-8", $ent->full_xml); my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/".$ent->id(); $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + return $ent->id() if $res->code == 200; $self->{last_error} = $res; return undef; @@ -159,11 +159,11 @@ sub delete($) my $content = encode("utf-8", $ent->full_xml); my $req = new HTTP::Request DELETE => $self->{url}."/".$ent->type()."/".$ent->id(); # $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + return $ent->id() if $res->code == 200; $self->{last_error} = $res; return undef; @@ -175,12 +175,12 @@ sub get($$) my $type = shift; my $id = shift; my $extra = shift; - + $extra = "/".$extra if (defined $extra); $extra = "" if not defined $extra; my $req = new HTTP::Request GET => $self->{url}."/$type/$id$extra"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -188,7 +188,7 @@ sub get($$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); @@ -215,7 +215,7 @@ sub resurrect($$) if (defined $ret || !defined $self->{last_error} || ($self->{last_error}->code != 410)) { return $ret; } - + my @ents = $self->get($type, $id, 'history'); # we want the last _visible_ one my $ent = $ents[-2]; @@ -270,9 +270,9 @@ sub get_subtype($$) my $type = shift; my $id = shift; my $subtype = shift; - + my $req = new HTTP::Request GET => $self->{url}."/$type/$id/$subtype"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -280,7 +280,7 @@ sub get_subtype($$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); @@ -289,7 +289,7 @@ sub get_subtype($$) { die "Unexpected response for get_subtype($type,$id,$subtype) [".$res->content()."]\n"; } - + return \@res; } @@ -297,7 +297,7 @@ sub get_node_ways($) { my $self = shift; my $id = shift; - + return $self->get_subtype("node",$id,"ways"); } @@ -305,9 +305,9 @@ sub map($$$$) { my $self = shift; my @bbox = @_; - + my $req = new HTTP::Request GET => $self->{url}."/map?bbox=$bbox[0],$bbox[1],$bbox[2],$bbox[3]"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -315,12 +315,12 @@ sub map($$$$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); undef $self->{buffer}; - + return \@res; } diff --git a/navit/script/osm/Geo/OSM/APIClientV6.pm b/navit/script/osm/Geo/OSM/APIClientV6.pm index d659ac14c..304564be5 100644 --- a/navit/script/osm/Geo/OSM/APIClientV6.pm +++ b/navit/script/osm/Geo/OSM/APIClientV6.pm @@ -24,10 +24,10 @@ use Socket qw(inet_ntoa); sub new { my( $class, %attr ) = @_; - + my $obj = bless {}, $class; - my $url = $attr{api}; + my $url = $attr{api}; if( not defined $url ) { croak "Did not specify api url"; @@ -36,13 +36,13 @@ sub new $url =~ s,/$,,; # Strip trailing slash $obj->{url} = URI->new($url); $obj->{client} = new LWP::UserAgent(agent => 'Geo::OSM::APIClientV6', timeout => 1200); - + if( defined $attr{username} and defined $attr{password} ) { my $encoded = MIME::Base64::encode_base64("$attr{username}:$attr{password}",""); $obj->{client}->default_header( "Authorization", "Basic $encoded" ); } - + # We had the problem of the client doing a DNS lookup each request. To # solve this we do a gethostbyname now and store that in the URI. { @@ -57,7 +57,7 @@ sub new } # Hack to avoid protocol lookups each time @LWP::Protocol::http::EXTRA_SOCK_OPTS = ( 'Proto' => 6 ); - + $obj->{reader} = init Geo::OSM::OsmReader( sub { _process($obj,@_) } ); return $obj; } @@ -75,7 +75,7 @@ sub _process if( ref $obj->{buffer} eq "CODE" ) { $obj->{buffer}->($ent); return } die "Internal error: don't know what to do with buffer $obj->{buffer}"; -} +} # Utility function to handle the temporary blocking of signals in a way that # works with exception handling. @@ -125,11 +125,11 @@ sub create_changeset $self->{changeset}=$res->content; return 1; } - + $self->{last_error} = $res; $self->{changeset}=undef; return 0; - + } sub close_changeset @@ -144,7 +144,7 @@ sub close_changeset return 1; } return 0; - + } sub create($) @@ -156,18 +156,18 @@ sub create($) $ent->set_id($oldid); my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/create"; $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + # print $res->as_string; if( $res->code == 200 ) { return $res->content } - + $self->{last_error} = $res; return undef; } @@ -179,11 +179,11 @@ sub modify($) my $content = encode("utf-8", $ent->full_xml); my $req = new HTTP::Request PUT => $self->{url}."/".$ent->type()."/".$ent->id(); $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + return $ent->id() if $res->code == 200; $self->{last_error} = $res; return undef; @@ -196,11 +196,11 @@ sub delete($) my $content = encode("utf-8", $ent->full_xml); my $req = new HTTP::Request DELETE => $self->{url}."/".$ent->type()."/".$ent->id(); $req->content($content); - + # print $req->as_string; - + my $res = $self->_request($req); - + return $ent->id() if $res->code == 200; $self->{last_error} = $res; return undef; @@ -212,12 +212,12 @@ sub get($$) my $type = shift; my $id = shift; my $extra = shift; - + $extra = "/".$extra if (defined $extra); $extra = "" if not defined $extra; my $req = new HTTP::Request GET => $self->{url}."/$type/$id$extra"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -225,7 +225,7 @@ sub get($$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); @@ -252,7 +252,7 @@ sub resurrect($$) if (defined $ret || !defined $self->{last_error} || ($self->{last_error}->code != 410)) { return $ret; } - + my @ents = $self->get($type, $id, 'history'); # we want the last _visible_ one my $ent = $ents[-2]; @@ -307,9 +307,9 @@ sub get_subtype($$) my $type = shift; my $id = shift; my $subtype = shift; - + my $req = new HTTP::Request GET => $self->{url}."/$type/$id/$subtype"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -317,7 +317,7 @@ sub get_subtype($$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); @@ -326,7 +326,7 @@ sub get_subtype($$) { die "Unexpected response for get_subtype($type,$id,$subtype) [".$res->content()."]\n"; } - + return \@res; } @@ -334,7 +334,7 @@ sub get_node_ways($) { my $self = shift; my $id = shift; - + return $self->get_subtype("node",$id,"ways"); } @@ -342,9 +342,9 @@ sub map($$$$) { my $self = shift; my @bbox = @_; - + my $req = new HTTP::Request GET => $self->{url}."/map?bbox=$bbox[0],$bbox[1],$bbox[2],$bbox[3]"; - + my $res = $self->_request($req); if( $res->code != 200 ) @@ -352,12 +352,12 @@ sub map($$$$) $self->{last_error} = $res; return undef; } - + my @res; $self->{buffer} = \@res; $self->{reader}->parse($res->content); undef $self->{buffer}; - + return \@res; } diff --git a/navit/script/osm/Geo/OSM/EntitiesV3.pm b/navit/script/osm/Geo/OSM/EntitiesV3.pm index 2708463c7..0e0581af4 100644 --- a/navit/script/osm/Geo/OSM/EntitiesV3.pm +++ b/navit/script/osm/Geo/OSM/EntitiesV3.pm @@ -67,9 +67,9 @@ sub tag_xml { my ($self,$writer) = @_; my @a = @{$self->{tags}}; - + my $str = ""; - + while( my($k,$v) = splice @a, 0, 2 ) { $writer->emptyTag( "tag", 'k' => $k, 'v' => $v ); @@ -83,9 +83,9 @@ sub set_id my($self,$id) = @_; if( not defined $id ) - { $id = $_ID-- } + { $id = $_ID-- } $self->{id} = $id; -} +} sub id { @@ -120,14 +120,14 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags, $segs) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_segs($segs); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); - + return $obj; } @@ -168,11 +168,11 @@ sub map my $incomplete = 0; my ($new_id) = $mapper->map('way',$self->id); # Determine mapped ID # It is ok for the new_id to be incomplete; it may be a create request - + my @new_segs = map { [ $mapper->map('segment',$_) ] } @{$self->segs}; map { $incomplete |= $_->[1] } @new_segs; # incomplete tracks if any of the segs are incomplete - + my $new_ent = new Geo::OSM::Way( {id=>$new_id, timestamp=>$self->timestamp}, $self->tags, [map {$_->[0]} @new_segs] ); return($new_ent,$incomplete); } @@ -183,15 +183,15 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); $obj->{from} = $attr->{from}; $obj->{to} = $attr->{to}; - + return $obj; } @@ -242,15 +242,15 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); $obj->{lon} = $attr->{lon}; $obj->{lat} = $attr->{lat}; - + return $obj; } @@ -277,7 +277,7 @@ sub xml my $self = shift; my $str = ""; my $writer = $self->_get_writer(\$str); - + $writer->startTag( "node", id => $self->id, lat => $self->lat, lon => $self->lon, timestamp => $self->timestamp ); $self->tag_xml( $writer ); $writer->endTag( "node" ); diff --git a/navit/script/osm/Geo/OSM/EntitiesV5.pm b/navit/script/osm/Geo/OSM/EntitiesV5.pm index 625ff6b03..fa9116daa 100644 --- a/navit/script/osm/Geo/OSM/EntitiesV5.pm +++ b/navit/script/osm/Geo/OSM/EntitiesV5.pm @@ -67,9 +67,9 @@ sub tag_xml { my ($self,$writer) = @_; my @a = @{$self->{tags}}; - + my $str = ""; - + while( my($k,$v) = splice @a, 0, 2 ) { $writer->emptyTag( "tag", 'k' => $k, 'v' => $v ); @@ -83,9 +83,9 @@ sub set_id my($self,$id) = @_; if( not defined $id ) - { $id = $_ID-- } + { $id = $_ID-- } $self->{id} = $id; -} +} sub id { @@ -121,14 +121,14 @@ use Carp; sub new { my($class, $attr, $tags, $nodes) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_nodes($nodes); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); - + return $obj; } @@ -175,11 +175,11 @@ sub map my $incomplete = 0; my ($new_id) = $mapper->map('way',$self->id); # Determine mapped ID # It is ok for the new_id to be incomplete; it may be a create request - + my @new_nodes = map { [ $mapper->map('node',$_) ] } @{$self->nodes}; map { $incomplete |= $_->[1] } @new_nodes; # incomplete tracks if any of the segs are incomplete - + my $new_ent = new Geo::OSM::Way( {id=>$new_id, timestamp=>$self->timestamp}, $self->tags, [map {$_->[0]} @new_nodes] ); return($new_ent,$incomplete); } @@ -204,7 +204,7 @@ sub new { $arg = { type => $arg->[0], ref => $arg->[1], role => $arg->[2] } } } if( ref($arg) eq "HASH" ) - { + { if( ref $arg->{ref} ) { $arg = [ $arg->{ref}->type, $arg->{ref}->id, $arg->{role} ] } else @@ -217,7 +217,7 @@ sub new croak "Bad member id '$arg->[1]'" unless $arg->[1] =~ /^-?\d+$/; $arg->[2] ||= ""; - + return bless $arg, $class; } @@ -249,14 +249,14 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags, $members) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_members($members); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); - + return $obj; } @@ -298,7 +298,7 @@ sub map { my($self,$mapper) = @_; my $incomplete = 0; - + my ($new_id) = $mapper->map('relation',$self->id); my @new_members = map { [ $_->map($mapper) ] } @{$self->members}; map { $incomplete |= $_->[1] } @new_members; @@ -314,9 +314,9 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); @@ -327,7 +327,7 @@ sub new } $obj->{lon} = $attr->{lon}; $obj->{lat} = $attr->{lat}; - + return $obj; } @@ -354,7 +354,7 @@ sub xml my $self = shift; my $str = ""; my $writer = $self->_get_writer(\$str); - + $writer->startTag( "node", id => $self->id, lat => $self->lat, lon => $self->lon, timestamp => $self->timestamp ); $self->tag_xml( $writer ); $writer->endTag( "node" ); diff --git a/navit/script/osm/Geo/OSM/EntitiesV6.pm b/navit/script/osm/Geo/OSM/EntitiesV6.pm index 8747c17f0..4a9b49cbb 100644 --- a/navit/script/osm/Geo/OSM/EntitiesV6.pm +++ b/navit/script/osm/Geo/OSM/EntitiesV6.pm @@ -67,9 +67,9 @@ sub tag_xml { my ($self,$writer) = @_; my @a = @{$self->{tags}}; - + my $str = ""; - + while( my($k,$v) = splice @a, 0, 2 ) { $writer->emptyTag( "tag", 'k' => $k, 'v' => $v ); @@ -83,9 +83,9 @@ sub set_id my($self,$id) = @_; if( not defined $id ) - { $id = $_ID-- } + { $id = $_ID-- } $self->{id} = $id; -} +} sub id { @@ -143,16 +143,16 @@ use Carp; sub new { my($class, $attr, $tags, $nodes) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_nodes($nodes); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); $obj->set_changeset( $attr->{changeset} ); $obj->set_version( $attr->{version} ); - + return $obj; } @@ -199,11 +199,11 @@ sub map my $incomplete = 0; my ($new_id) = $mapper->map('way',$self->id); # Determine mapped ID # It is ok for the new_id to be incomplete; it may be a create request - + my @new_nodes = map { [ $mapper->map('node',$_) ] } @{$self->nodes}; map { $incomplete |= $_->[1] } @new_nodes; # incomplete tracks if any of the segs are incomplete - + my $new_ent = new Geo::OSM::Way( {id=>$new_id, timestamp=>$self->timestamp}, $self->tags, [map {$_->[0]} @new_nodes] ); return($new_ent,$incomplete); } @@ -228,7 +228,7 @@ sub new { $arg = { type => $arg->[0], ref => $arg->[1], role => $arg->[2] } } } if( ref($arg) eq "HASH" ) - { + { if( ref $arg->{ref} ) { $arg = [ $arg->{ref}->type, $arg->{ref}->id, $arg->{role} ] } else @@ -241,7 +241,7 @@ sub new croak "Bad member id '$arg->[1]'" unless $arg->[1] =~ /^-?\d+$/; $arg->[2] ||= ""; - + return bless $arg, $class; } @@ -273,16 +273,16 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags, $members) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_members($members); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); $obj->set_changeset( $attr->{changeset} ); $obj->set_version( $attr->{version} ); - + return $obj; } @@ -324,7 +324,7 @@ sub map { my($self,$mapper) = @_; my $incomplete = 0; - + my ($new_id) = $mapper->map('relation',$self->id); my @new_members = map { [ $_->map($mapper) ] } @{$self->members}; map { $incomplete |= $_->[1] } @new_members; @@ -341,9 +341,9 @@ our @ISA = qw(Geo::OSM::Entity); sub new { my($class, $attr, $tags) = @_; - + my $obj = bless $class->SUPER::_new(), $class; - + $obj->set_tags($tags); $obj->set_id($attr->{id} ); $obj->set_timestamp( $attr->{timestamp} ); @@ -356,7 +356,7 @@ sub new } $obj->{lon} = $attr->{lon}; $obj->{lat} = $attr->{lat}; - + return $obj; } @@ -383,7 +383,7 @@ sub xml my $self = shift; my $str = ""; my $writer = $self->_get_writer(\$str); - + $writer->startTag( "node", id => $self->id, lat => $self->lat, lon => $self->lon, timestamp => $self->timestamp, changeset => $self->changeset, version => $self->version); $self->tag_xml( $writer ); $writer->endTag( "node" ); diff --git a/navit/script/osm/Geo/OSM/MapFeatures.pm b/navit/script/osm/Geo/OSM/MapFeatures.pm index c4ae62f89..473ff20de 100644 --- a/navit/script/osm/Geo/OSM/MapFeatures.pm +++ b/navit/script/osm/Geo/OSM/MapFeatures.pm @@ -49,7 +49,7 @@ sub load($;$){ return; } my $self = XMLin($fh); - + if (not $self) { print STDERR "WARNING: Could not parse osm data from $filename\n"; return; @@ -61,7 +61,7 @@ sub load($;$){ #warn Dumper(\$self->{rule}); #warn Dumper(keys %{$self}); #warn Dumper(%{$self}); - + bless($self,$class); return $self; } @@ -97,7 +97,7 @@ sub load_icons($$){ last; } } - + if ( ! $rule->{png} ) { warn "missing $img\n"; } @@ -139,7 +139,7 @@ sub get_icons($$$){ my $condition = $rule->{condition}; # print STDERR "condition: $condition->{k}=$condition->{v}\n"; - if ( defined ( $attr{scale_max}) && + if ( defined ( $attr{scale_max}) && $scale > $attr{scale_max}) { next; } @@ -150,7 +150,7 @@ sub get_icons($$$){ print STDERR "get_icon() image: $img\t"; $png = $rule->{png}; } - + return $png if $png; } return undef; diff --git a/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm b/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm index 65103a36e..ff99e4043 100644 --- a/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm +++ b/navit/script/osm/Geo/OSM/OsmChangeReaderV3.pm @@ -32,7 +32,7 @@ use constant FILETYPE_OSMCHANGE => 1; use constant FILETYPE_OSM => 2; sub new -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -46,7 +46,7 @@ sub new # With this initialiser, your process will get called with instantiated objects rather than useless details sub init -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -61,12 +61,12 @@ sub init sub _process { my($self, $command, $entity, $attr, $tags, $segs) = @_; - + if( defined $self->{oldproc} ) { return $self->{oldproc}->($command, $entity, $attr, $tags, $segs); } - + my $ent; if( $entity eq "node" ) { @@ -90,7 +90,7 @@ sub load{ $self->{filetype} = FILETYPE_UNKNOWN; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); my $fh = data_open($file_name); @@ -120,7 +120,7 @@ sub parse($) my ($self, $string) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); $self->{input_length} = length($string); @@ -145,7 +145,7 @@ sub parse($) # Function is called whenever an XML tag is started sub DoStart { -#print @_,"\n"; +#print @_,"\n"; my ($self, $Expat, $Name, %Attr) = @_; if( $self->{filetype} == FILETYPE_UNKNOWN ) @@ -161,7 +161,7 @@ sub DoStart } elsif($Name eq "osm"){ $self->{state} = STATE_EXPECT_ENTITY; $self->{filetype} = FILETYPE_OSM; - + if( $Attr{version} ne "0.3" and $Attr{version} ne "0.4" ) { die "OsmChangeReaderV3 can only read 0.3 and 0.4 files, found '$Attr{version}'\n" } } else { @@ -284,7 +284,7 @@ OsmChangeReaderV3 - Module for reading OpenStreetMap V3 Change XML data files my $OSM = new Geo::OSM::OsmChangeReader(\&process); $OSM->load("Data/changes.osc"); - + sub process { my($OSM, $command, $entity, $attr, $tags, $segs) = @_; diff --git a/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm b/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm index fdc65e1a9..50dfeea6d 100644 --- a/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm +++ b/navit/script/osm/Geo/OSM/OsmChangeReaderV5.pm @@ -33,7 +33,7 @@ use constant FILETYPE_OSM => 2; # With this initialiser, your process will get called with instantiated objects sub init -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -48,12 +48,12 @@ sub init sub _process { my($self, $command, $entity, $attr, $tags, $members) = @_; - + if( defined $self->{oldproc} ) { return $self->{oldproc}->($command, $entity, $attr, $tags, $members); } - + my $ent; if( $entity eq "node" ) { @@ -77,7 +77,7 @@ sub load{ $self->{filetype} = FILETYPE_UNKNOWN; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); my $fh = data_open($file_name); @@ -107,7 +107,7 @@ sub parse($) my ($self, $string) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); $self->{input_length} = length($string); @@ -132,7 +132,7 @@ sub parse($) # Function is called whenever an XML tag is started sub DoStart { -#print @_,"\n"; +#print @_,"\n"; my ($self, $Expat, $Name, %Attr) = @_; if( $self->{filetype} == FILETYPE_UNKNOWN ) @@ -148,7 +148,7 @@ sub DoStart } elsif($Name eq "osm"){ $self->{state} = STATE_EXPECT_ENTITY; $self->{filetype} = FILETYPE_OSM; - + if( $Attr{version} ne "0.5" ) { die "OsmChangeReaderV3 can only read 0.5 files, found '$Attr{version}'\n" } } else { @@ -276,7 +276,7 @@ OsmChangeReaderV5 - Module for reading OpenStreetMap V5 Change XML data files my $OSM = new Geo::OSM::OsmChangeReader(\&process); $OSM->load("Data/changes.osc"); - + sub process { my($OSM, $command, $entity) = @_; diff --git a/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm b/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm index e67397829..4e312f519 100644 --- a/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm +++ b/navit/script/osm/Geo/OSM/OsmChangeReaderV6.pm @@ -33,7 +33,7 @@ use constant FILETYPE_OSM => 2; # With this initialiser, your process will get called with instantiated objects sub init -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -48,12 +48,12 @@ sub init sub _process { my($self, $command, $entity, $attr, $tags, $members) = @_; - + if( defined $self->{oldproc} ) { return $self->{oldproc}->($command, $entity, $attr, $tags, $members); } - + my $ent; if( $entity eq "node" ) { @@ -77,7 +77,7 @@ sub load{ $self->{filetype} = FILETYPE_UNKNOWN; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); my $fh = data_open($file_name); @@ -107,7 +107,7 @@ sub parse($) my ($self, $string) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); $self->{input_length} = length($string); @@ -132,7 +132,7 @@ sub parse($) # Function is called whenever an XML tag is started sub DoStart { -#print @_,"\n"; +#print @_,"\n"; my ($self, $Expat, $Name, %Attr) = @_; if( $self->{filetype} == FILETYPE_UNKNOWN ) @@ -148,7 +148,7 @@ sub DoStart } elsif($Name eq "osm"){ $self->{state} = STATE_EXPECT_ENTITY; $self->{filetype} = FILETYPE_OSM; - + if( $Attr{version} ne "0.6" ) { die "OsmChangeReaderV6 can only read 0.6 files, found '$Attr{version}'\n" } } else { @@ -276,7 +276,7 @@ OsmChangeReaderV6 - Module for reading OpenStreetMap V6 Change XML data files my $OSM = new Geo::OSM::OsmChangeReader(\&process); $OSM->load("Data/changes.osc"); - + sub process { my($OSM, $command, $entity) = @_; diff --git a/navit/script/osm/Geo/OSM/OsmReaderV3.pm b/navit/script/osm/Geo/OSM/OsmReaderV3.pm index b01963470..6cc64b899 100644 --- a/navit/script/osm/Geo/OSM/OsmReaderV3.pm +++ b/navit/script/osm/Geo/OSM/OsmReaderV3.pm @@ -26,7 +26,7 @@ use constant STATE_EXPECT_BODY => 4; # With this initialiser, your process will get called with instantiated objects sub init -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -41,7 +41,7 @@ sub init sub _process { my($self, $entity, $attr, $tags, $members) = @_; - + my $ent; if( $entity eq "node" ) { @@ -65,7 +65,7 @@ sub load($) my ($self, $file_name) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); my $fh = data_open($file_name); @@ -94,7 +94,7 @@ sub parse($) my ($self, $string) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); $self->{input_length} = length($string); @@ -119,14 +119,14 @@ sub parse($) # Function is called whenever an XML tag is started sub DoStart { -#print @_,"\n"; +#print @_,"\n"; my ($self, $Expat, $Name, %Attr) = @_; if( $self->{state} == STATE_INIT ) { if($Name eq "osm"){ $self->{state} = STATE_EXPECT_ENTITY; - + if( $Attr{version} ne "0.3" and $Attr{version} ne "0.4") { die "OsmReaderV5 can only read 0.3 or 0.4 files, found '$Attr{version}'\n" } } else { @@ -206,7 +206,7 @@ OsmReaderV3 - Module for reading OpenStreetMap V3 XML data files my $OSM = new Geo::OSM::OsmReader(\&process); $OSM->load("Data/changes.osc"); - + sub process { my($OSM, $entity) = @_; diff --git a/navit/script/osm/Geo/OSM/OsmReaderV5.pm b/navit/script/osm/Geo/OSM/OsmReaderV5.pm index 37a477b1a..315e4dddf 100644 --- a/navit/script/osm/Geo/OSM/OsmReaderV5.pm +++ b/navit/script/osm/Geo/OSM/OsmReaderV5.pm @@ -26,7 +26,7 @@ use constant STATE_EXPECT_BODY => 4; # With this initialiser, your process will get called with instantiated objects sub init -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -41,7 +41,7 @@ sub init sub _process { my($self, $entity, $attr, $tags, $members) = @_; - + my $ent; if( $entity eq "node" ) { @@ -65,7 +65,7 @@ sub load($) my ($self, $file_name) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); my $fh = data_open($file_name); @@ -94,7 +94,7 @@ sub parse($) my ($self, $string) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); $self->{input_length} = length($string); @@ -119,14 +119,14 @@ sub parse($) # Function is called whenever an XML tag is started sub DoStart { -#print @_,"\n"; +#print @_,"\n"; my ($self, $Expat, $Name, %Attr) = @_; if( $self->{state} == STATE_INIT ) { if($Name eq "osm"){ $self->{state} = STATE_EXPECT_ENTITY; - + if( $Attr{version} ne "0.5" ) { die "OsmReaderV5 can only read 0.5 files, found '$Attr{version}'\n" } } else { @@ -209,7 +209,7 @@ OsmReaderV5 - Module for reading OpenStreetMap V5 XML data files my $OSM = new Geo::OSM::OsmReader(\&process); $OSM->load("Data/changes.osc"); - + sub process { my($OSM, $entity) = @_; diff --git a/navit/script/osm/Geo/OSM/OsmReaderV6.pm b/navit/script/osm/Geo/OSM/OsmReaderV6.pm index 4f6a683d2..7ad3c736a 100644 --- a/navit/script/osm/Geo/OSM/OsmReaderV6.pm +++ b/navit/script/osm/Geo/OSM/OsmReaderV6.pm @@ -26,7 +26,7 @@ use constant STATE_EXPECT_BODY => 4; # With this initialiser, your process will get called with instantiated objects sub init -{ +{ my $obj = bless{}, shift; my $proc = shift; my $prog = shift; @@ -41,7 +41,7 @@ sub init sub _process { my($self, $entity, $attr, $tags, $members) = @_; - + my $ent; if( $entity eq "node" ) { @@ -65,7 +65,7 @@ sub load($) my ($self, $file_name) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); my $fh = data_open($file_name); @@ -94,7 +94,7 @@ sub parse($) my ($self, $string) = @_; $self->{state} = STATE_INIT; - + my $start_time = time(); my $P = new XML::Parser(Handlers => {Start => sub{ DoStart( $self, @_ )}, End => sub { DoEnd( $self, @_ )}}); $self->{input_length} = length($string); @@ -119,14 +119,14 @@ sub parse($) # Function is called whenever an XML tag is started sub DoStart { -#print @_,"\n"; +#print @_,"\n"; my ($self, $Expat, $Name, %Attr) = @_; if( $self->{state} == STATE_INIT ) { if($Name eq "osm"){ $self->{state} = STATE_EXPECT_ENTITY; - + if( $Attr{version} ne "0.6" ) { die "OsmReaderV6 can only read 0.6 files, found '$Attr{version}'\n" } } else { @@ -209,7 +209,7 @@ OsmReaderV6 - Module for reading OpenStreetMap V6 XML data files my $OSM = new Geo::OSM::OsmReader(\&process); $OSM->load("Data/changes.osc"); - + sub process { my($OSM, $entity) = @_; diff --git a/navit/script/osm/Geo/OSM/OsmXML.pm b/navit/script/osm/Geo/OSM/OsmXML.pm index 60f458db7..f37d269c3 100644 --- a/navit/script/osm/Geo/OSM/OsmXML.pm +++ b/navit/script/osm/Geo/OSM/OsmXML.pm @@ -51,7 +51,7 @@ sub bounds(){ sub DoStart() { my ($Expat, $Name, %Attr) = @_; - + if($Name eq "node"){ undef %OsmXML::Tags; %OsmXML::MainAttr = %Attr; @@ -97,7 +97,7 @@ sub DoEnd(){ $OsmXML::Ways{$ID}{"segments"} = join(",",@OsmXML::WaySegments); foreach(keys(%OsmXML::Tags)){ $OsmXML::Ways{$ID}{$_} = $OsmXML::Tags{$_}; - } + } } } @@ -118,16 +118,16 @@ OsmXML - Module for reading OpenStreetMap XML data files $OSM = new OsmXML(); $OSM->load("Data/nottingham.osm"); - + foreach $Way(%OsmXML::Ways){ @Segments = split(/,/, $Way->{"segments"}); - + foreach $SegmentID(@Segments){ $Segment = $OsmXML::Segments{$SegmentID}; - + $Node1 = $OsmXML::Nodes{$Segment->{"from"}}; $Node2 = $OsmXML::Nodes{$Segment->{"to"}}; - + printf "Node at %f,%f, named %s, is a %s", $Node2->{"lat"}, $Node2->{"lon"}, diff --git a/navit/script/osm/Geo/OSM/Planet.pm b/navit/script/osm/Geo/OSM/Planet.pm index 25c533eb7..260b96b5f 100644 --- a/navit/script/osm/Geo/OSM/Planet.pm +++ b/navit/script/osm/Geo/OSM/Planet.pm @@ -64,10 +64,10 @@ my $estimations = { }; # ------------------------------------------------------------------ -# This routine estimates the maximum id for way,elem,seg,... +# This routine estimates the maximum id for way,elem,seg,... # The values are taken from older planet.osm Files # So they mostly are a little bit to low -# ARGS: +# ARGS: # $type: line|way|tag|... # RETURNS: # $result: number of estimated max_id @@ -81,10 +81,10 @@ sub estimated_max_id($){ } # ------------------------------------------------------------------ -# This routine estimates the maximim number of elements for way,elem,seg,... +# This routine estimates the maximim number of elements for way,elem,seg,... # The values are taken from older planet.osm Files # So they mostly are a little bit to low -# ARGS: +# ARGS: # $type: line|way|tag|... # RETURNS: # $result: number of estimated elements @@ -112,7 +112,7 @@ sub osm_dir() { chomp $home; $home = "/home/$home"; } - + $dir = "$home/osm"; return $dir; } @@ -144,22 +144,22 @@ sub sort_unique(@){ } return @erg } - + # ------------------------------------------------------------------ # mirror the newest planet.osm File to # ~/osm/planet/planet.osm.bz2 -# and the resulting +# and the resulting # Filename is returned # -# the file is -----NO LONGER--- Sanitized afterwards +# the file is -----NO LONGER--- Sanitized afterwards sub mirror_planet(){ my $planet_server="http://planet.openstreetmap.org"; my $url = "$planet_server"; my $mirror_dir=planet_dir(); mkdir_if_needed( $mirror_dir ); - + my $current_file; if ( !$Utils::LWP::Utils::NO_MIRROR ) { # Get Index.html of Planet.osm.org @@ -194,11 +194,11 @@ sub mirror_planet(){ print STDERR "Existing Files: \n\t".join("\n\t",@files)."\n"; } $current_file = $files[0]; - + if ( $DEBUG) { print STDERR "Chosen File: $current_file\n"; } - + return undef unless $current_file; # $current_file = UTF8sanitize($current_file); @@ -220,7 +220,7 @@ sub mirror_planet(){ # ~/osm/planet/planet-07XXXX-a.osm.bz2 # If a recent enought Version is found in ~/osm/planet/ # nothing is done, but the filename of the file is returned -# if the routine finds an uncompressed up to date Version +# if the routine finds an uncompressed up to date Version # ~/osm/planet/planet-07XXXX-a.osm # this Filename is returned. sub UTF8sanitize($){ @@ -259,7 +259,7 @@ sub UTF8sanitize($){ print "Command: $cmd" if $DEBUG || $VERBOSE; my $result = `$cmd`; print $result if $DEBUG || $VERBOSE; - + print "Sanitized $filename " if $DEBUG || $VERBOSE; print_time($start_time); @@ -279,7 +279,7 @@ sub UTF8sanitize($){ } # ------------------------------------------------------------------ -# find a file in the current Perl Search path. For now this was the +# find a file in the current Perl Search path. For now this was the # easiest solution to find programms like UTF8Sanitize # ARGS: relative filename (relative to @INC-path # RETURNS: Absolute path to file @@ -295,7 +295,7 @@ sub find_file_in_perl_path($){ last; }; } - + print "find_file_in_perl_path($file): --> $found_file\n" if $DEBUG; return $found_file; } diff --git a/navit/script/osm/Geo/OSM/SegmentList.pm b/navit/script/osm/Geo/OSM/SegmentList.pm index 0de35ebf5..8523173ce 100644 --- a/navit/script/osm/Geo/OSM/SegmentList.pm +++ b/navit/script/osm/Geo/OSM/SegmentList.pm @@ -54,7 +54,7 @@ sub load_segment_list($;$){ my $osm_filename = "${path}/csv/osm-segments.csv"; $osm_filename =~ s,\~/,$home/,; printf STDERR "check $osm_filename for loading\n" if $DEBUG; - + die "Cannot open $osm_filename\n" unless -s $osm_filename; $osm_segments = Geo::OSM::SegmentList::LoadOSM_segment_csv($osm_filename, $bounds); }; @@ -111,7 +111,7 @@ sub LoadOSM_segment_csv($;$){ $main::dont_write_osm_storable=1 || $check_bounds; $main::dont_read_osm_storable=1; - if ( -s "$filename.storable" && + if ( -s "$filename.storable" && ! file_needs_re_generation($filename,"$filename.storable") && ! $main::dont_read_osm_storable ) { # later we should compare if the file also is newer than the source @@ -178,7 +178,7 @@ sub LoadOSM_segment_csv($;$){ # ------------------------------------------------------- # Load the segment list from postgis # Args: {lat_min=> .., lat_max => ..., lon_min => .., lon_max => .. } -# This is a test to see if we can handle all segments of the world +# This is a test to see if we can handle all segments of the world # with reasonable query times sub LoadOSM_segment_postgis($;$){ my $bounds = shift; @@ -192,7 +192,7 @@ sub LoadOSM_segment_postgis($;$){ my $sth; use DBI; - + my $dbname="gis"; my $dbhost="/var/run/postgresql"; my $dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$dbhost", "", "", {AutoCommit => 0}); @@ -205,7 +205,7 @@ sub LoadOSM_segment_postgis($;$){ # WHERE the_geom && setsrid('BOX(47.36 21.40,51.185 21.53)'::box2d, 42102) # WHERE GeomFromText('POINT(25.3 25.40)', 42102) && the_geom \ # AND distance(the_geom, GeomFromText('POINT(25.7 5.3)', 42102)) = 0 - # WHERE distance(the_geom, setsrid('BOX(4.36 2.3,1.5 2.8)'::box2d, 42102)) = 0 + # WHERE distance(the_geom, setsrid('BOX(4.36 2.3,1.5 2.8)'::box2d, 42102)) = 0 # WHERE the_point && setsrid('BOX(295149 2315499, 465992 2163790)'::box2d, -1) ############################## @@ -223,12 +223,12 @@ sub LoadOSM_segment_postgis($;$){ my $polygon_text=sprintf("POLYGON((%.5f %.5f,%.5f %.5f,%.5f %.5f,%.5f %.5f,%.5f %.5f))", $bounds->{lat_min}-0.1 , $bounds->{lon_min}-0.1, - $bounds->{lat_max}+0.1 , $bounds->{lon_min}-0.1 , - $bounds->{lat_max}+0.1 , $bounds->{lon_max}+0.1 , - $bounds->{lat_min}-0.1 , $bounds->{lon_max}+0.1 , + $bounds->{lat_max}+0.1 , $bounds->{lon_min}-0.1 , + $bounds->{lat_max}+0.1 , $bounds->{lon_max}+0.1 , + $bounds->{lat_min}-0.1 , $bounds->{lon_max}+0.1 , $bounds->{lat_min}-0.1 , $bounds->{lon_min}-0.1); my $polygon="transform(GeomFromText('$polygon_text',${SRID_WGS84}),$SRID_OSM)"; - + my $select = "select osm_id,highway,name from planet_osm_line where highway is not null and way && ". " $polygon ". "limit 5;"; @@ -240,9 +240,9 @@ sub LoadOSM_segment_postgis($;$){ } printf STDERR "---------------------------------------------------------------\n" if $DEBUG || $VERBOSE; - + # $select = "SELECT name ,astext(way),$distance FROM planet_osm_roads WHERE $distance < 500 order by $distance;"; - + #SELECT * FROM planet_osm_roads WHERE way in ?", #$select = "SELECT name FROM planet_osm_roads WHERE distance(way,GeomFromText('POINT(856371.58 6683083.41)', 3395)) < 1000;"; # my $distance="distance(way, GeomFromText('POINT(856371.58 6683083.41)', 3395))"; @@ -277,7 +277,7 @@ sub LoadOSM_segment_postgis($;$){ } printf STDERR "---------------------------------------------------------------\n" if $DEBUG || $VERBOSE; - + my $count=0; my $count_read=0; while ( @row = $sth->fetchrow_array ) { @@ -359,7 +359,7 @@ my $from_node=0; sub DoStart() { my ($Expat, $Name, %Attr) = @_; - + if($Name eq "node"){ undef %Tags; %MainAttr = %Attr; @@ -389,7 +389,7 @@ sub DoStart() my $to_node = $Attr{"ref"}; if ( $from_node && defined($Nodes{$from_node}) && - defined($Nodes{$to_node}) + defined($Nodes{$to_node}) ) { my ($lat1,$lon1)=split(",",$Nodes{$from_node}); my ($lat2,$lon2)=split(",",$Nodes{$to_node}); @@ -407,12 +407,12 @@ sub DoStart() sub DoEnd(){ my ($Expat, $Element) = @_; my $ID = $MainAttr{"id"}; - + if($Element eq "node"){ my $node={}; $node->{"lat"} = $MainAttr{"lat"}; $node->{"lon"} = $MainAttr{"lon"}; - + if ( $AREA_FILTER->inside($node) ) { $Nodes{$ID} = sprintf("%f,%f",$MainAttr{lat}, $MainAttr{lon}); foreach(keys(%Tags)){ @@ -452,16 +452,16 @@ sub read_osm_file($;$) { # Insert Segments from osm File print("Reading OSM Segment from File $filename\n") if $VERBOSE || $DEBUG; if ( file_needs_re_generation($filename,"$filename.storable")) { print "$filename: ".(-s $filename)." Bytes\n" if $DEBUG; - + print STDERR "Parsing file: $filename\n" if $DEBUG; my $p = new XML::Parser( Handlers => { - Start => \&DoStart, - End => \&DoEnd, + Start => \&DoStart, + End => \&DoEnd, Char => \&DoChar, }, ErrorContext => 10, ); - + my $fh = data_open($filename); if (not $fh) { print STDERR "WARNING: Could not open osm data from $filename\n"; @@ -476,7 +476,7 @@ sub read_osm_file($;$) { # Insert Segments from osm File return; } #warn Dumper(\$read_osm_segments); - Storable_save($filename,$read_osm_segments); + Storable_save($filename,$read_osm_segments); } else { $read_osm_segments=Storable_load($filename); } diff --git a/navit/script/osm/Geo/OSM/Tracks2OSM.pm b/navit/script/osm/Geo/OSM/Tracks2OSM.pm index 4016f8c02..87302abc9 100644 --- a/navit/script/osm/Geo/OSM/Tracks2OSM.pm +++ b/navit/script/osm/Geo/OSM/Tracks2OSM.pm @@ -33,7 +33,7 @@ sub create_node($$) { my $osm_nodes = shift; my $elem = shift; - printf STDERR "create_node(): lat or lon undefined : $elem->{lat},$elem->{lon} ".Dumper(\$elem)."\n" + printf STDERR "create_node(): lat or lon undefined : $elem->{lat},$elem->{lon} ".Dumper(\$elem)."\n" unless defined($elem->{lat}) && defined($elem->{lon}) ; my $id=0; @@ -95,7 +95,7 @@ sub tracks2osm($){ }; for my $elem ( @{$track} ) { my $node_id = $elem->{node_id} || create_node($osm_nodes,$elem); - + # -------------------------------------------- Add to Way push(@{$osm_ways->{$osm_way_number}->{nd}},$node_id); $count_valid_points_for_ways++; diff --git a/navit/script/osm/Geo/OSM/Upload.pm b/navit/script/osm/Geo/OSM/Upload.pm index da18e97ec..7cd4de8cc 100644 --- a/navit/script/osm/Geo/OSM/Upload.pm +++ b/navit/script/osm/Geo/OSM/Upload.pm @@ -24,12 +24,12 @@ sub tempfiles(){ sub uploadWay(){ my ($self, $Tags, @Segments) = @_; $Tags .= sprintf("<tag k=\"created_by\" v=\"%s\"/>", $self->{UserAgent}); - + my $Segments = ""; foreach $Segment(@Segments){ $Segments .= "<seg id=\"$Segment\"/>"; } - + my $Way = "<way id=\"0\">$Segments$Tags</way>"; my $OSM = "<osm version=\"0.3\">$Way</osm>"; my $data = "<?xml version=\"1.0\"?>\n$OSM"; @@ -42,45 +42,45 @@ sub uploadWay(){ sub uploadSegment(){ my ($self, $Node1,$Node2,$Tags) = @_; $Tags .= sprintf("<tag k=\"created_by\" v=\"%s\"/>", $self->{UserAgent}); - + my $Segment = sprintf("<segment id=\"0\" from=\"%d\" to=\"%d\">$Tags</segment>", $Node1,$Node2); my $OSM = "<osm version=\"0.3\">$Segment</osm>"; my $data = "<?xml version=\"1.0\"?>\n$OSM"; my $path = "segment/0"; my ($response, $http_code) = $self->upload($data, $path); - - + + return($response); } sub uploadNode(){ my ($self, $Lat, $Long, $Tags) = @_; $Tags .= sprintf("<tag k=\"created_by\" v=\"%s\"/>", $self->{UserAgent}); - + my $Node = sprintf("<node id=\"0\" lon=\"%f\" lat=\"%f\">$Tags</node>", $Long, $Lat); my $OSM = "<osm version=\"0.3\">$Node</osm>"; my $data = "<?xml version=\"1.0\"?>\n$OSM"; my $path = "node/0"; my ($response, $http_code) = $self->upload($data, $path); - + return($response); } sub upload(){ my($self, $data, $path) = @_; - + my $curl = new WWW::Curl::easy; my $login = sprintf("%s:%s", $self->{Username}, $self->{Password}); - + open(my $FileToSend, ">", $self->{file1}); print $FileToSend $data; close $FileToSend; - - my $url = "http://www.openstreetmap.org/api/0.3/$path"; - + + my $url = "http://www.openstreetmap.org/api/0.3/$path"; + open(my $TxFile, "<", $self->{file1}); open(my $RxFile, ">",$self->{file2}); $curl->setopt(CURLOPT_URL,$url); @@ -91,20 +91,20 @@ sub upload(){ $curl->setopt(CURLOPT_INFILE,$TxFile); $curl->setopt(CURLOPT_INFILESIZE, -s $self->{file1}); $curl->setopt(CURLOPT_FILE, $RxFile); - + $curl->perform(); my $http_code = $curl->getinfo(CURLINFO_HTTP_CODE); my $err = $curl->errbuf; $curl->close(); close $TxFile; close $RxFile; - + open(my $ResponseFile, "<", $self->{file2}); my $response = int(<$ResponseFile>); close $ResponseFile; - + print "Code $http_code\n" if($http_code != 200); - + return($response, $http_code); } diff --git a/navit/script/osm/Geo/OSM/Write.pm b/navit/script/osm/Geo/OSM/Write.pm index 463c2d0cd..68c093b35 100644 --- a/navit/script/osm/Geo/OSM/Write.pm +++ b/navit/script/osm/Geo/OSM/Write.pm @@ -22,7 +22,7 @@ use Utils::Math; # ------------------------------------------------------------------ sub tags2osm($){ my $obj = shift; - + my $erg = ""; for my $k ( keys %{$obj->{tag}} ) { my $v = $obj->{tag}{$k}; @@ -73,10 +73,10 @@ sub write_osm_file($$) { # Write an osm File print $fh "<osm version=\'0.5\' generator=\'".$osm->{tool}."\'>\n"; if ( defined ( $osm->{bounds} ) ) { my $bounds = $osm->{bounds}; - my $bounds_sting = "$bounds->{lat_min},$bounds->{lon_min},$bounds->{lat_max},$bounds->{lon_max}"; + my $bounds_sting = "$bounds->{lat_min},$bounds->{lon_min},$bounds->{lat_max},$bounds->{lon_max}"; # -90,-180,90,180 print $fh " <bound box=\"$bounds_sting\" origin=\"OSM-perl-writer\" />\n"; - + } # --- Nodes @@ -90,9 +90,9 @@ sub write_osm_file($$) { # Write an osm File next; } print $fh " <node id=\'$node_id\' "; - print $fh " timestamp=\'".$node->{timestamp}."\' " + print $fh " timestamp=\'".$node->{timestamp}."\' " if defined $node->{timestamp}; - print $fh " changeset=\'".$node->{changeset}."\' " + print $fh " changeset=\'".$node->{changeset}."\' " if defined $node->{changeset}; print $fh " lat=\'$lat\' "; print $fh " lon=\'$lon\' "; @@ -109,10 +109,10 @@ sub write_osm_file($$) { # Write an osm File next unless scalar( @{$way->{nd}} )>1; print $fh " <way id=\'$way_id\'"; - print $fh " timestamp=\'".$way->{timestamp}."\'" + print $fh " timestamp=\'".$way->{timestamp}."\'" if defined $way->{timestamp}; print $fh ">"; - + for my $way_nd ( @{$way->{nd}} ) { next unless $way_nd; print $fh " <nd ref=\'$way_nd\' />\n"; @@ -120,7 +120,7 @@ sub write_osm_file($$) { # Write an osm File print $fh tags2osm($way); print $fh " </way>\n"; $count_ways++; - + } print $fh "</osm>\n"; diff --git a/navit/script/osm/border_follower.pl b/navit/script/osm/border_follower.pl index 3a5b31167..2ce699798 100755 --- a/navit/script/osm/border_follower.pl +++ b/navit/script/osm/border_follower.pl @@ -122,10 +122,10 @@ do { } } if ($count == 0) { - error "No connection" - } else { + error "No connection" + } else { if ($count > 1) { - error "Multiple connections ($count)" + error "Multiple connections ($count)" } else { $path="$path $wayid"; } diff --git a/navit/script/wiki2def b/navit/script/wiki2def index bbbbb5ba2..901f6d05e 100755 --- a/navit/script/wiki2def +++ b/navit/script/wiki2def @@ -29,9 +29,9 @@ EOT done type="n" wget -O - "http://wiki.navit-project.org/index.php/Item_def.h?action=edit" | -awk '/<textarea/,/<\/textarea/ { print $0 }' | +awk '/<textarea/,/<\/textarea/ { print $0 }' | grep "^| " | -sed -e 's/^| *//' -e 's/ *$//' -e 's/ *|/|/g' -e 's/| */|/g' -e 's/||/|/g' | +sed -e 's/^| *//' -e 's/ *$//' -e 's/ *|/|/g' -e 's/| */|/g' -e 's/||/|/g' | while read id item description osmtags dummy do if [[ "$id" == colspan=* ]] |