use of net.osmand.plus.onlinerouting.OnlineRoutingHelper in project Osmand by osmandapp.
the class SelectNavProfileBottomSheet method savePredefinedEngine.
private void savePredefinedEngine(RoutingDataObject profile) {
String stringKey = profile.getStringKey();
OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
ProfilesGroup profilesGroup = findGroupOfProfile(profile);
if (profilesGroup != null) {
PredefinedProfilesGroup group = (PredefinedProfilesGroup) profilesGroup;
String type = group.getType().toUpperCase();
OnlineRoutingEngine engine = EngineType.getTypeByName(type).newInstance(null);
engine.put(EngineParameter.KEY, stringKey);
engine.put(EngineParameter.VEHICLE_KEY, NONE_VEHICLE.getKey());
engine.put(EngineParameter.CUSTOM_URL, profile.getDescription());
String namePattern = getString(R.string.ltr_or_rtl_combine_via_dash);
String name = String.format(namePattern, group.getTitle(), profile.getName());
engine.put(EngineParameter.CUSTOM_NAME, name);
helper.saveEngine(engine);
}
}
use of net.osmand.plus.onlinerouting.OnlineRoutingHelper in project Osmand by osmandapp.
the class RoutingDataUtils method getOnlineRoutingProfiles.
private List<ProfileDataObject> getOnlineRoutingProfiles(boolean onlyCustom) {
OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
List<ProfileDataObject> objects = new ArrayList<>();
List<OnlineRoutingEngine> engines = onlyCustom ? helper.getOnlyCustomEngines() : helper.getEngines();
for (int i = 0; i < engines.size(); i++) {
OnlineRoutingDataObject profile = convertOnlineEngineToDataObject(engines.get(i));
profile.setOrder(i);
objects.add(profile);
}
return objects;
}
use of net.osmand.plus.onlinerouting.OnlineRoutingHelper in project Osmand by osmandapp.
the class RoutingDataUtils method getOnlineEngineByKey.
@Nullable
public ProfileDataObject getOnlineEngineByKey(String stringKey) {
OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
OnlineRoutingEngine engine = helper.getEngineByKey(stringKey);
if (engine != null) {
return convertOnlineEngineToDataObject(engine);
}
return null;
}
use of net.osmand.plus.onlinerouting.OnlineRoutingHelper in project Osmand by osmandapp.
the class AppInitializer method onCreateApplication.
public void onCreateApplication() {
// always update application mode to default
OsmandSettings osmandSettings = app.getSettings();
if (osmandSettings.FOLLOW_THE_ROUTE.get()) {
ApplicationMode savedMode = osmandSettings.readApplicationMode();
if (!osmandSettings.APPLICATION_MODE.get().getStringKey().equals(savedMode.getStringKey())) {
osmandSettings.setApplicationMode(savedMode);
}
} else {
osmandSettings.setApplicationMode(osmandSettings.DEFAULT_APPLICATION_MODE.get());
}
startTime = System.currentTimeMillis();
getLazyRoutingConfig();
app.applyTheme(app);
startupInit(app.reconnectToBRouter(), IBRouterService.class);
app.backupHelper = startupInit(new BackupHelper(app), BackupHelper.class);
app.inAppPurchaseHelper = startupInit(new InAppPurchaseHelperImpl(app), InAppPurchaseHelperImpl.class);
app.poiTypes = startupInit(MapPoiTypes.getDefaultNoInit(), MapPoiTypes.class);
app.transportRoutingHelper = startupInit(new TransportRoutingHelper(app), TransportRoutingHelper.class);
app.routingHelper = startupInit(new RoutingHelper(app), RoutingHelper.class);
app.routingOptionsHelper = startupInit(new RoutingOptionsHelper(app), RoutingOptionsHelper.class);
app.resourceManager = startupInit(new ResourceManager(app), ResourceManager.class);
app.daynightHelper = startupInit(new DayNightHelper(app), DayNightHelper.class);
app.locationProvider = startupInit(new OsmAndLocationProvider(app), OsmAndLocationProvider.class);
app.avoidSpecificRoads = startupInit(new AvoidSpecificRoads(app), AvoidSpecificRoads.class);
app.avoidRoadsHelper = startupInit(new AvoidRoadsHelper(app), AvoidRoadsHelper.class);
app.savingTrackHelper = startupInit(new SavingTrackHelper(app), SavingTrackHelper.class);
app.analyticsHelper = startupInit(new AnalyticsHelper(app), AnalyticsHelper.class);
app.notificationHelper = startupInit(new NotificationHelper(app), NotificationHelper.class);
app.liveMonitoringHelper = startupInit(new LiveMonitoringHelper(app), LiveMonitoringHelper.class);
app.selectedGpxHelper = startupInit(new GpxSelectionHelper(app, app.savingTrackHelper), GpxSelectionHelper.class);
app.gpxDbHelper = startupInit(new GpxDbHelper(app), GpxDbHelper.class);
app.favoritesHelper = startupInit(new FavouritesHelper(app), FavouritesHelper.class);
app.waypointHelper = startupInit(new WaypointHelper(app), WaypointHelper.class);
app.aidlApi = startupInit(new OsmandAidlApi(app), OsmandAidlApi.class);
app.regions = startupInit(new OsmandRegions(), OsmandRegions.class);
updateRegionVars();
app.poiFilters = startupInit(new PoiFiltersHelper(app), PoiFiltersHelper.class);
app.rendererRegistry = startupInit(new RendererRegistry(app), RendererRegistry.class);
app.geocodingLookupService = startupInit(new GeocodingLookupService(app), GeocodingLookupService.class);
app.targetPointsHelper = startupInit(new TargetPointsHelper(app), TargetPointsHelper.class);
app.mapMarkersDbHelper = startupInit(new MapMarkersDbHelper(app), MapMarkersDbHelper.class);
app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class);
app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class);
app.mapViewTrackingUtilities = startupInit(new MapViewTrackingUtilities(app), MapViewTrackingUtilities.class);
app.osmandMap = startupInit(new OsmandMap(app), OsmandMap.class);
// TODO TRAVEL_OBF_HELPER check ResourceManager and use TravelObfHelper
TravelHelper travelHelper = !TravelDbHelper.checkIfDbFileExists(app) ? new TravelObfHelper(app) : new TravelDbHelper(app);
app.travelHelper = startupInit(travelHelper, TravelHelper.class);
app.travelRendererHelper = startupInit(new TravelRendererHelper(app), TravelRendererHelper.class);
app.lockHelper = startupInit(new LockHelper(app), LockHelper.class);
app.fileSettingsHelper = startupInit(new FileSettingsHelper(app), FileSettingsHelper.class);
app.networkSettingsHelper = startupInit(new NetworkSettingsHelper(app), NetworkSettingsHelper.class);
app.quickActionRegistry = startupInit(new QuickActionRegistry(app.getSettings()), QuickActionRegistry.class);
app.osmOAuthHelper = startupInit(new OsmOAuthHelper(app), OsmOAuthHelper.class);
app.oprAuthHelper = startupInit(new OprAuthHelper(app), OprAuthHelper.class);
app.onlineRoutingHelper = startupInit(new OnlineRoutingHelper(app), OnlineRoutingHelper.class);
app.launcherShortcutsHelper = startupInit(new LauncherShortcutsHelper(app), LauncherShortcutsHelper.class);
app.gpsFilterHelper = startupInit(new GpsFilterHelper(app), GpsFilterHelper.class);
app.downloadTilesHelper = startupInit(new DownloadTilesHelper(app), DownloadTilesHelper.class);
initOpeningHoursParser();
}
use of net.osmand.plus.onlinerouting.OnlineRoutingHelper 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");
}
Aggregations