From 3cc7ad3d8644fdab41bfe6d7d78cb92fcd1eed96 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 25 Jul 2016 01:15:13 +0200 Subject: [PATCH] Fix #2855, fix uturns --- .../osmand/router/RouteResultPreparation.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java index 768f7d16cc..e52c6663a1 100644 --- a/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/net/osmand/router/RouteResultPreparation.java @@ -465,16 +465,16 @@ public class RouteResultPreparation { ut = false; } } - String highway = result.get(i).getObject().getHighway(); - if(highway == null || highway.endsWith("track") || highway.endsWith("services") || highway.endsWith("service") - || highway.endsWith("path")) { +// String highway = result.get(i).getObject().getHighway(); +// if(highway == null || highway.endsWith("track") || highway.endsWith("services") || highway.endsWith("service") +// || highway.endsWith("path")) { +// ut = false; +// } + if (result.get(i - 1).getObject().getOneway() == 0 || result.get(i + 1).getObject().getOneway() == 0) { ut = false; } - if (result.get(i).getObject().getOneway() == 0 || result.get(i + 1).getObject().getOneway() == 0) { - ut = false; - } - if (!Algorithms.objectEquals(result.get(i).getObject().getName(), - result.get(i + 1).getObject().getName())) { + if (!Algorithms.objectEquals(getStreetName(result, i - 1, false), + getStreetName(result, i + 1, true))) { ut = false; } if (ut) { @@ -494,6 +494,23 @@ public class RouteResultPreparation { return null; } + private String getStreetName(List result, int i, boolean dir) { + String nm = result.get(i).getObject().getName(); + if (Algorithms.isEmpty(nm)) { + if (!dir) { + if (i > 0) { + nm = result.get(i - 1).getObject().getName(); + } + } else { + if(i < result.size() - 1) { + nm = result.get(i + 1).getObject().getName(); + } + } + } + + return nm; + } + private void determineTurnsToMerge(boolean leftside, List result) { RouteSegmentResult nextSegment = null; double dist = 0;