Search in sources :

Example 11 with OneRun

use of com.graphhopper.routing.util.TestAlgoCollector.OneRun in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMIT method createAndorra.

List<OneRun> createAndorra() {
    List<OneRun> list = new ArrayList<OneRun>();
    list.add(new OneRun(42.56819, 1.603231, 42.571034, 1.520662, 17708, 524));
    list.add(new OneRun(42.529176, 1.571302, 42.571034, 1.520662, 11408, 305));
    return list;
}
Also used : ArrayList(java.util.ArrayList) OneRun(com.graphhopper.routing.util.TestAlgoCollector.OneRun)

Example 12 with OneRun

use of com.graphhopper.routing.util.TestAlgoCollector.OneRun in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMIT method createMonacoFoot.

List<OneRun> createMonacoFoot() {
    List<OneRun> list = new ArrayList<OneRun>();
    list.add(new OneRun(43.730729, 7.421288, 43.727697, 7.419199, 1566, 92));
    list.add(new OneRun(43.727687, 7.418737, 43.74958, 7.436566, 3438, 136));
    list.add(new OneRun(43.728677, 7.41016, 43.739213, 7.427806, 2085, 112));
    list.add(new OneRun(43.733802, 7.413433, 43.739662, 7.424355, 1425, 89));
    return list;
}
Also used : ArrayList(java.util.ArrayList) OneRun(com.graphhopper.routing.util.TestAlgoCollector.OneRun)

Example 13 with OneRun

use of com.graphhopper.routing.util.TestAlgoCollector.OneRun in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMIT method testOneWayCircleBug.

@Test
public void testOneWayCircleBug() {
    // export from http://www.openstreetmap.org/export#map=19/51.37605/-0.53155
    List<OneRun> list = new ArrayList<OneRun>();
    // going the bit longer way out of the circle
    list.add(new OneRun(51.376197, -0.531576, 51.376509, -0.530863, 153, 18));
    // now exacle the opposite direction: going into the circle (shorter)
    list.add(new OneRun(51.376509, -0.530863, 51.376197, -0.531576, 75, 15));
    runAlgo(testCollector, DIR + "/circle-bug.osm.gz", "target/circle-bug-gh", list, "car", true, "car", "shortest", false);
    assertEquals(testCollector.toString(), 0, testCollector.errors.size());
}
Also used : ArrayList(java.util.ArrayList) OneRun(com.graphhopper.routing.util.TestAlgoCollector.OneRun) Test(org.junit.Test)

Example 14 with OneRun

use of com.graphhopper.routing.util.TestAlgoCollector.OneRun in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMIT method testNeudrossenfeld.

@Test
public void testNeudrossenfeld() {
    List<OneRun> list = new ArrayList<OneRun>();
    // choose cycleway (Dreschenauer Straße)
    list.add(new OneRun(49.987132, 11.510496, 50.018839, 11.505024, 3985, 106));
    runAlgo(testCollector, DIR + "/north-bayreuth.osm.gz", "target/north-bayreuth-gh", list, "bike", true, "bike", "fastest", true);
    runAlgo(testCollector, DIR + "/north-bayreuth.osm.gz", "target/north-bayreuth-gh", list, "bike2", true, "bike2", "fastest", true);
    assertEquals(testCollector.toString(), 0, testCollector.errors.size());
}
Also used : ArrayList(java.util.ArrayList) OneRun(com.graphhopper.routing.util.TestAlgoCollector.OneRun) Test(org.junit.Test)

Example 15 with OneRun

use of com.graphhopper.routing.util.TestAlgoCollector.OneRun in project graphhopper by graphhopper.

the class RoutingAlgorithmWithOSMIT method runAlgo.

/**
     * @param withCH if true also the CH and LM algorithms will be tested which need
     *               preparation and takes a bit longer
     */
