From 368b2ff8f922fc4c8bfeda46d04141134af72f9f Mon Sep 17 00:00:00 2001 From: Kseniia Date: Thu, 4 Mar 2021 12:55:32 +0200 Subject: [PATCH] Add minor stop 10281 --- OsmAnd-java/build.gradle | 1 - .../net/osmand/binary/RouteDataObject.java | 14 +++++++++---- .../osmand/router/RouteResultPreparation.java | 21 ++++++++++++++----- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/OsmAnd-java/build.gradle b/OsmAnd-java/build.gradle index d4e77b9d85..d461ea8aff 100644 --- a/OsmAnd-java/build.gradle +++ b/OsmAnd-java/build.gradle @@ -112,7 +112,6 @@ dependencies { implementation group: 'org.json', name: 'json', version: '20171018' implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1' implementation 'org.apache.commons:commons-compress:1.17' - implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.0' implementation 'com.moparisthebest:junidecode:0.1.1' implementation 'com.vividsolutions:jts-core:1.14.0' implementation 'com.google.openlocationcode:openlocationcode:1.0.4' diff --git a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java index 61d282e5e4..d4c4024b27 100644 --- a/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java +++ b/OsmAnd-java/src/main/java/net/osmand/binary/RouteDataObject.java @@ -8,7 +8,6 @@ import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import net.osmand.util.TransliterationHelper; -import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.logging.Log; import java.text.MessageFormat; @@ -504,9 +503,16 @@ public class RouteDataObject { public void removePointType(int ind, int type) { if (pointTypes != null || ind < pointTypes.length) { int[] typesArr = pointTypes[ind]; - for (int t : typesArr) { - if (t == type) { - pointTypes[ind] = ArrayUtils.removeElement(typesArr, t); + + for (int i = 0; i < typesArr.length; i++) { + if (typesArr[i] == type) { + int[] result = new int[typesArr.length - 1]; + System.arraycopy(typesArr, 0, result, 0, i); + if (typesArr.length != i) { + System.arraycopy(typesArr, i + 1, result, i, typesArr.length - 1 - i); + pointTypes[ind] = result; + break; + } } } } diff --git a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java index d79bbc53da..2faf6b1833 100644 --- a/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java +++ b/OsmAnd-java/src/main/java/net/osmand/router/RouteResultPreparation.java @@ -177,19 +177,30 @@ public class RouteResultPreparation { validateAllPointsConnected(result); splitRoadsAndAttachRoadSegments(ctx, result, recalculation); for (int i = 0; i < result.size(); i++) { - prepareStopSign(result.get(i)); + filterMinorStops(result.get(i)); } calculateTimeSpeed(ctx, result); prepareTurnResults(ctx, result); return result; } - public RouteSegmentResult prepareStopSign(RouteSegmentResult seg) { - int start = seg.getStartPointIndex(); - int end = seg.getEndPointIndex(); + public RouteSegmentResult filterMinorStops(RouteSegmentResult seg) { + int startPoint = seg.getStartPointIndex(); + int endPoint = seg.getEndPointIndex(); + int start; + int end; + + if (startPoint < endPoint) { + start = startPoint; + end = endPoint; + } else { + start = endPoint; + end = startPoint; + } + List stops = new ArrayList<>(); - for (int i = start; i > end; i--) { + for (int i = start; i < end; i++) { int[] pointTypes = seg.getObject().getPointTypes(i); if (pointTypes != null) { for (int j = 0; j < pointTypes.length; j++) {