diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index 1fa0b3afad..89a6c4ead0 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -338,8 +338,8 @@ public class RouteResultPreparation { t = getTurnInfo(result, i, leftside); // justify turn if(t != null && i < result.size() - 1) { - boolean tl = TurnType.TL.equals(t.getValue()); - boolean tr = TurnType.TR.equals(t.getValue()); + boolean tl = TurnType.TL == t.getValue(); + boolean tr = TurnType.TR == t.getValue(); if(tl || tr) { TurnType tnext = getTurnInfo(result, i + 1, leftside); if (tnext != null && result.get(i).getDistance() < 35) { // @@ -357,10 +357,10 @@ public class RouteResultPreparation { ut = false; } if (ut) { - if (tl && TurnType.TL.equals(tnext.getValue())) { + if (tl && TurnType.TL == tnext.getValue()) { next = i + 2; t = TurnType.valueOf(TurnType.TU, false); - } else if (tr && TurnType.TR.equals(tnext.getValue())) { + } else if (tr && TurnType.TR == tnext.getValue()) { next = i + 2; t = TurnType.valueOf(TurnType.TU, true); } @@ -486,7 +486,7 @@ public class RouteResultPreparation { } } // 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())) ; return t; } diff --git a/OsmAnd-java/src/net/osmand/router/TurnType.java b/OsmAnd-java/src/net/osmand/router/TurnType.java index 488286a835..e6d0a35664 100644 --- a/OsmAnd-java/src/net/osmand/router/TurnType.java +++ b/OsmAnd-java/src/net/osmand/router/TurnType.java @@ -1,77 +1,148 @@ package net.osmand.router; public class TurnType { - public static final String C = "C"; // continue (go straight) //$NON-NLS-1$ - public static final String TL = "TL"; // turn left //$NON-NLS-1$ - public static final String TSLL = "TSLL"; // turn slightly left //$NON-NLS-1$ - public static final String TSHL = "TSHL"; // turn sharply left //$NON-NLS-1$ - public static final String TR = "TR"; // turn right //$NON-NLS-1$ - public static final String TSLR = "TSLR"; // turn slightly right //$NON-NLS-1$ - public static final String TSHR = "TSHR"; // turn sharply right //$NON-NLS-1$ - public static final String KL = "KL"; // keep left //$NON-NLS-1$ - public static final String KR = "KR"; // keep right//$NON-NLS-1$ - public static final String TU = "TU"; // U-turn //$NON-NLS-1$ - public static final String TRU = "TRU"; // Right U-turn //$NON-NLS-1$ - public static final String OFFR = "OFFR"; // 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 C = 1;//"C"; // continue (go straight) //$NON-NLS-1$ + public static final int TL = 2; // turn left //$NON-NLS-1$ + public static final int TSLL = 3; // turn slightly left //$NON-NLS-1$ + public static final int TSHL = 4; // turn sharply left //$NON-NLS-1$ + public static final int TR = 5; // turn right //$NON-NLS-1$ + public static final int TSLR = 6; // turn slightly right //$NON-NLS-1$ + public static final int TSHR = 7; // turn sharply right //$NON-NLS-1$ + public static final int KL = 8; // keep left //$NON-NLS-1$ + public static final int KR = 9; // keep right//$NON-NLS-1$ + public static final int TU = 10; // U-turn //$NON-NLS-1$ + public static final int TRU = 11; // Right U-turn //$NON-NLS-1$ + public static final int OFFR = 12; // Off route //$NON-NLS-1$ + 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); } - - public static TurnType valueOf(String s, boolean leftSide) { - for (String v : predefinedTypes) { - if (v.equals(s)) { - if (leftSide && TU.equals(v)) { - v = TRU; - } - return new TurnType(v); + + public String toXmlString() { + switch (value) { + case C: + return "C"; + case TL: + return "TL"; + 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$ - return getExitTurn(Integer.parseInt(s.substring(4)), 0, leftSide); + if(t == null) { + 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 boolean isLeftSide; // calculated clockwise head rotation if previous direction to NORTH private float turnAngle; private boolean skipToSpeak; private int[] lanes; - private static TurnType getExitTurn(int out, float angle, boolean leftSide) { - TurnType r = new TurnType("EXIT", out, leftSide); //$NON-NLS-1$ + public static TurnType getExitTurn(int out, float angle, boolean leftSide) { + TurnType r = valueOf(RNDB, leftSide); //$NON-NLS-1$ + r.exitOut = out; r.setTurnAngle(angle); return r; } - - private TurnType(String value, int exitOut, boolean leftSide) { - this.value = value; - this.exitOut = exitOut; - this.isLeftSide = leftSide; + + + private TurnType(int vl) { + this.value = vl; } + // calculated Clockwise head rotation if previous direction to NORTH public float getTurnAngle() { return turnAngle; } public boolean isLeftSide() { - return isLeftSide; + return value == RNLB || value == TRU; } public void setTurnAngle(float turnAngle) { this.turnAngle = turnAngle; } - - private TurnType(String value) { - this.value = value; - } - public String getValue() { + public int getValue() { return value; } @@ -80,66 +151,87 @@ public class TurnType { } public boolean isRoundAbout() { - return value.equals("EXIT"); //$NON-NLS-1$ + return value == RNDB || value == RNLB; //$NON-NLS-1$ } - // lanes encoded as array of int - // last bit is 1, 0 (should we take this lane) - // first bits 0 - left, 1 - straight, 2 - right + // lanes encoded as array of int + // 0 byte - 0/1 - to use or not + // 1-5 byte - additional turn info + // 6-10 byte - secondary turn public void setLanes(int[] 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() { return lanes; } public boolean keepLeft() { - return value.equals(KL); + return value == KL; } public boolean keepRight() { - return value.equals(KR); + return value == KR; } public boolean goAhead() { - return value.equals(C); + return value == C; } public boolean isSkipToSpeak() { return skipToSpeak; } + public void setSkipToSpeak(boolean skipToSpeak) { this.skipToSpeak = skipToSpeak; } @Override public String toString() { - if(isRoundAbout()){ + if (isRoundAbout()) { return "Take " + getExitOut() + " exit"; - } else if(value.equals(C)) { + } else if (value == C) { return "Go ahead"; - } else if(value.equals(TSLL)) { + } else if (value == TSLL) { return "Turn slightly left"; - } else if(value.equals(TL)) { + } else if (value == TL) { return "Turn left"; - } else if(value.equals(TSHL)) { + } else if (value == TSHL) { return "Turn sharply left"; - } else if(value.equals(TSLR)) { + } else if (value == TSLR) { return "Turn slightly right"; - } else if(value.equals(TR)) { + } else if (value == TR) { return "Turn right"; - } else if(value.equals(TSHR)) { + } else if (value == TSHR) { return "Turn sharply right"; - } else if(value.equals(TU)) { + } else if (value == TU) { return "Make uturn"; - } else if(value.equals(TRU)) { + } else if (value == TRU) { return "Make uturn"; - } else if(value.equals(KL)) { + } else if (value == KL) { return "Keep left"; - } else if(value.equals(KR)) { + } else if (value == KR) { return "Keep right"; - } else if(value.equals(OFFR)) { + } else if (value == OFFR) { return "Off route"; } return super.toString(); diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index d3bc32e2b2..a27081fa12 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -149,7 +149,7 @@ public class RouteCalculationResult { if (locationIndex > interLocations[currentIntermediate] && getDistanceToLocation(locations, intermediates.get(currentIntermediate), locationIndex) > 50) { 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.setStreetName(toSplit.getStreetName()); info.setDestinationName(toSplit.getDestinationName()); @@ -296,7 +296,7 @@ public class RouteCalculationResult { int previousLocation = 0; int prevBearingLocation = 0; - RouteDirectionInfo previousInfo = new RouteDirectionInfo(speed, TurnType.sraight()); + RouteDirectionInfo previousInfo = new RouteDirectionInfo(speed, TurnType.straight()); previousInfo.routePointOffset = 0; previousInfo.setDescriptionRoute(ctx.getString( R.string.route_head)); computeDirections.add(previousInfo); @@ -443,27 +443,27 @@ public class RouteCalculationResult { public static String toString(TurnType type, Context ctx) { if(type.isRoundAbout()){ 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); - } else if(type.getValue().equals(TurnType.TSLL)) { + } else if(type.getValue() == TurnType.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); - } else if(type.getValue().equals(TurnType.TSHL)) { + } else if(type.getValue() == TurnType.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); - } else if(type.getValue().equals(TurnType.TR)) { + } else if(type.getValue() == TurnType.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); - } else if(type.getValue().equals(TurnType.TU)) { + } else if(type.getValue() == TurnType.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); - } else if(type.getValue().equals(TurnType.KL)) { + } else if(type.getValue() == TurnType.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 ""; @@ -483,7 +483,7 @@ public class RouteCalculationResult { if (directions != null && directions.size() > 1) { for (int i = 1; i < directions.size();) { RouteDirectionInfo r = directions.get(i); - if (r.getTurnType().getValue().equals(TurnType.C)) { + if (r.getTurnType().getValue() == TurnType.C) { RouteDirectionInfo prev = directions.get(i - 1); prev.setAverageSpeed((prev.distance + r.distance) / (prev.distance / prev.getAverageSpeed() + r.distance / r.getAverageSpeed())); @@ -536,7 +536,7 @@ public class RouteCalculationResult { i.routePointOffset++; } RouteDirectionInfo info = new RouteDirectionInfo(directions.get(0).getAverageSpeed(), - TurnType.sraight()); + TurnType.straight()); info.routePointOffset = 0; // info.setDescriptionRoute(ctx.getString( R.string.route_head));//; //$NON-NLS-1$ directions.add(0, info); @@ -544,7 +544,7 @@ public class RouteCalculationResult { } RouteDirectionInfo lastDirInf = directions.size() > 0 ? directions.get(directions.size() - 1) : null; 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); float lastBearing = prevLast.bearingTo(locations.get(locations.size() - 1)); float[] compute = new float[2]; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 6272a32088..057bb2fcfc 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -850,9 +850,9 @@ public class RouteProvider { String stype = item.getExtensionsToRead().get("turn"); //$NON-NLS-1$ TurnType turnType; if (stype != null) { - turnType = TurnType.valueOf(stype.toUpperCase(), leftSide); + turnType = TurnType.fromString(stype.toUpperCase(), leftSide); } else { - turnType = TurnType.sraight(); + turnType = TurnType.straight(); } String sturn = item.getExtensionsToRead().get("turn-angle"); //$NON-NLS-1$ if (sturn != null) { @@ -861,7 +861,7 @@ public class RouteProvider { RouteDirectionInfo dirInfo = new RouteDirectionInfo(avgSpeed, turnType); dirInfo.setDescriptionRoute(item.desc); //$NON-NLS-1$ dirInfo.routePointOffset = offset; - if (previous != null && !TurnType.C.equals(previous.getTurnType().getValue()) && + if (previous != null && TurnType.C != previous.getTurnType().getValue() && !osmandRouter) { // calculate angle 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 if (previous.routePointOffset > 0 && previous.routePointOffset < res.size() - 1) { float paz = res.get(previous.routePointOffset - 1).bearingTo(res.get(previous.routePointOffset)); @@ -1035,12 +1035,9 @@ public class RouteProvider { pt.desc = dirInfo.getDescriptionRoute(ctx); Map extensions = pt.getExtensionsToWrite(); extensions.put("time", dirInfo.getExpectedTime() + ""); - String turnType = dirInfo.getTurnType().getValue(); - if (dirInfo.getTurnType().isRoundAbout()) { - turnType += dirInfo.getTurnType().getExitOut(); - } - if(!TurnType.C.equals(turnType)){ - extensions.put("turn", turnType); + int turnType = dirInfo.getTurnType().getValue(); + if(TurnType.C != turnType){ + extensions.put("turn", dirInfo.getTurnType().toXmlString()); extensions.put("turn-angle", dirInfo.getTurnType().getTurnAngle() + ""); } extensions.put("offset", (dirInfo.routePointOffset - cRoute) + ""); diff --git a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java index 0f8584c215..6c0a21c0cb 100644 --- a/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java +++ b/OsmAnd/src/net/osmand/plus/routing/VoiceRouter.java @@ -4,14 +4,10 @@ package net.osmand.plus.routing; import java.io.IOException; import java.util.List; -import android.media.AudioManager; -import android.media.SoundPool; import net.osmand.Location; import net.osmand.binary.RouteDataObject; -import net.osmand.data.LocationPoint; import net.osmand.plus.ApplicationMode; import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; @@ -25,6 +21,8 @@ import net.osmand.util.MapUtils; import alice.tuprolog.Struct; import alice.tuprolog.Term; import android.content.Context; +import android.media.AudioManager; +import android.media.SoundPool; public class VoiceRouter { @@ -567,7 +565,7 @@ public class VoiceRouter { play.prepareTurn(tParam, dist, getSpeakableStreetName(currentSegment, next)).play(); } else if(next.getTurnType().isRoundAbout()){ 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(); } } @@ -582,7 +580,7 @@ public class VoiceRouter { play.turn(tParam, dist, getSpeakableStreetName(currentSegment, next)); } else if (next.getTurnType().isRoundAbout()) { 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)); } else { isPlay = false; @@ -591,15 +589,15 @@ public class VoiceRouter { if (pronounceNextNext != null) { TurnType t = pronounceNextNext.getTurnType(); isPlay = true; - if (next.getTurnType().getValue().equals(TurnType.C) && - !TurnType.C.equals(t.getValue())) { + if (next.getTurnType().getValue() == TurnType.C && + TurnType.C != t.getValue()) { play.goAhead(dist, getSpeakableStreetName(currentSegment, next)); } - if (TurnType.TL.equals(t.getValue()) || TurnType.TSHL.equals(t.getValue()) || TurnType.TSLL.equals(t.getValue()) - || TurnType.TU.equals(t.getValue()) || TurnType.KL.equals(t.getValue())) { + if (TurnType.TL == t.getValue() || TurnType.TSHL == t.getValue() || TurnType.TSLL == t.getValue() + || TurnType.TU == t.getValue() || TurnType.KL == t.getValue()) { play.then().bearLeft( getSpeakableStreetName(currentSegment, next)); - } else if (TurnType.TR.equals(t.getValue()) || TurnType.TSHR.equals(t.getValue()) || TurnType.TSLR.equals(t.getValue()) - || TurnType.KR.equals(t.getValue())) { + } else if (TurnType.TR == t.getValue() || TurnType.TSHR == t.getValue() || TurnType.TSLR == t.getValue() + || TurnType.KR == t.getValue()) { play.then().bearRight( getSpeakableStreetName(currentSegment, next)); } } @@ -632,10 +630,10 @@ public class VoiceRouter { play.turn(tParam, getSpeakableStreetName(currentSegment, next)); } else if(next.getTurnType().isRoundAbout()){ 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)); // do not say it -// } else if(next.getTurnType().getValue().equals(TurnType.C)){ +// } else if(next.getTurnType().getValue() == TurnType.C)){ // play.goAhead(); } else { isplay = false; @@ -649,7 +647,7 @@ public class VoiceRouter { } else if (nextNext.getTurnType().isRoundAbout()) { if(isplay) { play.then(); } 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(); } play.makeUT(next.distance, empty); } @@ -662,21 +660,21 @@ public class VoiceRouter { } private String getTurnType(TurnType t){ - if(TurnType.TL.equals(t.getValue())){ + if(TurnType.TL == t.getValue()){ return AbstractPrologCommandPlayer.A_LEFT; - } else if(TurnType.TSHL.equals(t.getValue())){ + } else if(TurnType.TSHL == t.getValue()){ return AbstractPrologCommandPlayer.A_LEFT_SH; - } else if(TurnType.TSLL.equals(t.getValue())){ + } else if(TurnType.TSLL == t.getValue()){ return AbstractPrologCommandPlayer.A_LEFT_SL; - } else if(TurnType.TR.equals(t.getValue())){ + } else if(TurnType.TR == t.getValue()){ return AbstractPrologCommandPlayer.A_RIGHT; - } else if(TurnType.TSHR.equals(t.getValue())){ + } else if(TurnType.TSHR == t.getValue()){ return AbstractPrologCommandPlayer.A_RIGHT_SH; - } else if(TurnType.TSLR.equals(t.getValue())){ + } else if(TurnType.TSLR == t.getValue()){ return AbstractPrologCommandPlayer.A_RIGHT_SL; - } else if(TurnType.KL.equals(t.getValue())){ + } else if(TurnType.KL == t.getValue()){ return AbstractPrologCommandPlayer.A_LEFT_KEEP; - } else if(TurnType.KR.equals(t.getValue())){ + } else if(TurnType.KR == t.getValue()){ return AbstractPrologCommandPlayer.A_RIGHT_KEEP; } return null; diff --git a/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java b/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java index a64db6d620..06ca94f1d5 100644 --- a/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java +++ b/OsmAnd/src/net/osmand/plus/views/TurnPathHelper.java @@ -32,7 +32,7 @@ public class TurnPathHelper { float spartArrowL = (float) ((sarrowL - th / Math.sqrt(2)) / 2); float hpartArrowL = (float) (harrowL - th) / 2; - if (TurnType.C.equals(turnType.getValue())) { + if (TurnType.C == turnType.getValue()) { int h = (int) (ha - hpartArrowL - 16); pathForTurn.rMoveTo(th, 0); pathForTurn.rLineTo(0, -h); @@ -41,8 +41,8 @@ public class TurnPathHelper { pathForTurn.rLineTo(-harrowL / 2, harrowL / 2); pathForTurn.rLineTo(hpartArrowL, 0); pathForTurn.rLineTo(0, h); - } else if (TurnType.TR.equals(turnType.getValue())|| TurnType.TL.equals(turnType.getValue())) { - int b = TurnType.TR.equals(turnType.getValue())? 1 : -1; + } else if (TurnType.TR == turnType.getValue()|| TurnType.TL == turnType.getValue()) { + int b = TurnType.TR == turnType.getValue()? 1 : -1; float quadShiftX = 18; float quadShiftY = 18; int wl = 10; // width @@ -62,8 +62,8 @@ public class TurnPathHelper { pathForTurn.rLineTo(-b * wl, 0); pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th), quadShiftY + th); pathForTurn.rLineTo(0, h); - } else if (TurnType.KL.equals(turnType.getValue()) || TurnType.KR.equals(turnType.getValue())) { - int b = TurnType.KR.equals(turnType.getValue())? 1 : -1; + } else if (TurnType.KL == turnType.getValue() || TurnType.KR == turnType.getValue()) { + int b = TurnType.KR == turnType.getValue()? 1 : -1; float quadShiftX = 14; float quadShiftY = 14; th = 10; @@ -92,8 +92,8 @@ public class TurnPathHelper { pathForTurn.rQuadTo(-b * (quadShiftX + th), 0, -b * (quadShiftX + th ), quadShiftY + th); pathForTurn.rLineTo(0, lh ); - } else if (TurnType.TSLR.equals(turnType.getValue()) || TurnType.TSLL.equals(turnType.getValue())) { - int b = TurnType.TSLR.equals(turnType.getValue()) ? 1 : -1; + } else if (TurnType.TSLR == turnType.getValue() || TurnType.TSLL == turnType.getValue()) { + int b = TurnType.TSLR == turnType.getValue() ? 1 : -1; int h = 24; int quadShiftY = 22; float quadShiftX = (float) (quadShiftY / (1 + Math.sqrt(2))); @@ -109,8 +109,8 @@ public class TurnPathHelper { pathForTurn.rLineTo(b * spartArrowL, spartArrowL); pathForTurn.rQuadTo(b * nQuadShiftX, -nQuadShiftX, b * nQuadShiftX, nQuadShifty); pathForTurn.rLineTo(0, h); - } else if (TurnType.TSHR.equals(turnType.getValue()) || TurnType.TSHL.equals(turnType.getValue())) { - int b = TurnType.TSHR.equals(turnType.getValue()) ? 1 : -1; + } else if (TurnType.TSHR == turnType.getValue() || TurnType.TSHL == turnType.getValue()) { + int b = TurnType.TSHR == turnType.getValue() ? 1 : -1; int h = 28; float quadShiftX = 22; int sh = 10; @@ -127,10 +127,10 @@ public class TurnPathHelper { pathForTurn.rLineTo(-b * spartArrowL, spartArrowL); pathForTurn.rCubicTo(b * nQuadShiftX / 2, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftX / 2, b * nQuadShiftX, nQuadShiftY); 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; // right left - int b = TurnType.TU.equals(turnType.getValue()) ? 1 : -1; + int b = TurnType.TU == turnType.getValue() ? 1 : -1; float quadShiftX = 10; // 13 float quadShiftY = 10; // 13 int sm = 10; @@ -150,7 +150,7 @@ public class TurnPathHelper { pathForTurn.rQuadTo(0, -quadShiftX, b *quadShiftX, -quadShiftY); pathForTurn.rQuadTo(b * quadShiftX, 0, b * quadShiftX, quadShiftY); pathForTurn.rLineTo(0, h); - } else if (TurnType.OFFR.equals(turnType.getValue())){ + } else if (TurnType.OFFR == turnType.getValue()){ int h = (int) (ha - hpartArrowL - 16); pathForTurn.rMoveTo(th, 0); //12 0 //first square @@ -260,7 +260,7 @@ public class TurnPathHelper { paintRouteDirection.setStyle(Style.FILL_AND_STROKE); paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow_distant)); paintRouteDirection.setAntiAlias(true); - TurnPathHelper.calcTurnPath(dp, TurnType.sraight(), null); + TurnPathHelper.calcTurnPath(dp, TurnType.straight(), null); } @Override diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java index 0ecf360e9a..2b15b45b5a 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/RouteInfoWidgetsFactory.java @@ -55,7 +55,7 @@ public class RouteInfoWidgetsFactory { final OsmandSettings settings, Paint textPaint, Paint subtextPaint, boolean horisontalMini) { final NextTurnInfoWidget nextTurnInfo = new NextTurnInfoWidget(ctx, textPaint, subtextPaint, horisontalMini) { NextDirectionInfo calc1 = new NextDirectionInfo(); - TurnType straight = TurnType.sraight(); + TurnType straight = TurnType.straight(); @Override public boolean updateInfo(DrawSettings drawSettings) { @@ -526,7 +526,7 @@ public class RouteInfoWidgetsFactory { final Path laneStraight = new Path(); Matrix pathTransform = new Matrix(); pathTransform.postScale(scaleCoefficient / miniCoeff, scaleCoefficient / miniCoeff); - TurnPathHelper.calcTurnPath(laneStraight, TurnType.sraight(), pathTransform); + TurnPathHelper.calcTurnPath(laneStraight, TurnType.straight(), pathTransform); final Paint paintBlack = new Paint(); paintBlack.setStyle(Style.STROKE); paintBlack.setColor(Color.BLACK);