Investigate new routing

This commit is contained in:
vshcherb 2014-01-09 01:33:46 +01:00
parent cd28aaabaa
commit b9e4a8cc3d
4 changed files with 66 additions and 6 deletions

View file

@ -55,12 +55,12 @@ public class BinaryInspector {
BinaryInspector in = new BinaryInspector();
in.inspector(args);
// test cases show info
/*in.inspector(new String[]{
in.inspector(new String[]{
//"-vpoi",
"-vmap", "-vmapobjects",
//"-vstreets",
"-bbox=4,55,7,50",
"/home/victor/projects/osmand/osm-gen/World_seamarks_2.obf"});*/
//"-bbox=4,55,7,50",
"/home/victor/projects/osmand/osm-gen/Map.obf"});
}
private void printToFile(String s) throws IOException {

View file

@ -116,6 +116,8 @@ public class BinaryRoutePlanner {
graphSegments = graphDirectSegments;
}
ctx.loadBorderPoints();
/*RoutingContext baseCtx = new RoutingContext(ctx);
baseCtx.newRoutingPoints();*/
FinalRouteSegment finalSegment = null;
while (!graphSegments.isEmpty()) {

View file

@ -231,8 +231,12 @@ public class RouteResultPreparation {
double endLat = end.getLatitude();
double endLon = end.getLongitude();
println(MessageFormat.format("<test regions=\"\" description=\"\" best_percent=\"\" vehicle=\"{4}\" \n"
+ " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\" {5} >", startLat
+ "", startLon + "", endLat + "", endLon + "", ctx.config.routerName, "loadedTiles = \"" + ctx.loadedTiles + "\" " + "visitedSegments = \"" + ctx.visitedSegments + "\" " + "complete_distance = \"" + completeDistance + "\" " + "complete_time = \"" + completeTime + "\" " + "routing_time = \"" + ctx.routingTime + "\" "));
+ " start_lat=\"{0}\" start_lon=\"{1}\" target_lat=\"{2}\" target_lon=\"{3}\" {5} >",
startLat + "", startLon + "", endLat + "", endLon + "", ctx.config.routerName,
"loadedTiles = \"" + ctx.loadedTiles + "\" " + "visitedSegments = \"" + ctx.visitedSegments + "\" " +
"complete_distance = \"" + completeDistance + "\" " + "complete_time = \"" + completeTime + "\" " +
"routing_time = \"" + ctx.routingTime + "\" "));
double length = MapUtils.getDistance(start, end);
if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) {
for (RouteSegmentResult res : result) {
String name = res.getObject().getName();
@ -267,6 +271,49 @@ public class RouteResultPreparation {
}
}
println("</test>");
if (PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST) {
for (int d = 10; d <= 40; d += 10) {
System.out.println("---- " + d);
newRoutingAnalyzeDiff(start, end, result, length, d);
}
}
}
private void newRoutingAnalyzeDiff(LatLon start, LatLon end, List<RouteSegmentResult> result, double length, int d) {
for(int k = 0; k < result.size() - d; k++){
RouteSegmentResult res1 = result.get(k);
RouteSegmentResult res2 = result.get(k + d);
float realdist = 0;
for (int t = k; t < k + d + 1; t++) {
realdist += result.get(t).getDistance();
}
{
RouteDataObject obj1 = res1.getObject();
RouteDataObject obj2 = res2.getObject();
int si = res1.getStartPointIndex();
LatLon segStart = new LatLon(MapUtils.get31LatitudeY(obj1.getPoint31YTile(si)),
MapUtils.get31LongitudeX(obj1.getPoint31XTile(si)));
int ei = res2.getEndPointIndex();
LatLon segEnd = new LatLon(MapUtils.get31LatitudeY(obj2.getPoint31YTile(ei)),
MapUtils.get31LongitudeX(obj2.getPoint31XTile(ei)));
float maxSpeed = obj1.getMaximumSpeed();
if (maxSpeed > 0) {
double st = MapUtils.getDistance(start, segStart);
double en = MapUtils.getDistance(segEnd, end);
double segmentdist = MapUtils.getDistance(segStart, segEnd);
double f = length - st - en;
if (f > 0) {
double ratio = realdist/ f;
double speed_cut = maxSpeed / ratio * 3.6;
if (speed_cut > 60) {
System.out.println(" F " + segmentdist +" - " + realdist + " " + segStart + ".."+segEnd);
System.out.println("Ref ! " + k + ":" + (k + d) + " " + obj1.getRef() + "-" + obj2.getRef()
+ " DIFF " + (int) f + " / " + speed_cut);
}
}
}
}
}
}
@ -352,6 +399,7 @@ public class RouteResultPreparation {
double mpi = MapUtils.degreesDiff(prev.getBearingEnd(), rr.getBearingBegin());
if(noAttachedRoads){
// TODO VICTOR : look at the comment inside direction route
// ? avoid small zigzags is covered at (search for "zigzags")
// double begin = rr.getObject().directionRoute(rr.getStartPointIndex(), rr.getStartPointIndex() <
// rr.getEndPointIndex(), 25);
// mpi = MapUtils.degreesDiff(prev.getBearingEnd(), begin);

View file

@ -278,6 +278,16 @@ public class RoutingContext {
return ind;
}
public void newRoutingPoints() {
int middleX = startX / 2 + targetX / 2;
int middleY = startY / 2 + targetY;
List<RouteDataObject> dataObjects = new ArrayList<RouteDataObject>();
loadTileData(middleX, middleY, 17, dataObjects);
System.out.println("Size of data objects " + dataObjects.size());
}
public void loadBorderPoints() throws IOException {
Iterator<Entry<RouteRegion, BinaryMapIndexReader>> it = reverseMap.entrySet().iterator();
int sleft = Math.min(startX, targetX);
@ -354,7 +364,7 @@ public class RoutingContext {
}
}
if (minDist > 0) {
// System.out.println("Border line " + i + " exp="+res + " min="+ minDist);
System.out.println("Border line " + i + " exp="+res + " min="+ minDist);
res = (float) minDist;
}
}