use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class ExpressionVisitorTest method before.
@BeforeEach
public void before() {
StringEncodedValue sev = new StringEncodedValue("country", 10);
lookup = new GraphBuilder(new EncodingManager.Builder().add(sev).build()).create().getEncodingManager();
sev.setString(false, new IntsRef(1), "DEU");
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class DataFlagEncoderTest method reverseEdge.
@Test
public void reverseEdge() {
Graph graph = new GraphBuilder(encodingManager).create();
EdgeIteratorState edge = graph.edge(0, 1);
ReaderWay osmWay = new ReaderWay(0);
osmWay.setTag("highway", "primary");
osmWay.setTag("maxspeed:forward", "10");
long flags = encoder.handleWayTags(osmWay, 1, 0);
edge.setFlags(flags);
assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
assertEquals(-1, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
edge = edge.detach(true);
assertEquals(-1, encoder.getMaxspeed(edge, motorVehicleInt, false), .1);
assertEquals(10, encoder.getMaxspeed(edge, motorVehicleInt, true), .1);
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class DataFlagEncoderTest method setAccess.
@Test
public void setAccess() {
Graph graph = new GraphBuilder(encodingManager).create();
EdgeIteratorState edge = graph.edge(0, 1);
edge.setFlags(encoder.setAccess(edge.getFlags(), true, true));
assertTrue(encoder.isForward(edge, motorVehicleInt));
assertTrue(encoder.isBackward(edge, motorVehicleInt));
edge.setFlags(encoder.setAccess(edge.getFlags(), true, false));
assertTrue(encoder.isForward(edge, motorVehicleInt));
assertFalse(encoder.isBackward(edge, motorVehicleInt));
edge = edge.detach(true);
assertFalse(encoder.isForward(edge, motorVehicleInt));
assertTrue(encoder.isBackward(edge, motorVehicleInt));
edge = edge.detach(true);
assertTrue(encoder.isForward(edge, motorVehicleInt));
assertFalse(encoder.isBackward(edge, motorVehicleInt));
edge.setFlags(encoder.setAccess(edge.getFlags(), false, false));
assertFalse(encoder.isForward(edge, motorVehicleInt));
assertFalse(encoder.isBackward(edge, motorVehicleInt));
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class CHEdgeIteratorTest method testUpdateFlags.
@Test
public void testUpdateFlags() {
CarFlagEncoder carFlagEncoder = new CarFlagEncoder();
EncodingManager encodingManager = new EncodingManager(carFlagEncoder);
FastestWeighting weighting = new FastestWeighting(carFlagEncoder);
EdgeFilter carOutFilter = new DefaultEdgeFilter(carFlagEncoder, false, true);
GraphHopperStorage ghStorage = new GraphBuilder(encodingManager).setCHGraph(weighting).create();
CHGraph g = ghStorage.getGraph(CHGraph.class, weighting);
g.edge(0, 1).setDistance(12).setFlags(carFlagEncoder.setProperties(10, true, true));
g.edge(0, 2).setDistance(13).setFlags(carFlagEncoder.setProperties(20, true, true));
ghStorage.freeze();
assertEquals(2, GHUtility.count(g.getAllEdges()));
assertEquals(1, GHUtility.count(g.createEdgeExplorer(carOutFilter).setBaseNode(1)));
EdgeIteratorState iter = GHUtility.getEdge(g, 0, 1);
assertEquals(1, iter.getAdjNode());
assertEquals(carFlagEncoder.setProperties(10, true, true), iter.getFlags());
// update setProperties
iter.setFlags(carFlagEncoder.setProperties(20, true, false));
assertEquals(12, iter.getDistance(), 1e-4);
// update distance
iter.setDistance(10);
assertEquals(10, iter.getDistance(), 1e-4);
assertEquals(0, GHUtility.count(g.createEdgeExplorer(carOutFilter).setBaseNode(1)));
iter = GHUtility.getEdge(g, 0, 1);
assertEquals(carFlagEncoder.setProperties(20, true, false), iter.getFlags());
assertEquals(10, iter.getDistance(), 1e-4);
assertEquals(1, GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(1)).size());
assertEquals(0, GHUtility.getNeighbors(g.createEdgeExplorer(carOutFilter).setBaseNode(1)).size());
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class PrinctonReaderTest method testMediumRead.
@Test
public void testMediumRead() throws IOException {
Graph graph = new GraphBuilder(encodingManager).create();
new PrinctonReader(graph).setStream(new GZIPInputStream(PrinctonReader.class.getResourceAsStream("mediumEWD.txt.gz"))).read();
assertEquals(250, graph.getNodes());
EdgeExplorer explorer = graph.createEdgeExplorer(carOutEdges);
assertEquals(13, count(explorer.setBaseNode(244)));
assertEquals(11, count(explorer.setBaseNode(16)));
}
Aggregations