Search in sources :

Example 11 with RoutePlannerFrontEnd

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

the class DijkstraAlgorithm method main.

public static void main(String[] args) throws IOException, InterruptedException, XmlPullParserException {
    File fl = new File("/Users/victorshcherb/osmand/maps/Netherlands_europe_2.obf");
    // $NON-NLS-1$ //$NON-NLS-2$
    RandomAccessFile raf = new RandomAccessFile(fl, "r");
    RoutePlannerFrontEnd fe = new RoutePlannerFrontEnd(false);
    Builder builder = RoutingConfiguration.parseFromInputStream(new FileInputStream("/Users/victorshcherb/osmand/repos/resources/routing/routing.xml"));
    RoutingConfiguration config = builder.build("car", RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3);
    RoutingContext ctx = fe.buildRoutingContext(config, null, new BinaryMapIndexReader[] { new BinaryMapIndexReader(raf, fl) }, RouteCalculationMode.NORMAL);
    RouteResultPreparation.PRINT_TO_CONSOLE_ROUTE_INFORMATION_TO_TEST = true;
    List<RouteSegmentResult> route = fe.searchRoute(ctx, new LatLon(52.28283, 4.8622713), new LatLon(52.326496, 4.8753176), null);
}
Also used : LatLon(net.osmand.data.LatLon) RoutingContext(net.osmand.router.RoutingContext) RandomAccessFile(java.io.RandomAccessFile) RoutingConfiguration(net.osmand.router.RoutingConfiguration) Builder(net.osmand.router.RoutingConfiguration.Builder) RoutePlannerFrontEnd(net.osmand.router.RoutePlannerFrontEnd) BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) FileInputStream(java.io.FileInputStream) RouteSegmentResult(net.osmand.router.RouteSegmentResult)

Example 12 with RoutePlannerFrontEnd

use of net.osmand.router.RoutePlannerFrontEnd in project Osmand by osmandapp.

the class CurrentPositionHelper method initCtx.

private void initCtx(OsmandApplication app, List<BinaryMapReaderResource> checkReaders, @NonNull ApplicationMode appMode) {
    am = appMode;
    String p;
    if (am.isDerivedRoutingFrom(ApplicationMode.BICYCLE)) {
        p = GeneralRouterProfile.BICYCLE.name().toLowerCase();
    } else if (am.isDerivedRoutingFrom(ApplicationMode.PEDESTRIAN)) {
        p = GeneralRouterProfile.PEDESTRIAN.name().toLowerCase();
    } else if (am.isDerivedRoutingFrom(ApplicationMode.CAR)) {
        p = GeneralRouterProfile.CAR.name().toLowerCase();
    } else {
        p = "geocoding";
    }
    BinaryMapIndexReader[] rs = new BinaryMapIndexReader[checkReaders.size()];
    if (rs.length > 0) {
        int i = 0;
        for (BinaryMapReaderResource rep : checkReaders) {
            rs[i++] = rep.getReader(BinaryMapReaderResourceType.STREET_LOOKUP);
        }
        RoutingConfiguration cfg = app.getDefaultRoutingConfig().build(p, 10, new HashMap<String, String>());
        ctx = new RoutePlannerFrontEnd(false).buildRoutingContext(cfg, null, rs);
        RoutingConfiguration defCfg = app.getDefaultRoutingConfig().build("geocoding", 10, new HashMap<String, String>());
        defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
    } else {
        ctx = null;
        defCtx = null;
    }
    usedReaders = checkReaders;
}
Also used : BinaryMapReaderResource(net.osmand.plus.resources.ResourceManager.BinaryMapReaderResource) RoutingConfiguration(net.osmand.router.RoutingConfiguration) BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader) RoutePlannerFrontEnd(net.osmand.router.RoutePlannerFrontEnd)

Example 13 with RoutePlannerFrontEnd

use of net.osmand.router.RoutePlannerFrontEnd in project Osmand by osmandapp.

the class CurrentPositionHelper method initCtx.

private void initCtx(SampleApplication app, List<BinaryMapIndexReader> checkReaders) {
    BinaryMapIndexReader[] rs = checkReaders.toArray(new BinaryMapIndexReader[checkReaders.size()]);
    if (rs.length > 0) {
        RoutingConfiguration defCfg = RoutingConfiguration.getDefault().build("geocoding", 10, new HashMap<String, String>());
        defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
    } else {
        defCtx = null;
    }
    usedReaders = checkReaders;
}
Also used : RoutingConfiguration(net.osmand.router.RoutingConfiguration) BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader) RoutePlannerFrontEnd(net.osmand.router.RoutePlannerFrontEnd)

Aggregations

RoutePlannerFrontEnd (net.osmand.router.RoutePlannerFrontEnd)13 RoutingConfiguration (net.osmand.router.RoutingConfiguration)12 RoutingContext (net.osmand.router.RoutingContext)10 ArrayList (java.util.ArrayList)9 BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)7 Builder (net.osmand.router.RoutingConfiguration.Builder)5 File (java.io.File)4 RandomAccessFile (java.io.RandomAccessFile)4 RouteRegion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion)4 RouteSubregion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion)4 LatLon (net.osmand.data.LatLon)4 RoutingSubregionTile (net.osmand.router.RoutingContext.RoutingSubregionTile)4 Point (java.awt.Point)3 RouteDataObject (net.osmand.binary.RouteDataObject)3 RouteSegmentResult (net.osmand.router.RouteSegmentResult)3 TLongArrayList (gnu.trove.list.array.TLongArrayList)2 TLongHashSet (gnu.trove.set.hash.TLongHashSet)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Entity (net.osmand.osm.edit.Entity)2 Way (net.osmand.osm.edit.Way)2