[android] Improve AA route simulator.

Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
Viktor Govako
2025-09-20 20:22:45 -03:00
committed by x7z4w
parent 9912d19302
commit e73c37a5dd
7 changed files with 60 additions and 11 deletions

View File

@@ -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,

View File

@@ -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);
}
}