Search in sources :

Example 6 with Builder

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 ");
}
Also used : LatLon(net.osmand.data.LatLon) Builder(net.osmand.router.RoutingConfiguration.Builder) RouteSegment(net.osmand.router.BinaryRoutePlanner.RouteSegment) FinalRouteSegment(net.osmand.router.BinaryRoutePlanner.FinalRouteSegment)

Aggregations

Builder (net.osmand.router.RoutingConfiguration.Builder)6 RoutePlannerFrontEnd (net.osmand.router.RoutePlannerFrontEnd)4 RoutingConfiguration (net.osmand.router.RoutingConfiguration)4 RoutingContext (net.osmand.router.RoutingContext)4 ArrayList (java.util.ArrayList)3 LatLon (net.osmand.data.LatLon)3 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 RandomAccessFile (java.io.RandomAccessFile)2 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)2 RouteRegion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion)2 RouteSubregion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion)2 RouteDataObject (net.osmand.binary.RouteDataObject)2 RouteSegment (net.osmand.router.BinaryRoutePlanner.RouteSegment)2 RoutingSubregionTile (net.osmand.router.RoutingContext.RoutingSubregionTile)2 Point (java.awt.Point)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Way (net.osmand.osm.edit.Way)1 FinalRouteSegment (net.osmand.router.BinaryRoutePlanner.FinalRouteSegment)1