Difference between revisions of "User:Korrosa"

From Navit's Wiki
Jump to: navigation, search
(Speed camera OSD items from patch at 702)
(Android development environment)
 
(25 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
{{Userboxtop|}}
 +
{{User irc|korrosa}}
 +
{{User trac|korrosa}}
 +
{{user gb}}
 +
{{user en}}
 +
{{user nl}}
 +
{{user fr-1}}
 +
{{programming php}}
 +
{{programming javascript}}
 +
{{os linux}}
 +
{{os windows}}
 +
{{Userboxbottom|}}
 +
 +
=UK Postcode search with Navit=
 +
Using an external file containing full postcode centroids in lat/lon, a script can be used to pass the relevant postcode to Navit via dbus. This method was developed on Ubuntu (Linux). Postcodes do not include NI.
 +
 +
==Quickstart==
 +
# [[Dbus#Enabling | Enable dbus in navit.xml]]
 +
# Download the script and postcode file from: http://www.tiiiim.com/navit/p2n.tar.bz2 (23MB)
 +
# In the script, change the path to the postcode file. Set the executable bit of the script, then call the script with the postcode as arguments:
 +
 +
./p2n BA2 4HJ
 +
 +
If the postcode is valid, choose from the option to centre the map to the postcode, route to the postcode or set the postcode as your position.
 +
 +
==More Info==
 +
 +
===The script===
 +
The script is written in php, and requires <tt>php5-cli</tt> to be installed on your system.
 +
sudo apt-get install php5-cli
 +
 +
The script is shown below:
 +
{| width="100%" class="collapsible collapsed wikitable"
 +
|-
 +
! Postcode script (PHP)
 +
|-
 +
|
 +
<pre>
 +
#! /usr/bin/php5
 +
 +
<?php
 +
 +
$csvfilename="/home/netbook/.navit/maps/pc_lat_lon_gb.csv";
 +
 +
if($argc>=2){
 +
 +
// Add arguments to array
 +
$arr_postcode = $argv;
 +
// Remove name of script from array
 +
array_shift($arr_postcode);
 +
// Extract clean postcode from array
 +
$postcode = parse_postcode($arr_postcode);
 +
 +
echo "Searching for ". $postcode ." ... ";
 +
 +
if(!$file_handle = open_file($csvfilename)){
 +
exit("Error opening file. Check file is valid.\n");
 +
}
 +
 +
// Try searching for the postcode using divide and conquer algorithm
 +
if($array_postcode = pc2coord($postcode,$file_handle)){
 +
// DEBUG
 +
#print_r($array_postcode);
 +
}
 +
else{
 +
// Get first letter of the postcode
 +
$postcode_id = substr($postcode,0,1);
 +
// DEBUG
 +
#echo $postcode_id."\n";
 +
 +
// Set pointer to start of postcode letter
 +
$array_postcode = pc2coord($postcode_id,$file_handle);
 +
// DEBUG
 +
#print_r($array_postcode);
 +
 +
// Slowly go through the file to find the postcode
 +
$array_postcode = pc2coord_slow($postcode,$file_handle,$array_postcode[3]);
 +
// DEBUG
 +
#print_r($array_postcode);
 +
}
 +
 +
close_file($file_handle);
 +
 +
if($array_postcode){
 +
echo "Found  ".$array_postcode[0]. ": " .$array_postcode[1]." ".$array_postcode[2]."\n";
 +
 +
$keyboard = fopen("php://stdin","r");
 +
 +
echo "[R]oute to postcode, [v]iew postcode or set as [p]osition\n";
 +
 +
$answer = strtoupper(fgets($keyboard,2));
 +
 +
if($answer=="R"){
 +
echo "Routing to postcode.\n";
 +
navit_dbus("navit","set_destination","string:\"geo: ".$array_postcode[2]." ".$array_postcode[1]."\" string:\"Post Code Point\"");
 +
navit_dbus("navit","draw");
 +
}
 +
elseif($answer=="V"){
 +
echo "Centering map.\n";
 +
navit_dbus("navit","set_center_by_string","string:\"geo: ".$array_postcode[2]." ".$array_postcode[1]."\"");
 +
navit_dbus("navit","draw");
 +
}
 +
elseif($answer=="P"){
 +
echo "Setting as position.\n";
 +
navit_dbus("navit","set_position","string:\"geo: ".$array_postcode[2]." ".$array_postcode[1]."\"");
 +
navit_dbus("navit","draw");
 +
}
 +
else{
 +
echo "No choice made. Exit\n";
 +
}
 +
}
 +
else{
 +
echo "Postcode not found. Please try again.\n";
 +
}
 +
 +
}
 +
else{
 +
echo "No postcode specified. Please try again.\n";
 +
}
 +
 +
function open_file($filename){
 +
// Open file for reading and return handle
 +
return fopen($filename,"r");
 +
}
 +
 +
function close_file($file_handle){
 +
return fclose($file_handle);
 +
}
 +
 +
function parse_postcode($arr_postcode){
 +
# Clean up postcode formatting
 +
if(count($arr_postcode)>1){
 +
# There is more than one string in the postcode
 +
if(strlen($arr_postcode[0])<=3){
 +
# Postcode format entered is "B29 5AU"
 +
$postcode = strtoupper($arr_postcode[0]. " " . $arr_postcode[1]);
 +
}
 +
else{
 +
# Postcode format entered is "BN15 9RJ"
 +
$postcode = strtoupper($arr_postcode[0]. "" . $arr_postcode[1]);
 +
}
 +
}
 +
else{
 +
# Postcode is made up of only one string
 +
if(strlen($arr_postcode[0])<=6){
 +
# Postcode format entered is "B299RJ"
 +
$postcode = str_split($arr_postcode[0],3);
 +
$postcode = strtoupper($postcode[0] . " " . $postcode[1]);
 +
}
 +
else{
 +
# Postcode format entered is "BN159RJ"
 +
$postcode = strtoupper($arr_postcode[0]);
 +
}
 +
}
 +
 +
return $postcode;
 +
}
 +
 +
function navit_dbus($path,$method,$arguments=""){
 +
// Executes a dbus command, with the specified parameters.
 +
// Returns the dbus return as a string
 +
return shell_exec("dbus-send  --print-reply --session --dest=org.navit_project.navit /org/navit_project/navit/default_navit org.navit_project.navit.".$path.".".$method." ".$arguments);
 +
}
 +
 +
function pc2coord($postcode,$csvfilehandle){
 +
 +
$low=0;
 +
$found = false;
 +
 +
fseek($csvfilehandle,0,SEEK_END);
 +
$high=ftell($csvfilehandle);
 +
 +
while($low<=$high){
 +
// Move to mid point between low and high
 +
$mid=floor(($low+$high)/2);
 +
fseek($csvfilehandle, $mid);
 +
 +
// Moves to end of line
 +
$line=fgets($csvfilehandle); // Is this actually doing anything of value?
 +
 +
// Turn line into an array.
 +
$array_postcode_data=fgetcsv($csvfilehandle, 100, ",");
 +
 +
// Extract the postcode
 +
$csv_postcode = $array_postcode_data[0];
 +
#echo $csv_postcode;
 +
 +
// Compare postcodes
 +
$compare = strncasecmp($array_postcode_data[0],$postcode,7);
 +
 +
if(!$compare){
 +
#echo " Found it!\n";
 +
#echo $array_postcode_data[1].",".$array_postcode_data[2]."\n";
 +
$low=999999999;
 +
$found=true;
 +
//break;
 +
}
 +
elseif($compare<0){
 +
$low=$mid+1;
 +
#echo " Move up"."\n";
 +
}
 +
elseif($compare>0){
 +
$high=$mid-1;
 +
#echo " Move down"."\n";
 +
}
 +
else{
 +
echo "Something's gone wrong.\n";
 +
$low=999999999;
 +
}
 +
}
 +
 +
$array_postcode_data[] = $mid;
 +
 +
unset($line);
 +
if($found)
 +
return $array_postcode_data;
 +
else
 +
return false;
 +
}
 +
 +
function pc2coord_slow($postcode,$csvfilehandle,$line){
 +
$found = false;
 +
$postcode_id = substr($postcode,0,1);
 +
 +
fseek($csvfilehandle, $line-1);
 +
 +
while (!feof($csvfilehandle)) {
 +
 +
$array_postcode_data = fgetcsv($csvfilehandle, 44, ",");
 +
 +
#echo $array_postcode_data[0]." --> ".$postcode."\n";
 +
 +
if(trim($array_postcode_data[0]) == trim($postcode)){
 +
$found=true;
 +
break;
 +
}
 +
 +
// Stop checking if the postcode id becomes different
 +
if(substr($array_postcode_data[0],0,1)!=$postcode_id){
 +
break;
 +
}
 +
}
 +
 +
if($found)
 +
return $array_postcode_data;
 +
else
 +
return false;
 +
}
 +
 +
?>
 +
</pre>
 +
|}
 +
 +
===The postcode file===
 +
The postcode data comes from Ordnance Survey CodePoint Open data: https://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/index.html. The original data uses OSGB Northing and Easting to define the postcode centroids, but the data can be processed into a csv file with lat/lon coordinates using the method found here: http://baroque.posterous.com/uk-postcode-latitudelongitude. The result of this method is what's included in the download at http://www.tiiiim.com/navit/p2n.tar.bz2.
 +
 
=OSM Layout=
 
=OSM Layout=
 
[http://wiki.navit-project.org/index.php/Layouts/mapnik Mapnik-style rendering]
 
[http://wiki.navit-project.org/index.php/Layouts/mapnik Mapnik-style rendering]
Line 21: Line 277:
 
*Plans to also use speed camera data in OSM
 
*Plans to also use speed camera data in OSM
  
==Configuration==
+
==Use==
 
+
To use the ''speed_cam'' OSD type, the following OSD item must be added to navit.xml. This of course assumes that you have patched navit with the patch at {{Trac|702}}:
     <osd enabled="yes" type="speed_cam" w="500" h="40"  x="30" y="350" font_size="450" text_color="#FF0000" announce_on="0" label=" ${distance} | ${camera_type} | ${camera_dir} | ${direction} | ${speed_limit}" />
+
     <osd enabled="yes" type="speed_cam" w="500" h="40"  x="30" y="350" font_size="450" text_color="#FF0000" announce_on="0" label=" ${distance} | ${camera_type} | ${camera_dir} | ${direction} | ${speed_limit}" path="speed_cam_data.txt" />
 
 
  
 +
===Configuration===
 
Most parts are self explanatory:
 
Most parts are self explanatory:
* '''announce_on''' is set by default to 1 (i.e. this osd item will announce upcoming cameras with a "Look out! Camera!" warning
+
* '''announce_on''' is set by default to 1 (i.e. this osd item will announce upcoming cameras with a "Look out! Camera!" warning) if this attribute is not set.
 
* '''label''' can display the following variables. The values in ''${STRING}'' are replaced with the appropriate number or word when running Navit:
 
* '''label''' can display the following variables. The values in ''${STRING}'' are replaced with the appropriate number or word when running Navit:
 
** distance to the camera - ''${distance}''
 
** distance to the camera - ''${distance}''
** type of camera - ''${camera_type}''. Possible types:
+
** type of camera - ''${camera_type}''. See [[User:Korrosa#Camera Types]] for possible types:
*** None
 
*** Fix
 
*** Traffic lamp
 
*** Red detect
 
*** Section
 
*** Mobile
 
*** Rail
 
*** Traffipax(non persistent)
 
 
** direction in which the camera operates - ''${camera_dir}''
 
** direction in which the camera operates - ''${camera_dir}''
 
*** all
 
*** all
 
*** single direction
 
*** single direction
 
*** both directions
 
*** both directions
** direction of the camera - ''${direction}'' (0-360 degrees)
+
** direction which the camera is facing, in degrees (0-360, i.e. north, east, south, west etc) - ''${direction}''
 
** the active speed limit which the camera may be enforcing - ''${speed_limit}''
 
** the active speed limit which the camera may be enforcing - ''${speed_limit}''
  
 +
===Data Sources===
 +
Currently, the speed_cam OSD looks in the following locations for speed camera data, in the following order. Note that the speed_cam OSD will only use the first data source:
 +
* IGO8 file defined by the ''path='' attribute in the <osd /> tag
 +
* '''speedcam.txt''' IGO8 file in your default navit directory (usually ~/.navit)
 +
* Speed camera bin mapfile (see [[User:Korrosa#Creating camera bin mapfiles]]) defined in the currently active mapset.
 +
 +
Note that if you use one of the first two options, the cameras will not actually appear on the map, but will still be announced. Only by using a binfile will the cameras appear on the map.
 +
 +
==Creating camera bin mapfiles==
 +
The following steps will enable you to convert an IGO8 speed camera textfile into a Navit bin mapfile. The advantage is reduced resource usage when using a binfile, and that the cameras will appear on the map.
 +
* Using [http://trac.navit-project.org/attachment/ticket/702/igo2navittext.pl igo2navittext.pl], convert the IGO8 file into a standard navit textfile. The script reads its input on standard input and outputs navit textfile on stdout. Use in the following manner:
 +
    perl igo2navittext.pl  < speedcam.txt  > speedcam_navit.txt
 +
* Copy the resulting '''speedcam_navit.txt''' to the '''/navit/maps''' folder in the source tree.
 +
* Issue the following command in the '''maps''' folder:
 +
    make speedcam_navit.bin
 +
* Add the just-created '''speedcam_navit.bin''' to your active mapset in navit.xml. For example, having moved the binfile to ~/navit/maps:
 +
    <map type="binfile" enabled="yes" data="~/.navit/maps/speedcam_navit.bin"/>
 +
 +
Next time you start Navit the cameras should appear on the map. If they don't try changing the zoom settings of the ''tec_common'' item type in your map layout in navit.xml.
 +
 +
==Camera Types==
 +
* '''None'''
 +
* '''Fix'''
 +
** ''Type'': [http://en.wikipedia.org/wiki/Speed_limit_enforcement Fixed speed enforcement camera]
 +
** ''Enforces'': Speed
 +
** ''Description'': Probably the most common type of traffic enforcement camera. Usually located on the side of the road, and uses radar to detect vehicle speed. Can take photos from either the front or the rear. Front facing cameras tend to use IR flash guns, instead of traditional bulb flashes, to ensure that the driver does not get blinded.
 +
** ''Suggested English name'': Fixed.
 +
* '''Traffic lamp'''
 +
** ''Type'': Traffic light enforcement camera
 +
** ''Enforces'': Speed and/or red light (unsure)
 +
** ''Description'': These cameras seem to be located inside (?) traffic lights. It is unknown whether these are for speed, red light or both.
 +
** ''Suggested English name'': Traffic light.
 +
* '''Red detect'''
 +
** ''Type'': [http://en.wikipedia.org/wiki/Red_light_camera Red light enforcement camera]
 +
** ''Enforces'': Red light
 +
** ''Description'': Located close to traffic light controlled junctions, these cameras will detect if a car has run a red light. Usually, these cameras will face down the flow of traffic, thus take a picture from the rear.
 +
** ''Suggested English name'': Red light.
 +
* '''Section'''
 +
** ''Type'': [http://en.wikipedia.org/wiki/Average_Speed_Check Average speed check camera]
 +
** ''Enforces'': Speed
 +
** ''Description'': In the UK at least, these cameras are used a lot on motorway roadwork sections. CCTV ANPR cameras are located at strategic locations along the works, and take average speed readings of vehicles by reading their number plates. Nightime use is facilitated through the use of IR lamps.
 +
** ''Suggested English name'': Avg speed
 +
* '''Mobile'''
 +
** ''Type'': Mobile speed enforcement camera
 +
** ''Enforces'': Speed
 +
** ''Description'': There are many types of mobile cameras: common ones are hand-held cameras, either held by an officer from the police car window, or mounted on a tripod. Other types include those mounted on the police car dashboard or rear parcel shelf, or those which point through windows of special speed camera vans (common in the UK)
 +
** ''Suggested English name'': Mobile
 +
* '''Rail'''
 +
** ''Type'': Railway level crossing enforcement camera
 +
** ''Enforces'': barriers/access
 +
** ''Description'': Used at railway level crossings, to enforce any barriers or warning lights. It's usually an offence to enter the level crossing once you've been warned not to (however far away the train is), hence the cameras.
 +
** ''Suggested English name'': Level crossing
 +
* '''Traffipax(non persistent)'''
 +
** ''Type'': Mobile speed enforcement camera
 +
** ''Enforces'': Speed (?)
 +
** ''Description'': ''Note: this is conjecture at the moment.'' This seems to be a specific type of mobile speed camera.
 +
** ''Suggested English name'': Mobile
  
 
=Configuration=
 
=Configuration=
Line 55: Line 360:
 
** dbl = double
 
** dbl = double
  
{| style="border-style:solid;border-width:1px;border-color:#aaa;background: #FFFFFF;border-collapse: collapse;font-size: 95%;width:100%;" border="1" cellpadding="5"
+
=OpenStreetMap=
|+ Navit configuration options
+
''Drafting complete re-write of the [[OpenStreetMap]] page''
|-
+
 
! scope="col" | Tag
+
[[User:Korrosa/OpenStreetMap]]
! scope="col" | Attribute
+
 
! scope="col" | Units
+
 
! scope="col" | Values
+
 
! scope="col" | Notes
+
=Notable Tickets=
! scope="col" | Example
+
* sort items by distance in the adress search dialog {{trac|35}}
|- style="background:#EEEEEE"
+
* It'd be nice to have several waypoints, not only a destination {{trac|46}}
! scope="row" rowspan="11"| navit
+
* do not announce when following a curved way/road {{trac|171}}
|
+
* Incorrect ETA and TR - new method required? {{trac|417}}
|
+
* Change Default Menu that Appears {{trac|560}}
|
 
|
 
|
 
|- style="background:#EEEEEE"
 
| center
 
| coords
 
| <tt>DD.dd</tt> or <tt>DDMM.ss</tt>
 
| Map will be centred at these coordinates on startup. Coordinates are either in decimal degrees (with sign in front to denote N/S or E/W) or decimal minutes with trailing N/S or E/W where appropriate.<br />'''Default: <tt>53.13 11.70</tt>'''
 
| <tt>center="4808 N 1134 E"</tt>
 
|- style="background:#EEEEEE"
 
| orientation
 
|
 
| 0 / '''-1'''
 
| <tt>orientation="0"</tt>: Map oriented North.<br /><tt>orientation="-1"</tt>: Map oriented in direction of travel.<br />This is equivalent to selecting <tt>Settings -> Rules -> Northing</tt> in the internal gui.
 
| <tt>orientation="-1"</tt>
 
|- style="background:#EEEEEE"
 
| tracking
 
|
 
| 0 / '''1'''
 
| <tt>tracking="1"</tt>: Vehicle cursor will lock to the roads on the map.<br />This is equivalent to selecting <tt>Settings -> Rules -> Lock on road</tt> in the internal gui.
 
| <tt>tracking="1"</tt>
 
|- style="background:#EEEEEE"
 
| zoom
 
|
 
| 1 - &infin;<br /> '''256'''
 
| <tt>zoom="1"</tt>: Most zoomed in. Upper limit is actually 2097152.<br />Map will be zoomed in at this level on startup.
 
| <tt>zoom="50"</tt>
 
|-
 
| autozoom_active
 
|
 
| '''0''' / 1
 
| <tt>autozoom_active="0"</tt>: Autozoom disabled.<br /><tt>autozoom_active="1"</tt>: Autozoom enabled.<br />
 
| <tt>autozoom_active="1"</tt>
 
|-
 
| autozoom_secs
 
| seconds
 
| 1 - &infin;<br />'''10'''
 
| Number of seconds of the way ahead to leave visible during autozoom.<br /> In effect, this specifies the zoom level when autozoom is enabled.<br /><tt>autozoom_secs="1"</tt> is closest zoom.<br />This attribute has no effect without <tt>autozoom_active="1"</tt>.
 
| <tt>autozoom_secs="60"</tt>
 
|-
 
| pitch
 
| degrees
 
| 1 - 359
 
| <tt>pitch="0"</tt>: Bird's-eye view of map.<br /><tt>pitch="20"</tt>: Map tilted by 20 degrees to give 3D view.
 
| <tt>pitch="20"</tt>
 
|-
 
| radius
 
| percent
 
| 1 - 100<br />'''30'''
 
| Percentage of screen size to offset map from centre when moving.<br />This causes the map to "lead" the vehicle, showing more of where you're going and less of where you've been.
 
| <tt>radius="33"</tt>
 
|-
 
| recent_dest
 
|  
 
| 1 - &infin;<br />'''10'''
 
| Number of entries kept in destination.txt. This text file stores the most recent destinations set by the user in Navit.<br /> Default: &infin;
 
| <tt>recent_dest="20"</tt>
 
|-
 
| timeout
 
| gps updates
 
| 1 - &infin;<br />'''10'''
 
| When the user scrolls the map, it stays there. After <tt>timeout</tt> number of GPS updates the map jumps back to the current location of the active vehicle. (see {{Trac|653}})
 
| <tt>timeout="5"</tt>
 
  
|- style="background:#EEEEEE"
+
=Configuring Navit=
! scope="row" rowspan="2"| graphics
+
''Complete re-style of conifguration page''
|
 
|
 
|
 
| Insert inbetween <tt><navit> ... </navit></tt> tags
 
|
 
|- style="background:#EEEEEE"
 
| type
 
|
 
| <tt>gtk_drawing_area<br />qt_qpainter<br />sdl<br />opengl</tt>
 
| Type of graphics to use for display.
 
| <tt>graphics="gtk_drawing_area"</tt>
 
  
|- style="background:#EEEEEE"
+
[[User:Korrosa/Configuring Navit]]
! scope="row" rowspan="13"| gui
 
|
 
|
 
|
 
| Insert inbetween <tt><navit> ... </navit></tt> tags
 
|
 
|- style="background:#EEEEEE"
 
| type
 
|
 
| <tt>gtk<br />internal<br />qml<br />cegui</tt>
 
| Type of user interface to use
 
| <tt>type="internal"</tt>
 
|- style="background:#EEEEEE"
 
| enabled
 
|
 
| <tt>yes</tt> / <tt>no</tt>
 
| Enable this user interface. This attribute enables you to define multiple user interfaces within navit.xml (i.e. multiple <tt><gui> ... </gui></tt> tags), and quickly switch between them by changing the <tt>enabled</tt> status.
 
| <tt>enabled="yes"</tt>
 
|-
 
| font_size
 
| Pt fractions
 
| 1 - &infin;
 
| The base text size to use for text and labels in the menus. This only applies when <tt>type="internal"</tt>
 
| <tt>font_size="350"</tt>
 
|-
 
| icon_xs
 
| pixels
 
| 1 - &infin;
 
| The size that extra-small style icons should be scaled to (e.g. country flag on town search). This only applies when <tt>type="internal"</tt>
 
| <tt>icon_xs="32"</tt>
 
|-
 
| icon_s
 
| pixels
 
| 1 - &infin;
 
| The size that small style icons should be scaled to (e.g. icons of internal GUI toolbar). This only applies when <tt>type="internal"</tt>
 
| <tt>icon_s="96"</tt>
 
|-
 
| icon_l
 
| pixels
 
| 1 - &infin;
 
| The size that large style icons should be scaled to (e.g. icons of internal GUI menu). This only applies when <tt>type="internal"</tt>
 
| <tt>icon_l="96"</tt>
 
|-
 
| fullscreen
 
|
 
| 0 / 1
 
| <tt>fullscreen="1"</tt>: Start Navit in fullscreen mode
 
| <tt>fullscreen="1"</tt>
 
|-
 
| menubar
 
|
 
| 0 / 1
 
| Toggle display of the menu bar. This only applies when <tt>type="gtk"</tt>
 
| <tt>menubar="1"</tt>
 
|-
 
| menu_on_map_click
 
|
 
| 0 / '''1'''
 
| Toggles the ability to bring up the menu screen when clicking on the map. When using <tt>menu_on_map_click="0"</tt> it is recommended to use an [[OSD#button|OSD button]] with the [[OSD#Navit_commands|command <tt>gui.menu()</tt>]], or else you can't get to the menu screen! This only applies when <tt>type="internal"</tt>
 
| <tt>menu_on_map_click="0"</tt>
 
|-
 
| toolbar
 
|
 
| 0 / 1
 
| Toggle display of the toolbar. This only applies when <tt>type="gtk"</tt>
 
| <tt>toolbar="1"</tt>
 
|-
 
| statusbar
 
|
 
| 0 / 1
 
| Toggle display of the status bar. This only applies when <tt>type="gtk"</tt>
 
| <tt>statusbar="1"</tt>
 
|-
 
| skin
 
|
 
|
 
|
 
|
 
  
|- style="background:#EEEEEE"
+
=Android development environment=
! scope="row" rowspan="8"| log
+
Setting up an environment in which you can compile your own Android versions of Navit
|
+
==Pre-requisites ==
|
+
Ensure that a java jdk is installed. On Ubuntu:
|
+
sudo apt-get install openjdk-6-jdk
| Insert inbetween <tt><navit> ... </navit></tt> tags for <tt>type="textfile_debug"</tt>.<br />Insert inbetween <tt><vehicle> ... </vehicle></tt> tags for all other types.
+
Ensure that '''ant''' is installed. On Ubuntu:
|
+
sudo apt-get install ant1.8
|- style="background:#EEEEEE"
 
| type
 
|
 
| <tt>nmea<br />gpx<br />textfile<br />binfile</tt>
 
| Type of log to output.<br /><tt>type="nmea"</tt>: outputs data as NMEA messages (the data format used by most GPS receivers).<br /><tt>type="gpx"</tt>: outputs GPX XML files (e.g. for upload to OpenStreetMap).<br /><tt>type="textfile"</tt>: creates a text file that can be used as a [[Navit_textfile_format|map within Navit]]<br /><tt>type="binfile"</tt>: outputs a binary map file for use within Navit<br /><tt>type="textfile_debug"</tt>: outputs a debug text file.
 
| <tt>type="gpx"</tt>
 
|- style="background:#EEEEEE"
 
| enabled
 
|
 
| <tt>yes</tt> / <tt>no</tt>
 
| Enable logging. This attribute enables you to define multiple log types within navit.xml (i.e. multiple <tt><log> ... </log></tt> tags), and quickly switch between them by changing the <tt>enabled</tt> status.
 
| <tt>enabled="yes"</tt>
 
|- style="background:#EEEEEE"
 
| data
 
|
 
| ''filename''
 
| The name for the logfile. There is support for date and time placeholders:<br /><tt>%Y</tt>: Current year<br /><tt>%m</tt>: Current month<br /><tt>%d</tt>: Current day<br /><tt>%i</tt>: Next sequential logfile number (to make the filename unique)
 
| <tt>data="%Y%m%d-%i.gpx"</tt>
 
|-  
 
| overwrite
 
|
 
| '''0''' / 1
 
| Toggle to choose whether an existing tracklog of the same name gets:<br /><tt>overwrite="0"</tt>: Appended to, or<br /><tt>overwrite="1"</tt>: overwritten
 
| <tt>overwrite="1"</tt>
 
|-
 
| flush_size
 
| bytes
 
| 0 - &infin;
 
| The file is kept in memory and will be committed to disk if the size reaches the <tt>flush_size</tt> limit.<br /><tt>flush_size="0"</tt>: Writes the tracklog to disk immediately.<br />When used in combination with <tt>flush_time</tt>, whichever limit is reached first triggers a disk write.
 
| <tt>flush_size="1048576"</tt>
 
|-
 
| flush_time
 
| seconds
 
| 0 - &infin;
 
| The file is kept in memory and will be committed to disk after <tt>flush_time</tt> seconds.<br /><tt>flush_time="0"</tt>: Writes the tracklog to disk immediately.<br />When used in combination with <tt>flush_size</tt>, whichever limit is reached first triggers a disk write.
 
| <tt>flush_size="90"</tt>
 
|-  
 
| attr_types
 
|
 
| <tt>position_time_iso8601<br />position_direction<br />position_speed <br />profilename <br />position_radius<br />position_height <br />position_sats_used <br />position_hdop </tt>
 
| Comma-separated list which determines what information will be stored in the log file (in addition to the position, and only if supported by the GPS receiver). This only applies when <tt>type="gpx"</tt><br />See [[Configuring_Navit#Logging_Trips]] for descriptions of each type.
 
| <tt>attr_types="position_height,<br />position_direction"</tt>
 
  
|-
+
==Android development files==
! scope="row" rowspan="1"| osd
+
* Download Android SDK
|
+
wget http://dl.google.com/android/android-sdk_r16-linux.tgz
|
+
* Unzip to a directory of your choice. We shall use '''~/src'''
|
+
* Move to the SDK directory, and initiate the download of the Android API's
| Insert inbetween <tt><navit> ... </navit></tt> tags.<br /> See [[OSD]] for comprehensive information on on-screen display settings.
+
cd ~/src/android-sdk-linux
|
+
tools/android update sdk --no-ui
 +
* Download Android NDK
 +
wget http://dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar.bz2
 +
* Unzip to a directory of your choice. We shall use '''~/src'''
  
|-
+
==Download Navit source==
! scope="row" rowspan="9"| vehicle
+
* Get the latest Navit from svn
|
+
cd ~/src
|
+
svn co https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit navit-svn
|
 
| Insert inbetween <tt><navit> ... </navit></tt> tags.
 
|
 
|- style="background:#EEEEEE"
 
| name
 
|
 
| ''vehiclename''
 
| Name of the vehicle being defined. This can be any name you like, but it's usually best to provide descriptive names, perhaps depending on the gps source, or the type of vehicle.
 
| <tt>name="Car gpsd"</tt>
 
|- style="background:#EEEEEE"
 
| profilename
 
|
 
| ''profilename''
 
| The name of the vehicle profile (see below) to use for routing and announcements for this vehicle.
 
| <tt>profilename="car"</tt>
 
|- style="background:#EEEEEE"
 
| source
 
|
 
|
 
| Source of GPS data. See [[Configuring_Navit#Vehicle]] for the available options.
 
| <tt>source="gpsd://localhost"</tt>
 
|-
 
| active
 
|
 
| 0 / 1
 
| Makes the vehicle the active vehicle in Navit - i.e. all its options are used for routing, view centering and map redraws. Note that a vehicle must be <tt>enabled="yes"</tt> before it can be made <tt>active="1"</tt>.
 
| <tt>active="1"</tt>
 
|-
 
| baudrate
 
| baud rate
 
| 0 - &infin;
 
| Baudrate of the com port of a WinCE device. Required if <tt>source="wince:COMx:"</tt> (where <tt>x</tt> is the COM port of the gps device). The baud rate should be 4800 in most cases.
 
| <tt>baudrate="4800"</tt>
 
|-
 
| enabled
 
|
 
| '''<tt>yes</tt>''' / <tt>no</tt>
 
| Enable the vehicle. This attribute enables you to define multiple vehicles within navit.xml (i.e. multiple <tt><vehicle> ... </vehicle></tt> tags), and quickly switch between them by changing the <tt>enabled</tt> status or by using the menu options within Navit.<br />If there is no <tt>enabled=</tt> tag, the vehicle is automatically enabled.
 
| <tt>enabled="yes"</tt>
 
|-
 
| follow
 
|
 
| 0 - &infin;
 
| Specifies how many GPS updates to wait before map is refreshed. A value of zero means vehicle will leave the edge of the map before the map is refreshed.
 
| <tt>follow="1"</tt>
 
|-
 
| gpsd_query
 
|
 
| ''gpsd query''
 
| Command to send to gpsd. Required if <tt>source="gpsd://localhost"</tt>, otherwise this is not used.<br /> The string used in the example is sufficient for use in Navit.
 
| <tt>gpsd_query="w+xj"</tt>
 
  
|-
+
==Setup your environment==
! scope="row" rowspan="2"| tracking
+
* Manually create a build directory
|
+
cd ~/src
|
+
mkdir android-build
|
+
* Step into the build directory
| Insert inbetween <tt><navit> ... </navit></tt> tags.
+
cd ~/src/android-build
|
+
* Configure environment variables
|-
+
export ANDROID_NDK=~/src/android-ndk-r6b \
| cdf_histsize
+
export ANDROID_SDK=~/src/android-sdk-linux \
| metres
+
export PATH=$PATH:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$ANDROID_SDK/tools \
| 0 - &infin;
+
SOURCE_PATH=~/src/navit-svn
| Cumulative displacement filter. '''Currently not used by Navit'''. See [http://julien.cayzac.name/code/gps/] for what it would do.
 
| <tt>cdf_histsize="4"</tt>
 
  
|-
 
! scope="row" rowspan="9"| vehicleprofile
 
|
 
|
 
|
 
| Insert inbetween <tt><navit> ... </navit></tt> tags.
 
|
 
|- style="background:#EEEEEE"
 
| name
 
|
 
| ''profilename''
 
| The name of the vehicle profile. This name is used by the <tt>profilename</tt> attribute inside the <tt>vehicle</tt> tag.
 
| <tt>name="car"</tt>
 
|- style="background:#EEEEEE"
 
| flags
 
|
 
| hex value
 
| The flags (as defined in AF_* in [http://navit.svn.sourceforge.net/viewvc/navit/trunk/navit/navit/attr.h?revision=3641&view=markup attr.h]) which needs to be set to be able to pass this road. See [[VehicleprofileFlags]] for a comprehensive list of bit values.
 
| <tt>flags="0x4000000"</tt>
 
|-
 
| flags_forward_mask
 
|
 
| hex value
 
| The bits the <tt>flags_forward_mask</tt> has set in addition to <tt>flags</tt>, a way must not have set in order to be used in forward direction. More technically: the <tt>flags</tt> of a way are ANDed with this mask, if the route uses the way in forward direction. The result must match <tt>flags</tt> otherwise the way must not be used. E.g. flags_forward_mask="0x4000000" and flags_forward_mask="0x4000002" means a road may be used in forward direction if it is a ONEWAYREV (See [[VehicleprofileFlags]]).
 
| <tt>flags_forward_mask="0x40000000"</tt>
 
|-
 
| flags_reverse_mask
 
|
 
| hex value
 
| Identical to <tt>flags_forward_mask</tt> for ways in the reverse direction.
 
| <tt>flags_reverse_mask="0x40000000"</tt>
 
|-
 
| maxspeed_handling
 
|
 
| 0 - 2
 
| <tt>maxspeed_handling="0"</tt>: Always handle the maxspeed attribute of a street.<br /><tt>maxspeed_handling="1"</tt>: Only handle the maxspeed attribute of a street if it restricts the speed.<br /><tt>maxspeed_handling="2"</tt>: Never. Reason behind this is that a pedestrian doesn't want to travel with 30 km/h when there is a speed limit.
 
| <tt>maxspeed_handling="1"</tt>
 
|-
 
| route_mode
 
|
 
| 0 - 2
 
| <tt>route_mode="0"</tt>: Automatically select between an on-road route and an off-road route (if the off-0road route is shorter than the distance to the next street from the current position plus the distance to the next street from the destination).<br /><tt>route_mode="1"</tt>: Always use an on-road route. <br /><tt>route_mode="2"</tt>:: Always us an off-road route
 
| <tt>route_mode="0"</tt>
 
|-
 
| static_speed
 
| km/h
 
| 0 - &infin;
 
| If the speed between positions from two gps updates is larger than <tt>static_speed</tt> Navit will accept the new position.
 
| <tt>static_speed="5"</tt>
 
|-
 
| static_distance
 
| metres
 
| 0 - &infin;
 
| If the distance between positions from two gps updates is larger than <tt>static_distance</tt> Navit will accept the new position.
 
| <tt>static_distance="25"</tt>
 
  
|-
+
==Building==
! scope="row" rowspan="5"| roadprofile
+
* Ensure that you're in the build directory created in the previous step, then run '''cmake'''
|
+
cmake -DCMAKE_TOOLCHAIN_FILE=$SOURCE_PATH/Toolchain/arm-eabi.cmake -DCACHE_SIZE="(20*1024*1024)" -DAVOID_FLOAT=1 -DANDROID_PERMISSIONS="CAMERA" -DANDROID_API_VERSION=8 $SOURCE_PATH
|
+
* Then make the package
|
+
make && make apkg
| Insert inbetween <tt><vehicleprofile> ... </vehicleprofile></tt> tags.
 
|
 
|- style="background:#EEEEEE"
 
| item_types
 
|
 
|
 
| Types of ways for which this roadprofile is valid. '''Way types can be found in FIXME'''.
 
| <tt>item_types="steps"</tt>
 
|- style="background:#EEEEEE"
 
| route_weight
 
| km/h
 
| 0 - &infin;
 
| The weighting which the routing algorithm should give this road type. A large <tt>route_weight</tt> will force the routing algorithm to choose that road type over others when calculating a route. This value is also used to calculate the route time remaining IF <tt>maxspeed_handling="2"</tt>.
 
| <tt>route_weight="150"</tt>
 
|- style="background:#EEEEEE"
 
| speed
 
| km/h
 
| 0 - &infin;
 
| ns.
 
| <tt>speed="50"</tt>
 
|-
 
| maxspeed
 
| km/h
 
| 0 - &infin;
 
| When driving, Navit will use the <tt>maxspeed</tt> of the road type to inform the driver of the current speed limit using the [[OSD#speed_warner|speed_warner]]. <tt>maxspeed</tt> will only be used if there is no OSM speed data for that road. This data is '''not''' used for routing calculations.
 
| <tt>maxspeed="50"</tt>
 
  
|-
+
==Install Navit==
! scope="row" rowspan="3"| announcement
+
* The new Navit package is called ''navit-debug'' and can be found in:
|
+
~/src/android-build/navit/android/bin
|
+
** Copy navit/android/bin/Navit-debug.apk to your device (i.e. sd-card) and run it from there or
|
+
** If debug bridge (adb) is enabled run adb install navit/android/bin/Navit-debug.apk
| Insert inbetween <tt><roadprofile> ... </roadprofile></tt> tags.
 
|
 
|- style="background:#EEEEEE"
 
| level
 
|
 
| 0, 1, 2
 
| Type of oral announcement to make. For example, <tt>level="2"</tt> means an announcement such as "Turn left soon" will be made.
 
| <tt>level="0"</tt>
 
|- style="background:#EEEEEE"
 
| distance_metric
 
| metres
 
| 0 - &infin;
 
| Distance from the upcoming manoeuvre to perform the announcement.
 
| <tt>distance_metric="25"</tt>
 
|}
 

Latest revision as of 14:25, 1 March 2012

IRC Korrosa appears on irc with the nick korrosa.
Trac Korrosa appears on trac with the nick korrosa.
en This user is a native speaker of English.


nl Deze gebruiker heeft Nederlands als moedertaal.


fr-1 Cet utilisateur peut contribuer avec un niveau élémentaire de français.


PHP This user programs in PHP
Javascript This user programs in Javascript
Linux This user uses Linux
Windows This user uses Windows


UK Postcode search with Navit[edit]

Using an external file containing full postcode centroids in lat/lon, a script can be used to pass the relevant postcode to Navit via dbus. This method was developed on Ubuntu (Linux). Postcodes do not include NI.

Quickstart[edit]

  1. Enable dbus in navit.xml
  2. Download the script and postcode file from: http://www.tiiiim.com/navit/p2n.tar.bz2 (23MB)
  3. In the script, change the path to the postcode file. Set the executable bit of the script, then call the script with the postcode as arguments:
./p2n BA2 4HJ

If the postcode is valid, choose from the option to centre the map to the postcode, route to the postcode or set the postcode as your position.

More Info[edit]

The script[edit]

The script is written in php, and requires php5-cli to be installed on your system.

sudo apt-get install php5-cli

The script is shown below:

The postcode file[edit]

The postcode data comes from Ordnance Survey CodePoint Open data: https://www.ordnancesurvey.co.uk/oswebsite/products/code-point-open/index.html. The original data uses OSGB Northing and Easting to define the postcode centroids, but the data can be processed into a csv file with lat/lon coordinates using the method found here: http://baroque.posterous.com/uk-postcode-latitudelongitude. The result of this method is what's included in the download at http://www.tiiiim.com/navit/p2n.tar.bz2.

OSM Layout[edit]

Mapnik-style rendering

OSD: Speed Camera[edit]

Currently a patch at #702.

  • Provides visual and audible warnings of approaching speed cameras.
  • Uses speed camera data from an external file in IGO8 format: files available from http://speedcamerapoi.com/download.php. Example IGO8 format shown below:
X,Y,TYPE,SPEED,DIRTYPE,DIRECTION
13.74132,51.04641,2,50,0,0
8.34681,49.62934,2,50,0,0
12.11390,49.02778,3,0,0,0
8.83805,53.08262,3,0,0,0
9.14767,47.68987,3,0,0,0
6.94611,51.12167,1,30,0,0
7.82556,51.46417,1,70,0,0
14.17350,51.12366,5,50,0,0
13.89502,52.25109,5,100,0,0
  • Plans to also use speed camera data in OSM

Use[edit]

To use the speed_cam OSD type, the following OSD item must be added to navit.xml. This of course assumes that you have patched navit with the patch at #702:

    <osd enabled="yes" type="speed_cam" w="500" h="40"  x="30" y="350" font_size="450" text_color="#FF0000" announce_on="0" label=" ${distance} | ${camera_type} | ${camera_dir} | ${direction} | ${speed_limit}" path="speed_cam_data.txt" />

Configuration[edit]

Most parts are self explanatory:

  • announce_on is set by default to 1 (i.e. this osd item will announce upcoming cameras with a "Look out! Camera!" warning) if this attribute is not set.
  • label can display the following variables. The values in ${STRING} are replaced with the appropriate number or word when running Navit:
    • distance to the camera - ${distance}
    • type of camera - ${camera_type}. See User:Korrosa#Camera Types for possible types:
    • direction in which the camera operates - ${camera_dir}
      • all
      • single direction
      • both directions
    • direction which the camera is facing, in degrees (0-360, i.e. north, east, south, west etc) - ${direction}
    • the active speed limit which the camera may be enforcing - ${speed_limit}

Data Sources[edit]

Currently, the speed_cam OSD looks in the following locations for speed camera data, in the following order. Note that the speed_cam OSD will only use the first data source:

  • IGO8 file defined by the path= attribute in the <osd /> tag
  • speedcam.txt IGO8 file in your default navit directory (usually ~/.navit)
  • Speed camera bin mapfile (see User:Korrosa#Creating camera bin mapfiles) defined in the currently active mapset.

Note that if you use one of the first two options, the cameras will not actually appear on the map, but will still be announced. Only by using a binfile will the cameras appear on the map.

Creating camera bin mapfiles[edit]

The following steps will enable you to convert an IGO8 speed camera textfile into a Navit bin mapfile. The advantage is reduced resource usage when using a binfile, and that the cameras will appear on the map.

  • Using igo2navittext.pl, convert the IGO8 file into a standard navit textfile. The script reads its input on standard input and outputs navit textfile on stdout. Use in the following manner:
    perl igo2navittext.pl  < speedcam.txt  > speedcam_navit.txt
  • Copy the resulting speedcam_navit.txt to the /navit/maps folder in the source tree.
  • Issue the following command in the maps folder:
    make speedcam_navit.bin
  • Add the just-created speedcam_navit.bin to your active mapset in navit.xml. For example, having moved the binfile to ~/navit/maps:
    <map type="binfile" enabled="yes" data="~/.navit/maps/speedcam_navit.bin"/>

Next time you start Navit the cameras should appear on the map. If they don't try changing the zoom settings of the tec_common item type in your map layout in navit.xml.

Camera Types[edit]

  • None
  • Fix
    • Type: Fixed speed enforcement camera
    • Enforces: Speed
    • Description: Probably the most common type of traffic enforcement camera. Usually located on the side of the road, and uses radar to detect vehicle speed. Can take photos from either the front or the rear. Front facing cameras tend to use IR flash guns, instead of traditional bulb flashes, to ensure that the driver does not get blinded.
    • Suggested English name: Fixed.
  • Traffic lamp
    • Type: Traffic light enforcement camera
    • Enforces: Speed and/or red light (unsure)
    • Description: These cameras seem to be located inside (?) traffic lights. It is unknown whether these are for speed, red light or both.
    • Suggested English name: Traffic light.
  • Red detect
    • Type: Red light enforcement camera
    • Enforces: Red light
    • Description: Located close to traffic light controlled junctions, these cameras will detect if a car has run a red light. Usually, these cameras will face down the flow of traffic, thus take a picture from the rear.
    • Suggested English name: Red light.
  • Section
    • Type: Average speed check camera
    • Enforces: Speed
    • Description: In the UK at least, these cameras are used a lot on motorway roadwork sections. CCTV ANPR cameras are located at strategic locations along the works, and take average speed readings of vehicles by reading their number plates. Nightime use is facilitated through the use of IR lamps.
    • Suggested English name: Avg speed
  • Mobile
    • Type: Mobile speed enforcement camera
    • Enforces: Speed
    • Description: There are many types of mobile cameras: common ones are hand-held cameras, either held by an officer from the police car window, or mounted on a tripod. Other types include those mounted on the police car dashboard or rear parcel shelf, or those which point through windows of special speed camera vans (common in the UK)
    • Suggested English name: Mobile
  • Rail
    • Type: Railway level crossing enforcement camera
    • Enforces: barriers/access
    • Description: Used at railway level crossings, to enforce any barriers or warning lights. It's usually an offence to enter the level crossing once you've been warned not to (however far away the train is), hence the cameras.
    • Suggested English name: Level crossing
  • Traffipax(non persistent)
    • Type: Mobile speed enforcement camera
    • Enforces: Speed (?)
    • Description: Note: this is conjecture at the moment. This seems to be a specific type of mobile speed camera.
    • Suggested English name: Mobile

Configuration[edit]

  • Tags shown in order of appearance in the navit.xml shipped with Navit.
  • Bold values denote default values if attributes are not explicitly specified.
  • Value types:
    • int = integer
    • bool = boolean 1 or 0
    • dbl = double

OpenStreetMap[edit]

Drafting complete re-write of the OpenStreetMap page

User:Korrosa/OpenStreetMap


Notable Tickets[edit]

  • sort items by distance in the adress search dialog #35
  • It'd be nice to have several waypoints, not only a destination #46
  • do not announce when following a curved way/road #171
  • Incorrect ETA and TR - new method required? #417
  • Change Default Menu that Appears #560

Configuring Navit[edit]

Complete re-style of conifguration page

User:Korrosa/Configuring Navit

Android development environment[edit]

Setting up an environment in which you can compile your own Android versions of Navit

Pre-requisites[edit]

Ensure that a java jdk is installed. On Ubuntu:

sudo apt-get install openjdk-6-jdk

Ensure that ant is installed. On Ubuntu:

sudo apt-get install ant1.8

Android development files[edit]

  • Download Android SDK
wget http://dl.google.com/android/android-sdk_r16-linux.tgz
  • Unzip to a directory of your choice. We shall use ~/src
  • Move to the SDK directory, and initiate the download of the Android API's
cd ~/src/android-sdk-linux
tools/android update sdk --no-ui
  • Download Android NDK
wget http://dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar.bz2
  • Unzip to a directory of your choice. We shall use ~/src

Download Navit source[edit]

  • Get the latest Navit from svn
cd ~/src
svn co https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit navit-svn

Setup your environment[edit]

  • Manually create a build directory
cd ~/src
mkdir android-build
  • Step into the build directory
cd ~/src/android-build
  • Configure environment variables
export ANDROID_NDK=~/src/android-ndk-r6b \
export ANDROID_SDK=~/src/android-sdk-linux \
export PATH=$PATH:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$ANDROID_SDK/tools \
SOURCE_PATH=~/src/navit-svn


Building[edit]

  • Ensure that you're in the build directory created in the previous step, then run cmake
cmake -DCMAKE_TOOLCHAIN_FILE=$SOURCE_PATH/Toolchain/arm-eabi.cmake -DCACHE_SIZE="(20*1024*1024)" -DAVOID_FLOAT=1 -DANDROID_PERMISSIONS="CAMERA" -DANDROID_API_VERSION=8 $SOURCE_PATH
  • Then make the package
make && make apkg

Install Navit[edit]

  • The new Navit package is called navit-debug and can be found in:
~/src/android-build/navit/android/bin
    • Copy navit/android/bin/Navit-debug.apk to your device (i.e. sd-card) and run it from there or
    • If debug bridge (adb) is enabled run adb install navit/android/bin/Navit-debug.apk