Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-02-11 11:45:20 +01:00
commit 68bb6db601

View file

@ -310,8 +310,7 @@ public class GeneralRouter implements VehicleRouter {
int percentIncl = (int) (incl * 100); int percentIncl = (int) (incl * 100);
percentIncl = (percentIncl + 2)/ 3 * 3 - 2; // 1, 4, 7, 10, . percentIncl = (percentIncl + 2)/ 3 * 3 - 2; // 1, 4, 7, 10, .
if(percentIncl > 0) { if(percentIncl > 0) {
// IMPROVEMENT: register with value and cache parsed value objContext.paramContext.incline = percentIncl;
objContext.paramContext.vars.put("incline", percentIncl + "");
sum += objContext.evaluateFloat(road.region, types, 0) * diff; sum += objContext.evaluateFloat(road.region, types, 0) * diff;
} }
} }
@ -468,6 +467,7 @@ public class GeneralRouter implements VehicleRouter {
private class ParameterContext { private class ParameterContext {
private Map<String, String> vars; private Map<String, String> vars;
private double incline = 0;
} }
public class RouteAttributeContext { public class RouteAttributeContext {
@ -670,6 +670,8 @@ public class GeneralRouter implements VehicleRouter {
int v = findBit.nextSetBit(0); int v = findBit.nextSetBit(0);
o = parseValueFromTag(v, valueType); o = parseValueFromTag(v, valueType);
} }
} else if (value instanceof String && value.equals(":incline")) {
return paramContext.incline;
} else if (value instanceof String && value.toString().startsWith(":")) { } else if (value instanceof String && value.toString().startsWith(":")) {
String p = ((String) value).substring(1); String p = ((String) value).substring(1);
if (paramContext != null && paramContext.vars.containsKey(p)) { if (paramContext != null && paramContext.vars.containsKey(p)) {