diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-05-18 10:01:53 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2008-05-18 10:01:53 +0000 |
commit | 0b74d7f4ee6d448ac811e2741e8cb1ed04f5ce76 (patch) | |
tree | be7bb1cb1020f4022e41c004e2fa9d561ea3580d /navit/script | |
parent | f46eb419c46011d6d103b7f06cb2c842a2cbe6c9 (diff) | |
download | navit-0b74d7f4ee6d448ac811e2741e8cb1ed04f5ce76.tar.gz |
Fix:Core:Renamed src to navit for cleanup of includes
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@1059 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/script')
-rwxr-xr-x | navit/script/check_itemdef | 26 | ||||
-rw-r--r-- | navit/script/download_index.html | 145 | ||||
-rwxr-xr-x | navit/script/geotag | 36 | ||||
-rwxr-xr-x | navit/script/get_map | 5 | ||||
-rwxr-xr-x | navit/script/gps_emu | 19 | ||||
-rwxr-xr-x | navit/script/gps_emu2 | 46 | ||||
-rwxr-xr-x | navit/script/gps_emu3 | 12 | ||||
-rw-r--r-- | navit/script/mapExtract.class.php | 283 | ||||
-rw-r--r-- | navit/script/map_index.php | 42 | ||||
-rw-r--r-- | navit/script/mapextract.php | 225 | ||||
-rwxr-xr-x | navit/script/wiki2def | 37 |
11 files changed, 876 insertions, 0 deletions
diff --git a/navit/script/check_itemdef b/navit/script/check_itemdef new file mode 100755 index 000000000..361f87be3 --- /dev/null +++ b/navit/script/check_itemdef @@ -0,0 +1,26 @@ +#! /bin/sh +function check_item +{ + grep -q "[(,]$1)" ../item_def.h || echo "$1 missing" +} + +echo osm2navit.c +egrep '^ "[nw] +[^ ]+ +[^ ]+ +' ../osm2navit.c | sed "s/.* //" | +while read -r x +do + check_item "${x%%\\n\"}" +done + +echo "navit.xml" +grep '<item type="' <../navit.xml | cut -d \" -f 2 | tr "," "\012" | +while read -r x +do + check_item "$x" +done + +echo "garmintypes.txt" +grep ^0x ../data/garmin/garmintypes.txt | sed -e 's/[A-Z][A-Z]*, //' -e 's/.*= \([^,]*\),.*/\1/' | +while read -r x +do + check_item "$x" +done diff --git a/navit/script/download_index.html b/navit/script/download_index.html new file mode 100644 index 000000000..51ca2cf66 --- /dev/null +++ b/navit/script/download_index.html @@ -0,0 +1,145 @@ +<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Planet Extraction</title>
+ <style type="text/css">
+ html, body {
+ margin: 0;
+ padding: 1em;
+ font: 0.9em Verdana, Arial, sans serif;
+ }
+ input, select, textarea {
+ font: 1em Verdana, Arial, sans serif;
+ }
+ .input {
+ border: none;
+ width: 100px;
+ }
+ .bbox {
+ font-size: 12px;
+ color: #000;
+ background-color: #fff;
+ width: 300px;
+ border: 1px solid gray;
+ }
+ .button {
+ width: 200px;
+ height: 50px;
+ font-weight: bold;
+ }
+ #map {
+ float: left;
+ width: 500px;
+ height: 500px;
+ border: 1px solid gray;
+ }
+ #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'});
+
+ 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++) {
+ if (polygonLayer.features[i] != feature) {
+ old.push(polygonLayer.features[i]);
+ }
+ }
+ 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;
+ document.form.bounds_left.value = bounds.left;
+ bbox_set=true;
+ }
+ function download() {
+ var bbox = document.form.bounds_left.value + "," +
+ document.form.bounds_btm.value + "," +
+ document.form.bounds_right.value + "," +
+ document.form.bounds_top.value;
+ if (bbox_set) {
+ location.href="http://maps.navit-project.org/api/map?bbox=" + bbox;
+ } else {
+ alert("Please select a bounding box first\n");
+ }
+ }
+ function setOptions(options) {
+ polygonControl.handler.setOptions(options);
+ }
+ function setSize(fraction) {
+ var radius = fraction * map.getExtent().getHeight();
+ polygonControl.handler.setOptions({radius: radius,
+ angle: 0});
+ }
+ </script>
+ </head>
+ <body onload="init()">
+ <h2>Planet extract</h2>
+ <div id="map"></div>
+ <div id="controls">
+ <ul style="list-style:none;"><b>Map Controls</b>
+ <li>
+ <input type="radio" name="type"
+ value="none" id="noneToggle"
+ onclick="polygonControl.deactivate()"
+ checked="checked" />
+ <label for="noneToggle">navigate</label>
+ </li>
+ <li>
+ <input type="radio" name="type"
+ value="polygon" id="polygonToggle"
+ onclick="polygonControl.activate()" />
+ <label for="polygonToggle">select</label>
+ </li>
+ </ul>
+ <ul style="list-style:none"><b>Fetch box</b>
+ <form name="form">
+ <li>Top Right: <input type="text" name="bounds_top" class="input">,
+ <input type="text" name="bounds_right" class="input"></li>
+ <li>Bottom left: <input type="text" name="bounds_btm" class="input">,
+ <input type="text" name="bounds_left" class="input"></li>
+ </form>
+ <li> </li>
+ <li><input type="button" value="Get map!" onclick="javascript:download()"></li>
+ </ul>
+ </div>
+ </body>
+</html>
diff --git a/navit/script/geotag b/navit/script/geotag new file mode 100755 index 000000000..e025cbc61 --- /dev/null +++ b/navit/script/geotag @@ -0,0 +1,36 @@ +#! /bin/sh +#TZ=UTC+00:00:00 +TZ=UTC+00:59:57 +export TZ +order=${5%%,*} +case $order in +10|11) + size=1000 + ;; +12|13) + size=4000 + ;; +14|15) + size=16000 + ;; +16|17|18|19) + size=64000 + ;; +*) + exit +esac +ls -l --full-time images/*.jpg | sed -e 's/^\([^ ]* \)\{5\}//' -e 's/20\([0-9]*\)-\([0-9]*\)-\([0-9]*\) \([0-9]*\):\([0-9]*\):\([0-9]*\)\.[0-9]* [^ ]*/\\$GPRMC,\4\5\6\\.000,\\([^,]*,\\)\\{7\\}\3\2\1,\\([^,]*,\\)\\{2\\}[^,]*\\*..$/' | tail +2 | +while read -r sentence image +do + if [ ! -f $image.$size ] + then + djpeg -scale 1/8 $image | pamscale -pixels $size | cjpeg >$image.$size + + fi + if [ ! -f $image.txt ] + then + grep -e "$sentence" tracks/* | sed -e 's/^\([^,]*,\)\{3\}\(\([^,]*,\)\{4\}\).*/\2/' -e 's/,/ /g' > $image.txt + [ -s $image.txt ] || echo "$sentence not found" >&2 + fi + sed "s&\$&type=poi_image label=$image.$size&" <$image.txt +done diff --git a/navit/script/get_map b/navit/script/get_map new file mode 100755 index 000000000..7c8ef970f --- /dev/null +++ b/navit/script/get_map @@ -0,0 +1,5 @@ +#! /bin/bash +echo "/* XPM */" >map.xpm +req="<MapRequest reqVer='100' format='jpeg' visibleRoutes='111111111' colorDepth='4'><Rect l='0' t='0' r='$1' b='$2'></Rect><Rect l='$3' t='$4' r='$5' b='$6'></Rect></MapRequest>" +perl -e 'print (pack("a20",length($ARGV[0]))) ; print $ARGV[0]' "$req" | netcat localhost 10371 | dd bs=20 skip=1 2>/dev/null | tail +2 >>map.xpm +xv map.xpm & diff --git a/navit/script/gps_emu b/navit/script/gps_emu new file mode 100755 index 000000000..f2eef3e50 --- /dev/null +++ b/navit/script/gps_emu @@ -0,0 +1,19 @@ +#! /bin/bash +function send_data +{ + trap send_data SIGPIPE + while read line + do + case $line in + \$GPVTG*) + echo "$line" + sleep 1 + ;; + *) + echo "$line" + ;; + esac + done <track/all.txt >/tmp/gpsdata +} + +send_data diff --git a/navit/script/gps_emu2 b/navit/script/gps_emu2 new file mode 100755 index 000000000..e9e79b42a --- /dev/null +++ b/navit/script/gps_emu2 @@ -0,0 +1,46 @@ +#! /usr/bin/perl + +open(FILE,"<$ARGV[0]"); +read(FILE,$header,64); + +($magic,$version)=unpack("a8l",$header); + +#print "magic=$magic version=$version\n"; + +select STDOUT; $| = 1; + +$count=$ARGV[1]; +while ($count) { + read(FILE,$record,64); + $count--; +} + +while (read(FILE,$record,64)) +{ + ($flags,$status,$mode,$hdop,$vdop,$pdop,$sats,$timestampl,$timestamph,$latitude,$longitude,$altitude,$speed,$direction)=unpack("SCCCCCCLLddddd",$record); + + + 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); + $long_dir="E"; + $lat_dir="N"; + if ($longitude < 0) { + $long_dir="W"; + $logitude=-$longitude; + } + if ($latitude < 0) { + $lat_dir="S"; + $latitude=-$latitude; + } + $long_deg=int($longitude); + $lat_deg=int($latitude); + $long_gps=$long_deg*100+($longitude-$long_deg)*60; + $lat_gps=$lat_deg*100+($latitude-$lat_deg)*60; + $lastpos="$lat_gps $lat_dir $long_gps $long_dir"; + printf("\$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); + 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/gps_emu3 b/navit/script/gps_emu3 new file mode 100755 index 000000000..5c0ecf256 --- /dev/null +++ b/navit/script/gps_emu3 @@ -0,0 +1,12 @@ +#! /bin/bash +while read line +do + if [ -n "$line" ] + then + echo $line + fi + if [ "${line#\$GPVTG}" != "$line" ] + then + sleep 1 + fi +done <$1 diff --git a/navit/script/mapExtract.class.php b/navit/script/mapExtract.class.php new file mode 100644 index 000000000..f5c4bbbc3 --- /dev/null +++ b/navit/script/mapExtract.class.php @@ -0,0 +1,283 @@ +<?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" . "ziptime"; # time + $formats['zipheader'] .= "/s" . "zipdate"; # date + $formats['zipheader'] .= "/l" . "zipcrc"; # crc checksum + $formats['zipheader'] .= "/L" . "zipsize"; # data size + $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/". + "c" . "zipcver/". + "c" . "zipcos/". + "c" . "zipcvxt/". + "c" . "zipcexos/". + "s" . "zipcflg/". + "s" . "zipcmthd/". + "s" . "ziptim/". + "s" . "zipdat/". + "i" . "zipccrc/". + "I" . "zipcsiz/". + "I" . "zipcunc/". + "S" . "zipcfnl/". + "S" . "zipcxtl/". + "S" . "zipccml/". + "S" . "zipdsk/". + "S" . "zipint/". + "I" . "zipext/". + "I" . "zipofst"; + + $formats['zipeocpack'] = "iSSSSIIs"; + $formats['zipeoc'] = "". + "i" . "zipesig/". + "S" . "zipedsk/". + "S" . "zipecen/". + "S" . "zipenum/". + "S" . "zipecenn/". + "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"; + } + # + if (!$this->input_fd) { + return "No useable input set"; + } + if (!$this->output_fd) { + return "No useable output set"; + } + $filecount = 0; + $offset = 0; + $zipcd_data = ''; + $report = array(); + + /** + * Read through zipheaders + * + */ + for(;;) { + $buffer = fread($this->input_fd, 30); + if (! strlen($buffer)) + break; + $tileinfo = unpack($this->formats['zipheader'], $buffer); + + 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); + 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']; + $r['l']['y'] = $c['y']; + break; + case 'b': + $r['h']['x'] = $c['x']; + $r['l']['y'] = $c['y']; + break; + case 'c': + $r['l']['x'] = $c['x']; + $r['h']['y'] = $c['y']; + break; + case 'd': + $r['h']['x'] = $c['x']; + $r['h']['y'] = $c['y']; + break; + default: + $done=true; + } + if ($done) + break; + } + # print "zipsize=" . $tileinfo['zipsize']; + $tilecontent = fread($this->input_fd, $tileinfo['zipsize']); + + # 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'], + $tileinfo['ziplocsig'], + $tileinfo['zipver'], + $tileinfo['zipgenfld'], + $tileinfo['zipmthd'], + $tileinfo['ziptime'], + $tileinfo['zipdate'], + $tileinfo['zipcrc'], + $tileinfo['zipsize'], + $tileinfo['zipuncmp'], + $tileinfo['zipfnln'], + $tileinfo['zipxtraln'] + ); + } + + $put = $zipheader.$filename.$tilecontent; + + /* Zip directory */ + $zipcd_data .= pack($this->formats['zipcdpack'], + 0x02014b50, + $tileinfo['zipver'], + 0x00, + 0x0a, + 0x00, + 0x00, + $tileinfo['zipmthd'], + $tileinfo['ziptime'], + $tileinfo['zipdate'], + $tileinfo['zipcrc'], + $tileinfo['zipsize'], + $tileinfo['zipuncmp'], + $tileinfo['zipfnln'], + 0x00, + 0x00, + 0x00, + 0x00, + 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'], + 0x06054b50, #zipesig; + 0, #zipedsk; + 0, #zipecen; + $filecount, #zipenum; + $filecount, #zipecenn; + $ecsz, #zipecsz; + $offset, #zipeofst; + 0 #zipecoml; + ); + fwrite($this->output_fd, $zip_eoc); + + + return null; + } + + function setBbox($sx,$sy,$ex,$ey) { + if ($ex<$sx) + return false; + if ($ey<$sy) + return false; + $this->fetchBbox = $this->getmercator($sx,$sy,$ex,$ey); + return true; + } + + function setInput($file) { + $this->input_fd=fopen($file,'r'); + } + function setInputFD($fd) { + $this->input_fd=$fd; + } + + function setOutput($file) { + $this->output_fd=fopen($file,'w'); + } + + function setOutputFD($fd) { + $this->output_fd=$fd; + } + + + function contains_bbox(&$r) { + $c =& $this->fetchBbox; + if ($c['l']['x'] > $r['h']['x']) + return false; + elseif ($c['h']['x'] < $r['l']['x']) + return false; + elseif ($c['l']['y'] > $r['h']['y']) + return false; + elseif ($c['h']['y'] < $r['l']['y']) + return false; + 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( + 'l' => array( + 'x' => $sx, + 'y' => $sy + ), + 'h' => array( + 'x' => $ex, + 'y' => $ey + ) + ); + } + +} + + +?> diff --git a/navit/script/map_index.php b/navit/script/map_index.php new file mode 100644 index 000000000..b71dbac6a --- /dev/null +++ b/navit/script/map_index.php @@ -0,0 +1,42 @@ +<?php + set_time_limit(600); + require_once("mapExtract.class.php"); + $bbox=split(',',urldecode($HTTP_GET_VARS['bbox'])); + if (count($bbox) == 4) { + $mapextract = new mapExtract(); + $mapextract->setBbox($bbox[0], $bbox[1], $bbox[2], $bbox[3]); + $fp=fopen('php://output','w'); + $mapextract->setInput('../../planet.bin'); + $mapextract->setOutputFD($fp); + if(isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')) + header('Content-Type: application/force-download'); + else + header('Content-Type: application/octet-stream'); + $name='osm_bbox_'; + $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\""); + $error=$mapextract->process(); + if ($error) { + header('Content-Type: text/plain'); + echo $error; + } + fclose($fp); + } else { + #echo "<pre>"; + #print_r($HTTP_HOST); + #echo "</pre>"; + $areas=array( + 'Germany' => '5,47,16,55.1', + ); + $url='http://' . $HTTP_HOST . $PHP_SELF; + echo "Use: $url?bbox=bllon,bllat,trlon,trlat <br />\n"; + echo "<br />\n"; + while (list($area,$bbox)=each($areas)) { + $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 new file mode 100644 index 000000000..004b63caf --- /dev/null +++ b/navit/script/mapextract.php @@ -0,0 +1,225 @@ +#!/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,
+ 'y' => $sy
+ ),
+ 'h' => array(
+ 'x' => $ex,
+ 'y' => $ey
+ )
+ );
+
+}
+function contains_bbox($c, &$r) {
+ if ($c['l']['x'] > $r['h']['x'])
+ return false;
+ elseif ($c['h']['x'] < $r['l']['x'])
+ return false;
+ elseif ($c['l']['y'] > $r['h']['y'])
+ return false;
+ elseif ($c['h']['y'] < $r['l']['y'])
+ return false;
+ else
+ return true;
+}
+
+$fetch_bbox = getmercator(11.3, 47.9, 11.4, 48.0);
+
+$files = array();
+$files['input'] = '/home/burner/carputer/navit/src/maps/osm_bbox_11.3,47.9,11.7,48.2.bin';
+$files['output'] = 'myarea.bin';
+
+$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" . "ziptime"; # time
+$formats['zipheader'] .= "/s" . "zipdate"; # date
+$formats['zipheader'] .= "/l" . "zipcrc"; # crc checksum
+$formats['zipheader'] .= "/L" . "zipsize"; # data size
+$formats['zipheader'] .= "/L" . "zipuncmp"; # uncompressed size
+$formats['zipheader'] .= "/S" . "zipfnln"; # length of filename
+$formats['zipheader'] .= "/S" . "zipxtraln";# length of extra data (always 0)
+
+$formats['zipcd'] = "".
+ "i" . "zipcensig/".
+ "c" . "zipcver/".
+ "c" . "zipcos/".
+ "c" . "zipcvxt/".
+ "c" . "zipcexos/".
+ "s" . "zipcflg/".
+ "s" . "zipcmthd/".
+ "s" . "ziptim/".
+ "s" . "zipdat/".
+ "i" . "zipccrc/".
+ "I" . "zipcsiz/".
+ "I" . "zipcunc/".
+ "S" . "zipcfnl/".
+ "S" . "zipcxtl/".
+ "S" . "zipccml/".
+ "S" . "zipdsk/".
+ "S" . "zipint/".
+ "I" . "zipext/".
+ "I" . "zipofst/".
+$formats['zipcdpack'] = "iccccssssiIISSSSSII";
+
+$formats['zipcontent'] = "i5x/i5y/ii";
+
+$world_bbox = array();
+$world_bbox['l']['x'] = -20000000;
+$world_bbox['l']['y'] = -20000000;
+$world_bbox['h']['x'] = 20000000;
+$world_bbox['h']['y'] = 20000000;
+
+$fp = fopen($files['input'], 'r');
+$sp = fopen($files['output'], 'w');
+
+$files = array();
+$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'];
+ $r['l']['y'] = $c['y'];
+ break;
+ case 'b':
+ $r['h']['x'] = $c['x'];
+ $r['l']['y'] = $c['y'];
+ break;
+ case 'c':
+ $r['l']['x'] = $c['x'];
+ $r['h']['y'] = $c['y'];
+ break;
+ case 'd':
+ $r['h']['x'] = $c['x'];
+ $r['h']['y'] = $c['y'];
+ break;
+ default:
+ $done=true;
+ }
+ $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'],
+ $tileinfo['ziplocsig'],
+ $tileinfo['zipver'],
+ $tileinfo['zipgenfld'],
+ $tileinfo['zipmthd'],
+ $tileinfo['ziptime'],
+ $tileinfo['zipdate'],
+ $tileinfo['zipcrc'],
+ $tileinfo['zipsize'],
+ $tileinfo['zipuncmp'],
+ $tileinfo['zipfnln'],
+ $tileinfo['zipxtraln']
+ );
+ }
+
+ $put = $zipheader.$filename.$tilecontent;
+ $files[$filename]['header'] = $tileinfo;
+ $files[$filename]['size'] = strlen($put);
+
+ $zipcd = array();
+ $zipcd['zipcensig'] = 0x02014b50;
+ $zipcd['zipcver'] = $tileinfo['zipver'];
+ $zipcd['zipcos'] = 0x00;
+ $zipcd['zipcvxt'] = 0x0a;
+ $zipcd['zipcexos'] = 0x00;
+ $zipcd['zipcflg'] = 0x00;
+ $zipcd['zipcmthd'] = $tileinfo['zipmthd'];
+ $zipcd['ziptim'] = $tileinfo['ziptime'];
+ $zipcd['zipdat'] = $tileinfo['zipdate'];
+ $zipcd['zipccrc'] = $tileinfo['zipcrc'];
+ $zipcd['zipcsiz'] = $tileinfo['zipsize'];
+ $zipcd['zipcunc'] = $tileinfo['zipuncmp'];
+ $zipcd['zipcfnl'] = $tileinfo['zipfnln'];
+ $zipcd['zipcxtl'] = 0x00;
+ $zipcd['zipccml'] = 0x00;
+ $zipcd['zipdsk'] = 0x00;
+ $zipcd['zipint'] = 0x00;
+ $zipcd['zipext'] = 0x00;
+ $zipcd['zipofst'] = $offset;
+
+ $zipcd_data .= pack($formats['zipcdpack'],
+ $zipcd['zipcensig'],
+ $zipcd['zipcver'],
+ $zipcd['zipcos'],
+ $zipcd['zipcvxt'],
+ $zipcd['zipcexos'],
+ $zipcd['zipcflg'],
+ $zipcd['zipcmthd'],
+ $zipcd['ziptim'],
+ $zipcd['zipdat'],
+ $zipcd['zipccrc'],
+ $zipcd['zipcsiz'],
+ $zipcd['zipcunc'],
+ $zipcd['zipcfnl'],
+ $zipcd['zipcxtl'],
+ $zipcd['zipccml'],
+ $zipcd['zipdsk'],
+ $zipcd['zipint'],
+ $zipcd['zipext'],
+ $zipcd['zipofst']
+ ) . $filename;
+
+
+ fwrite($sp, $put);
+ $offset += strlen($put);
+
+}
+
+fwrite($sp, $zipcd_data);
+
+fclose($fp);
+fclose($sp);
+
+?>
diff --git a/navit/script/wiki2def b/navit/script/wiki2def new file mode 100755 index 000000000..ab8349358 --- /dev/null +++ b/navit/script/wiki2def @@ -0,0 +1,37 @@ +#! /bin/bash +rm -f item_def.h.wiki +rm -f osmmap_def.h.wiki +IFS="|" +echo "/* This file is generated from http://wiki.navit-project.org/index.php/Item_def.h, do not edit it, edit the wiki page instead */" >item_def.h.wiki +echo "/* This file is generated from http://wiki.navit-project.org/index.php/Item_def.h, do not edit it, edit the wiki page instead */" >osmmap_def.h.wiki +type="n" +wget -O - "http://wiki.navit-project.org/index.php/Item_def.h?action=edit" | +awk '/<textarea/,/<\/textarea/ { print $0 }' | +grep "^| " | +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=* ]] + then + echo "/* $item */" >>item_def.h.wiki + continue + fi + if [[ -z "$id" ]] + then + echo "ITEM($item)" >>item_def.h.wiki + else + echo "ITEM2($id,$item)" >>item_def.h.wiki + if [ "$id" == "0x80000000" ] + then + type="w" + fi + fi + if [[ -n "$osmtags" ]] + then + for osmtag in $(echo "$osmtags" | sed 's/<br\/>/|/g') + do + printf '"%s\t%s\t%s\t%s\\n"\n' $type $osmtag $item >> osmmap_def.h.wiki + done + fi +done +exit 0 |