Custom routing config initial commit
This commit is contained in:
parent
8cee733641
commit
5a62f55a5b
13 changed files with 97 additions and 68 deletions
|
@ -69,8 +69,10 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import btools.routingapp.BRouterServiceConnection;
|
import btools.routingapp.BRouterServiceConnection;
|
||||||
|
@ -593,19 +595,23 @@ public class AppInitializer implements IProgress {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadRoutingFiles(final OsmandApplication app, final LoadRoutingFilesCallback callback) {
|
public static void loadRoutingFiles(final OsmandApplication app, final LoadRoutingFilesCallback callback) {
|
||||||
new AsyncTask<Void, Void, RoutingConfiguration.Builder>() {
|
new AsyncTask<Void, Void, Map<String, RoutingConfiguration.Builder>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected RoutingConfiguration.Builder doInBackground(Void... voids) {
|
protected Map<String, RoutingConfiguration.Builder> doInBackground(Void... voids) {
|
||||||
|
Map<String, RoutingConfiguration.Builder> customConfigs = new HashMap<>();
|
||||||
File routingFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
File routingFolder = app.getAppPath(IndexConstants.ROUTING_PROFILES_DIR);
|
||||||
RoutingConfiguration.Builder builder = RoutingConfiguration.getDefault();
|
RoutingConfiguration.Builder defaultBuilder = RoutingConfiguration.getDefault();
|
||||||
if (routingFolder.isDirectory()) {
|
if (routingFolder.isDirectory()) {
|
||||||
File[] fl = routingFolder.listFiles();
|
File[] fl = routingFolder.listFiles();
|
||||||
if (fl != null && fl.length > 0) {
|
if (fl != null && fl.length > 0) {
|
||||||
for (File f : fl) {
|
for (File f : fl) {
|
||||||
if (f.isFile() && f.getName().endsWith(".xml") && f.canRead()) {
|
if (f.isFile() && f.getName().endsWith(IndexConstants.ROUTING_FILE_EXT) && f.canRead()) {
|
||||||
try {
|
try {
|
||||||
RoutingConfiguration.parseFromInputStream(new FileInputStream(f), f.getName(), builder);
|
String fileName = f.getName();
|
||||||
|
RoutingConfiguration.Builder builder = new RoutingConfiguration.Builder();
|
||||||
|
RoutingConfiguration.parseFromInputStream(new FileInputStream(f), fileName, builder);
|
||||||
|
customConfigs.put(fileName, builder);
|
||||||
} catch (XmlPullParserException | IOException e) {
|
} catch (XmlPullParserException | IOException e) {
|
||||||
throw new IllegalStateException(e);
|
throw new IllegalStateException(e);
|
||||||
}
|
}
|
||||||
|
@ -613,13 +619,14 @@ public class AppInitializer implements IProgress {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return builder;
|
return customConfigs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(RoutingConfiguration.Builder builder) {
|
protected void onPostExecute(Map<String, RoutingConfiguration.Builder> customConfigs) {
|
||||||
super.onPostExecute(builder);
|
if (!customConfigs.isEmpty()) {
|
||||||
app.updateRoutingConfig(builder);
|
app.getCustomRoutingConfigs().putAll(customConfigs);
|
||||||
|
}
|
||||||
callback.onRoutingFilesLoaded();
|
callback.onRoutingFilesLoaded();
|
||||||
}
|
}
|
||||||
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
|
@ -137,11 +137,11 @@ public class CurrentPositionHelper {
|
||||||
for (BinaryMapReaderResource rep : checkReaders) {
|
for (BinaryMapReaderResource rep : checkReaders) {
|
||||||
rs[i++] = rep.getReader(BinaryMapReaderResourceType.STREET_LOOKUP);
|
rs[i++] = rep.getReader(BinaryMapReaderResourceType.STREET_LOOKUP);
|
||||||
}
|
}
|
||||||
RoutingConfiguration cfg = app.getRoutingConfig().build(p, 10,
|
RoutingConfiguration cfg = app.getRoutingConfigForMode(am).build(p, 10,
|
||||||
new HashMap<String, String>());
|
new HashMap<String, String>());
|
||||||
cfg.routeCalculationTime = System.currentTimeMillis();
|
cfg.routeCalculationTime = System.currentTimeMillis();
|
||||||
ctx = new RoutePlannerFrontEnd().buildRoutingContext(cfg, null, rs);
|
ctx = new RoutePlannerFrontEnd().buildRoutingContext(cfg, null, rs);
|
||||||
RoutingConfiguration defCfg = app.getRoutingConfig().build("geocoding", 10,
|
RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build("geocoding", 10,
|
||||||
new HashMap<String, String>());
|
new HashMap<String, String>());
|
||||||
defCtx = new RoutePlannerFrontEnd().buildRoutingContext(defCfg, null, rs);
|
defCtx = new RoutePlannerFrontEnd().buildRoutingContext(defCfg, null, rs);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,12 +25,9 @@ import android.support.v7.app.AlertDialog;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.accessibility.AccessibilityManager;
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.CallbackWithObject;
|
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
import net.osmand.access.AccessibilityPlugin;
|
||||||
|
@ -59,7 +56,6 @@ import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||||
import net.osmand.plus.helpers.LockHelper;
|
import net.osmand.plus.helpers.LockHelper;
|
||||||
import net.osmand.plus.helpers.WaypointHelper;
|
import net.osmand.plus.helpers.WaypointHelper;
|
||||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
|
|
||||||
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
import net.osmand.plus.mapmarkers.MapMarkersDbHelper;
|
||||||
import net.osmand.plus.monitoring.LiveMonitoringHelper;
|
import net.osmand.plus.monitoring.LiveMonitoringHelper;
|
||||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||||
|
@ -84,11 +80,15 @@ import java.io.PrintStream;
|
||||||
import java.lang.Thread.UncaughtExceptionHandler;
|
import java.lang.Thread.UncaughtExceptionHandler;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import btools.routingapp.BRouterServiceConnection;
|
import btools.routingapp.BRouterServiceConnection;
|
||||||
import btools.routingapp.IBRouterService;
|
import btools.routingapp.IBRouterService;
|
||||||
|
|
||||||
|
import static net.osmand.IndexConstants.ROUTING_FILE_EXT;
|
||||||
|
|
||||||
public class OsmandApplication extends MultiDexApplication {
|
public class OsmandApplication extends MultiDexApplication {
|
||||||
public static final String EXCEPTION_PATH = "exception.log";
|
public static final String EXCEPTION_PATH = "exception.log";
|
||||||
public static final String OSMAND_PRIVACY_POLICY_URL = "https://osmand.net/help-online/privacy-policy";
|
public static final String OSMAND_PRIVACY_POLICY_URL = "https://osmand.net/help-online/privacy-policy";
|
||||||
|
@ -143,7 +143,8 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
|
|
||||||
private Resources localizedResources;
|
private Resources localizedResources;
|
||||||
|
|
||||||
private RoutingConfiguration.Builder routingConfig;
|
private Map<String, Builder> customRoutingConfigs = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
private Locale preferredLocale = null;
|
private Locale preferredLocale = null;
|
||||||
private Locale defaultLocale;
|
private Locale defaultLocale;
|
||||||
private File externalStorageDirectory;
|
private File externalStorageDirectory;
|
||||||
|
@ -810,18 +811,29 @@ public class OsmandApplication extends MultiDexApplication {
|
||||||
return localizedResources != null ? localizedResources : super.getResources();
|
return localizedResources != null ? localizedResources : super.getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized RoutingConfiguration.Builder getRoutingConfig() {
|
public RoutingConfiguration.Builder getDefaultRoutingConfig() {
|
||||||
RoutingConfiguration.Builder rc;
|
return RoutingConfiguration.getDefault();
|
||||||
if(routingConfig == null) {
|
|
||||||
rc = new RoutingConfiguration.Builder();
|
|
||||||
} else {
|
|
||||||
rc = routingConfig;
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRoutingConfig(Builder update) {
|
public Map<String, RoutingConfiguration.Builder> getCustomRoutingConfigs() {
|
||||||
routingConfig = update;
|
return customRoutingConfigs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RoutingConfiguration.Builder getCustomRoutingConfig(String key) {
|
||||||
|
return customRoutingConfigs.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized RoutingConfiguration.Builder getRoutingConfigForMode(ApplicationMode mode) {
|
||||||
|
RoutingConfiguration.Builder builder = null;
|
||||||
|
String routingProfileKey = mode.getRoutingProfile();
|
||||||
|
if (!Algorithms.isEmpty(routingProfileKey)) {
|
||||||
|
int index = routingProfileKey.indexOf(ROUTING_FILE_EXT);
|
||||||
|
if (index != -1) {
|
||||||
|
String configKey = routingProfileKey.substring(0, index + ROUTING_FILE_EXT.length());
|
||||||
|
builder = customRoutingConfigs.get(configKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder != null ? builder : getDefaultRoutingConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OsmandRegions getRegions() {
|
public OsmandRegions getRegions() {
|
||||||
|
|
|
@ -314,7 +314,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
cat.addPreference(fastRoute);
|
cat.addPreference(fastRoute);
|
||||||
} else {
|
} else {
|
||||||
ApplicationMode am = settings.getApplicationMode();
|
ApplicationMode am = settings.getApplicationMode();
|
||||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am);
|
GeneralRouter router = getRouter(getMyApplication().getRoutingConfigForMode(am), am);
|
||||||
clearParameters();
|
clearParameters();
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
GeneralRouterProfile routerProfile = router.getProfile();
|
GeneralRouterProfile routerProfile = router.getProfile();
|
||||||
|
@ -728,7 +728,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
|
|
||||||
GeneralRouter router = getRouter(app.getRoutingConfig(), mode);
|
GeneralRouter router = getRouter(app.getRoutingConfigForMode(mode), mode);
|
||||||
SpeedConstants units = settings.SPEED_SYSTEM.getModeValue(mode);
|
SpeedConstants units = settings.SPEED_SYSTEM.getModeValue(mode);
|
||||||
String speedUnits = units.toShortString(activity);
|
String speedUnits = units.toShortString(activity);
|
||||||
final float[] ratio = new float[1];
|
final float[] ratio = new float[1];
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class AvoidSpecificRoads {
|
||||||
app.getSettings().removeImpassableRoad(latLon);
|
app.getSettings().removeImpassableRoad(latLon);
|
||||||
RouteDataObject obj = impassableRoads.remove(latLon);
|
RouteDataObject obj = impassableRoads.remove(latLon);
|
||||||
if (obj != null) {
|
if (obj != null) {
|
||||||
app.getRoutingConfig().removeImpassableRoad(obj);
|
app.getDefaultRoutingConfig().removeImpassableRoad(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ public class AvoidSpecificRoads {
|
||||||
final LatLon oldLoc = getLocation(currentObject);
|
final LatLon oldLoc = getLocation(currentObject);
|
||||||
app.getSettings().moveImpassableRoad(oldLoc, newLoc);
|
app.getSettings().moveImpassableRoad(oldLoc, newLoc);
|
||||||
impassableRoads.remove(oldLoc);
|
impassableRoads.remove(oldLoc);
|
||||||
app.getRoutingConfig().removeImpassableRoad(currentObject);
|
app.getDefaultRoutingConfig().removeImpassableRoad(currentObject);
|
||||||
addImpassableRoadInternal(object, ll, showDialog, activity, newLoc);
|
addImpassableRoadInternal(object, ll, showDialog, activity, newLoc);
|
||||||
|
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
@ -310,7 +310,7 @@ public class AvoidSpecificRoads {
|
||||||
boolean showDialog,
|
boolean showDialog,
|
||||||
@Nullable MapActivity activity,
|
@Nullable MapActivity activity,
|
||||||
@NonNull LatLon loc) {
|
@NonNull LatLon loc) {
|
||||||
if (app.getRoutingConfig().addImpassableRoad(object, ll)) {
|
if (app.getDefaultRoutingConfig().addImpassableRoad(object, ll)) {
|
||||||
impassableRoads.put(loc, object);
|
impassableRoads.put(loc, object);
|
||||||
} else {
|
} else {
|
||||||
LatLon location = getLocation(object);
|
LatLon location = getLocation(object);
|
||||||
|
@ -339,7 +339,7 @@ public class AvoidSpecificRoads {
|
||||||
}
|
}
|
||||||
|
|
||||||
public LatLon getLocation(RouteDataObject object) {
|
public LatLon getLocation(RouteDataObject object) {
|
||||||
Location location = app.getRoutingConfig().getImpassableRoadLocations().get(object.getId());
|
Location location = app.getDefaultRoutingConfig().getImpassableRoadLocations().get(object.getId());
|
||||||
return location == null ? null : new LatLon(location.getLatitude(), location.getLongitude());
|
return location == null ? null : new LatLon(location.getLatitude(), location.getLongitude());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,6 @@ import net.osmand.router.RoutingConfiguration;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -661,7 +660,7 @@ public class ImportHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
@SuppressLint("StaticFieldLeak")
|
||||||
private void handleRoutingFileImport(final Uri uri, final String fileName, final CallbackWithObject<String> callback) {
|
private void handleRoutingFileImport(final Uri uri, final String fileName, final CallbackWithObject<RoutingConfiguration.Builder> callback) {
|
||||||
final AsyncTask<Void, Void, String> routingImportTask = new AsyncTask<Void, Void, String>() {
|
final AsyncTask<Void, Void, String> routingImportTask = new AsyncTask<Void, Void, String>() {
|
||||||
|
|
||||||
String mFileName;
|
String mFileName;
|
||||||
|
@ -698,11 +697,11 @@ public class ImportHelper {
|
||||||
if (isActivityNotDestroyed(activity)) {
|
if (isActivityNotDestroyed(activity)) {
|
||||||
progress.dismiss();
|
progress.dismiss();
|
||||||
}
|
}
|
||||||
String profileKey = app.getRoutingConfig().getRoutingProfileKeyByFileName(mFileName);
|
RoutingConfiguration.Builder builder = app.getCustomRoutingConfig(mFileName);
|
||||||
if (profileKey != null) {
|
if (builder != null) {
|
||||||
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, mFileName));
|
app.showShortToastMessage(app.getString(R.string.file_imported_successfully, mFileName));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.processResult(profileKey);
|
callback.processResult(builder);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
app.showToastMessage(app.getString(R.string.file_does_not_contain_routing_rules, mFileName));
|
app.showToastMessage(app.getString(R.string.file_does_not_contain_routing_rules, mFileName));
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||||
import net.osmand.plus.settings.MainSettingsFragment;
|
import net.osmand.plus.settings.MainSettingsFragment;
|
||||||
import net.osmand.plus.settings.NavigationFragment;
|
import net.osmand.plus.settings.NavigationFragment;
|
||||||
import net.osmand.plus.settings.ProfileAppearanceFragment;
|
import net.osmand.plus.settings.ProfileAppearanceFragment;
|
||||||
|
import net.osmand.router.RoutingConfiguration;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -160,9 +161,9 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mapActivity.getImportHelper().chooseFileToImport(ROUTING, false,
|
mapActivity.getImportHelper().chooseFileToImport(ROUTING, false,
|
||||||
new CallbackWithObject<String>() {
|
new CallbackWithObject<RoutingConfiguration.Builder>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean processResult(String profileKey) {
|
public boolean processResult(RoutingConfiguration.Builder builder) {
|
||||||
refreshView();
|
refreshView();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,7 +409,7 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public LocalRoutingParameter getRoutingParameterInnerById(ApplicationMode am, String parameterId) {
|
public LocalRoutingParameter getRoutingParameterInnerById(ApplicationMode am, String parameterId) {
|
||||||
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
|
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
|
||||||
GeneralRouter rm = getRouter(app.getRoutingConfig(), am);
|
GeneralRouter rm = getRouter(app.getRoutingConfigForMode(am), am);
|
||||||
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
|
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -493,7 +493,7 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
|
RouteProvider.GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
|
||||||
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>(getGpxRouterParameters(am));
|
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>(getGpxRouterParameters(am));
|
||||||
GeneralRouter rm = SettingsNavigationActivity.getRouter(app.getRoutingConfig(), am);
|
GeneralRouter rm = SettingsNavigationActivity.getRouter(app.getRoutingConfigForMode(am), am);
|
||||||
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
|
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ public class RoutingOptionsHelper {
|
||||||
|
|
||||||
public List<GeneralRouter.RoutingParameter> getAvoidRoutingPrefsForAppMode(ApplicationMode applicationMode) {
|
public List<GeneralRouter.RoutingParameter> getAvoidRoutingPrefsForAppMode(ApplicationMode applicationMode) {
|
||||||
List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
List<GeneralRouter.RoutingParameter> avoidParameters = new ArrayList<GeneralRouter.RoutingParameter>();
|
||||||
GeneralRouter router = getRouter(app.getRoutingConfig(), applicationMode);
|
GeneralRouter router = getRouter(app.getRoutingConfigForMode(applicationMode), applicationMode);
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : router.getParameters().entrySet()) {
|
for (Map.Entry<String, GeneralRouter.RoutingParameter> e : router.getParameters().entrySet()) {
|
||||||
String param = e.getKey();
|
String param = e.getKey();
|
||||||
|
@ -597,7 +597,7 @@ public class RoutingOptionsHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneralRouter.RoutingParameter getRoutingPrefsForAppModeById(ApplicationMode applicationMode, String parameterId) {
|
public GeneralRouter.RoutingParameter getRoutingPrefsForAppModeById(ApplicationMode applicationMode, String parameterId) {
|
||||||
GeneralRouter router = getRouter(app.getRoutingConfig(), applicationMode);
|
GeneralRouter router = getRouter(app.getRoutingConfigForMode(applicationMode), applicationMode);
|
||||||
GeneralRouter.RoutingParameter parameter = null;
|
GeneralRouter.RoutingParameter parameter = null;
|
||||||
|
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
|
|
|
@ -598,9 +598,9 @@ public class RouteProvider {
|
||||||
OsmandSettings settings = params.ctx.getSettings();
|
OsmandSettings settings = params.ctx.getSettings();
|
||||||
router.setUseFastRecalculation(settings.USE_FAST_RECALCULATION.get());
|
router.setUseFastRecalculation(settings.USE_FAST_RECALCULATION.get());
|
||||||
|
|
||||||
RoutingConfiguration.Builder config = params.ctx.getRoutingConfig();
|
RoutingConfiguration.Builder config = params.ctx.getRoutingConfigForMode(params.mode);
|
||||||
GeneralRouter generalRouter = SettingsNavigationActivity.getRouter(config, params.mode);
|
GeneralRouter generalRouter = SettingsNavigationActivity.getRouter(config, params.mode);
|
||||||
if(generalRouter == null) {
|
if (generalRouter == null) {
|
||||||
return applicationModeNotSupported(params);
|
return applicationModeNotSupported(params);
|
||||||
}
|
}
|
||||||
RoutingConfiguration cf = initOsmAndRoutingConfig(config, params, settings, generalRouter);
|
RoutingConfiguration cf = initOsmAndRoutingConfig(config, params, settings, generalRouter);
|
||||||
|
|
|
@ -452,7 +452,7 @@ public class TransportRoutingHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TransportRouteResult> calculateRouteImpl(TransportRouteCalculationParams params) throws IOException, InterruptedException {
|
private List<TransportRouteResult> calculateRouteImpl(TransportRouteCalculationParams params) throws IOException, InterruptedException {
|
||||||
RoutingConfiguration.Builder config = params.ctx.getRoutingConfig();
|
RoutingConfiguration.Builder config = params.ctx.getRoutingConfigForMode(params.mode);
|
||||||
BinaryMapIndexReader[] files = params.ctx.getResourceManager().getTransportRoutingMapFiles();
|
BinaryMapIndexReader[] files = params.ctx.getResourceManager().getTransportRoutingMapFiles();
|
||||||
params.params.clear();
|
params.params.clear();
|
||||||
OsmandSettings settings = params.ctx.getSettings();
|
OsmandSettings settings = params.ctx.getSettings();
|
||||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.plus.profiles.SelectProfileBottomSheetDialogFragment;
|
||||||
import net.osmand.plus.routing.RouteProvider;
|
import net.osmand.plus.routing.RouteProvider;
|
||||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||||
import net.osmand.router.GeneralRouter;
|
import net.osmand.router.GeneralRouter;
|
||||||
|
import net.osmand.router.RoutingConfiguration;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -158,7 +159,7 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
RouteProvider.RouteService routeService;
|
RouteProvider.RouteService routeService;
|
||||||
if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
|
if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
|
||||||
routeService = RouteProvider.RouteService.STRAIGHT;
|
routeService = RouteProvider.RouteService.STRAIGHT;
|
||||||
} else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())){
|
} else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())) {
|
||||||
routeService = RouteProvider.RouteService.DIRECT_TO;
|
routeService = RouteProvider.RouteService.DIRECT_TO;
|
||||||
} else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) {
|
} else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) {
|
||||||
routeService = RouteProvider.RouteService.BROUTER;
|
routeService = RouteProvider.RouteService.BROUTER;
|
||||||
|
@ -227,26 +228,33 @@ public class NavigationFragment extends BaseSettingsFragment {
|
||||||
false, null));
|
false, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, GeneralRouter> inputProfiles = context.getRoutingConfig().getAllRouters();
|
collectRoutingProfilesFromConfig(context, context.getDefaultRoutingConfig(), profilesObjects);
|
||||||
for (Map.Entry<String, GeneralRouter> e : inputProfiles.entrySet()) {
|
for (RoutingConfiguration.Builder builder : context.getCustomRoutingConfigs().values()) {
|
||||||
if (!e.getKey().equals("geocoding")) {
|
collectRoutingProfilesFromConfig(context, builder, profilesObjects);
|
||||||
int iconRes = R.drawable.ic_action_gdirections_dark;
|
|
||||||
String name = e.getValue().getProfileName();
|
|
||||||
String description = context.getString(R.string.osmand_default_routing);
|
|
||||||
if (!Algorithms.isEmpty(e.getValue().getFilename())) {
|
|
||||||
description = e.getValue().getFilename();
|
|
||||||
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) {
|
|
||||||
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
|
||||||
name = context
|
|
||||||
.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
|
||||||
}
|
|
||||||
profilesObjects.put(e.getKey(), new RoutingProfileDataObject(e.getKey(), name, description,
|
|
||||||
iconRes, false, e.getValue().getFilename()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return profilesObjects;
|
return profilesObjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void collectRoutingProfilesFromConfig(OsmandApplication app, RoutingConfiguration.Builder builder, Map<String, RoutingProfileDataObject> profilesObjects) {
|
||||||
|
for (Map.Entry<String, GeneralRouter> entry : builder.getAllRouters().entrySet()) {
|
||||||
|
String routerKey = entry.getKey();
|
||||||
|
GeneralRouter router = entry.getValue();
|
||||||
|
if (!routerKey.equals("geocoding")) {
|
||||||
|
int iconRes = R.drawable.ic_action_gdirections_dark;
|
||||||
|
String name = router.getProfileName();
|
||||||
|
String description = app.getString(R.string.osmand_default_routing);
|
||||||
|
if (!Algorithms.isEmpty(router.getFilename())) {
|
||||||
|
description = router.getFilename();
|
||||||
|
} else if (RoutingProfilesResources.isRpValue(name.toUpperCase())) {
|
||||||
|
iconRes = RoutingProfilesResources.valueOf(name.toUpperCase()).getIconRes();
|
||||||
|
name = app.getString(RoutingProfilesResources.valueOf(name.toUpperCase()).getStringRes());
|
||||||
|
}
|
||||||
|
profilesObjects.put(routerKey, new RoutingProfileDataObject(routerKey, name, description,
|
||||||
|
iconRes, false, router.getFilename()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static List<ProfileDataObject> getBaseProfiles(Context ctx) {
|
public static List<ProfileDataObject> getBaseProfiles(Context ctx) {
|
||||||
List<ProfileDataObject> profiles = new ArrayList<>();
|
List<ProfileDataObject> profiles = new ArrayList<>();
|
||||||
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
|
for (ApplicationMode mode : ApplicationMode.getDefaultValues()) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
|
||||||
if (am.getRouteService() != RouteProvider.RouteService.OSMAND) {
|
if (am.getRouteService() != RouteProvider.RouteService.OSMAND) {
|
||||||
screen.addPreference(fastRoute);
|
screen.addPreference(fastRoute);
|
||||||
} else {
|
} else {
|
||||||
GeneralRouter router = getRouter(getMyApplication().getRoutingConfig(), am);
|
GeneralRouter router = getRouter(app.getRoutingConfigForMode(am), am);
|
||||||
clearParameters();
|
clearParameters();
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
Map<String, RoutingParameter> parameters = router.getParameters();
|
Map<String, RoutingParameter> parameters = router.getParameters();
|
||||||
|
|
|
@ -6,6 +6,7 @@ import android.support.v7.preference.Preference;
|
||||||
import android.support.v7.preference.PreferenceViewHolder;
|
import android.support.v7.preference.PreferenceViewHolder;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
@ -38,9 +39,10 @@ public class VehicleParametersFragment extends BaseSettingsFragment implements O
|
||||||
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
vehicleParametersInfo.setIcon(getContentIcon(R.drawable.ic_action_info_dark));
|
||||||
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
|
vehicleParametersInfo.setTitle(getString(R.string.route_parameters_info, getSelectedAppMode().toHumanString()));
|
||||||
|
|
||||||
RouteService routeService = getSelectedAppMode().getRouteService();
|
ApplicationMode mode = getSelectedAppMode();
|
||||||
|
RouteService routeService = mode.getRouteService();
|
||||||
if (routeService == RouteService.OSMAND) {
|
if (routeService == RouteService.OSMAND) {
|
||||||
GeneralRouter router = getRouter(app.getRoutingConfig(), getSelectedAppMode());
|
GeneralRouter router = getRouter(app.getRoutingConfigForMode(mode), mode);
|
||||||
if (router != null) {
|
if (router != null) {
|
||||||
Map<String, GeneralRouter.RoutingParameter> parameters = router.getParameters();
|
Map<String, GeneralRouter.RoutingParameter> parameters = router.getParameters();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue