diff --git a/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java b/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java
index 54d686c437..e9d612898c 100644
--- a/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java
+++ b/DataExtractionOSM/src-tests/net/osmand/router/JUnitRouteTest.java
@@ -30,7 +30,7 @@ public class JUnitRouteTest {
return;
}
lib = NativeSwingRendering.getDefaultFromSettings();
- BinaryRoutePlanner.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = false;
+ BinaryRoutePlanner.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
String obfdir = System.getenv("OBF_DIR");
if(Algoritms.isEmpty(obfdir)){
obfdir = DataExtractionSettings.getSettings().getBinaryFilesDir();
diff --git a/DataExtractionOSM/src-tests/net/osmand/router/cz.test.xml b/DataExtractionOSM/src-tests/net/osmand/router/cz.test.xml
index 6d9368da54..844488e967 100644
--- a/DataExtractionOSM/src-tests/net/osmand/router/cz.test.xml
+++ b/DataExtractionOSM/src-tests/net/osmand/router/cz.test.xml
@@ -1,39 +1,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ start_lat="50.07577452522076" start_lon="14.45427417755127" target_lat="49.120547036367746" target_lon="16.335017681121826" complete_time="7241.0713" loadedTiles = "250" visitedSegments = "2598" complete_distance = "204110.28" >
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
@@ -54,8 +51,7 @@
-
-
+
@@ -198,45 +194,60 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DataExtractionOSM/src-tests/net/osmand/router/nl.test.xml b/DataExtractionOSM/src-tests/net/osmand/router/nl.test.xml
index 89a915337e..59dc69c507 100644
--- a/DataExtractionOSM/src-tests/net/osmand/router/nl.test.xml
+++ b/DataExtractionOSM/src-tests/net/osmand/router/nl.test.xml
@@ -1,356 +1,391 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DataExtractionOSM/src-tests/net/osmand/router/nl2.test.xml b/DataExtractionOSM/src-tests/net/osmand/router/nl2.test.xml
index eef60b1772..a2bc6c0122 100644
--- a/DataExtractionOSM/src-tests/net/osmand/router/nl2.test.xml
+++ b/DataExtractionOSM/src-tests/net/osmand/router/nl2.test.xml
@@ -1,16 +1,27 @@
-
-
-
-
-
-
-
-
-
+ start_lat="52.29344776082418" start_lon="4.834756851196289" target_lat="51.21717320613008" target_lon="4.402492046356201" complete_time="5541.6855" loadedTiles = "438" visitedSegments = "9031" complete_distance = "155763.8" >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -27,13 +38,13 @@
-
+
-
-
-
+
+
+
-
+
@@ -46,45 +57,45 @@
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
@@ -94,18 +105,18 @@
-
+
-
+
-
+
@@ -114,7 +125,7 @@
-
+
@@ -124,7 +135,7 @@
-
+
@@ -135,28 +146,24 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
-
+
@@ -164,13 +171,13 @@
-
+
-
+
-
-
+
+
@@ -179,40 +186,40 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
@@ -221,53 +228,78 @@
-
-
+
+
-
-
-
+
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
\ No newline at end of file
diff --git a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java
index b2c62e8961..bc971d69e8 100644
--- a/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java
+++ b/DataExtractionOSM/src/net/osmand/router/BinaryRoutePlanner.java
@@ -46,7 +46,7 @@ public class BinaryRoutePlanner {
public BinaryRoutePlanner(NativeLibrary nativeLib, BinaryMapIndexReader... map) {
this.nativeLib = nativeLib;
if(nativeLib != null) {
- RoutingConfiguration.DEFAULT_DESIRABLE_TILES_IN_MEMORY = 50;
+ RoutingConfiguration.DEFAULT_DESIRABLE_TILES_IN_MEMORY = 100;
}
for (BinaryMapIndexReader mr : map) {
List rr = mr.getRoutingIndexes();
@@ -395,7 +395,7 @@ public class BinaryRoutePlanner {
// int after = graphSegments.size();
// println(statStart.toString());
// println(statEnd.toString());
-// println("Relaxing : before " + before + " after " + after + " maxdiststart " + ((float) maxd) + " minend " + ((float) mine));
+// println("Relaxing : before " + before + " after " + after + " minend " + ((float) mine));
}
private double h(final RoutingContext ctx, int targetEndX, int targetEndY,
@@ -465,9 +465,25 @@ public class BinaryRoutePlanner {
final int middle = segment.segmentStart;
double obstaclePlusTime = 0;
double obstacleMinusTime = 0;
+
+
+ // This is correct way of checking but it has problem with relaxing strategy
+// long ntf = (segment.road.getId() << ROUTE_POINTS) + segment.segmentStart;
+// visitedSegments.put(ntf, segment);
+// if (oppositeSegments.contains(ntf) && oppositeSegments.get(ntf) != null) {
+// RouteSegment opposite = oppositeSegments.get(ntf);
+// if (opposite.segmentStart == segment.segmentStart) {
+ // if (reverseWaySearch) {
+ // reverse : segment.parentSegmentEnd - segment.parentRoute
+ // } else {
+ // reverse : opposite.parentSegmentEnd - oppositie.parentRoute
+ // }
+// return true;
+// }
+// }
// 0. mark route segment as visited
- long nt = (road.getId() << 11l) + middle;
+ long nt = (road.getId() << ROUTE_POINTS) + middle;
// avoid empty segments to connect but mark the point as visited
visitedSegments.put(nt, null);
@@ -545,20 +561,27 @@ public class BinaryRoutePlanner {
if(positive){
double obstacle = ctx.getRouter().defineObstacle(road, segmentEnd);
if(obstacle < 0){
- plusAllowed = false;
- continue;
+ if(obstacle == -1) {
+ plusAllowed = false;
+ continue;
+ } else {
+ obstacle = -obstacle;
+ }
}
obstaclePlusTime += obstacle;
} else {
double obstacle = ctx.getRouter().defineObstacle(road, segmentEnd);
if(obstacle < 0){
- minusAllowed = false;
- continue;
+ if(obstacle == -1) {
+ minusAllowed = false;
+ continue;
+ } else {
+ obstacle = -obstacle;
+ }
}
obstacleMinusTime += obstacle;
}
-
long l = (((long) x) << 31) + (long) y;
RouteSegment next = tile.getSegment(l, ctx);
// 3. get intersected ways
@@ -689,11 +712,11 @@ public class BinaryRoutePlanner {
if(nextIterator != null) {
next = nextIterator.next();
}
- long nts = (next.road.getId() << ROUTE_POINTS) + next.segmentStart;
+ long nts = (next.road.getId() << ROUTE_POINTS) + next.segmentStart;
// 1. Check if opposite segment found so we can stop calculations
if (oppositeSegments.contains(nts) && oppositeSegments.get(nts) != null) {
- // check restrictions
+ // restrictions checked
RouteSegment opposite = oppositeSegments.get(nts);
if (reverseWay) {
ctx.finalReverseEndSegment = segmentEnd;
@@ -710,16 +733,20 @@ public class BinaryRoutePlanner {
}
// road.id could be equal on roundabout, but we should accept them
boolean alreadyVisited = visitedSegments.contains(nts);
- if (!alreadyVisited) {
+ if (!alreadyVisited) {
double distanceToEnd = h(ctx, distToFinalPoint, next);
if (next.parentRoute == null
|| ctx.roadPriorityComparator(next.distanceFromStart, next.distanceToEnd, distFromStart, distanceToEnd) > 0) {
- next.distanceFromStart = distFromStart;
- next.distanceToEnd = distanceToEnd;
if (next.parentRoute != null) {
// already in queue remove it
- graphSegments.remove(next);
+ if(!graphSegments.remove(next)){
+ // exist in different queue!
+ RouteSegment cpy = new RouteSegment(next.getRoad(), next.segmentStart);
+ next = cpy;
+ }
}
+ next.distanceFromStart = distFromStart;
+ next.distanceToEnd = distanceToEnd;
// put additional information to recover whole route after
next.parentRoute = segment;
next.parentSegmentEnd = segmentEnd;
@@ -818,11 +845,10 @@ public class BinaryRoutePlanner {
road.getPoint31YTile(next));
distance += d;
double obstacle = ctx.getRouter().defineObstacle(road, j);
- if(obstacle >= 0) {
- distOnRoadToPass += d / speed + obstacle;
- } else {
- System.err.println("Something completely wrong if we pass obstacle < 0 " + Arrays.toString(road.getPointTypes(j)));
+ if(obstacle < 0) {
+ obstacle = 30; // configurable ?
}
+ distOnRoadToPass += d / speed + obstacle;
List attachedRoutes = rr.getAttachedRoutes(next);
if (next != rr.getEndPointIndex() && !rr.getObject().roundabout() && attachedRoutes != null) {
diff --git a/DataExtractionOSM/src/net/osmand/router/RoutingConfiguration.java b/DataExtractionOSM/src/net/osmand/router/RoutingConfiguration.java
index 0ce953e0b2..bb08b4067c 100644
--- a/DataExtractionOSM/src/net/osmand/router/RoutingConfiguration.java
+++ b/DataExtractionOSM/src/net/osmand/router/RoutingConfiguration.java
@@ -23,7 +23,7 @@ public class RoutingConfiguration {
// 1.1 tile load parameters (should not affect routing)
public int ZOOM_TO_LOAD_TILES = 13; // 12?, 14?
public int ITERATIONS_TO_RUN_GC = 100;
- public static int DEFAULT_DESIRABLE_TILES_IN_MEMORY = 25;
+ public static int DEFAULT_DESIRABLE_TILES_IN_MEMORY = 30;
public int NUMBER_OF_DESIRABLE_TILES_IN_MEMORY = DEFAULT_DESIRABLE_TILES_IN_MEMORY;
// 1.2 Dynamic road prioritizing (heuristic)
diff --git a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java
index 4729d3c9ea..00e21e907c 100644
--- a/DataExtractionOSM/src/net/osmand/router/RoutingContext.java
+++ b/DataExtractionOSM/src/net/osmand/router/RoutingContext.java
@@ -285,7 +285,6 @@ public class RoutingContext {
}
}
}
- System.out.println(matcher);
loadedTiles++;
if (tile.isUnloaded()) {
loadedPrevUnloadedTiles++;
diff --git a/DataExtractionOSM/src/net/osmand/router/routing.xml b/DataExtractionOSM/src/net/osmand/router/routing.xml
index 093ff935d2..75277d6cce 100644
--- a/DataExtractionOSM/src/net/osmand/router/routing.xml
+++ b/DataExtractionOSM/src/net/osmand/router/routing.xml
@@ -12,6 +12,7 @@
+
@@ -39,7 +40,7 @@
-
@@ -90,16 +91,17 @@
-
+
-
-
-
+
+
+
+
diff --git a/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java b/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java
index e2f7c8811f..38212b29d2 100644
--- a/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java
+++ b/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java
@@ -600,7 +600,8 @@ public class MapRouterLayer implements MapPanelLayer {
String[] props = m.split("\\,");
BinaryRoutePlanner router = new BinaryRoutePlanner(NativeSwingRendering.getDefaultFromSettings(), rs);
RoutingConfiguration config = builder.build(props[0], props);
- config.NUMBER_OF_DESIRABLE_TILES_IN_MEMORY = 300;
+ // config.NUMBER_OF_DESIRABLE_TILES_IN_MEMORY = 300;
+ // config.ZOOM_TO_LOAD_TILES = 14;
RoutingContext ctx = new RoutingContext(config);
ctx.previouslyCalculatedRoute = previousRoute;
log.info("Use " + config.routerName + "mode for routing");
diff --git a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java
index 2e1d3d7c68..8c1aa0453f 100644
--- a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java
@@ -289,8 +289,8 @@ public class GeoIntentActivity extends OsmandListActivity {
lonIndex = lonIndex > 0 ? lonIndex : geo.length();
if (latIndex > 0) {
try {
- double latitude = Double.parseDouble(geo.substring(0, latIndex));
- double longitude = Double.parseDouble(geo.substring(latIndex + 1, lonIndex));
+ double latitude = Double.parseDouble(geo.substring(0, latIndex).trim());
+ double longitude = Double.parseDouble(geo.substring(latIndex + 1, lonIndex).trim());
// TODO zoom is omited for now
point = new MapObject(new Node(latitude, longitude, -1)) {
private static final long serialVersionUID = -7028586132795853725L;