Adapt / prepare for text values for altitude

This commit is contained in:
Victor Shcherb 2019-07-21 15:40:09 +02:00
parent 5b9e711e2a
commit 718f79a9cd
2 changed files with 30 additions and 14 deletions

View file

@ -42,7 +42,7 @@ public class BinaryMapRouteReaderAdapter {
String condition = "";
OpeningHoursParser.OpeningHours hours = null;
String value;
int routeType;
int ruleid;
}
public static class RouteTypeRule {
@ -124,7 +124,7 @@ public class BinaryMapRouteReaderAdapter {
i.setTimeInMillis(time);
for (RouteTypeCondition c : conditions) {
if (c.hours != null && c.hours.isOpenedForTime(i)) {
return c.routeType;
return c.ruleid;
}
}
}
@ -294,7 +294,7 @@ public class BinaryMapRouteReaderAdapter {
String tag = rtr.getNonConditionalTag();
for(RouteTypeCondition c : rtr.conditions ) {
if(tag != null && c.value != null) {
c.routeType = findOrCreateRouteType(tag, c.value);
c.ruleid = findOrCreateRouteType(tag, c.value);
}
}

View file

@ -186,17 +186,13 @@ public class RouteDataObject {
if(k == getPointsLength() - 1) {
height = endHeight;
} else {
int[] tps = getPointTypes(k);
if (tps != null) {
for (int id : tps) {
RouteTypeRule rt = region.quickGetEncodingRule(id);
if (rt.getTag().equals("osmand_ele_asc")) {
height = (prevHeight + Float.parseFloat(rt.getValue()));
break;
} else if (rt.getTag().equals("osmand_ele_desc")) {
height = (prevHeight - Float.parseFloat(rt.getValue()));
break;
}
String asc = getValue(k, "osmand_ele_asc");
if(asc != null && asc.length() > 0) {
height = (prevHeight + Float.parseFloat(asc));
} else {
String desc = getValue(k, "osmand_ele_desc");
if(desc != null && desc.length() > 0) {
height = (prevHeight - Float.parseFloat(asc));
}
}
}
@ -702,6 +698,26 @@ public class RouteDataObject {
return null;
}
public String getValue(int pnt, String tag) {
if (pointTypes != null && pnt < pointTypes.length && pointTypes[pnt] != null) {
for (int i = 0; i < pointTypes[pnt].length; i++) {
RouteTypeRule r = region.quickGetEncodingRule(pointTypes[pnt][i]);
if (r.getTag().equals(tag)) {
return r.getValue();
}
}
}
if (pointNameTypes != null && pnt < pointNameTypes.length && pointNameTypes[pnt] != null) {
for (int i = 0; i < pointNameTypes[pnt].length; i++) {
RouteTypeRule r = region.quickGetEncodingRule(pointNameTypes[pnt][i]);
if (r.getTag().equals(tag)) {
return pointNames[pnt][i];
}
}
}
return null;
}
public static String getHighway(int[] types, RouteRegion region) {
String highway = null;
int sz = types.length;