use of com.graphhopper.routing.util.EncodingManager in project graphhopper by graphhopper.
the class DepthFirstSearchTest method testDFS2.
@Test
public void testDFS2() {
DepthFirstSearch dfs = new DepthFirstSearch() {
@Override
public boolean goFurther(int v) {
counter++;
assertTrue("v " + v + " is already contained in set. iteration:" + counter, !set.contains(v));
set.add(v);
list.add(v);
return super.goFurther(v);
}
};
EncodingManager em = new EncodingManager("car");
FlagEncoder fe = em.getEncoder("car");
Graph g = new GraphBuilder(em).create();
g.edge(1, 2, 1, false);
g.edge(1, 4, 1, true);
g.edge(1, 3, 1, false);
g.edge(2, 3, 1, false);
g.edge(4, 3, 1, true);
dfs.start(g.createEdgeExplorer(new DefaultEdgeFilter(fe, false, true)), 1);
assertTrue(counter > 0);
assertEquals("[1, 2, 3, 4]", list.toString());
}
use of com.graphhopper.routing.util.EncodingManager in project graphhopper by graphhopper.
the class ShapeFileReaderTest method initHopper.
private static GraphHopper initHopper(GraphHopper gh, String inputFile, String outDir) {
URL resourceURL = ShapeFileReaderTest.class.getResource(inputFile);
try {
inputFile = new File(resourceURL.toURI()).getAbsolutePath();
} catch (Exception e) {
throw new RuntimeException(e);
}
// turn off geometry simplification so geometry should be the same
// between pbf and shapefile readers
gh.setWayPointMaxDistance(0);
return gh.setStoreOnFlush(false).setDataReaderFile(inputFile).setGraphHopperLocation(new File(outDir).getAbsolutePath()).setEncodingManager(new EncodingManager(new CarFlagEncoder())).setCHEnabled(false).importOrLoad();
}
use of com.graphhopper.routing.util.EncodingManager in project graphhopper by graphhopper.
the class GraphHopperIT method beforeClass.
@BeforeClass
public static void beforeClass() {
// make sure we are using fresh graphhopper files with correct vehicle
Helper.removeDir(new File(graphFileFoot));
hopper = new GraphHopperOSM().setOSMFile(osmFile).setStoreOnFlush(true).setCHEnabled(false).setGraphHopperLocation(graphFileFoot).setEncodingManager(new EncodingManager(importVehicles)).importOrLoad();
}
use of com.graphhopper.routing.util.EncodingManager in project graphhopper by graphhopper.
the class GraphHopperIT method testMultipleVehiclesWithCH.
@Test
public void testMultipleVehiclesWithCH() {
String tmpOsmFile = DIR + "/monaco.osm.gz";
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(tmpOsmFile).setStoreOnFlush(true).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("bike,car")).importOrLoad();
assertEquals("bike", tmpHopper.getDefaultVehicle().toString());
checkMultiVehiclesWithCH(tmpHopper);
tmpHopper.close();
tmpHopper.clean();
// new instance, try different order, resulting only in different default vehicle
tmpHopper = new GraphHopperOSM().setOSMFile(tmpOsmFile).setStoreOnFlush(true).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("car,bike")).importOrLoad();
assertEquals("car", tmpHopper.getDefaultVehicle().toString());
checkMultiVehiclesWithCH(tmpHopper);
tmpHopper.close();
}
use of com.graphhopper.routing.util.EncodingManager in project graphhopper by graphhopper.
the class GraphHopperIT method testCHAndTurnCostsWithFlexmode.
@Test
public void testCHAndTurnCostsWithFlexmode() {
GraphHopper tmpHopper = new GraphHopperOSM().setOSMFile(DIR + "/moscow.osm.gz").setStoreOnFlush(true).setGraphHopperLocation(tmpGraphFile).setEncodingManager(new EncodingManager("car|turn_costs=true"));
tmpHopper.getCHFactoryDecorator().setDisablingAllowed(true);
tmpHopper.importOrLoad();
// without turn costs (default for CH)
GHRequest req = new GHRequest(55.813357, 37.5958585, 55.811042, 37.594689);
GHResponse rsp = tmpHopper.route(req);
assertFalse(rsp.getErrors().toString(), rsp.hasErrors());
assertEquals(400, rsp.getBest().getDistance(), 1);
// with turn costs
req.getHints().put(CH.DISABLE, "true");
req.getHints().put(Routing.EDGE_BASED, "true");
rsp = tmpHopper.route(req);
assertEquals(1044, rsp.getBest().getDistance(), 1);
}
Aggregations