navit-project.org

forum for navit navigation tool
It is currently 21 Nov 2017, 19:19
View unanswered posts | View active topics


All times are UTC


Forum rules


Feel free to ask anything here related to the installation and configuration of Navit.

Some notes before your first post:

Please provide as much informations as possible:



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Script to converting of gpx track to navit map under android
PostPosted: 11 Apr 2015, 17:23 
Offline

Joined: 03 Aug 2014, 09:42
Posts: 9
This small scripts creates navit map from downloaded gpx.
You need to install QPython to be able to start it, I have saved it on common path of qpython scripts.
The navit map has to be added to navit.xml:
Code:
<map type="textfile" enabled="yes" data="/sdcard/navit/NavitRoute.txt"/>

Then first one has to download gpx (usually it is saved to “/sdcard/Download”)
Then one need to start the script: it does following:
-it reads any gpx file from downloaded directory (any means any: if there are few tracs I do not know which will be opened),
-it converts it to navit map and saves to NavitRoute.txt, if file is present it will be overwritten.
-it deletes also converted gpx track.

Script is strictly tailored to my wishes:
It is overwriting and deleting without any confirmation. Paths are hard coded, so I am not asked for anything.


Code:
import sys
import os
import re
from xml.dom.minidom import parseString

gpxpath=""
for dirname, dirnames, filenames in os.walk('/sdcard/Download'):
    for filename in filenames:
        if '.gpx' in filename:   
            gpxpath= os.path.join(dirname, filename)
            print gpxpath
gpx = open(gpxpath,"r")
Data = gpx.read()
gpx.close()
os.remove(gpxpath)
Route = open("/sdcard/navit/NavitRoute.txt","w")
Route.write("type=track label=\"MeineRoute\" desc=\"\" type=\"\" length=\"\" count=\"\"")
dom = parseString(Data)
for i in range(dom.getElementsByTagName('trkpt').length):
    dataElement=dom.getElementsByTagName('trkpt')[i].toxml()
    Point=""
    m = re.search('lon=\"(\d+\.\d+)\"', dataElement)
    if m.group(1) is not None:
        Point =m.group(1)+" "
    m = re.search('lat=\"(\d+\.\d+)\"', dataElement)
    if m.group(1) is not None:
        Point +=m.group(1)+"\n"
    Route.write(Point)



Script is os independent, runs also under windows (python 2.x has to be present, and paths have to be adapted)


 Profile  
 
 Post subject: Re: Script to converting of gpx track to navit map under and
PostPosted: 13 Apr 2015, 05:07 
Offline

Joined: 27 Sep 2013, 21:10
Posts: 50
Thanks NavitNutzer for sharing this.

Is the purpose to be able to follow a route from a downloaded GPX?


 Profile  
 
 Post subject: Re: Script to converting of gpx track to navit map under and
PostPosted: 14 Apr 2015, 17:58 
Offline

Joined: 03 Aug 2014, 09:42
Posts: 9
never used.
what about this:
http://wiki.navit-project.org/index.php/OSD
search for "route_guard"


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Silver Orange 2.0.6 for IPB Designed by Skins and Hosting
Converted for phpBB3, based on Royal Blue template by BigB © 2007 2008 AEON KINGS