use of com.graphhopper.routing.util.FlagEncoder in project graphhopper by graphhopper.
the class GraphHopperStorageForDataFlagEncoderTest method testStorageProperties.
@Test
public void testStorageProperties() {
graph = new GraphBuilder(encodingManager).setStore(true).setLocation(defaultGraphLoc).create();
// 0-1
ReaderWay way_0_1 = new ReaderWay(27l);
way_0_1.setTag("highway", "primary");
way_0_1.setTag("maxheight", "4.4");
graph.edge(0, 1, 1, true);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 0, 0.00, 0.00);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 1, 0.01, 0.01);
graph.getEdgeIteratorState(0, 1).setFlags(encoder.handleWayTags(way_0_1, 1, 0));
// 1-2
ReaderWay way_1_2 = new ReaderWay(28l);
way_1_2.setTag("highway", "primary");
way_1_2.setTag("maxweight", "45");
graph.edge(1, 2, 1, true);
AbstractRoutingAlgorithmTester.updateDistancesFor(graph, 2, 0.02, 0.02);
graph.getEdgeIteratorState(1, 2).setFlags(encoder.handleWayTags(way_1_2, 1, 0));
// 2-0
ReaderWay way_2_0 = new ReaderWay(29l);
way_2_0.setTag("highway", "primary");
way_2_0.setTag("maxwidth", "5");
graph.edge(2, 0, 1, true);
graph.getEdgeIteratorState(2, 0).setFlags(encoder.handleWayTags(way_2_0, 1, 0));
graph.flush();
graph.close();
GraphHopper hopper = new GraphHopper().setGraphHopperLocation(defaultGraphLoc).setCHEnabled(false).importOrLoad();
EncodingManager em = hopper.getEncodingManager();
assertNotNull(em);
assertEquals(1, em.fetchEdgeEncoders().size());
FlagEncoder flagEncoder = em.fetchEdgeEncoders().get(0);
assertTrue(flagEncoder instanceof DataFlagEncoder);
DataFlagEncoder dataFlagEncoder = (DataFlagEncoder) flagEncoder;
assertTrue(dataFlagEncoder.isStoreHeight());
assertTrue(dataFlagEncoder.isStoreWeight());
assertFalse(dataFlagEncoder.isStoreWidth());
}
use of com.graphhopper.routing.util.FlagEncoder in project graphhopper by graphhopper.
the class DepthFirstSearchTest method testDFS1.
@Test
public void testDFS1() {
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, 5, 1, false);
g.edge(1, 4, 1, false);
g.edge(2, 3, 1, false);
g.edge(3, 4, 1, false);
g.edge(5, 6, 1, false);
g.edge(6, 4, 1, false);
dfs.start(g.createEdgeExplorer(new DefaultEdgeFilter(fe, false, true)), 1);
assertTrue(counter > 0);
assertEquals("[1, 2, 3, 4, 5, 6]", list.toString());
}
use of com.graphhopper.routing.util.FlagEncoder 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());
}
Aggregations