Skip to content

Commit

Permalink
more instruction annotations and bug fix (#1814)
Browse files Browse the repository at this point in the history
* more instruction annotations

* fix bug introduced in #1811

* avoid too many changes in i18n
  • Loading branch information
karussell committed Dec 5, 2019
1 parent d992b90 commit cb1bea1
Show file tree
Hide file tree
Showing 46 changed files with 233 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.graphhopper.routing;

import com.graphhopper.routing.profiles.*;
import com.graphhopper.routing.util.BikeCommonFlagEncoder;
import com.graphhopper.routing.util.DefaultEdgeFilter;
import com.graphhopper.routing.util.FlagEncoder;
import com.graphhopper.routing.weighting.Weighting;
Expand Down Expand Up @@ -52,6 +53,8 @@ public class InstructionsFromEdges implements Path.EdgeVisitor {
private final EnumEncodedValue<RouteNetwork> bikeRouteEnc;
private final EnumEncodedValue<RoadClass> roadClassEnc;
private final EnumEncodedValue<RoadEnvironment> roadEnvEnc;
private final EnumEncodedValue<RoadAccess> roadAccessEnc;
private final EnumEncodedValue<Toll> tollEnc;

/*
* We need three points to make directions
Expand Down Expand Up @@ -95,13 +98,16 @@ public InstructionsFromEdges(Graph graph, Weighting weighting, EncodedValueLooku
this.accessEnc = evLookup.getBooleanEncodedValue(getKey(encoder.toString(), "access"));
this.roundaboutEnc = evLookup.getBooleanEncodedValue(Roundabout.KEY);

// both EncodedValues are optional and only used when bike encoders are added
// both EncodedValues are optional; And return annotation only when instructions for bike encoder is requested
String key = getKey("bike", RouteNetwork.EV_SUFFIX);
this.bikeRouteEnc = evLookup.hasEncodedValue(key) ? evLookup.getEnumEncodedValue(key, RouteNetwork.class) : null;
this.getOffBikeEnc = evLookup.hasEncodedValue(GetOffBike.KEY) ? evLookup.getBooleanEncodedValue(GetOffBike.KEY) : null;
this.getOffBikeEnc = encoder instanceof BikeCommonFlagEncoder && evLookup.hasEncodedValue(GetOffBike.KEY)
? evLookup.getBooleanEncodedValue(GetOffBike.KEY) : null;
this.tollEnc = evLookup.hasEncodedValue(Toll.KEY) ? evLookup.getEnumEncodedValue(Toll.KEY, Toll.class) : null;

this.roadClassEnc = evLookup.getEnumEncodedValue(RoadClass.KEY, RoadClass.class);
this.roadEnvEnc = evLookup.getEnumEncodedValue(RoadEnvironment.KEY, RoadEnvironment.class);
this.roadAccessEnc = evLookup.getEnumEncodedValue(RoadAccess.KEY, RoadAccess.class);
this.nodeAccess = graph.getNodeAccess();
this.tr = tr;
this.ways = ways;
Expand All @@ -127,7 +133,6 @@ public static InstructionList calcInstructions(Path path, Graph graph, Weighting
return ways;
}


@Override
public void next(EdgeIteratorState edge, int index, int prevEdgeId) {
if (prevNode == -1) {
Expand Down Expand Up @@ -157,20 +162,39 @@ public void next(EdgeIteratorState edge, int index, int prevEdgeId) {
}

String name = edge.getName();
InstructionAnnotation annotation = InstructionAnnotation.EMPTY;
String info = "";
int importance = 1;
if (getOffBikeEnc != null) {
// only for bikes do
if (edge.get(roadClassEnc) == RoadClass.CYCLEWAY
|| bikeRouteEnc != null && edge.get(bikeRouteEnc) != RouteNetwork.OTHER) {
// for backward compatibility
annotation = new InstructionAnnotation(0, tr.tr("cycleway"));
importance = 0;
info = tr.tr("cycleway");
} else if (edge.get(getOffBikeEnc)) {
annotation = new InstructionAnnotation(1, tr.tr("off_bike"));
info = tr.tr("off_bike");
}
} else if (edge.get(roadEnvEnc) == RoadEnvironment.FORD) {
annotation = new InstructionAnnotation(1, tr.tr("way_contains_ford"));
}

RoadEnvironment re = edge.get(roadEnvEnc);
if (re == RoadEnvironment.FORD) {
importance = 2; // could be dangerous
info = tr.tr("way_contains_ford");
} else if (re == RoadEnvironment.FERRY) {
info = tr.tr("way_contains_ferry");
}

// if private access is allowed we need a warning
RoadAccess ra = edge.get(roadAccessEnc);
if (ra == RoadAccess.PRIVATE)
info = info.isEmpty() ? tr.tr("way_contains_private") : info + ", " + tr.tr("way_contains_private");

if (tollEnc != null && edge.get(tollEnc) != Toll.NO)
info = info.isEmpty() ? tr.tr("way_contains_toll") : info + ", " + tr.tr("way_contains_toll");

InstructionAnnotation annotation = info.isEmpty()
? InstructionAnnotation.EMPTY
: new InstructionAnnotation(importance, info);

if ((prevName == null) && (!isRoundabout)) // very first instruction (if not in Roundabout)
{
int sign = Instruction.CONTINUE_ON_STREET;
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/ar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=في الدوران ، أتخذ مخرج %1$s من خلا
total_ascend=%1$s اجمالى صعود
total_descend=%1$s اجمالى نزول
way_contains_ford=هناك مخاضة على طول الطريق
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=ادخل %1$s
pt_end_trip=مغادرة %1$s
pt_transfer_to=انتقل الى %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/ast.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Na rotonda, toma la salida %1$s haza %2$s
total_ascend=%1$s d'ascensu total
total_descend=%1$s de descensu total
way_contains_ford=hai un vau nel camín
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=xubi a %1$s
pt_end_trip=baxa de %1$s
pt_transfer_to=cambia a %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/bg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=На кръговото кръстовище използв
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/ca.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=A la rotonda, agafa la %1$sa sortida cap a %2$s
total_ascend=%1$s de pujada total
total_descend=%1$s de baixada total
way_contains_ford=hi ha un gual en el camí
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=entra a %1$s
pt_end_trip=surt de %1$s
pt_transfer_to=canvia a %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/cs_CZ.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Na kruhovém objezdu použijte %1$s. výjezd, směrem na %2
total_ascend=Celkové stoupání %1$s
total_descend=Celkové klesání %1$s
way_contains_ford=na cestě je brod
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=nastupte do %1$s
pt_end_trip=vystupte z %1$s
pt_transfer_to=přestupte na %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/da_DK.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=I rundskørslen, tag udkørsel %1$s ind på %2$s
total_ascend=%1$s samlet stigning
total_descend=%1$s samlet fald
way_contains_ford=der er et vadested undervejs
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=stig på %1$s
pt_end_trip=stig af %1$s
pt_transfer_to=omstigning til %1$s
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/resources/com/graphhopper/util/de_DE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ roundabout_exit=Im Kreisverkehr Ausfahrt %1$s nehmen
roundabout_exit_onto=Im Kreisverkehr Ausfahrt %1$s auf %2$s nehmen
total_ascend=%1$s Gesamtaufstieg
total_descend=%1$s Gesamtabstieg
way_contains_ford=es liegt eine Furt auf dem Weg
way_contains_ford=Achtung, es liegt eine Furt auf dem Weg
way_contains_ferry=die Fähre nehmen
way_contains_private=Privatweg
way_contains_toll=Mautpflichtige Straße
pt_start_trip=einsteigen in %1$s
pt_end_trip=aus %1$s aussteigen
pt_transfer_to=umsteigen auf %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/el.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Στον κυκλικό κόμβο βγείτε στην έ
total_ascend=%1$s συνολική ανάβαση
total_descend=%1$s συνολική κατάβαση
way_contains_ford=υπάρχει πέρασμα στο δρόμο
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=μπείτε στο %1$s
pt_end_trip=αφήστε το %1$s
pt_transfer_to=αλλάξτε στο %1$s
Expand Down
5 changes: 4 additions & 1 deletion core/src/main/resources/com/graphhopper/util/en_US.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ roundabout_exit=At roundabout, take exit %1$s
roundabout_exit_onto=At roundabout, take exit %1$s onto %2$s
total_ascend=%1$s total ascent
total_descend=%1$s total descent
way_contains_ford=there is a ford along the way
way_contains_ford=Attention, there is a ford on the way
way_contains_ferry=take the ferry
way_contains_private=private road
way_contains_toll=toll road
pt_start_trip=enter %1$s
pt_end_trip=leave %1$s
pt_transfer_to=change to %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/eo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Ĉe trafikcirklo, elveturu al %1$s-a vojo al %2$s
total_ascend=%1$s supreniro tute
total_descend=%1$s malsupreniro tute
way_contains_ford=travadejo sur la kurso
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=eniru al %1$s
pt_end_trip=eliru el %1$s
pt_transfer_to=transveturiĝu al %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/es.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=En la rotonda, toma la %1$sª salida hacia %2$s
total_ascend=Ascender %1$s en total
total_descend=Descender %1$s en total
way_contains_ford=hay un vado en el camino
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=entra en %1$s
pt_end_trip=sal de %1$s
pt_transfer_to=cambia a %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/fa.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=در فلکه، از خروجی %1$s به %2$s بروید
total_ascend=مجموع صعود %1$s
total_descend=مجموع نزول %1$s
way_contains_ford=در طول مسیر گُدار وجود دارد
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=وارد %1$s شوید
pt_end_trip=از %1$s خارج شوید
pt_transfer_to=مسیر را به %1$s تغییر دهید
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/fi.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Liikenneympyrästä poistu %1$s. liittymästä suuntaan %2$
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/fil.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Sa rotonda, lumabas sa exit papunta %1$s %2$s
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/fr_CH.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Au giratoire, prenez la %1$s sortie vers %2$s
total_ascend=%1$s de dénivelé positif
total_descend=%1$s de dénivelé négatif
way_contains_ford=cet itinéraire comprend un passage à gué
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=montez dans %1$s
pt_end_trip=descendez de %1$s
pt_transfer_to=changez vers %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/fr_FR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Au rond-point, prenez la %1$s sortie vers %2$s
total_ascend=%1$s de dénivelé positif
total_descend=%1$s de dénivelé négatif
way_contains_ford=cet itinéraire comprend un passage à gué
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=montez dans %1$s
pt_end_trip=descendez de %1$s
pt_transfer_to=changez vers %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/gl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Na rotonda, tome a saída %1$s cara %2$s
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/he.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=בכיכר, יש לצאת ביציאה %1$s לתוך %2$s
total_ascend=עלייה כוללת של %1$s
total_descend=ירידה כוללת של %1$s
way_contains_ford=יש מעבר מים לאורך הדרך
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=יש להיכנס אל %1$s
pt_end_trip=יש לצאת מ%1$s
pt_transfer_to=להחליף ל%1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/hr_HR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Sa kružnog toka izađite na izlaz %1$s na %2$s
total_ascend=%1$s ukupni uspon
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/hsb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=we kružnym wobchadźe %1$s. wujězd na %2$s wzać
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/hu_HU.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Hajtson ki a körforgalomból itt: %1$s. kijárat, majd haj
total_ascend=Összes szintemelkedés: %1$s
total_descend=Összes szintcsökkenés: %1$s
way_contains_ford=gázló van az útvonalon
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=szálljon fel erre: %1$s
pt_end_trip=szálljon le erről: %1$s
pt_transfer_to=szálljon át erre: %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/in_ID.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=At roundabout, take exit %1$s onto %2$s
total_ascend=naik dengan jarak %1$s
total_descend=turun dengan jarak %1$s
way_contains_ford=terdapat jalan untuk dilewati
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=masuk dalam %1$s
pt_end_trip=keluar dalam %1$s
pt_transfer_to=berpindah ke jalur %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/it.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Nella rotatoria, prendere l'uscita %1$s su %2$s
total_ascend=%1$s di dislivello positivo
total_descend=%1$s di dislivello negativo
way_contains_ford=c'é un guado sulla strada
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=prendi %1$s
pt_end_trip=lascia %1$s
pt_transfer_to=cambia con %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/ja.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=円形交差点の出口%1$sから%2$sへ
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/ko.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=회전교차로에서 %1$s 진출 후 %2$s 이동
total_ascend=오르막길 총 %1$s
total_descend=내리막길 총 %1$s
way_contains_ford=경로에 여울이 있습니다
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=%1$s 진입
pt_end_trip=%1$s 진출
pt_transfer_to=%1$s(으)로 환승
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/lt_LT.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Žiede išvažiuokite %1$s išvažiavime į %2$s
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/ne.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=घुम्तीमा %1$s नम्बर को मो
total_ascend=
total_descend=
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=
pt_end_trip=
pt_transfer_to=
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/nl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=neem afslag %1$s naar %2$s op de rotonde
total_ascend=%1$s totale klim
total_descend=%1$s totale daling
way_contains_ford=Er is een doorwaadbare plaats
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=Neem de %1$s
pt_end_trip=Stap uit de %1$s uit
pt_transfer_to=Stap over op de %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/pl_PL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Zjedź z ronda %1$s zjazdem na %2$s
total_ascend=%1$s podejść ogółem
total_descend=%1$s zejść ogółem
way_contains_ford=bród na trasie
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=wsiądź w %1$s
pt_end_trip=wysiądź z %1$s
pt_transfer_to=przesiądź się na %1$s
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/com/graphhopper/util/pt_BR.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ roundabout_exit_onto=Na rotatória, saia na %1$s saida em direção a %2$s
total_ascend=subida de %1$s
total_descend=descida de %1$s
way_contains_ford=
way_contains_ferry=
way_contains_private=
way_contains_toll=
pt_start_trip=embarque %1$s
pt_end_trip=desembarque %1$s
pt_transfer_to=mude para %1$s
Expand Down
Loading

0 comments on commit cb1bea1

Please sign in to comment.