Add minor stop 10281

This commit is contained in:
Kseniia 2021-03-04 12:55:32 +02:00
parent e15dece046
commit 368b2ff8f9
3 changed files with 26 additions and 10 deletions

View file

@ -112,7 +112,6 @@ dependencies {
implementation group: 'org.json', name: 'json', version: '20171018' implementation group: 'org.json', name: 'json', version: '20171018'
implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1' implementation 'it.unibo.alice.tuprolog:tuprolog:3.2.1'
implementation 'org.apache.commons:commons-compress:1.17' 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.moparisthebest:junidecode:0.1.1'
implementation 'com.vividsolutions:jts-core:1.14.0' implementation 'com.vividsolutions:jts-core:1.14.0'
implementation 'com.google.openlocationcode:openlocationcode:1.0.4' implementation 'com.google.openlocationcode:openlocationcode:1.0.4'

View file

@ -8,7 +8,6 @@ import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import net.osmand.util.MapUtils;
import net.osmand.util.TransliterationHelper; import net.osmand.util.TransliterationHelper;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.text.MessageFormat; import java.text.MessageFormat;
@ -504,9 +503,16 @@ public class RouteDataObject {
public void removePointType(int ind, int type) { public void removePointType(int ind, int type) {
if (pointTypes != null || ind < pointTypes.length) { if (pointTypes != null || ind < pointTypes.length) {
int[] typesArr = pointTypes[ind]; int[] typesArr = pointTypes[ind];
for (int t : typesArr) {
if (t == type) { for (int i = 0; i < typesArr.length; i++) {
pointTypes[ind] = ArrayUtils.removeElement(typesArr, t); 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;
}
} }
} }
} }

View file

@ -177,19 +177,30 @@ public class RouteResultPreparation {
validateAllPointsConnected(result); validateAllPointsConnected(result);
splitRoadsAndAttachRoadSegments(ctx, result, recalculation); splitRoadsAndAttachRoadSegments(ctx, result, recalculation);
for (int i = 0; i < result.size(); i++) { for (int i = 0; i < result.size(); i++) {
prepareStopSign(result.get(i)); filterMinorStops(result.get(i));
} }
calculateTimeSpeed(ctx, result); calculateTimeSpeed(ctx, result);
prepareTurnResults(ctx, result); prepareTurnResults(ctx, result);
return result; return result;
} }
public RouteSegmentResult prepareStopSign(RouteSegmentResult seg) { public RouteSegmentResult filterMinorStops(RouteSegmentResult seg) {
int start = seg.getStartPointIndex(); int startPoint = seg.getStartPointIndex();
int end = seg.getEndPointIndex(); int endPoint = seg.getEndPointIndex();
int start;
int end;
if (startPoint < endPoint) {
start = startPoint;
end = endPoint;
} else {
start = endPoint;
end = startPoint;
}
List<Integer> stops = new ArrayList<>(); List<Integer> stops = new ArrayList<>();
for (int i = start; i > end; i--) { for (int i = start; i < end; i++) {
int[] pointTypes = seg.getObject().getPointTypes(i); int[] pointTypes = seg.getObject().getPointTypes(i);
if (pointTypes != null) { if (pointTypes != null) {
for (int j = 0; j < pointTypes.length; j++) { for (int j = 0; j < pointTypes.length; j++) {