Search in sources :

Example 1 with RouteCalculationMode

use of net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode in project OsmAnd-tools by osmandapp.

the class ManyToOneRoadCalculation method cut.

private void cut(BinaryMapIndexReader reader) throws IOException {
    RoutePlannerFrontEnd frontEnd = new RoutePlannerFrontEnd(false);
    RoutingConfiguration config = RoutingConfiguration.getDefault().build("car", 1000);
    RouteCalculationMode mode = RouteCalculationMode.BASE;
    RoutingContext ctx = frontEnd.buildRoutingContext(config, null, new BinaryMapIndexReader[] { reader }, mode);
    RouteRegion reg = reader.getRoutingIndexes().get(0);
    List<RouteSubregion> baseSubregions = reg.getBaseSubregions();
    List<RoutingSubregionTile> tiles = new ArrayList<RoutingContext.RoutingSubregionTile>();
    for (RouteSubregion s : baseSubregions) {
        List<RoutingSubregionTile> loadTiles = ctx.loadAllSubregionTiles(reader, s);
        tiles.addAll(loadTiles);
    }
    int zoom = 9;
    int ty = (int) MapUtils.getTileNumberY(zoom, reg.getTopLatitude());
    int by = (int) MapUtils.getTileNumberY(zoom, reg.getBottomLatitude()) + 1;
    int lx = (int) MapUtils.getTileNumberX(zoom, reg.getLeftLongitude());
    int rx = (int) MapUtils.getTileNumberX(zoom, reg.getRightLongitude()) + 1;
    for (int ky = ty + 1; ky < by; ky++) {
        for (int kx = lx + 1; kx < rx; kx++) {
            cutByQuadrant((kx - 1) << (31 - zoom), (ky - 1) << (31 - zoom), kx << (31 - zoom), ky << (31 - zoom), ctx, tiles);
        }
    }
}
Also used : RoutingContext(net.osmand.router.RoutingContext) RouteSubregion(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion) RoutingConfiguration(net.osmand.router.RoutingConfiguration) RouteRegion(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion) RoutePlannerFrontEnd(net.osmand.router.RoutePlannerFrontEnd) RouteCalculationMode(net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode) ArrayList(java.util.ArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList) RoutingSubregionTile(net.osmand.router.RoutingContext.RoutingSubregionTile)

Example 2 with RouteCalculationMode

use of net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode in project OsmAnd-tools by osmandapp.

the class ManyToOneRoadCalculation method manyToManyCalculation.

private void manyToManyCalculation(BinaryMapIndexReader reader, double top, double bottom) throws IOException {
    RoutePlannerFrontEnd frontEnd = new RoutePlannerFrontEnd(false);
    RoutingConfiguration config = RoutingConfiguration.getDefault().build("car", 1000);
    RouteCalculationMode mode = RouteCalculationMode.BASE;
    RoutingContext ctx = frontEnd.buildRoutingContext(config, null, new BinaryMapIndexReader[] { reader }, mode);
    RouteRegion reg = reader.getRoutingIndexes().get(0);
    List<RouteSubregion> baseSubregions = reg.getBaseSubregions();
    List<RoutingSubregionTile> tiles = new ArrayList<RoutingContext.RoutingSubregionTile>();
    for (RouteSubregion s : baseSubregions) {
        List<RoutingSubregionTile> loadTiles = ctx.loadAllSubregionTiles(reader, s);
        tiles.addAll(loadTiles);
    }
    int st = MapUtils.get31TileNumberY(top);
    int sb = MapUtils.get31TileNumberY(bottom);
    List<ManyToManySegment> topIntersects = new ArrayList<ManyToManySegment>();
    List<ManyToManySegment> bottomIntersects = new ArrayList<ManyToManySegment>();
    TLongObjectHashMap<ManyToManySegment> allSegments = initSegments(st, sb, ctx, tiles, topIntersects, bottomIntersects);
    filterDisconnected(ctx, allSegments, topIntersects);
    filterDisconnected(ctx, allSegments, topIntersects);
    System.out.println("TOP " + topIntersects.size());
    System.out.println("BOTTOM " + bottomIntersects.size());
    calculateManyToMany(ctx, allSegments, topIntersects, bottomIntersects, st, sb);
}
Also used : RouteSubregion(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion) ArrayList(java.util.ArrayList) TLongArrayList(gnu.trove.list.array.TLongArrayList) RoutingContext(net.osmand.router.RoutingContext) RoutingConfiguration(net.osmand.router.RoutingConfiguration) RouteRegion(net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion) RoutePlannerFrontEnd(net.osmand.router.RoutePlannerFrontEnd) RouteCalculationMode(net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode) RoutingSubregionTile(net.osmand.router.RoutingContext.RoutingSubregionTile)

Aggregations

TLongArrayList (gnu.trove.list.array.TLongArrayList)2 ArrayList (java.util.ArrayList)2 RouteRegion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion)2 RouteSubregion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion)2 RoutePlannerFrontEnd (net.osmand.router.RoutePlannerFrontEnd)2 RouteCalculationMode (net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode)2 RoutingConfiguration (net.osmand.router.RoutingConfiguration)2 RoutingContext (net.osmand.router.RoutingContext)2 RoutingSubregionTile (net.osmand.router.RoutingContext.RoutingSubregionTile)2