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;
}
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;
}
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());
}
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());
}
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));
}
}
Aggregations