// Disable routing for huge distances
@NonNull
    public static Geopoint[] getTrack(final Geopoint start, final Geopoint destination) {
        if (brouter == null || Settings.getRoutingMode() == RoutingMode.STRAIGHT) {
            return defaultTrack(start, destination);
        }
        // avoid updating to frequently
        final long timeNow = System.currentTimeMillis();
        if ((timeNow - timeLastUpdate) < 1000 * UPDATE_MIN_DELAY_SECONDS) {
            return ensureTrack(lastRoutingPoints, start, destination);
        }
        // Disable routing for huge distances
        final int maxThresholdKm = Settings.getBrouterThreshold();
        final float targetDistance = start.distanceTo(destination);
        if (targetDistance > maxThresholdKm) {
            return defaultTrack(start, destination);
        }
        // disable routing when near the target
        if (targetDistance < MIN_ROUTING_DISTANCE_KILOMETERS) {
            return defaultTrack(start, destination);
        }
        // Use cached route if current position has not changed more than 5m and we had a route
        // TODO: Maybe adjust this to current zoomlevel
        if (lastDirectionUpdatePoint != null && destination == lastDestination && start.distanceTo(lastDirectionUpdatePoint) < UPDATE_MIN_DISTANCE_KILOMETERS && lastRoutingPoints != null) {
            return lastRoutingPoints;
        }
        // now really calculate a new route
        lastDestination = destination;
        lastRoutingPoints = calculateRouting(start, destination);
        lastDirectionUpdatePoint = start;
        timeLastUpdate = timeNow;
        return ensureTrack(lastRoutingPoints, start, destination);
    }
return ensureTrack(lastRoutingPoints, start, destination);
}
// Disable routing for huge distances
final int maxThresholdKm = Settings.getBrouterThreshold();
final float targetDistance = start.distanceTo(destination);
@NonNull
public static Geopoint[] getTrack(final Geopoint start, final Geopoint destination) {
if (brouter == null || Settings.getRoutingMode() == RoutingMode.STRAIGHT) {
return defaultTrack(start, destination);
}
// avoid updating to frequently
final long timeNow = System.currentTimeMillis();
if ((timeNow - timeLastUpdate) < 1000 * UPDATE_MIN_DELAY_SECONDS) {
return ensureTrack(lastRoutingPoints, start, destination);
}
// Disable routing for huge distances
final int maxThresholdKm = Settings.getBrouterThreshold();
final float targetDistance = start.distanceTo(destination);
if (targetDistance > maxThresholdKm) {
return defaultTrack(start, destination);
}
// disable routing when near the target
if (targetDistance < MIN_ROUTING_DISTANCE_KILOMETERS) {
return defaultTrack(start, destination);
}
// Use cached route if current position has not changed more than 5m and we had a route
@NonNull
public static Geopoint[] getTrack(final Geopoint start, final Geopoint destination) {
if (brouter == null || Settings.getRoutingMode() == RoutingMode.STRAIGHT) {
return defaultTrack(start, destination);
}
// avoid updating to frequently
final long timeNow = System.currentTimeMillis();
if ((timeNow - timeLastUpdate) < 1000 * UPDATE_MIN_DELAY_SECONDS) {
return ensureTrack(lastRoutingPoints, start, destination);
}
// Disable routing for huge distances
final int maxThresholdKm = Settings.getBrouterThreshold();
final float targetDistance = start.distanceTo(destination);
if (targetDistance > maxThresholdKm) {
return defaultTrack(start, destination);
}
// disable routing when near the target
if (targetDistance < MIN_ROUTING_DISTANCE_KILOMETERS) {
return defaultTrack(start, destination);
}
// Use cached route if current position has not changed more than 5m and we had a route
// TODO: Maybe adjust this to current zoomlevel
if (lastDirectionUpdatePoint != null && destination == lastDestination && start.distanceTo(lastDirectionUpdatePoint) < UPDATE_MIN_DISTANCE_KILOMETERS && lastRoutingPoints != null) {
return lastRoutingPoints;
}
// now really calculate a new route
lastDestination = destination;
lastRoutingPoints = calculateRouting(start, destination);
lastDirectionUpdatePoint = start;
timeLastUpdate = timeNow;
return ensureTrack(lastRoutingPoints, start, destination);