introduce destination:ref:forward/backward support

This commit is contained in:
sonora 2016-08-19 18:55:53 +02:00
parent fc3dbd40b8
commit a97fbba724
10 changed files with 26 additions and 14 deletions

View file

@ -234,7 +234,7 @@ public class BinaryMapRouteReaderAdapter {
refTypeRule = id;
} else if (tags.equals("destination") || tags.equals("destination:forward") || tags.equals("destination:backward")) {
destinationTypeRule = id;
} else if (tags.equals("destination:ref")) {
} else if (tags.equals("destination:ref") || tags.equals("destination:ref:forward") || tags.equals("destination:ref:backward")) {
destinationRefTypeRule = id;
}
}

View file

@ -173,14 +173,14 @@ public class GeocodingUtilities {
continue;
}
// System.out.println(road.toString() + " " + Math.sqrt(p.distSquare));
boolean emptyName = Algorithms.isEmpty(road.getName()) && Algorithms.isEmpty(road.getRef());
boolean emptyName = Algorithms.isEmpty(road.getName()) && Algorithms.isEmpty(road.getRef(true));
if (!emptyName) {
if (distSquare == 0 || distSquare > p.distSquare) {
distSquare = p.distSquare;
}
GeocodingResult sr = new GeocodingResult();
sr.searchPoint = new LatLon(lat, lon);
sr.streetName = Algorithms.isEmpty(road.getName()) ? road.getRef() : road.getName();
sr.streetName = Algorithms.isEmpty(road.getName()) ? road.getRef(true) : road.getName();
sr.point = p;
sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX));
sr.regionFP = road.region.getFilePointer();

View file

@ -98,9 +98,21 @@ public class RouteDataObject {
return names;
}
public String getRef(){
public String getRef(boolean direction) {
if (names != null) {
String ref = names.get(region.destinationRefTypeRule);
int[] kt = names.keys();
String refTag = (direction == true) ? "destination:ref:forward" : "destination:ref:backward";
String ref = null;
for(int i = 0 ; i < kt.length; i++) {
int k = kt[i];
if(region.routeEncodingRules.size() > k) {
if(refTag.equals(region.routeEncodingRules.get(k).getTag())) {
return names.get(k);
}
}
}
ref = names.get(region.destinationRefTypeRule);
if (ref != null) {
return ref;
}
@ -521,7 +533,7 @@ public class RouteDataObject {
@Override
public String toString() {
String name = getName();
String rf = getRef();
String rf = getRef(true);
return MessageFormat.format("Road id {0} name {1} ref {2}", (getId() / 64) + "", name == null ? "" : name,
rf == null ? "" : rf);
}

View file

@ -333,7 +333,7 @@ public class RouteResultPreparation {
if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) {
for (RouteSegmentResult res : result) {
String name = res.getObject().getName();
String ref = res.getObject().getRef();
String ref = res.getObject().getRef(res.isForwardDirection());
if (name == null) {
name = "";
}

View file

@ -158,7 +158,7 @@ public class GeocodingLookupService {
if (Algorithms.isEmpty(sname)) {
sname = "";
}
String ref = rd.getRef();
String ref = rd.getRef(true);
if (!Algorithms.isEmpty(ref)) {
if (!Algorithms.isEmpty(sname)) {
sname += ", ";

View file

@ -111,7 +111,7 @@ public class AvoidSpecificRoads {
protected String getText(RouteDataObject obj) {
return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()),
obj.getRef(), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), true), app.getString(R.string.towards));
obj.getRef(true), obj.getDestinationName(app.getSettings().MAP_PREFERRED_LOCALE.get(), true), app.getString(R.string.towards));
}
public void showDialog(@NonNull final MapActivity mapActivity) {

View file

@ -253,7 +253,7 @@ public class RouteCalculationResult {
info.routeEndPointOffset = roundAboutEnd;
}
RouteSegmentResult next = list.get(lind);
info.setRef(next.getObject().getRef());
info.setRef(next.getObject().getRef(next.isForwardDirection()));
info.setStreetName(next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get()));
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(), next.isForwardDirection()));
}

View file

@ -760,7 +760,7 @@ public class RoutingHelper {
RouteSegmentResult rs = getCurrentSegmentResult();
if(rs != null) {
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get());
String rf = rs.getObject().getRef();
String rf = rs.getObject().getRef(rs.isForwardDirection());
String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rs.isForwardDirection());
return formatStreetName(nm, rf, dn, "»");
}

View file

@ -586,12 +586,12 @@ public class VoiceRouter {
// Issue 2377: Play Dest here only if not already previously announced, to avoid repetition
if (includeDest == true) {
RouteDataObject obj = currentSegment.getObject();
current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef())),
current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef(currentSegment.isForwardDirection()))),
getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get()))),
getTermString(getSpeakablePointName(obj.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), currentSegment.isForwardDirection()))) });
} else {
RouteDataObject obj = currentSegment.getObject();
current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef())),
current = new Struct(new Term[] { getTermString(getSpeakablePointName(obj.getRef(currentSegment.isForwardDirection()))),
getTermString(getSpeakablePointName(obj.getName(settings.MAP_PREFERRED_LOCALE.get()))),
empty });
}

View file

@ -581,7 +581,7 @@ public class MapInfoWidgetsFactory {
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
if (rt != null) {
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()),
rt.getRef(), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), "»");
rt.getRef(rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())), "»");
}
if (text == null) {
text = "";