Graph runAlgo(TestAlgoCollector testCollector, String osmFile, String graphFile, List<OneRun> forEveryAlgo, String importVehicles, boolean withCH, String vehicle, String weightStr, boolean is3D) {
    // for different weightings we need a different storage, otherwise we would need to remove the graph folder
    // everytime we come with a different weighting
    // graphFile += weightStr;
    AlgoHelperEntry algoEntry = null;
    OneRun tmpOneRun = null;
    try {
        Helper.removeDir(new File(graphFile));
        GraphHopper hopper = new GraphHopperOSM().setStoreOnFlush(true).setCHEnabled(false).setDataReaderFile(osmFile).setGraphHopperLocation(graphFile).setEncodingManager(new EncodingManager(importVehicles));
        // avoid that path.getDistance is too different to path.getPoint.calcDistance
        hopper.setWayPointMaxDistance(0);
        // always enable landmarks
        hopper.getLMFactoryDecorator().addWeighting(weightStr).setEnabled(true).setDisablingAllowed(true);
        if (withCH)
            hopper.getCHFactoryDecorator().addWeighting(weightStr).setEnabled(true).setDisablingAllowed(true);
        if (is3D)
            hopper.setElevationProvider(new SRTMProvider().setCacheDir(new File(DIR)));
        hopper.importOrLoad();
        TraversalMode tMode = importVehicles.contains("turn_costs=true") ? TraversalMode.EDGE_BASED_2DIR : TraversalMode.NODE_BASED;
        FlagEncoder encoder = hopper.getEncodingManager().getEncoder(vehicle);
        HintsMap hints = new HintsMap().setWeighting(weightStr).setVehicle(vehicle);
        Collection<AlgoHelperEntry> prepares = RoutingAlgorithmIT.createAlgos(hopper, hints, tMode);
        EdgeFilter edgeFilter = new DefaultEdgeFilter(encoder);
        for (AlgoHelperEntry entry : prepares) {
            algoEntry = entry;
            LocationIndex idx = entry.getIdx();
            for (OneRun oneRun : forEveryAlgo) {
                tmpOneRun = oneRun;
                List<QueryResult> list = oneRun.getList(idx, edgeFilter);
                testCollector.assertDistance(algoEntry, list, oneRun);
            }
        }
        return hopper.getGraphHopperStorage();
    } catch (Exception ex) {
        if (algoEntry == null)
            throw new RuntimeException("cannot handle file " + osmFile + ", " + ex.getMessage(), ex);
        throw new RuntimeException("cannot handle " + algoEntry.toString() + ", for " + tmpOneRun + ", file " + osmFile + ", " + ex.getMessage(), ex);
    } finally {
    // Helper.removeDir(new File(graphFile));
    }
}
Also used : AlgoHelperEntry(com.graphhopper.routing.util.TestAlgoCollector.AlgoHelperEntry) OneRun(com.graphhopper.routing.util.TestAlgoCollector.OneRun) GraphHopperOSM(com.graphhopper.reader.osm.GraphHopperOSM) GraphHopper(com.graphhopper.GraphHopper) LocationIndex(com.graphhopper.storage.index.LocationIndex) IOException(java.io.IOException) SRTMProvider(com.graphhopper.reader.dem.SRTMProvider) QueryResult(com.graphhopper.storage.index.QueryResult) File(java.io.File)

Aggregations

OneRun (com.graphhopper.routing.util.TestAlgoCollector.OneRun)23 ArrayList (java.util.ArrayList)22 Test (org.junit.Test)19 GraphHopper (com.graphhopper.GraphHopper)2 GraphHopperOSM (com.graphhopper.reader.osm.GraphHopperOSM)2 AlgoHelperEntry (com.graphhopper.routing.util.TestAlgoCollector.AlgoHelperEntry)2 LocationIndex (com.graphhopper.storage.index.LocationIndex)2 File (java.io.File)2 SRTMProvider (com.graphhopper.reader.dem.SRTMProvider)1 ShortestWeighting (com.graphhopper.routing.weighting.ShortestWeighting)1 Weighting (com.graphhopper.routing.weighting.Weighting)1 Graph (com.graphhopper.storage.Graph)1 QueryResult (com.graphhopper.storage.index.QueryResult)1 IOException (java.io.IOException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1