use of net.osmand.router.RoutingConfiguration.Builder in project Osmand by osmandapp.
the class TestRouting method calculateRoute.
private static void calculateRoute(double startLat, double startLon, double endLat, double endLon, BinaryMapIndexReader[] rs) throws IOException, InterruptedException {
long ts = System.currentTimeMillis();
Builder config = RoutingConfiguration.getDefault();
RoutingConfiguration rconfig = config.build(vehicle, MEMORY_TEST_LIMIT);
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(oldRouting);
RoutingContext ctx = router.buildRoutingContext(rconfig, lib, rs);
RouteSegment startSegment = router.findRouteSegment(startLat, startLon, ctx, null);
RouteSegment endSegment = router.findRouteSegment(endLat, endLon, ctx, null);
if (startSegment == null) {
throw new IllegalArgumentException("Start segment is not found ");
}
if (endSegment == null) {
throw new IllegalArgumentException("End segment is not found ");
}
// Clear ctx
ctx = router.buildRoutingContext(rconfig, lib, rs);
List<RouteSegmentResult> route = router.searchRoute(ctx, new LatLon(startLat, startLon), new LatLon(endLat, endLon), null);
System.out.println("Route is " + route.size() + " segments " + (System.currentTimeMillis() - ts) + " ms ");
}
Aggregations