use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.OnlineRoutingResponse in project Osmand by osmandapp.
the class RouteProvider method findOnlineRoute.
private RouteCalculationResult findOnlineRoute(RouteCalculationParams params) throws IOException, JSONException {
OsmandApplication app = params.ctx;
OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
OsmandSettings settings = app.getSettings();
String engineKey = params.mode.getRoutingProfile();
OnlineRoutingResponse response = helper.calculateRouteOnline(engineKey, getPathFromParams(params), params.start.hasBearing() ? params.start.getBearing() : null, params.leftSide, params.initialCalculation);
if (response != null) {
if (response.getGpxFile() != null) {
GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(response.getGpxFile(), settings);
builder.setCalculatedRouteTimeSpeed(response.hasCalculatedTimeSpeed());
params.gpxRoute = builder.build(app);
return calculateGpxRoute(params);
}
List<Location> route = response.getRoute();
List<RouteDirectionInfo> directions = response.getDirections();
if (!Algorithms.isEmpty(route) && !Algorithms.isEmpty(directions)) {
params.intermediates = null;
return new RouteCalculationResult(route, directions, params, null, false);
}
} else {
params.initialCalculation = false;
}
return new RouteCalculationResult("Route is empty");
}
use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine.OnlineRoutingResponse 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);
}
Aggregations