commit
d230a323ce
3 changed files with 87 additions and 17 deletions
|
@ -1,25 +1,9 @@
|
|||
package net.osmand.binary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import com.google.protobuf.CodedInputStream;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.WireFormat;
|
||||
|
||||
import gnu.trove.iterator.TLongObjectIterator;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.list.array.TLongArrayList;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
|
@ -34,6 +18,23 @@ import net.osmand.util.Algorithms;
|
|||
import net.osmand.util.MapUtils;
|
||||
import net.osmand.util.OpeningHoursParser;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import gnu.trove.iterator.TLongObjectIterator;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import gnu.trove.list.array.TLongArrayList;
|
||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||
|
||||
public class BinaryMapRouteReaderAdapter {
|
||||
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
||||
private static final int SHIFT_COORDINATES = 4;
|
||||
|
@ -303,6 +304,7 @@ public class BinaryMapRouteReaderAdapter {
|
|||
public int directionTrafficSignalsBackward = -1;
|
||||
public int trafficSignals = -1;
|
||||
public int stopSign = -1;
|
||||
public int stopMinor = -1;
|
||||
public int giveWaySign = -1;
|
||||
|
||||
int nameTypeRule = -1;
|
||||
|
@ -363,6 +365,8 @@ public class BinaryMapRouteReaderAdapter {
|
|||
destinationRefTypeRule = id;
|
||||
} else if (tags.equals("highway") && val.equals("traffic_signals")){
|
||||
trafficSignals = id;
|
||||
} else if (tags.equals("stop") && val.equals("minor")) {
|
||||
stopMinor = id;
|
||||
} else if (tags.equals("highway") && val.equals("stop")){
|
||||
stopSign = id;
|
||||
} else if (tags.equals("highway") && val.equals("give_way")){
|
||||
|
|
|
@ -519,6 +519,24 @@ public class RouteDataObject {
|
|||
}
|
||||
return pointTypes[ind];
|
||||
}
|
||||
|
||||
public void removePointType(int ind, int type) {
|
||||
if (pointTypes != null || ind < pointTypes.length) {
|
||||
int[] typesArr = pointTypes[ind];
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getTypes() {
|
||||
return types;
|
||||
|
|
|
@ -176,11 +176,59 @@ public class RouteResultPreparation {
|
|||
combineWayPointsForAreaRouting(ctx, result);
|
||||
validateAllPointsConnected(result);
|
||||
splitRoadsAndAttachRoadSegments(ctx, result, recalculation);
|
||||
for (int i = 0; i < result.size(); i++) {
|
||||
filterMinorStops(result.get(i));
|
||||
}
|
||||
calculateTimeSpeed(ctx, result);
|
||||
|
||||
prepareTurnResults(ctx, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public RouteSegmentResult filterMinorStops(RouteSegmentResult seg) {
|
||||
List<Integer> stops = null;
|
||||
int startPoint = seg.getStartPointIndex();
|
||||
int endPoint = seg.getEndPointIndex();
|
||||
int start;
|
||||
int end;
|
||||
|
||||
if (startPoint < endPoint) {
|
||||
start = startPoint;
|
||||
end = endPoint;
|
||||
} else {
|
||||
start = endPoint;
|
||||
end = startPoint;
|
||||
}
|
||||
|
||||
while (start <= end) {
|
||||
int[] pointTypes = seg.getObject().getPointTypes(start);
|
||||
if (pointTypes != null) {
|
||||
for (int j = 0; j < pointTypes.length; j++) {
|
||||
if (pointTypes[j] == seg.getObject().region.stopMinor) {
|
||||
if (stops == null) {
|
||||
stops = new ArrayList<>();
|
||||
}
|
||||
stops.add(start);
|
||||
}
|
||||
}
|
||||
}
|
||||
start++;
|
||||
}
|
||||
|
||||
if (stops != null) {
|
||||
for (int stop : stops) {
|
||||
List<RouteSegmentResult> attachedRoutes = seg.getAttachedRoutes(stop);
|
||||
for (RouteSegmentResult attached : attachedRoutes) {
|
||||
int attStopPriority = highwaySpeakPriority(attached.getObject().getHighway());
|
||||
int segStopPriority = highwaySpeakPriority(seg.getObject().getHighway());
|
||||
if (segStopPriority < attStopPriority) {
|
||||
seg.getObject().removePointType(stop, seg.getObject().region.stopSign);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return seg;
|
||||
}
|
||||
|
||||
public void prepareTurnResults(RoutingContext ctx, List<RouteSegmentResult> result) {
|
||||
for (int i = 0; i < result.size(); i ++) {
|
||||
|
|
Loading…
Reference in a new issue