Search in sources :

Example 6 with OnlineRoutingHelper

use of net.osmand.plus.onlinerouting.OnlineRoutingHelper in project Osmand by osmandapp.

the class MissingMapsHelper method findOnlineRoutePoints.

public List<Location> findOnlineRoutePoints() throws IOException, JSONException {
    List<LatLon> points = new ArrayList<>();
    List<Location> routeLocation = new ArrayList<>();
    OnlineRoutingHelper onlineRoutingHelper = params.ctx.getOnlineRoutingHelper();
    List<Location> location = getStartFinishIntermediatePoints();
    for (Location e : location) {
        points.add(new LatLon(e.getLatitude(), e.getLongitude()));
    }
    OnlineRoutingEngine engine = onlineRoutingHelper.startOsrmEngine(params.mode);
    if (engine != null) {
        OnlineRoutingResponse response = onlineRoutingHelper.calculateRouteOnline(engine, points, params.start.hasBearing() ? params.start.getBearing() : null, params.leftSide, false);
        if (response != null) {
            routeLocation.addAll(response.getRoute());
        }
    }
    return removeDensePoints(routeLocation);
}
Also used : LatLon(net.osmand.data.LatLon) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) ArrayList(java.util.ArrayList) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) OnlineRoutingResponse(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.OnlineRoutingResponse) Location(net.osmand.Location)

Aggregations

OnlineRoutingHelper (net.osmand.plus.onlinerouting.OnlineRoutingHelper)6 OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)4 ArrayList (java.util.ArrayList)2 Location (net.osmand.Location)2 OnlineRoutingResponse (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.OnlineRoutingResponse)2 OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)2 Nullable (androidx.annotation.Nullable)1 OsmandAidlApi (net.osmand.aidl.OsmandAidlApi)1 LatLon (net.osmand.data.LatLon)1 OsmandRegions (net.osmand.map.OsmandRegions)1 MapPoiTypes (net.osmand.osm.MapPoiTypes)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 BackupHelper (net.osmand.plus.backup.BackupHelper)1 NetworkSettingsHelper (net.osmand.plus.backup.NetworkSettingsHelper)1 MapViewTrackingUtilities (net.osmand.plus.base.MapViewTrackingUtilities)1 AnalyticsHelper (net.osmand.plus.helpers.AnalyticsHelper)1 AvoidSpecificRoads (net.osmand.plus.helpers.AvoidSpecificRoads)1 DayNightHelper (net.osmand.plus.helpers.DayNightHelper)1 LauncherShortcutsHelper (net.osmand.plus.helpers.LauncherShortcutsHelper)1 LockHelper (net.osmand.plus.helpers.LockHelper)1