mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-13 07:34:31 +00:00
[android] Improve AA route simulator.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
@@ -201,7 +201,8 @@ public class Framework
|
||||
public static native RoutingInfo nativeGetRouteFollowingInfo();
|
||||
|
||||
@Nullable
|
||||
public static native JunctionInfo[] nativeGetRouteJunctionPoints();
|
||||
/// @param[in] maxDistM Max distance between points in meters.
|
||||
public static native JunctionInfo[] nativeGetRouteJunctionPoints(double maxDistM);
|
||||
|
||||
@Nullable
|
||||
public static native final int[] nativeGenerateRouteAltitudeChartBits(int width, int height,
|
||||
|
||||
@@ -16,6 +16,7 @@ class RouteSimulationProvider extends BaseLocationProvider
|
||||
|
||||
private final JunctionInfo[] mPoints;
|
||||
private int mCurrentPoint = 0;
|
||||
private Location mPrev = null;
|
||||
private boolean mActive = false;
|
||||
|
||||
RouteSimulationProvider(@NonNull Context context, @NonNull Listener listener, JunctionInfo[] points)
|
||||
@@ -56,9 +57,20 @@ class RouteSimulationProvider extends BaseLocationProvider
|
||||
location.setLatitude(mPoints[mCurrentPoint].mLat);
|
||||
location.setLongitude(mPoints[mCurrentPoint].mLon);
|
||||
location.setAccuracy(1.0f);
|
||||
|
||||
if (mPrev != null)
|
||||
{
|
||||
location.setSpeed(mPrev.distanceTo(location) / (INTERVAL_MS / 1000));
|
||||
location.setBearing(mPrev.bearingTo(location));
|
||||
}
|
||||
|
||||
location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
|
||||
location.setTime(System.currentTimeMillis());
|
||||
|
||||
mListener.onLocationChanged(location);
|
||||
mCurrentPoint += 1;
|
||||
mPrev = location;
|
||||
|
||||
UiThread.runLater(this::nextPoint, INTERVAL_MS);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user