Difference between revisions of "Other maps"

From Navit's Wiki
Jump to: navigation, search
m (Convert CSV POIs to Navit format)
m (Convert CSV POIs to Navit format)
Line 42: Line 42:
 
poi_type=""
 
poi_type=""
  
if [ ! -f "$csvfile" ]; then
+
if [ ! -f "$csvfile" ] || !(echo "$(head "$csvfile" -n1)" | grep -q "[^,]\+,[^,]\+,[^,]\+"); then
 
echo "You must provide a valid csv file"
 
echo "You must provide a valid csv file"
 
exit 1
 
exit 1

Revision as of 17:45, 26 April 2009

POI as Navit Text maps

You can display Points of Interest as a Navit map. Therefore was built a utility called gpx2navit_txt which converts gpx files to navit text map-Files. It is possible to convert waypoints and tracks.

Insert the text map Files into the navit.xml like this:

        <mapset enabled="yes">
               <map type="textfile" enabled="yes" data="/home/andi/osm_maps/navit_poi.txt"/>
               <map type="binfile" enabled="yes" data="$NAVIT_SHAREDIR/maps/osm_bbox_11.3,47.9,11.7,48.2.bin"/>

and you will get the poi-data on the map.

That will look like this: POI

Troubleshooting

If nothing is displayed

* check the area of the map
* check if the items of the textfile are defined in your 'navit.xml'
* this is also true for tracks - here it might be that the track is hidden by other objects, check the 'navit.xml'
* check if the xpm-Files are defined and accessible

For example imagine:

* in the text-map you converted with 'gpx2navit_txt' is a type='poi_gc_multi' for a Multicache
* Then the navit symbol will be 'poi_gc_multi' and has to be defined in 'navit.xml' (see for 'example poi_airport')
* the xpm file (normally under '/usr/local/share/navit/xpm') 'gc_multi.xpm' must be present
* for track-display the type is 'track' and 'track' must be defined in 'navit.xml'

If tracks or routes from gpx are not converted

* error message 'no move recorded' --> use '-f' flag of gpx2navit_txt

Convert CSV POIs to Navit format

Many commercial Navigators use the CVS format for Point of Interest files. You can convert them to the navit txt format using a script like this:

#!/bin/bash
# Marco Trevisan (Treviño) -- Copyright 2009
# Released under the GPLv2 terms.

csvfile="$1"
poitxtfile="$PWD/$(basename "$csvfile" .csv).txt"
poi_type=""

if [ ! -f "$csvfile" ] || !(echo "$(head "$csvfile" -n1)" | grep -q "[^,]\+,[^,]\+,[^,]\+"); then
	echo "You must provide a valid csv file"
	exit 1
fi

rm -f "$poitxtfile"
echo "Parsing file $csvfile..."
filelen=$(wc -l "$csvfile"|cut -f1 -d' ')
linen=1

while read line; do
	lon=$(echo "$line" | cut -f1 -d',')
	lat=$(echo "$line" | cut -f2 -d',')
	name=$(echo "$line" | cut -f3 -d',')
	
	poi_label="$name"
	poi_desc="$name"
	
	if [ -z "$poi_type" ]; then
		poi_type="poi_attraction"
	fi
	
	echo "type=$poi_type label=\"$poi_label\" description=\"$poi_desc\" gc_type=\"\"" >> $poitxtfile
	echo "$lon $lat" >> $poitxtfile
			
	status="\t$csvfile ($linen/$filelen)"
	if [ $linen -gt 1 ]; then
		for ((k=0; $k < $(expr length "$status"); k++)); do
			echo -n -e "\b"
		done
	fi
	
	if [ $linen != $filelen ]; then
		echo -e -n "$status"
	fi

	linen=$(($linen+1))
done < "$csvfile"

echo "POI file saved in $poitxtfile"