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; refTypeRule = id;
} else if (tags.equals("destination") || tags.equals("destination:forward") || tags.equals("destination:backward")) { } else if (tags.equals("destination") || tags.equals("destination:forward") || tags.equals("destination:backward")) {
destinationTypeRule = id; 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; destinationRefTypeRule = id;
} }
} }

View file

@ -173,14 +173,14 @@ public class GeocodingUtilities {
continue; continue;
} }
// System.out.println(road.toString() + " " + Math.sqrt(p.distSquare)); // 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 (!emptyName) {
if (distSquare == 0 || distSquare > p.distSquare) { if (distSquare == 0 || distSquare > p.distSquare) {
distSquare = p.distSquare; distSquare = p.distSquare;
} }
GeocodingResult sr = new GeocodingResult(); GeocodingResult sr = new GeocodingResult();
sr.searchPoint = new LatLon(lat, lon); 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.point = p;
sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX)); sr.connectionPoint = new LatLon(MapUtils.get31LatitudeY(p.preciseY), MapUtils.get31LongitudeX(p.preciseX));
sr.regionFP = road.region.getFilePointer(); sr.regionFP = road.region.getFilePointer();

View file

@ -98,9 +98,21 @@ public class RouteDataObject {
return names; return names;
} }
public String getRef(){ public String getRef(boolean direction) {
if (names != null) { 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) { if (ref != null) {
return ref; return ref;
} }
@ -521,7 +533,7 @@ public class RouteDataObject {
@Override @Override
public String toString() { public String toString() {
String name = getName(); 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, return MessageFormat.format("Road id {0} name {1} ref {2}", (getId() / 64) + "", name == null ? "" : name,
rf == null ? "" : rf); rf == null ? "" : rf);
} }

View file

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

View file

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

View file

@ -111,7 +111,7 @@ public class AvoidSpecificRoads {
protected String getText(RouteDataObject obj) { protected String getText(RouteDataObject obj) {
return RoutingHelper.formatStreetName(obj.getName(app.getSettings().MAP_PREFERRED_LOCALE.get()), 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) { public void showDialog(@NonNull final MapActivity mapActivity) {

View file

@ -253,7 +253,7 @@ public class RouteCalculationResult {
info.routeEndPointOffset = roundAboutEnd; info.routeEndPointOffset = roundAboutEnd;
} }
RouteSegmentResult next = list.get(lind); 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.setStreetName(next.getObject().getName(ctx.getSettings().MAP_PREFERRED_LOCALE.get()));
info.setDestinationName(next.getObject().getDestinationName(ctx.getSettings().MAP_PREFERRED_LOCALE.get(), next.isForwardDirection())); 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(); RouteSegmentResult rs = getCurrentSegmentResult();
if(rs != null) { if(rs != null) {
String nm = rs.getObject().getName(settings.MAP_PREFERRED_LOCALE.get()); 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()); String dn = rs.getObject().getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), rs.isForwardDirection());
return formatStreetName(nm, rf, dn, "»"); 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 // Issue 2377: Play Dest here only if not already previously announced, to avoid repetition
if (includeDest == true) { if (includeDest == true) {
RouteDataObject obj = currentSegment.getObject(); 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.getName(settings.MAP_PREFERRED_LOCALE.get()))),
getTermString(getSpeakablePointName(obj.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), currentSegment.isForwardDirection()))) }); getTermString(getSpeakablePointName(obj.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), currentSegment.isForwardDirection()))) });
} else { } else {
RouteDataObject obj = currentSegment.getObject(); 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.getName(settings.MAP_PREFERRED_LOCALE.get()))),
empty }); empty });
} }

View file

@ -581,7 +581,7 @@ public class MapInfoWidgetsFactory {
RouteDataObject rt = locationProvider.getLastKnownRouteSegment(); RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
if (rt != null) { if (rt != null) {
text = RoutingHelper.formatStreetName(rt.getName(settings.MAP_PREFERRED_LOCALE.get()), 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) { if (text == null) {
text = ""; text = "";