Refactor turn types

This commit is contained in:
Victor Shcherb 2014-10-02 13:47:34 +02:00
parent d03ab35906
commit 2c6b19b775
7 changed files with 216 additions and 129 deletions

View file

@ -338,8 +338,8 @@ public class RouteResultPreparation {
t = getTurnInfo(result, i, leftside); t = getTurnInfo(result, i, leftside);
// justify turn // justify turn
if(t != null && i < result.size() - 1) { if(t != null && i < result.size() - 1) {
boolean tl = TurnType.TL.equals(t.getValue()); boolean tl = TurnType.TL == t.getValue();
boolean tr = TurnType.TR.equals(t.getValue()); boolean tr = TurnType.TR == t.getValue();
if(tl || tr) { if(tl || tr) {
TurnType tnext = getTurnInfo(result, i + 1, leftside); TurnType tnext = getTurnInfo(result, i + 1, leftside);
if (tnext != null && result.get(i).getDistance() < 35) { // if (tnext != null && result.get(i).getDistance() < 35) { //
@ -357,10 +357,10 @@ public class RouteResultPreparation {
ut = false; ut = false;
} }
if (ut) { if (ut) {
if (tl && TurnType.TL.equals(tnext.getValue())) { if (tl && TurnType.TL == tnext.getValue()) {
next = i + 2; next = i + 2;
t = TurnType.valueOf(TurnType.TU, false); t = TurnType.valueOf(TurnType.TU, false);
} else if (tr && TurnType.TR.equals(tnext.getValue())) { } else if (tr && TurnType.TR == tnext.getValue()) {
next = i + 2; next = i + 2;
t = TurnType.valueOf(TurnType.TU, true); t = TurnType.valueOf(TurnType.TU, true);
} }
@ -486,7 +486,7 @@ public class RouteResultPreparation {
} }
} }
// combine all roundabouts // combine all roundabouts
TurnType t = TurnType.valueOf("EXIT"+exit, leftSide); TurnType t = TurnType.getExitTurn(exit, 0, leftSide);
t.setTurnAngle((float) MapUtils.degreesDiff(last.getBearingBegin(), prev.getBearingEnd())) ; t.setTurnAngle((float) MapUtils.degreesDiff(last.getBearingBegin(), prev.getBearingEnd())) ;
return t; return t;
} }

View file

@ -1,77 +1,148 @@
package net.osmand.router; package net.osmand.router;
public class TurnType { public class TurnType {
public static final String C = "C"; // continue (go straight) //$NON-NLS-1$ public static final int C = 1;//"C"; // continue (go straight) //$NON-NLS-1$
public static final String TL = "TL"; // turn left //$NON-NLS-1$ public static final int TL = 2; // turn left //$NON-NLS-1$
public static final String TSLL = "TSLL"; // turn slightly left //$NON-NLS-1$ public static final int TSLL = 3; // turn slightly left //$NON-NLS-1$
public static final String TSHL = "TSHL"; // turn sharply left //$NON-NLS-1$ public static final int TSHL = 4; // turn sharply left //$NON-NLS-1$
public static final String TR = "TR"; // turn right //$NON-NLS-1$ public static final int TR = 5; // turn right //$NON-NLS-1$
public static final String TSLR = "TSLR"; // turn slightly right //$NON-NLS-1$ public static final int TSLR = 6; // turn slightly right //$NON-NLS-1$
public static final String TSHR = "TSHR"; // turn sharply right //$NON-NLS-1$ public static final int TSHR = 7; // turn sharply right //$NON-NLS-1$
public static final String KL = "KL"; // keep left //$NON-NLS-1$ public static final int KL = 8; // keep left //$NON-NLS-1$
public static final String KR = "KR"; // keep right//$NON-NLS-1$ public static final int KR = 9; // keep right//$NON-NLS-1$
public static final String TU = "TU"; // U-turn //$NON-NLS-1$ public static final int TU = 10; // U-turn //$NON-NLS-1$
public static final String TRU = "TRU"; // Right U-turn //$NON-NLS-1$ public static final int TRU = 11; // Right U-turn //$NON-NLS-1$
public static final String OFFR = "OFFR"; // Off route //$NON-NLS-1$ public static final int OFFR = 12; // Off route //$NON-NLS-1$
public static String[] predefinedTypes = new String[] { C, KL, KR, TL, TSLL, TSHL, TR, TSLR, TSHR, TU, TRU, OFFR }; public static final int RNDB = 13; // Roundabout
public static final int RNLB = 14; // Roundabout left
public static TurnType sraight() { public static TurnType straight() {
return valueOf(C, false); return valueOf(C, false);
} }
public static TurnType valueOf(String s, boolean leftSide) { public String toXmlString() {
for (String v : predefinedTypes) { switch (value) {
if (v.equals(s)) { case C:
if (leftSide && TU.equals(v)) { return "C";
v = TRU; case TL:
} return "TL";
return new TurnType(v); case TSLL:
return "TSLL";
case TSHL:
return "TSHL";
case TR:
return "TR";
case TSLR:
return "TSLR";
case TSHR:
return "TSHR";
case KL:
return "KL";
case KR:
return "KR";
case TU:
return "TU";
case TRU:
return "TRU";
case OFFR:
return "OFFR";
case RNDB:
return "RNDB"+exitOut;
case RNLB:
return "RNLB"+exitOut;
}
return "C";
}
public static TurnType fromString(String s, boolean leftSide) {
TurnType t = null;
if ("C".equals(s)) {
t = TurnType.valueOf(C, leftSide);
} else if ("TL".equals(s)) {
t = TurnType.valueOf(TL, leftSide);
} else if ("TSLL".equals(s)) {
t = TurnType.valueOf(TSLL, leftSide);
} else if ("TSHL".equals(s)) {
t = TurnType.valueOf(TSHL, leftSide);
} else if ("TR".equals(s)) {
t = TurnType.valueOf(TR, leftSide);
} else if ("TSLR".equals(s)) {
t = TurnType.valueOf(TSLR, leftSide);
} else if ("TSHR".equals(s)) {
t = TurnType.valueOf(TSHR, leftSide);
} else if ("KL".equals(s)) {
t = TurnType.valueOf(KL, leftSide);
} else if ("KR".equals(s)) {
t = TurnType.valueOf(KR, leftSide);
} else if ("TU".equals(s)) {
t = TurnType.valueOf(TU, leftSide);
} else if ("TRU".equals(s)) {
t = TurnType.valueOf(TRU, leftSide);
} else if ("OFFR".equals(s)) {
t = TurnType.valueOf(OFFR, leftSide);
} else if (s != null && (s.startsWith("EXIT") ||
s.startsWith("RNDB") || s.startsWith("RNLB"))) {
try {
t = TurnType.getExitTurn(Integer.parseInt(s.substring(4)), 0, leftSide);
} catch (NumberFormatException e) {
e.printStackTrace();
} }
} }
if (s != null && s.startsWith("EXIT")) { //$NON-NLS-1$ if(t == null) {
return getExitTurn(Integer.parseInt(s.substring(4)), 0, leftSide); t = TurnType.straight();
} }
return null; return t;
}
public static TurnType valueOf(int vs, boolean leftSide) {
if(vs == TU && leftSide) {
vs = TRU;
} else if(vs == RNDB && leftSide) {
vs = RNLB;
}
return new TurnType(vs);
// if (s != null && s.startsWith("EXIT")) { //$NON-NLS-1$
// return getExitTurn(Integer.parseInt(s.substring(4)), 0, leftSide);
// }
// return null;
} }
private final String value; private final int value;
private int exitOut; private int exitOut;
private boolean isLeftSide;
// calculated clockwise head rotation if previous direction to NORTH // calculated clockwise head rotation if previous direction to NORTH
private float turnAngle; private float turnAngle;
private boolean skipToSpeak; private boolean skipToSpeak;
private int[] lanes; private int[] lanes;
private static TurnType getExitTurn(int out, float angle, boolean leftSide) { public static TurnType getExitTurn(int out, float angle, boolean leftSide) {
TurnType r = new TurnType("EXIT", out, leftSide); //$NON-NLS-1$ TurnType r = valueOf(RNDB, leftSide); //$NON-NLS-1$
r.exitOut = out;
r.setTurnAngle(angle); r.setTurnAngle(angle);
return r; return r;
} }
private TurnType(String value, int exitOut, boolean leftSide) {
this.value = value; private TurnType(int vl) {
this.exitOut = exitOut; this.value = vl;
this.isLeftSide = leftSide;
} }
// calculated Clockwise head rotation if previous direction to NORTH // calculated Clockwise head rotation if previous direction to NORTH
public float getTurnAngle() { public float getTurnAngle() {
return turnAngle; return turnAngle;
} }
public boolean isLeftSide() { public boolean isLeftSide() {
return isLeftSide; return value == RNLB || value == TRU;
} }
public void setTurnAngle(float turnAngle) { public void setTurnAngle(float turnAngle) {
this.turnAngle = turnAngle; this.turnAngle = turnAngle;
} }
private TurnType(String value) {
this.value = value;
}
public String getValue() { public int getValue() {
return value; return value;
} }
@ -80,66 +151,87 @@ public class TurnType {
} }
public boolean isRoundAbout() { public boolean isRoundAbout() {
return value.equals("EXIT"); //$NON-NLS-1$ return value == RNDB || value == RNLB; //$NON-NLS-1$
} }
// lanes encoded as array of int // lanes encoded as array of int
// last bit is 1, 0 (should we take this lane) // 0 byte - 0/1 - to use or not
// first bits 0 - left, 1 - straight, 2 - right // 1-5 byte - additional turn info
// 6-10 byte - secondary turn
public void setLanes(int[] lanes) { public void setLanes(int[] lanes) {
this.lanes = lanes; this.lanes = lanes;
} }
// Note that there is no "weight" or ordering between the primary and secondary turns.
public void setPrimaryTurn(int lane, int turnType) {
lanes[lane] |= (turnType << 1);
}
public int getPrimaryTurn(int lane) {
// Get the primary turn modifier for the lane
return (lanes[lane] >> 1) & ((1 << 4) - 1);
}
public void setSecondaryTurn(int lane, int turnType) {
lanes[lane] |= (turnType << 5);
}
public int getSecondaryTurn(int lane) {
return (lanes[lane] >> 5);
}
public int[] getLanes() { public int[] getLanes() {
return lanes; return lanes;
} }
public boolean keepLeft() { public boolean keepLeft() {
return value.equals(KL); return value == KL;
} }
public boolean keepRight() { public boolean keepRight() {
return value.equals(KR); return value == KR;
} }
public boolean goAhead() { public boolean goAhead() {
return value.equals(C); return value == C;
} }
public boolean isSkipToSpeak() { public boolean isSkipToSpeak() {
return skipToSpeak; return skipToSpeak;
} }
public void setSkipToSpeak(boolean skipToSpeak) { public void setSkipToSpeak(boolean skipToSpeak) {
this.skipToSpeak = skipToSpeak; this.skipToSpeak = skipToSpeak;
} }
@Override @Override
public String toString() { public String toString() {
if(isRoundAbout()){ if (isRoundAbout()) {
return "Take " + getExitOut() + " exit"; return "Take " + getExitOut() + " exit";
} else if(value.equals(C)) { } else if (value == C) {
return "Go ahead"; return "Go ahead";
} else if(value.equals(TSLL)) { } else if (value == TSLL) {
return "Turn slightly left"; return "Turn slightly left";
} else if(value.equals(TL)) { } else if (value == TL) {
return "Turn left"; return "Turn left";
} else if(value.equals(TSHL)) { } else if (value == TSHL) {
return "Turn sharply left"; return "Turn sharply left";
} else if(value.equals(TSLR)) { } else if (value == TSLR) {
return "Turn slightly right"; return "Turn slightly right";
} else if(value.equals(TR)) { } else if (value == TR) {
return "Turn right"; return "Turn right";
} else if(value.equals(TSHR)) { } else if (value == TSHR) {
return "Turn sharply right"; return "Turn sharply right";
} else if(value.equals(TU)) { } else if (value == TU) {
return "Make uturn"; return "Make uturn";
} else if(value.equals(TRU)) { } else if (value == TRU) {
return "Make uturn"; return "Make uturn";
} else if(value.equals(KL)) { } else if (value == KL) {
return "Keep left"; return "Keep left";
} else if(value.equals(KR)) { } else if (value == KR) {
return "Keep right"; return "Keep right";
} else if(value.equals(OFFR)) { } else if (value == OFFR) {
return "Off route"; return "Off route";
} }
return super.toString(); return super.toString();

View file

@ -149,7 +149,7 @@ public class RouteCalculationResult {
if (locationIndex > interLocations[currentIntermediate] if (locationIndex > interLocations[currentIntermediate]
&& getDistanceToLocation(locations, intermediates.get(currentIntermediate), locationIndex) > 50) { && getDistanceToLocation(locations, intermediates.get(currentIntermediate), locationIndex) > 50) {
RouteDirectionInfo toSplit = localDirections.get(currentDirection); RouteDirectionInfo toSplit = localDirections.get(currentDirection);
RouteDirectionInfo info = new RouteDirectionInfo(localDirections.get(currentDirection).getAverageSpeed(), TurnType.sraight()); RouteDirectionInfo info = new RouteDirectionInfo(localDirections.get(currentDirection).getAverageSpeed(), TurnType.straight());
info.setRef(toSplit.getRef()); info.setRef(toSplit.getRef());
info.setStreetName(toSplit.getStreetName()); info.setStreetName(toSplit.getStreetName());
info.setDestinationName(toSplit.getDestinationName()); info.setDestinationName(toSplit.getDestinationName());
@ -296,7 +296,7 @@ public class RouteCalculationResult {
int previousLocation = 0; int previousLocation = 0;
int prevBearingLocation = 0; int prevBearingLocation = 0;
RouteDirectionInfo previousInfo = new RouteDirectionInfo(speed, TurnType.sraight()); RouteDirectionInfo previousInfo = new RouteDirectionInfo(speed, TurnType.straight());
previousInfo.routePointOffset = 0; previousInfo.routePointOffset = 0;
previousInfo.setDescriptionRoute(ctx.getString( R.string.route_head)); previousInfo.setDescriptionRoute(ctx.getString( R.string.route_head));
computeDirections.add(previousInfo); computeDirections.add(previousInfo);
@ -443,27 +443,27 @@ public class RouteCalculationResult {
public static String toString(TurnType type, Context ctx) { public static String toString(TurnType type, Context ctx) {
if(type.isRoundAbout()){ if(type.isRoundAbout()){
return ctx.getString(R.string.route_roundabout, type.getExitOut()); return ctx.getString(R.string.route_roundabout, type.getExitOut());
} else if(type.getValue().equals(TurnType.C)) { } else if(type.getValue() == TurnType.C) {
return ctx.getString(R.string.route_head); return ctx.getString(R.string.route_head);
} else if(type.getValue().equals(TurnType.TSLL)) { } else if(type.getValue() == TurnType.TSLL) {
return ctx.getString(R.string.route_tsll); return ctx.getString(R.string.route_tsll);
} else if(type.getValue().equals(TurnType.TL)) { } else if(type.getValue() == TurnType.TL) {
return ctx.getString(R.string.route_tl); return ctx.getString(R.string.route_tl);
} else if(type.getValue().equals(TurnType.TSHL)) { } else if(type.getValue() == TurnType.TSHL) {
return ctx.getString(R.string.route_tshl); return ctx.getString(R.string.route_tshl);
} else if(type.getValue().equals(TurnType.TSLR)) { } else if(type.getValue() == TurnType.TSLR) {
return ctx.getString(R.string.route_tslr); return ctx.getString(R.string.route_tslr);
} else if(type.getValue().equals(TurnType.TR)) { } else if(type.getValue() == TurnType.TR) {
return ctx.getString(R.string.route_tr); return ctx.getString(R.string.route_tr);
} else if(type.getValue().equals(TurnType.TSHR)) { } else if(type.getValue() == TurnType.TSHR) {
return ctx.getString(R.string.route_tshr); return ctx.getString(R.string.route_tshr);
} else if(type.getValue().equals(TurnType.TU)) { } else if(type.getValue() == TurnType.TU) {
return ctx.getString(R.string.route_tu); return ctx.getString(R.string.route_tu);
} else if(type.getValue().equals(TurnType.TRU)) { } else if(type.getValue() == TurnType.TRU) {
return ctx.getString(R.string.route_tu); return ctx.getString(R.string.route_tu);
} else if(type.getValue().equals(TurnType.KL)) { } else if(type.getValue() == TurnType.KL) {
return ctx.getString(R.string.route_kl); return ctx.getString(R.string.route_kl);
} else if(type.getValue().equals(TurnType.KR)) { } else if(type.getValue() == TurnType.KR) {
return ctx.getString(R.string.route_kr); return ctx.getString(R.string.route_kr);
} }
return ""; return "";
@ -483,7 +483,7 @@ public class RouteCalculationResult {
if (directions != null && directions.size() > 1) { if (directions != null && directions.size() > 1) {
for (int i = 1; i < directions.size();) { for (int i = 1; i < directions.size();) {
RouteDirectionInfo r = directions.get(i); RouteDirectionInfo r = directions.get(i);
if (r.getTurnType().getValue().equals(TurnType.C)) { if (r.getTurnType().getValue() == TurnType.C) {
RouteDirectionInfo prev = directions.get(i - 1); RouteDirectionInfo prev = directions.get(i - 1);
prev.setAverageSpeed((prev.distance + r.distance) prev.setAverageSpeed((prev.distance + r.distance)
/ (prev.distance / prev.getAverageSpeed() + r.distance / r.getAverageSpeed())); / (prev.distance / prev.getAverageSpeed() + r.distance / r.getAverageSpeed()));
@ -536,7 +536,7 @@ public class RouteCalculationResult {
i.routePointOffset++; i.routePointOffset++;
} }
RouteDirectionInfo info = new RouteDirectionInfo(directions.get(0).getAverageSpeed(), RouteDirectionInfo info = new RouteDirectionInfo(directions.get(0).getAverageSpeed(),
TurnType.sraight()); TurnType.straight());
info.routePointOffset = 0; info.routePointOffset = 0;
// info.setDescriptionRoute(ctx.getString( R.string.route_head));//; //$NON-NLS-1$ // info.setDescriptionRoute(ctx.getString( R.string.route_head));//; //$NON-NLS-1$
directions.add(0, info); directions.add(0, info);
@ -544,7 +544,7 @@ public class RouteCalculationResult {
} }
RouteDirectionInfo lastDirInf = directions.size() > 0 ? directions.get(directions.size() - 1) : null; RouteDirectionInfo lastDirInf = directions.size() > 0 ? directions.get(directions.size() - 1) : null;
if((lastDirInf == null || lastDirInf.routePointOffset < locations.size() - 1) && locations.size() - 1 > 0) { if((lastDirInf == null || lastDirInf.routePointOffset < locations.size() - 1) && locations.size() - 1 > 0) {
String type = TurnType.C; int type = TurnType.C;
Location prevLast = locations.get(locations.size() - 2); Location prevLast = locations.get(locations.size() - 2);
float lastBearing = prevLast.bearingTo(locations.get(locations.size() - 1)); float lastBearing = prevLast.bearingTo(locations.get(locations.size() - 1));
float[] compute = new float[2]; float[] compute = new float[2];

View file

@ -850,9 +850,9 @@ public class RouteProvider {
String stype = item.getExtensionsToRead().get("turn"); //$NON-NLS-1$ String stype = item.getExtensionsToRead().get("turn"); //$NON-NLS-1$
TurnType turnType; TurnType turnType;
if (stype != null) { if (stype != null) {
turnType = TurnType.valueOf(stype.toUpperCase(), leftSide); turnType = TurnType.fromString(stype.toUpperCase(), leftSide);
} else { } else {
turnType = TurnType.sraight(); turnType = TurnType.straight();
} }
String sturn = item.getExtensionsToRead().get("turn-angle"); //$NON-NLS-1$ String sturn = item.getExtensionsToRead().get("turn-angle"); //$NON-NLS-1$
if (sturn != null) { if (sturn != null) {
@ -861,7 +861,7 @@ public class RouteProvider {
RouteDirectionInfo dirInfo = new RouteDirectionInfo(avgSpeed, turnType); RouteDirectionInfo dirInfo = new RouteDirectionInfo(avgSpeed, turnType);
dirInfo.setDescriptionRoute(item.desc); //$NON-NLS-1$ dirInfo.setDescriptionRoute(item.desc); //$NON-NLS-1$
dirInfo.routePointOffset = offset; dirInfo.routePointOffset = offset;
if (previous != null && !TurnType.C.equals(previous.getTurnType().getValue()) && if (previous != null && TurnType.C != previous.getTurnType().getValue() &&
!osmandRouter) { !osmandRouter) {
// calculate angle // calculate angle
if (previous.routePointOffset > 0) { if (previous.routePointOffset > 0) {
@ -897,7 +897,7 @@ public class RouteProvider {
} }
} }
} }
if (previous != null && !TurnType.C.equals(previous.getTurnType().getValue())) { if (previous != null && TurnType.C != previous.getTurnType().getValue()) {
// calculate angle // calculate angle
if (previous.routePointOffset > 0 && previous.routePointOffset < res.size() - 1) { if (previous.routePointOffset > 0 && previous.routePointOffset < res.size() - 1) {
float paz = res.get(previous.routePointOffset - 1).bearingTo(res.get(previous.routePointOffset)); float paz = res.get(previous.routePointOffset - 1).bearingTo(res.get(previous.routePointOffset));
@ -1035,12 +1035,9 @@ public class RouteProvider {
pt.desc = dirInfo.getDescriptionRoute(ctx); pt.desc = dirInfo.getDescriptionRoute(ctx);
Map<String, String> extensions = pt.getExtensionsToWrite(); Map<String, String> extensions = pt.getExtensionsToWrite();
extensions.put("time", dirInfo.getExpectedTime() + ""); extensions.put("time", dirInfo.getExpectedTime() + "");
String turnType = dirInfo.getTurnType().getValue(); int turnType = dirInfo.getTurnType().getValue();
if (dirInfo.getTurnType().isRoundAbout()) { if(TurnType.C != turnType){
turnType += dirInfo.getTurnType().getExitOut(); extensions.put("turn", dirInfo.getTurnType().toXmlString());
}
if(!TurnType.C.equals(turnType)){
extensions.put("turn", turnType);
extensions.put("turn-angle", dirInfo.getTurnType().getTurnAngle() + ""); extensions.put("turn-angle", dirInfo.getTurnType().getTurnAngle() + "");
} }
extensions.put("offset", (dirInfo.routePointOffset - cRoute) + ""); extensions.put("offset", (dirInfo.routePointOffset - cRoute) + "");

View file

@ -4,14 +4,10 @@ package net.osmand.plus.routing;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import android.media.AudioManager;
import android.media.SoundPool;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LocationPoint;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
@ -25,6 +21,8 @@ import net.osmand.util.MapUtils;
import alice.tuprolog.Struct; import alice.tuprolog.Struct;
import alice.tuprolog.Term; import alice.tuprolog.Term;
import android.content.Context; import android.content.Context;
import android.media.AudioManager;
import android.media.SoundPool;
public class VoiceRouter { public class VoiceRouter {
@ -567,7 +565,7 @@ public class VoiceRouter {
play.prepareTurn(tParam, dist, getSpeakableStreetName(currentSegment, next)).play(); play.prepareTurn(tParam, dist, getSpeakableStreetName(currentSegment, next)).play();
} else if(next.getTurnType().isRoundAbout()){ } else if(next.getTurnType().isRoundAbout()){
play.prepareRoundAbout(dist, next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next)).play(); play.prepareRoundAbout(dist, next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next)).play();
} else if(next.getTurnType().getValue().equals(TurnType.TU) || next.getTurnType().getValue().equals(TurnType.TRU)){ } else if(next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU){
play.prepareMakeUT(dist, getSpeakableStreetName(currentSegment, next)).play(); play.prepareMakeUT(dist, getSpeakableStreetName(currentSegment, next)).play();
} }
} }
@ -582,7 +580,7 @@ public class VoiceRouter {
play.turn(tParam, dist, getSpeakableStreetName(currentSegment, next)); play.turn(tParam, dist, getSpeakableStreetName(currentSegment, next));
} else if (next.getTurnType().isRoundAbout()) { } else if (next.getTurnType().isRoundAbout()) {
play.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next)); play.roundAbout(dist, next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next));
} else if (next.getTurnType().getValue().equals(TurnType.TU) || next.getTurnType().getValue().equals(TurnType.TRU)) { } else if (next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU) {
play.makeUT(dist, getSpeakableStreetName(currentSegment, next)); play.makeUT(dist, getSpeakableStreetName(currentSegment, next));
} else { } else {
isPlay = false; isPlay = false;
@ -591,15 +589,15 @@ public class VoiceRouter {
if (pronounceNextNext != null) { if (pronounceNextNext != null) {
TurnType t = pronounceNextNext.getTurnType(); TurnType t = pronounceNextNext.getTurnType();
isPlay = true; isPlay = true;
if (next.getTurnType().getValue().equals(TurnType.C) && if (next.getTurnType().getValue() == TurnType.C &&
!TurnType.C.equals(t.getValue())) { TurnType.C != t.getValue()) {
play.goAhead(dist, getSpeakableStreetName(currentSegment, next)); play.goAhead(dist, getSpeakableStreetName(currentSegment, next));
} }
if (TurnType.TL.equals(t.getValue()) || TurnType.TSHL.equals(t.getValue()) || TurnType.TSLL.equals(t.getValue()) if (TurnType.TL == t.getValue() || TurnType.TSHL == t.getValue() || TurnType.TSLL == t.getValue()
|| TurnType.TU.equals(t.getValue()) || TurnType.KL.equals(t.getValue())) { || TurnType.TU == t.getValue() || TurnType.KL == t.getValue()) {
play.then().bearLeft( getSpeakableStreetName(currentSegment, next)); play.then().bearLeft( getSpeakableStreetName(currentSegment, next));
} else if (TurnType.TR.equals(t.getValue()) || TurnType.TSHR.equals(t.getValue()) || TurnType.TSLR.equals(t.getValue()) } else if (TurnType.TR == t.getValue() || TurnType.TSHR == t.getValue() || TurnType.TSLR == t.getValue()
|| TurnType.KR.equals(t.getValue())) { || TurnType.KR == t.getValue()) {
play.then().bearRight( getSpeakableStreetName(currentSegment, next)); play.then().bearRight( getSpeakableStreetName(currentSegment, next));
} }
} }
@ -632,10 +630,10 @@ public class VoiceRouter {
play.turn(tParam, getSpeakableStreetName(currentSegment, next)); play.turn(tParam, getSpeakableStreetName(currentSegment, next));
} else if(next.getTurnType().isRoundAbout()){ } else if(next.getTurnType().isRoundAbout()){
play.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next)); play.roundAbout(next.getTurnType().getTurnAngle(), next.getTurnType().getExitOut(), getSpeakableStreetName(currentSegment, next));
} else if(next.getTurnType().getValue().equals(TurnType.TU) || next.getTurnType().getValue().equals(TurnType.TRU)){ } else if(next.getTurnType().getValue() == TurnType.TU || next.getTurnType().getValue() == TurnType.TRU){
play.makeUT( getSpeakableStreetName(currentSegment, next)); play.makeUT( getSpeakableStreetName(currentSegment, next));
// do not say it // do not say it
// } else if(next.getTurnType().getValue().equals(TurnType.C)){ // } else if(next.getTurnType().getValue() == TurnType.C)){
// play.goAhead(); // play.goAhead();
} else { } else {
isplay = false; isplay = false;
@ -649,7 +647,7 @@ public class VoiceRouter {
} else if (nextNext.getTurnType().isRoundAbout()) { } else if (nextNext.getTurnType().isRoundAbout()) {
if(isplay) { play.then(); } if(isplay) { play.then(); }
play.roundAbout(next.distance, nextNext.getTurnType().getTurnAngle(), nextNext.getTurnType().getExitOut(), empty); play.roundAbout(next.distance, nextNext.getTurnType().getTurnAngle(), nextNext.getTurnType().getExitOut(), empty);
} else if (nextNext.getTurnType().getValue().equals(TurnType.TU)) { } else if (nextNext.getTurnType().getValue() == TurnType.TU) {
if(isplay) { play.then(); } if(isplay) { play.then(); }
play.makeUT(next.distance, empty); play.makeUT(next.distance, empty);
} }
@ -662,21 +660,21 @@ public class VoiceRouter {
} }
private String getTurnType(TurnType t){ private String getTurnType(TurnType t){
if(TurnType.TL.equals(t.getValue())){ if(TurnType.TL == t.getValue()){
return AbstractPrologCommandPlayer.A_LEFT; return AbstractPrologCommandPlayer.A_LEFT;
} else if(TurnType.TSHL.equals(t.getValue())){ } else if(TurnType.TSHL == t.getValue()){
return AbstractPrologCommandPlayer.A_LEFT_SH; return AbstractPrologCommandPlayer.A_LEFT_SH;
} else if(TurnType.TSLL.equals(t.getValue())){ } else if(TurnType.TSLL == t.getValue()){
return AbstractPrologCommandPlayer.A_LEFT_SL; return AbstractPrologCommandPlayer.A_LEFT_SL;
} else if(TurnType.TR.equals(t.getValue())){ } else if(TurnType.TR == t.getValue()){
return AbstractPrologCommandPlayer.A_RIGHT; return AbstractPrologCommandPlayer.A_RIGHT;
} else if(TurnType.TSHR.equals(t.getValue())){ } else if(TurnType.TSHR == t.getValue()){
return AbstractPrologCommandPlayer.A_RIGHT_SH; return AbstractPrologCommandPlayer.A_RIGHT_SH;
} else if(TurnType.TSLR.equals(t.getValue())){ } else if(TurnType.TSLR == t.getValue()){
return AbstractPrologCommandPlayer.A_RIGHT_SL; return AbstractPrologCommandPlayer.A_RIGHT_SL;
} else if(TurnType.KL.equals(t.getValue())){ } else if(TurnType.KL == t.getValue()){
return AbstractPrologCommandPlayer.A_LEFT_KEEP; return AbstractPrologCommandPlayer.A_LEFT_KEEP;
} else if(TurnType.KR.equals(t.getValue())){ } else if(TurnType.KR == t.getValue()){
return AbstractPrologCommandPlayer.A_RIGHT_KEEP; return AbstractPrologCommandPlayer.A_RIGHT_KEEP;
} }
return null; return null;

View file

@ -32,7 +32,7 @@ public class TurnPathHelper {
float spartArrowL = (float) ((sarrowL - th / Math.sqrt(2)) / 2); float spartArrowL = (float) ((sarrowL - th / Math.sqrt(2)) / 2);
float hpartArrowL = (float) (harrowL - th) / 2; float hpartArrowL = (float) (harrowL - th) / 2;
if (TurnType.C.equals(turnType.getValue())) { if (TurnType.C == turnType.getValue()) {
int h = (int) (ha - hpartArrowL - 16); int h = (int) (ha - hpartArrowL - 16);
pathForTurn.rMoveTo(th, 0); pathForTurn.rMoveTo(th, 0);
pathForTurn.rLineTo(0, -h); pathForTurn.rLineTo(0, -h);
@ -41,8 +41,8 @@ public class TurnPathHelper {
pathForTurn.rLineTo(-harrowL / 2, harrowL / 2); pathForTurn.rLineTo(-harrowL / 2, harrowL / 2);
pathForTurn.rLineTo(hpartArrowL, 0); pathForTurn.rLineTo(hpartArrowL, 0);
pathForTurn.rLineTo(0, h); pathForTurn.rLineTo(0, h);
} else if (TurnType.TR.equals(turnType.getValue())|| TurnType.TL.equals(turnType.getValue())) { } else if (TurnType.TR == turnType.getValue()|| TurnType.TL == turnType.getValue()) {
int b = TurnType.TR.equals(turnType.getValue())? 1 : -1; int b = TurnType.TR == turnType.getValue()? 1 : -1;
float quadShiftX = 18; float quadShiftX = 18;
float quadShiftY = 18; float quadShiftY = 18;
int wl = 10; // width int wl = 10; // width
@ -62,8 +62,8 @@ public class TurnPathHelper {
pathForTurn.rLineTo(-b * wl, 0); pathForTurn.rLineTo(-b * wl, 0);
pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th); pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th);
pathForTurn.rLineTo(0, h); pathForTurn.rLineTo(0, h);
} else if (TurnType.KL.equals(turnType.getValue()) || TurnType.KR.equals(turnType.getValue())) { } else if (TurnType.KL == turnType.getValue() || TurnType.KR == turnType.getValue()) {
int b = TurnType.KR.equals(turnType.getValue())? 1 : -1; int b = TurnType.KR == turnType.getValue()? 1 : -1;
float quadShiftX = 14; float quadShiftX = 14;
float quadShiftY = 14; float quadShiftY = 14;
th = 10; th = 10;
@ -92,8 +92,8 @@ public class TurnPathHelper {
pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th ), quadShiftY + th); pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th ), quadShiftY + th);
pathForTurn.rLineTo(0, lh ); pathForTurn.rLineTo(0, lh );
} else if (TurnType.TSLR.equals(turnType.getValue()) || TurnType.TSLL.equals(turnType.getValue())) { } else if (TurnType.TSLR == turnType.getValue() || TurnType.TSLL == turnType.getValue()) {
int b = TurnType.TSLR.equals(turnType.getValue()) ? 1 : -1; int b = TurnType.TSLR == turnType.getValue() ? 1 : -1;
int h = 24; int h = 24;
int quadShiftY = 22; int quadShiftY = 22;
float quadShiftX = (float) (quadShiftY / (1 + Math.sqrt(2))); float quadShiftX = (float) (quadShiftY / (1 + Math.sqrt(2)));
@ -109,8 +109,8 @@ public class TurnPathHelper {
pathForTurn.rLineTo(b * spartArrowL, spartArrowL); pathForTurn.rLineTo(b * spartArrowL, spartArrowL);
pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty); pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty);
pathForTurn.rLineTo(0, h); pathForTurn.rLineTo(0, h);
} else if (TurnType.TSHR.equals(turnType.getValue()) || TurnType.TSHL.equals(turnType.getValue())) { } else if (TurnType.TSHR == turnType.getValue() || TurnType.TSHL == turnType.getValue()) {
int b = TurnType.TSHR.equals(turnType.getValue()) ? 1 : -1; int b = TurnType.TSHR == turnType.getValue() ? 1 : -1;
int h = 28; int h = 28;
float quadShiftX = 22; float quadShiftX = 22;
int sh = 10; int sh = 10;
@ -127,10 +127,10 @@ public class TurnPathHelper {
pathForTurn.rLineTo(-b * spartArrowL, spartArrowL); pathForTurn.rLineTo(-b * spartArrowL, spartArrowL);
pathForTurn.rCubicTo(b * nQuadShiftX / 2, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftY); pathForTurn.rCubicTo(b * nQuadShiftX / 2, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftY);
pathForTurn.rLineTo(0, h); pathForTurn.rLineTo(0, h);
} else if(TurnType.TU.equals(turnType.getValue()) || TurnType.TRU.equals(turnType.getValue())) { } else if(TurnType.TU == turnType.getValue() || TurnType.TRU == turnType.getValue()) {
int h = 40; int h = 40;
// right left // right left
int b = TurnType.TU.equals(turnType.getValue()) ? 1 : -1; int b = TurnType.TU == turnType.getValue() ? 1 : -1;
float quadShiftX = 10; // 13 float quadShiftX = 10; // 13
float quadShiftY = 10; // 13 float quadShiftY = 10; // 13
int sm = 10; int sm = 10;
@ -150,7 +150,7 @@ public class TurnPathHelper {
pathForTurn.rQuadTo(0, -quadShiftX, b *quadShiftX, -quadShiftY); pathForTurn.rQuadTo(0, -quadShiftX, b *quadShiftX, -quadShiftY);
pathForTurn.rQuadTo(b * quadShiftX, 0, b * quadShiftX, quadShiftY); pathForTurn.rQuadTo(b * quadShiftX, 0, b * quadShiftX, quadShiftY);
pathForTurn.rLineTo(0, h); pathForTurn.rLineTo(0, h);
} else if (TurnType.OFFR.equals(turnType.getValue())){ } else if (TurnType.OFFR == turnType.getValue()){
int h = (int) (ha - hpartArrowL - 16); int h = (int) (ha - hpartArrowL - 16);
pathForTurn.rMoveTo(th, 0); //12 0 pathForTurn.rMoveTo(th, 0); //12 0
//first square //first square
@ -260,7 +260,7 @@ public class TurnPathHelper {
paintRouteDirection.setStyle(Style.FILL_AND_STROKE); paintRouteDirection.setStyle(Style.FILL_AND_STROKE);
paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow_distant)); paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow_distant));
paintRouteDirection.setAntiAlias(true); paintRouteDirection.setAntiAlias(true);
TurnPathHelper.calcTurnPath(dp, TurnType.sraight(), null); TurnPathHelper.calcTurnPath(dp, TurnType.straight(), null);
} }
@Override @Override

View file

@ -55,7 +55,7 @@ public class RouteInfoWidgetsFactory {
final OsmandSettings settings, Paint textPaint, Paint subtextPaint, boolean horisontalMini) { final OsmandSettings settings, Paint textPaint, Paint subtextPaint, boolean horisontalMini) {
final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(ctx, textPaint, subtextPaint, horisontalMini) { final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(ctx, textPaint, subtextPaint, horisontalMini) {
NextDirectionInfo calc1 = new NextDirectionInfo(); NextDirectionInfo calc1 = new NextDirectionInfo();
TurnType straight = TurnType.sraight(); TurnType straight = TurnType.straight();
@Override @Override
public boolean updateInfo(DrawSettings drawSettings) { public boolean updateInfo(DrawSettings drawSettings) {
@ -526,7 +526,7 @@ public class RouteInfoWidgetsFactory {
final Path laneStraight = new Path(); final Path laneStraight = new Path();
Matrix pathTransform = new Matrix(); Matrix pathTransform = new Matrix();
pathTransform.postScale(scaleCoefficient / miniCoeff, scaleCoefficient / miniCoeff); pathTransform.postScale(scaleCoefficient / miniCoeff, scaleCoefficient / miniCoeff);
TurnPathHelper.calcTurnPath(laneStraight, TurnType.sraight(), pathTransform); TurnPathHelper.calcTurnPath(laneStraight, TurnType.straight(), pathTransform);
final Paint paintBlack = new Paint(); final Paint paintBlack = new Paint();
paintBlack.setStyle(Style.STROKE); paintBlack.setStyle(Style.STROKE);
paintBlack.setColor(Color.BLACK); paintBlack.setColor(Color.BLACK);