Search in sources :

Example 1 with GeneralRouterProfile

use of net.osmand.router.GeneralRouter.GeneralRouterProfile in project Osmand by osmandapp.

the class RoutingConfiguration method parseRoutingProfile.

private static GeneralRouter parseRoutingProfile(XmlPullParser parser, final RoutingConfiguration.Builder config) {
    String currentSelectedRouter = parser.getAttributeValue("", "name");
    Map<String, String> attrs = new LinkedHashMap<String, String>();
    for (int i = 0; i < parser.getAttributeCount(); i++) {
        attrs.put(parser.getAttributeName(i), parser.getAttributeValue(i));
    }
    GeneralRouterProfile c = Algorithms.parseEnumValue(GeneralRouterProfile.values(), parser.getAttributeValue("", "baseProfile"), GeneralRouterProfile.CAR);
    GeneralRouter currentRouter = new GeneralRouter(c, attrs);
    config.routers.put(currentSelectedRouter, currentRouter);
    return currentRouter;
}
Also used : GeneralRouterProfile(net.osmand.router.GeneralRouter.GeneralRouterProfile) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with GeneralRouterProfile

use of net.osmand.router.GeneralRouter.GeneralRouterProfile 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;
}
Also used : CommonPreference(net.osmand.plus.OsmandSettings.CommonPreference) GeneralRouterProfile(net.osmand.router.GeneralRouter.GeneralRouterProfile) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) LocationPoint(net.osmand.data.LocationPoint) LinkedHashMap(java.util.LinkedHashMap) RoutingParameter(net.osmand.router.GeneralRouter.RoutingParameter) RoutingConfiguration(net.osmand.router.RoutingConfiguration) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

LinkedHashMap (java.util.LinkedHashMap)2 GeneralRouterProfile (net.osmand.router.GeneralRouter.GeneralRouterProfile)2 Map (java.util.Map)1 LocationPoint (net.osmand.data.LocationPoint)1 CommonPreference (net.osmand.plus.OsmandSettings.CommonPreference)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 RoutingParameter (net.osmand.router.GeneralRouter.RoutingParameter)1 RoutingConfiguration (net.osmand.router.RoutingConfiguration)1