From df6cf9f48079ca8ac607aabdcb8ea79596747ed5 Mon Sep 17 00:00:00 2001 From: vshcherb Date: Fri, 21 Feb 2014 01:03:27 +0100 Subject: [PATCH] Update routing --- .../net/osmand/binary/BinaryInspector.java | 9 ++++-- .../osmand/router/RoutePlannerFrontEnd.java | 6 ++-- .../src/net/osmand/router/RoutingContext.java | 28 ++++++++++++------- .../osmand/plus/CurrentPositionHelper.java | 2 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java index 6060070356..07e0dcb1d9 100644 --- a/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java +++ b/OsmAnd-java/src/net/osmand/binary/BinaryInspector.java @@ -57,10 +57,13 @@ public class BinaryInspector { if(args.length == 1 && "test".equals(args[0])) { in.inspector(new String[]{ //"-vpoi", - // "-vmap", "-vmapobjects", - //"-vstreets", + //"-vmap", "-vmapobjects", + //"-vaddress", "-vcities", "-vstreets", "-vstreetgroups","-vbuildings", + //"-zoom=16", //"-bbox=4,55,7,50", - "/home/victor/projects/osmand/osm-gen/Map.obf"}); + //"/home/victor/osmand/Test.obf" + //"/home/victor/projects/osmand/osm-gen/Map.obf" + }); } else { in.inspector(args); } diff --git a/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java b/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java index 36a5047e2a..b466cb0dcf 100644 --- a/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java +++ b/OsmAnd-java/src/net/osmand/router/RoutePlannerFrontEnd.java @@ -156,10 +156,7 @@ public class RoutePlannerFrontEnd { private List searchRouteInternalPrepare(final RoutingContext ctx, RouteSegment start, RouteSegment end, PrecalculatedRouteDirection routeDirection) throws IOException, InterruptedException { - ctx.targetX = end.road.getPoint31XTile(end.getSegmentStart()); - ctx.targetY = end.road.getPoint31YTile(end.getSegmentStart()); - ctx.startX = start.road.getPoint31XTile(start.getSegmentStart()); - ctx.startY = start.road.getPoint31YTile(start.getSegmentStart()); + ctx.initStartAndTargetPoints(start, end); if(routeDirection != null) { ctx.precalculatedRouteDirection = routeDirection.adopt(ctx); } @@ -178,6 +175,7 @@ public class RoutePlannerFrontEnd { } } + private void refreshProgressDistance(RoutingContext ctx) { if(ctx.calculationProgress != null) { ctx.calculationProgress.distanceFromBegin = 0; diff --git a/OsmAnd-java/src/net/osmand/router/RoutingContext.java b/OsmAnd-java/src/net/osmand/router/RoutingContext.java index 187b30f5c0..7889ca7b34 100644 --- a/OsmAnd-java/src/net/osmand/router/RoutingContext.java +++ b/OsmAnd-java/src/net/osmand/router/RoutingContext.java @@ -78,7 +78,7 @@ public class RoutingContext { // 3. Warm object caches ArrayList segmentsToVisitPrescripted = new ArrayList(5); ArrayList segmentsToVisitNotForbidden = new ArrayList(5); - + // 5. debug information (package accessor) public TileStatistics global = new TileStatistics(); @@ -106,7 +106,10 @@ public class RoutingContext { // old planner public FinalRouteSegment finalRouteSegment; - public RoutingContext(RoutingContext cp) { + + + + RoutingContext(RoutingContext cp) { this.config = cp.config; this.map.putAll(cp.map); this.calculationMode = cp.calculationMode; @@ -131,11 +134,7 @@ public class RoutingContext { } } - public RoutingContext(RoutingConfiguration config, NativeLibrary nativeLibrary, BinaryMapIndexReader[] map) { - this(config, nativeLibrary, map, null); - } - - public RoutingContext(RoutingConfiguration config, NativeLibrary nativeLibrary, BinaryMapIndexReader[] map, RouteCalculationMode calcMode) { + RoutingContext(RoutingConfiguration config, NativeLibrary nativeLibrary, BinaryMapIndexReader[] map, RouteCalculationMode calcMode) { this.calculationMode = calcMode; for (BinaryMapIndexReader mr : map) { List rr = mr.getRoutingIndexes(); @@ -207,6 +206,13 @@ public class RoutingContext { config.heuristicCoefficient); } + public void initStartAndTargetPoints(RouteSegment start, RouteSegment end) { + targetX = end.road.getPoint31XTile(end.getSegmentStart()); + targetY = end.road.getPoint31YTile(end.getSegmentStart()); + startX = start.road.getPoint31XTile(start.getSegmentStart()); + startY = start.road.getPoint31YTile(start.getSegmentStart()); + } + public void registerRouteDataObject(RouteDataObject o ) { if(!getRouter().acceptLine(o)){ return; @@ -459,8 +465,9 @@ public class RoutingContext { } } TLongIterator it = ts.iterator(); + TLongObjectHashMap excludeDuplications = new TLongObjectHashMap(); while(it.hasNext()){ - getAllObjects(it.next(), toFillIn); + getAllObjects(it.next(), toFillIn, excludeDuplications); } timeToFindInitialSegments += (System.nanoTime() - now); } @@ -573,8 +580,7 @@ public class RoutingContext { } } - private void getAllObjects(long tileId, final List toFillIn) { - TLongObjectHashMap excludeDuplications = new TLongObjectHashMap(); + private void getAllObjects(long tileId, final List toFillIn, TLongObjectHashMap excludeDuplications) { if (tileRoutes.containsKey(tileId)) { List routes = tileRoutes.get(tileId); if (routes != null) { @@ -843,5 +849,7 @@ public class RoutingContext { return map.keySet().toArray(new BinaryMapIndexReader[map.size()]); } + + } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java index 63dc37855b..27aac2c31e 100644 --- a/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java +++ b/OsmAnd/src/net/osmand/plus/CurrentPositionHelper.java @@ -37,7 +37,7 @@ public class CurrentPositionHelper { return; } RoutingConfiguration cfg = RoutingConfiguration.getDefault().build(p.name().toLowerCase(), 10); - ctx = new RoutingContext(cfg, null, app.getTodoAPI().getRoutingMapFiles()); + ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, app.getTodoAPI().getRoutingMapFiles()); } private RouteDataObject runUpdateInThread(Location loc) {