Simplify tags

This commit is contained in:
Victor Shcherb 2019-07-21 15:12:42 +02:00
parent 918495b2ad
commit 5b9e711e2a
2 changed files with 10 additions and 9 deletions

View file

@ -42,6 +42,7 @@ public class BinaryMapRouteReaderAdapter {
String condition = ""; String condition = "";
OpeningHoursParser.OpeningHours hours = null; OpeningHoursParser.OpeningHours hours = null;
String value; String value;
int routeType;
} }
public static class RouteTypeRule { public static class RouteTypeRule {
@ -117,17 +118,17 @@ public class BinaryMapRouteReaderAdapter {
return 0; return 0;
} }
public String conditionalValue(long time) { public int conditionalValue(long time) {
if (conditional()) { if (conditional()) {
Calendar i = Calendar.getInstance(); Calendar i = Calendar.getInstance();
i.setTimeInMillis(time); i.setTimeInMillis(time);
for (RouteTypeCondition c : conditions) { for (RouteTypeCondition c : conditions) {
if (c.hours != null && c.hours.isOpenedForTime(i)) { if (c.hours != null && c.hours.isOpenedForTime(i)) {
return c.value; return c.routeType;
} }
} }
} }
return null; return 0;
} }
public float maxSpeed(){ public float maxSpeed(){
@ -293,7 +294,7 @@ public class BinaryMapRouteReaderAdapter {
String tag = rtr.getNonConditionalTag(); String tag = rtr.getNonConditionalTag();
for(RouteTypeCondition c : rtr.conditions ) { for(RouteTypeCondition c : rtr.conditions ) {
if(tag != null && c.value != null) { if(tag != null && c.value != null) {
findOrCreateRouteType(tag, c.value); c.routeType = findOrCreateRouteType(tag, c.value);
} }
} }

View file

@ -492,14 +492,14 @@ public class RouteDataObject {
for (int i = 0; i < sz; i++) { for (int i = 0; i < sz; i++) {
RouteTypeRule r = region.quickGetEncodingRule(types[i]); RouteTypeRule r = region.quickGetEncodingRule(types[i]);
if (r != null && r.conditional()) { if (r != null && r.conditional()) {
String vl = r.conditionalValue(conditionalTime); int vl = r.conditionalValue(conditionalTime);
if(vl != null) { if(vl != 0) {
String nonCondTag = r.getNonConditionalTag(); RouteTypeRule rtr = region.quickGetEncodingRule(vl);
int tp = region.findOrCreateRouteType(nonCondTag, vl); String nonCondTag = rtr.getTag();
for(int ks = 0; ks < types.length; ks++) { for(int ks = 0; ks < types.length; ks++) {
RouteTypeRule toReplace = region.quickGetEncodingRule(types[ks]); RouteTypeRule toReplace = region.quickGetEncodingRule(types[ks]);
if(toReplace != null && toReplace.getTag().equals(nonCondTag)) { if(toReplace != null && toReplace.getTag().equals(nonCondTag)) {
types[ks] = tp; types[ks] = vl;
break; break;
} }
} }