Difference between revisions of "Other maps"

From Navit's Wiki
Jump to: navigation, search
m (Python Version)
m (Python Version)
Line 109: Line 109:
outlist = list()
outlist = list()
for line in csvfile:
for line in csvfile:
cvsparts = re.match(csvmatch, line)
cvsparts = re.match(csvmatch, line)
Line 131: Line 132:
linen = linen+1
linen = linen+1
if (len(outlist)):
if (len(outlist)):
outfile = os.path.splitext(currentfile)[0]+".txt"
outfile = os.path.splitext(currentfile)[0]+".txt"

Revision as of 22:00, 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


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 these:

Bash version

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

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

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

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

while read line; do
	lon=$(echo "$line" | cut -f1 -d',')
	lat=$(echo "$line" | cut -f2 -d',')
	name=$(echo "$line" | cut -f3 -d',')
	if [ -z "$poi_type" ]; then
	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"
	if [ $linen != $filelen ]; then
		echo -e -n "$status"

done < "$csvfile"

echo "POI file saved in $poitxtfile"

Python Version

Much more quick.

# Convert CSV-POI files to Navit
# Marco Trevisan (3v1n0) -- Copyright 2009
# Released under the GPLv2 terms.

import os, sys, re

poi_type = ""

csvmatch = re.compile("([^,]+),([^,]+),([^,]+)\n")

for i in range(1, len(sys.argv)):
	currentfile = sys.argv[i]
	if (os.path.exists(currentfile)):
		csvfile = open(currentfile, 'r')
		print "Parsing "+currentfile+"..."
		filelen = len(csvfile.readlines())
		linen = 1
		outlist = list()

		for line in csvfile:
			cvsparts = re.match(csvmatch, line)
			if cvsparts:
				lon = cvsparts.group(1)
				lat = cvsparts.group(2)
				name = cvsparts.group(3)
				poi_label = name
				poi_desc = ""
				if not len(poi_type):
					poi_type = "poi_attraction"
				outlist.append("type="+poi_type+" label=\""+poi_label+"\"" \
							" description=\""+poi_desc+"\" gc_type=\"\"\n")
				outlist.append(lon+" "+lat+"\n")
			status = "\t"+os.path.basename(currentfile)+" ("+str(linen)+"/"+str(filelen)+")"
			print status,"\r",
			linen = linen+1

		if (len(outlist)):
			outfile = os.path.splitext(currentfile)[0]+".txt"
			print "\nWriting output at "+outfile+"..."
			gpxfile = open(outfile, 'w')