Andrei Suvorov
Andrei Suvorov

Reputation: 531

Here Mobile SDK PositionSimulator

I'm using Here Mobile Android SDK and try to simulate GPX track, in order to test my map behaviour. I use PositionSimulator class, set callback for position updates, but when I call startPlayback(filename) it parse my gpx files with no errors on android, but not simulate fake gps coordinates.

Can someone provide a workable gpx file for PositionSimulator or workable code sample?

My code:

posManager = PositioningManager.getInstance();
posManager.start(PositioningManager.LocationMethod.GPS_NETWORK);
posManager.addListener(
   new WeakReference<PositioningManager.OnPositionChangedListener>(positionListener));
mapFragment.getPositionIndicator().setVisible(true);
simulator = new PositionSimulator();
PositionSimulator.PlaybackError err = simulator.startPlayback(trackFileName);

simulator instance received correct number of points, but my location marker and camera don't move at all. I try different gpx files with routes, waypoints and tracks. Maybe I need to setup a timestamps inside gpx somehow? Permissions for Moc locations added.

Is there any better way to test camera movements, when simulating driving among some route? Any help will be appreciated.

Upvotes: 1

Views: 387

Answers (2)

Andrei Suvorov
Andrei Suvorov

Reputation: 531

Below you can see example of the gpx, which can be played by PositionSimulator:

<gpx>
  <metadata>
   <name>london</name>
   <time>2017-01-19T17:41:11Z</time>
  </metadata>
<trk>
  <name>test</name>
<trkseg>
  <trkpt lat="51.47785480" lon="-0.14754295">
    <ele>8.0000000</ele>
    <time>2010-01-01T00:00:00Z</time>
    <hdop>33</hdop></trkpt>
  <trkpt lat="51.47788554" lon="-0.14778173">
    <ele>8.0000000</ele>
    <time>2010-01-01T00:00:01Z</time>
    <hdop>42</hdop></trkpt>
  <trkpt lat="51.47787976" lon="-0.14807005">
    <ele>6.0000000</ele>
    <time>2010-01-01T00:00:02Z</time>
    <hdop>20</hdop></trkpt>
....
</trkseg>
</trk>
</gpx>

The only one thing I did wrong was not providing hdop field - value for accuracy. Even if you turn off the accuracy displayments for PositionIndicator - apparently it will not be played without that hdop value.

AndrewJC, thanks for help.

Upvotes: 1

AndrewJC
AndrewJC

Reputation: 1478

Have you set your app in the "Settings > Developer Options > Select mock location app" dialog? More info

Also, you can try troubleshooting by using the PositionSimulator getPositionCount, getCurrentPositionIndex and getPosition APIs to see if it seems to be handling your GPX log properly.

You can try creating a GPX log using the HERE SDK by using the PositioningManager setLogType API with LogType#DATA_SOURCE

Upvotes: 0

Related Questions