Fix bug in countries with mph limits

This commit is contained in:
vshcherb 2014-04-07 00:55:53 +02:00
parent d97c6ce0da
commit fc241fa688
2 changed files with 13 additions and 5 deletions

View file

@ -21,7 +21,7 @@ import net.osmand.util.MapUtils;
public class GeneralRouter implements VehicleRouter {
private static final float CAR_SHORTEST_DEFAULT_SPEED = 45/3.6f;
private static final float CAR_SHORTEST_DEFAULT_SPEED = 55/3.6f;
public static final String USE_SHORTEST_WAY = "short_way";
public static final String AVOID_FERRIES = "avoid_ferries";
public static final String AVOID_TOLL = "avoid_toll";
@ -45,7 +45,9 @@ public class GeneralRouter implements VehicleRouter {
private float leftTurn;
private float roundaboutTurn;
private float rightTurn;
// speed in m/s
private float minDefaultSpeed = 10;
// speed in m/s
private float maxDefaultSpeed = 10;
@ -278,7 +280,7 @@ public class GeneralRouter implements VehicleRouter {
@Override
public float defineVehicleSpeed(RouteDataObject road) {
return getObjContext(RouteDataObjectAttribute.ROAD_SPEED) .evaluateFloat(road, getMinDefaultSpeed() * 3.6f) / 3.6f;
return getObjContext(RouteDataObjectAttribute.ROAD_SPEED) .evaluateFloat(road, getMinDefaultSpeed());
}
@Override

View file

@ -143,6 +143,7 @@ public class RoutingConfiguration {
final RoutingConfiguration.Builder config = new RoutingConfiguration.Builder();
GeneralRouter currentRouter = null;
RouteDataObjectAttribute currentAttribute = null;
String preType = null;
Stack<RoutingRule> rulesStck = new Stack<RoutingConfiguration.RoutingRule>();
parser.setInput(is, "UTF-8");
int tok;
@ -160,8 +161,9 @@ public class RoutingConfiguration {
} else if ("point".equals(name) || "way".equals(name)) {
String attribute = parser.getAttributeValue("", "attribute");
currentAttribute = RouteDataObjectAttribute.getValueOf(attribute);
preType = parser.getAttributeValue("", "type");
} else {
parseRoutingRule(parser, currentRouter, currentAttribute, rulesStck);
parseRoutingRule(parser, currentRouter, currentAttribute, preType, rulesStck);
}
} else if (tok == XmlPullParser.END_TAG) {
String pname = parser.getName();
@ -207,7 +209,7 @@ public class RoutingConfiguration {
}
private static void parseRoutingRule(XmlPullParser parser, GeneralRouter currentRouter, RouteDataObjectAttribute attr,
Stack<RoutingRule> stack) {
String parentType, Stack<RoutingRule> stack) {
String pname = parser.getName();
if (checkTag(pname)) {
if(attr == null){
@ -221,11 +223,15 @@ public class RoutingConfiguration {
rr.value1 = parser.getAttributeValue("", "value1");
rr.value2 = parser.getAttributeValue("", "value2");
rr.type = parser.getAttributeValue("", "type");
if((rr.type == null || rr.type.length() == 0) &&
parentType != null && parentType.length() > 0) {
rr.type = parentType;
}
RouteAttributeContext ctx = currentRouter.getObjContext(attr);
if("select".equals(rr.tagName)) {
String val = parser.getAttributeValue("", "value");
String type = parser.getAttributeValue("", "type");
String type = rr.type;
ctx.registerNewRule(val, type);
addSubclause(rr, ctx);
for (int i = 0; i < stack.size(); i++) {