Forum: General Topics

Forums / General Topics / How can I create a route from a GPX file?

 

Subject:How can I create a route from a GPX file? 

dewoob

6:28
Tuesday
20-May-2008

Hi there,

first of all, thank you very much for this great software! I've been using it on several tours now and it's a great pleasure!

What I'd like to know: Some biking tours are downloadable on the web as GPX tracks. I'd like to take some of these tours on my own, but yet I haven't found out how to get a GPX track into TMJ as a route. I thought about importing the track as CSV and converting it to a route, but I don't know a free tool that converts GPX to CSV (I wouldn't like to buy Ozi Explorer). If you told me some details about the CSV format TMJ needs (which colums, order of columns, separator, column headers, ...), I could try programming one on my own. :-) - or is there an easy way to get it done?

Thanks!
 

Stephen

9:25
Tuesday
20-May-2008

Location:
Surrey, UK

Phone Model:
BB 9800 Torch
BlackBerry 8900
SE W910i
Nokia 5800

Hello,

Theres a fairly straightforward way to do this, though it needs to be done via this website, so you'll need to have internet access on the phone.

On the website:
1. Firstly login to your TMJ account and click the FOLDERS link on the left
2. If you haven't already got a folder called Routes then create one using the 'Create New Folder' box.
3. Click on the new folder and make sure the 'Make available to TMJ-Mobile' option is set to Yes.
4. Upload your GPX file into the new folder via the Upload GPX File link on the left (under the UPLOAD option). Note that the GPX importer only looks for <trkpt> markers in the file - any waypoints, etc are ignored.

Then, on the phone:
1. In TMJ-Mobile select the Main Menu/Web/Download Route/Update Folders function. The phone should then connect to the website and download a list of the available folders and routes.
2. Back in the Main Menu/Web/Download Route menu there should now be a new folder called 'Routes' or whatever you called the folder above. Select the route that you uploaded and it will then be downloaded to the phone and appear on the Route page.

Hope this helps!

Incidentally, if you do try the Import Route CSV option the format is simply a list of latitude,longitude pairs, with each pair on a new line. The first line in the file is ignored (so that it can be used as a comment, etc).
eg:
Header Line
51.3, -0.3
51.2, -0.1
51.4, 0.2
51.3, 0.1


Cheers,
Stephen


 

dewoob

6:22
Wednesday
21-May-2008

Thank you very much for your detailed answer. I will try this out right after work today! :-)
 

dewoob

6:54
Wednesday
21-May-2008

When importing my GPX file, a route that should go 34km west was displayed as going about 12000km south, telling me to cross the Sahara and land straight in the ocean! :-) So I tried the csv way (no, wasn't at work yet!), which works a lot better.


<?php
$file = $_GET["file"];
$doc = new DOMDocument();
$doc->load($file);
$nodes = $doc->getElementsByTagName("trkpt");
$csv = "Latitude,Longitude\n";
foreach( $nodes as $node ) {
  $lat = $node->getAttribute("lat");
  $lon = $node->getAttribute("lon");
  $csv .= "$lat,$lon\n";
}
echo $csv;
?>


Isn't php like sugar sometimes? :-)
 
 

Stephen

9:36
Wednesday
21-May-2008

Location:
Surrey, UK

Phone Model:
BB 9800 Torch
BlackBerry 8900
SE W910i
Nokia 5800

Very sweet code indeed! ;-)

Looks like you've found the same bug as ChrisM in the other GPX thread. Unfortunately my webserver is only running PHP4 so I don't think the DOMDocument() is available, otherwise this would be an ideal solution. I'm using the XMLParser functions instead, but I've obviously made an error somewhere...!

Cheers,
Stephen
 

(You must be logged in to post a reply to this thread)