use of net.osmand.router.RoutingConfiguration in project Osmand by osmandapp.
the class CurrentPositionHelper method initCtx.
private void initCtx(OsmandApplication app, List<BinaryMapReaderResource> checkReaders, @NonNull ApplicationMode appMode) {
am = appMode;
String p;
if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
p = GeneralRouterProfile.BICYCLE.name().toLowerCase();
} else if (am.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
p = GeneralRouterProfile.PEDESTRIAN.name().toLowerCase();
} else if (am.isDerivedRoutingFrom(ApplicationMode.CAR)) {
p = GeneralRouterProfile.CAR.name().toLowerCase();
} else {
p = "geocoding";
}
BinaryMapIndexReader[] rs = new BinaryMapIndexReader[checkReaders.size()];
if (rs.length > 0) {
int i = 0;
for (BinaryMapReaderResource rep : checkReaders) {
rs[i++] = rep.getReader(BinaryMapReaderResourceType.STREET_LOOKUP);
}
RoutingConfiguration cfg = app.getDefaultRoutingConfig().build(p, 10, new HashMap<String, String>());
ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, rs);
RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build("geocoding", 10, new HashMap<String, String>());
defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
} else {
ctx = null;
defCtx = null;
}
usedReaders = checkReaders;
}
use of net.osmand.router.RoutingConfiguration in project Osmand by osmandapp.
the class RouteProvider method initOsmAndRoutingConfig.
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();
RoutingParameter pr = e.getValue();
String vl;
if (key.equals(GeneralRouter.USE_SHORTEST_WAY)) {
Boolean bool = !settings.FAST_ROUTE_MODE.getModeValue(params.mode);
vl = bool ? "true" : null;
} else if (pr.getType() == RoutingParameterType.BOOLEAN) {
CommonPreference<Boolean> pref = settings.getCustomRoutingBooleanProperty(key, pr.getDefaultBoolean());
Boolean bool = pref.getModeValue(params.mode);
vl = bool ? "true" : null;
} else {
vl = settings.getCustomRoutingProperty(key, "").getModeValue(params.mode);
}
if (vl != null && vl.length() > 0) {
paramsR.put(key, vl);
}
}
if (params.inSnapToRoadMode) {
paramsR.put(GeneralRouter.ALLOW_PRIVATE, "true");
}
float mb = (1 << 20);
Runtime rt = Runtime.getRuntime();
// 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);
return cf;
}
use of net.osmand.router.RoutingConfiguration in project Osmand by osmandapp.
the class CurrentPositionHelper method initCtx.
private void initCtx(SampleApplication app, List<BinaryMapIndexReader> checkReaders) {
BinaryMapIndexReader[] rs = checkReaders.toArray(new BinaryMapIndexReader[checkReaders.size()]);
if (rs.length > 0) {
RoutingConfiguration defCfg = RoutingConfiguration.getDefault().build("geocoding", 10, new HashMap<String, String>());
defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
} else {
defCtx = null;
}
usedReaders = checkReaders;
}
Aggregations