refactoring custom routing calculation params
This commit is contained in:
parent
9916b72555
commit
ab0e7f0f1c
5 changed files with 11 additions and 27 deletions
|
@ -93,7 +93,7 @@ public class GeneralRouter implements VehicleRouter {
|
|||
PEDESTRIAN,
|
||||
BICYCLE,
|
||||
BOAT,
|
||||
PUBLIC_TRANSPORT,
|
||||
PUBLIC_TRANSPORT
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ public class RoutingConfiguration {
|
|||
currentRouter.setProfileName(currentSelectedRouterName);
|
||||
if (filename != null) {
|
||||
currentRouter.setFilename(filename);
|
||||
currentSelectedRouterName = filename + "//" + currentSelectedRouterName;
|
||||
currentSelectedRouterName = filename + "/" + currentSelectedRouterName;
|
||||
}
|
||||
|
||||
config.routers.put(currentSelectedRouterName, currentRouter);
|
||||
|
|
|
@ -47,7 +47,6 @@ import net.osmand.plus.activities.SavingTrackHelper;
|
|||
import net.osmand.plus.api.SQLiteAPI;
|
||||
import net.osmand.plus.api.SQLiteAPIImpl;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashErrorFragment;
|
||||
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
|
||||
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
|
||||
import net.osmand.plus.download.DownloadIndexesThread;
|
||||
|
@ -135,7 +134,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
InAppPurchaseHelper inAppPurchaseHelper;
|
||||
MapViewTrackingUtilities mapViewTrackingUtilities;
|
||||
|
||||
RoutingConfiguration.Builder defaultRoutingConfig;
|
||||
RoutingConfiguration.Builder routingConfig;
|
||||
private Locale preferredLocale = null;
|
||||
private Locale defaultLocale;
|
||||
private File externalStorageDirectory;
|
||||
|
@ -808,12 +807,12 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
}
|
||||
|
||||
public synchronized RoutingConfiguration.Builder getRoutingConfig() {
|
||||
if(defaultRoutingConfig == null) {
|
||||
defaultRoutingConfig = appInitializer.getLazyRoutingConfig();
|
||||
if(routingConfig == null) {
|
||||
routingConfig = appInitializer.getLazyRoutingConfig();
|
||||
}
|
||||
return defaultRoutingConfig;
|
||||
return routingConfig;
|
||||
}
|
||||
|
||||
|
||||
public OsmandRegions getRegions() {
|
||||
return regions;
|
||||
}
|
||||
|
|
|
@ -360,7 +360,7 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
public static GeneralRouter getRouter(net.osmand.router.RoutingConfiguration.Builder builder, ApplicationMode am) {
|
||||
GeneralRouter router = builder.getRouter(am.getRoutingProfile());
|
||||
if(router == null && am.getParent() != null) {
|
||||
router = builder.getRouter(am.getParent().getRoutingProfile());
|
||||
router = builder.getRouter(am.getParent().getStringKey());
|
||||
}
|
||||
return router;
|
||||
}
|
||||
|
|
|
@ -680,20 +680,6 @@ public class RouteProvider {
|
|||
|
||||
private RoutingConfiguration initOsmAndRoutingConfig(Builder config, final RouteCalculationParams params, OsmandSettings settings,
|
||||
GeneralRouter generalRouter) throws IOException, FileNotFoundException {
|
||||
GeneralRouterProfile p ;
|
||||
|
||||
if (params.mode.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
|
||||
p = GeneralRouterProfile.BICYCLE;
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
|
||||
p = GeneralRouterProfile.PEDESTRIAN;
|
||||
} else if(params.mode.isDerivedRoutingFrom(ApplicationMode.CAR)){
|
||||
p = GeneralRouterProfile.CAR;
|
||||
} else if (params.mode.isDerivedRoutingFrom(ApplicationMode.BOAT)) {
|
||||
p = GeneralRouterProfile.BOAT;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, String> paramsR = new LinkedHashMap<String, String>();
|
||||
for(Map.Entry<String, RoutingParameter> e : generalRouter.getParameters().entrySet()){
|
||||
String key = e.getKey();
|
||||
|
@ -721,10 +707,9 @@ public class RouteProvider {
|
|||
// make visible
|
||||
int memoryLimit = (int) (0.95 * ((rt.maxMemory() - rt.totalMemory()) + rt.freeMemory()) / mb);
|
||||
log.warn("Use " + memoryLimit + " MB Free " + rt.freeMemory() / mb + " of " + rt.totalMemory() / mb + " max " + rt.maxMemory() / mb);
|
||||
|
||||
RoutingConfiguration cf = config.build(p.name().toLowerCase(), params.start.hasBearing() ?
|
||||
params.start.getBearing() / 180d * Math.PI : null,
|
||||
memoryLimit, paramsR);
|
||||
RoutingConfiguration cf = config.build( params.mode.getRoutingProfile(), params.start.hasBearing() ?
|
||||
params.start.getBearing() / 180d * Math.PI : null,
|
||||
memoryLimit, paramsR);
|
||||
return cf;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue