From c792360fdd4f8db7155375d4f4c5c09fe3ba9162 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 15 Jun 2016 01:20:36 +0200 Subject: [PATCH] Add tests from pr-1428 --- .../net/osmand/binary/RouteDataObject.java | 39 ++++++++++++++----- .../osmand/router/RouteResultPreparation.java | 3 +- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java index bfc95225af..23784ec5ea 100644 --- a/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/net/osmand/binary/RouteDataObject.java @@ -280,11 +280,15 @@ public class RouteDataObject { if(pref.contains("km")) { f *= 1000; } - if(pref.contains("\"")) { + if(pref.contains("\"") || pref.contains("in")) { f *= 0.0254; - } else if (pref.contains("\'") || pref.contains("ft")) { + } else if (pref.contains("\'") || pref.contains("ft") || pref.contains("feet")) { // foot to meters f *= 0.3048; + } else if (pref.contains("cm")) { + f *= 0.01; + } else if (pref.contains("mile")) { + f *= 1609.34f; } return f + add; } @@ -467,14 +471,29 @@ public class RouteDataObject { public static void main(String[] args) { assertTrueLength("10 km", 10000); - assertTrueLength("0.01 km", 10); - assertTrueLength("0.01 km 10 m", 20); - assertTrueLength("10 m", 10); - assertTrueLength("10m", 10); - assertTrueLength("3.4 m", 3.4f); - assertTrueLength("14'10\"", 4.5212f); - assertTrueLength("14.5'", 4.4196f); - assertTrueLength("15ft", 4.572f); + assertTrueLength("0.01 km", 10); + assertTrueLength("0.01 km 10 m", 20); + assertTrueLength("10 m", 10); + assertTrueLength("10m", 10); + assertTrueLength("3.4 m", 3.4f); + assertTrueLength("3.40 m", 3.4f); + assertTrueLength("10 m 10m", 20); + assertTrueLength("14'10\"", 4.5212f); + assertTrueLength("14.5'", 4.4196f); + assertTrueLength("14.5 ft", 4.4196f); + assertTrueLength("14'0\"", 4.2672f); + assertTrueLength("15ft", 4.572f); + assertTrueLength("15 ft 1 in", 4.5974f); + assertTrueLength("4.1 metres", 4.1f); + assertTrueLength("14'0''", 4.2672f); + assertTrueLength("14 feet", 4.2672f); + assertTrueLength("14 mile", 22530.76f); + assertTrueLength("14 cm", 0.14f); + +// float badValue = -1; +// assertTrueLength("none", badValue); +// assertTrueLength("m 4.1", badValue); +// assertTrueLength("1F4 m", badValue); } public String coordinates() { diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index a86123fb89..a38e0648c9 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -731,8 +731,7 @@ public class RouteResultPreparation { return t; } - private int[] getTurnLanesInfo(RouteSegmentResult prevSegm, int mainTurnType) { - String turnLanes = getTurnLanesString(prevSegm); + private int[] getTurnLanesInfo(RouteSegmentResult prevSegm, int mainTurnType) { String turnLanes = getTurnLanesString(prevSegm); int[] lanesArray ; if (turnLanes == null) { if(prevSegm.getTurnType() != null && prevSegm.getTurnType().getLanes() != null