commit
d230a323ce
3 changed files with 87 additions and 17 deletions
|
@ -1,25 +1,9 @@
|
||||||
package net.osmand.binary;
|
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.CodedInputStream;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.WireFormat;
|
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.PlatformUtil;
|
||||||
import net.osmand.ResultMatcher;
|
import net.osmand.ResultMatcher;
|
||||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||||
|
@ -34,6 +18,23 @@ import net.osmand.util.Algorithms;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
import net.osmand.util.OpeningHoursParser;
|
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 {
|
public class BinaryMapRouteReaderAdapter {
|
||||||
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
protected static final Log LOG = PlatformUtil.getLog(BinaryMapRouteReaderAdapter.class);
|
||||||
private static final int SHIFT_COORDINATES = 4;
|
private static final int SHIFT_COORDINATES = 4;
|
||||||
|
@ -303,6 +304,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
public int directionTrafficSignalsBackward = -1;
|
public int directionTrafficSignalsBackward = -1;
|
||||||
public int trafficSignals = -1;
|
public int trafficSignals = -1;
|
||||||
public int stopSign = -1;
|
public int stopSign = -1;
|
||||||
|
public int stopMinor = -1;
|
||||||
public int giveWaySign = -1;
|
public int giveWaySign = -1;
|
||||||
|
|
||||||
int nameTypeRule = -1;
|
int nameTypeRule = -1;
|
||||||
|
@ -363,6 +365,8 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
destinationRefTypeRule = id;
|
destinationRefTypeRule = id;
|
||||||
} else if (tags.equals("highway") && val.equals("traffic_signals")){
|
} else if (tags.equals("highway") && val.equals("traffic_signals")){
|
||||||
trafficSignals = id;
|
trafficSignals = id;
|
||||||
|
} else if (tags.equals("stop") && val.equals("minor")) {
|
||||||
|
stopMinor = id;
|
||||||
} else if (tags.equals("highway") && val.equals("stop")){
|
} else if (tags.equals("highway") && val.equals("stop")){
|
||||||
stopSign = id;
|
stopSign = id;
|
||||||
} else if (tags.equals("highway") && val.equals("give_way")){
|
} else if (tags.equals("highway") && val.equals("give_way")){
|
||||||
|
|
|
@ -519,6 +519,24 @@ public class RouteDataObject {
|
||||||
}
|
}
|
||||||
return pointTypes[ind];
|
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() {
|
public int[] getTypes() {
|
||||||
return types;
|
return types;
|
||||||
|
|
|
@ -176,11 +176,59 @@ public class RouteResultPreparation {
|
||||||
combineWayPointsForAreaRouting(ctx, result);
|
combineWayPointsForAreaRouting(ctx, result);
|
||||||
validateAllPointsConnected(result);
|
validateAllPointsConnected(result);
|
||||||
splitRoadsAndAttachRoadSegments(ctx, result, recalculation);
|
splitRoadsAndAttachRoadSegments(ctx, result, recalculation);
|
||||||
|
for (int i = 0; i < result.size(); i++) {
|
||||||
|
filterMinorStops(result.get(i));
|
||||||
|
}
|
||||||
calculateTimeSpeed(ctx, result);
|
calculateTimeSpeed(ctx, result);
|
||||||
|
|
||||||
prepareTurnResults(ctx, result);
|
prepareTurnResults(ctx, result);
|
||||||
return 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) {
|
public void prepareTurnResults(RoutingContext ctx, List<RouteSegmentResult> result) {
|
||||||
for (int i = 0; i < result.size(); i ++) {
|
for (int i = 0; i < result.size(); i ++) {
|
||||||
|
|
Loading…
Reference in a new issue