Route simulation using GPX on Android

13,741

Solution 1

In order to emulate driving your trackpoints and waypoints within the gpx file you will need to manually add the time parameter to each one. Each time parameter should increase second by second.

Here is a gpx file example: (Note: Use the first three lines if your gpx file is incompatible)

GPX file example:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="MapSource 6.16.1" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-

instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">

<trk>
<name>emulate</name>
<trkseg>
<trkpt lat="-33.91015" lon="151.16772"><ele>0.000000</ele><time>2014-03-05T20:00:01Z</time></trkpt>
<trkpt lat="-33.91014" lon="151.16770"><ele>0.000000</ele><time>2014-03-05T20:00:02Z</time></trkpt>
<trkpt lat="-33.90998" lon="151.16752"><ele>0.000000</ele><time>2014-03-05T20:00:03Z</time></trkpt>
<trkpt lat="-33.90998" lon="151.16752"><ele>0.000000</ele><time>2014-03-05T20:00:04Z</time></trkpt>
<trkpt lat="-33.90982" lon="151.16732"><ele>0.000000</ele><time>2014-03-05T20:00:05Z</time></trkpt>
<trkpt lat="-33.90982" lon="151.16732"><ele>0.000000</ele><time>2014-03-05T20:00:06Z</time></trkpt>
<trkpt lat="-33.90962" lon="151.16709"><ele>0.000000</ele><time>2014-03-05T20:00:07Z</time></trkpt>
<trkpt lat="-33.90962" lon="151.16709"><ele>0.000000</ele><time>2014-03-05T20:00:08Z</time></trkpt>
<trkpt lat="-33.90939" lon="151.16681"><ele>0.000000</ele><time>2014-03-05T20:00:09Z</time></trkpt>
<trkpt lat="-33.90939" lon="151.16681"><ele>0.000000</ele><time>2014-03-05T20:00:10Z</time></trkpt>
<trkpt lat="-33.90916" lon="151.16654"><ele>0.000000</ele><time>2014-03-05T20:00:11Z</time></trkpt>
<trkpt lat="-33.90916" lon="151.16654"><ele>0.000000</ele><time>2014-03-05T20:00:12Z</time></trkpt>
</trkseg>
</trk>
</gpx>

Notice I am increasing the seconds in the time from 20:00:01 up to 20:00:12

Solution 2

you can use this website can create for you a gpx file in second just set the destination on google maps and copy the link to this website and click create

MAPS GPX

Solution 3

My answer is not complete as I can guide u till the step you can load .pgx file to DDMS perspective in Eclipse.

Step 1. Add below code as book mark in your firefox browser.

javascript:(function(){var%20script=document.createElement('script');script.src='http://www.elsewhere.org/GMapToGPX/gmaptogpx.js';document.getElementsByTagName('head')[0].appendChild(script);})()

Step 2. Open a new tab and open google map. Click on get direction and enter source and destination to get route.

Step 3. Click on the bookmark and u will see a new pop up which will contain code. You can save this file as .gpx file.

Step 4. Open DDMS perspective. Click Emulator Control tab. On location control Load gpx under GPX tab.

Till here only I have worked. If any further information I will update my answer. Hope it help some way.

Source of information Link

update*

You can start the google api emulator and run your app. Every time you click on play button, its location will be updated. (Basically onLocationChange() will be called if you are playing with it.).

Share:
13,741
vkinra
Author by

vkinra

Updated on June 15, 2022

Comments

  • vkinra
    vkinra about 2 years

    I've asked this question before but still no resolution. Here is what I'm looking for. I am working on a GPS Navigation application on Android. For that I would like to be able to simulate driving on a map. I read that I can achieve it using a GPX file and using the Android emulator. So I added GPS support to an emulator and launched it. Then I created a GPX file using two different sites:

    1. wtracks.appspot.com: The gpx file I created using it, after loading it in DDMS, nothing happens. That is, I don't even see the file being loaded so the play button is grayed out

    2. Mapmyride.com: The GPX file I created using this do get loaded in DDMS and shows the 835 points in the point count in the emulator window. The green play button is enabled but when I select it, it shows the pause button for a second and then goes back to the green play button. That is, it's almost like the file runs for a second and stops.

    So really, all I want is if someone can show me the exact steps to be able to create a GPX file by some easy method like clicking on a map and then once I have a valid GPX file, to be able to load it in DDMS and run it to simulate car driving on a map. If it works, I will accept the answer immediately.

    Thanks,

    -Vivek

  • SSS
    SSS about 10 years
    ok .. Can u tell me the next step ?? After adding this gpx file in DDMS , what is the next step? Do I need to parse this in program or it will show automatically in my emulator?
  • Jan Hudec
    Jan Hudec over 9 years
    The important bits is that it must be GPX 1.1 and must have times.