use of com.graphhopper.util.CmdArgs in project graphhopper by graphhopper.
the class GraphHopperDataflagEncoderSpatialRulesIT method setUp.
@Before
public void setUp() {
CmdArgs args = new CmdArgs().put("config", "../config-example.properties").put("graph.flag_encoders", "generic").put("prepare.ch.weightings", "no").put("spatial_rules.location", "../core/files/spatialrules/countries.geo.json").put("spatial_rules.max_bbox", "11.4,11.7,49.9,50.1").put("datareader.file", "../core/files/north-bayreuth.osm.gz").put("graph.location", DIR);
setUpJetty(args);
}
use of com.graphhopper.util.CmdArgs in project graphhopper by graphhopper.
the class GraphHopperServletIT method setUp.
@Before
public void setUp() {
CmdArgs args = new CmdArgs().put("config", "../config-example.properties").put("prepare.min_network_size", "0").put("prepare.min_one_way_network_size", "0").put("datareader.file", "../core/files/andorra.osm.pbf").put("graph.location", DIR);
setUpJetty(args);
}
use of com.graphhopper.util.CmdArgs in project graphhopper by graphhopper.
the class GraphHopperOSMTest method testVia.
@Test
public void testVia() {
instance = new GraphHopperOSM().setStoreOnFlush(true).init(new CmdArgs().put("datareader.file", testOsm3).put("prepare.min_network_size", "1").put("graph.flag_encoders", "car")).setGraphHopperLocation(ghLoc);
instance.importOrLoad();
// A -> B -> C
GHPoint first = new GHPoint(11.1, 50);
GHPoint second = new GHPoint(12, 51);
GHPoint third = new GHPoint(11.2, 51.9);
GHResponse rsp12 = instance.route(new GHRequest().addPoint(first).addPoint(second));
assertFalse("should find 1->2", rsp12.hasErrors());
assertEquals(147930.5, rsp12.getBest().getDistance(), .1);
GHResponse rsp23 = instance.route(new GHRequest().addPoint(second).addPoint(third));
assertFalse("should find 2->3", rsp23.hasErrors());
assertEquals(176608.9, rsp23.getBest().getDistance(), .1);
GHResponse grsp = instance.route(new GHRequest().addPoint(first).addPoint(second).addPoint(third));
assertFalse("should find 1->2->3", grsp.hasErrors());
PathWrapper rsp = grsp.getBest();
assertEquals(rsp12.getBest().getDistance() + rsp23.getBest().getDistance(), rsp.getDistance(), 1e-6);
assertEquals(4, rsp.getPoints().getSize());
assertEquals(5, rsp.getInstructions().size());
assertEquals(Instruction.REACHED_VIA, rsp.getInstructions().get(1).getSign());
}
use of com.graphhopper.util.CmdArgs in project graphhopper by graphhopper.
the class GraphHopperLandmarksIT method setUp.
@Before
public void setUp() {
CmdArgs args = new CmdArgs().put("config", "../config-example.properties").put("prepare.ch.weightings", "fastest").put("prepare.lm.weightings", "fastest").put("datareader.file", "../core/files/belarus-east.osm.gz").put("prepare.min_network_size", 0).put("prepare.min_one_way_network_size", 0).put("routing.ch.disabling_allowed", true).put("graph.location", DIR);
// force landmark creation even for tiny networks:
args.put("prepare.lm.min_network_size", 2);
setUpJetty(args);
}
use of com.graphhopper.util.CmdArgs in project graphhopper by graphhopper.
the class GraphHopperOSMTest method testCustomFactoryForNoneCH.
@Test
public void testCustomFactoryForNoneCH() {
CarFlagEncoder carEncoder = new CarFlagEncoder();
EncodingManager em = new EncodingManager(carEncoder);
// Weighting weighting = new FastestWeighting(carEncoder);
instance = new GraphHopperOSM().setStoreOnFlush(false).setCHEnabled(false).setEncodingManager(em).setGraphHopperLocation(ghLoc).setDataReaderFile(testOsm);
final RoutingAlgorithmFactory af = new RoutingAlgorithmFactorySimple();
instance.addAlgorithmFactoryDecorator(new RoutingAlgorithmFactoryDecorator() {
@Override
public void init(CmdArgs args) {
}
@Override
public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory algoFactory, HintsMap map) {
return af;
}
@Override
public boolean isEnabled() {
return true;
}
});
instance.importOrLoad();
assertTrue(af == instance.getAlgorithmFactory(null));
// test that hints are passed to algorithm opts
final AtomicInteger cnt = new AtomicInteger(0);
instance.addAlgorithmFactoryDecorator(new RoutingAlgorithmFactoryDecorator() {
@Override
public void init(CmdArgs args) {
}
public RoutingAlgorithmFactory getDecoratedAlgorithmFactory(RoutingAlgorithmFactory algoFactory, HintsMap map) {
return new RoutingAlgorithmFactorySimple() {
@Override
public RoutingAlgorithm createAlgo(Graph g, AlgorithmOptions opts) {
cnt.addAndGet(1);
assertFalse(opts.getHints().getBool("test", true));
return super.createAlgo(g, opts);
}
};
}
@Override
public boolean isEnabled() {
return true;
}
});
GHRequest req = new GHRequest(51.2492152, 9.4317166, 51.2, 9.4);
req.getHints().put("test", false);
instance.route(req);
assertEquals(1, cnt.get());
}
Aggregations