use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class PrinctonReaderTest method testRead.
@Test
public void testRead() {
Graph graph = new GraphBuilder(encodingManager).create();
new PrinctonReader(graph).setStream(PrinctonReader.class.getResourceAsStream("tinyEWD.txt")).read();
assertEquals(8, graph.getNodes());
EdgeExplorer explorer = graph.createEdgeExplorer(carOutEdges);
assertEquals(2, count(explorer.setBaseNode(0)));
assertEquals(3, count(explorer.setBaseNode(6)));
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class OSMTurnRelationTest method testGetRestrictionAsEntries.
@Test
public void testGetRestrictionAsEntries() {
CarFlagEncoder encoder = new CarFlagEncoder(5, 5, 1);
final Map<Long, Integer> osmNodeToInternal = new HashMap<Long, Integer>();
final Map<Integer, Long> internalToOSMEdge = new HashMap<Integer, Long>();
osmNodeToInternal.put(3L, 3);
// edge ids are only stored if they occured before in an OSMRelation
internalToOSMEdge.put(3, 3L);
internalToOSMEdge.put(4, 4L);
GraphHopperStorage ghStorage = new GraphBuilder(new EncodingManager(encoder)).create();
EdgeBasedRoutingAlgorithmTest.initGraph(ghStorage);
OSMReader osmReader = new OSMReader(ghStorage) {
@Override
public int getInternalNodeIdOfOsmNode(long nodeOsmId) {
return osmNodeToInternal.get(nodeOsmId);
}
@Override
public long getOsmIdOfInternalEdge(int edgeId) {
Long l = internalToOSMEdge.get(edgeId);
if (l == null)
return -1;
return l;
}
};
EdgeExplorer edgeExplorer = ghStorage.createEdgeExplorer();
// TYPE == ONLY
OSMTurnRelation instance = new OSMTurnRelation(4, 3, 3, Type.ONLY);
Collection<OSMTurnRelation.TurnCostTableEntry> result = instance.getRestrictionAsEntries(encoder, edgeExplorer, edgeExplorer, osmReader);
assertEquals(2, result.size());
Iterator<OSMTurnRelation.TurnCostTableEntry> iter = result.iterator();
OSMTurnRelation.TurnCostTableEntry entry = iter.next();
assertEquals(4, entry.edgeFrom);
assertEquals(6, entry.edgeTo);
assertEquals(3, entry.nodeVia);
entry = iter.next();
assertEquals(4, entry.edgeFrom);
assertEquals(2, entry.edgeTo);
assertEquals(3, entry.nodeVia);
// TYPE == NOT
instance = new OSMTurnRelation(4, 3, 3, Type.NOT);
result = instance.getRestrictionAsEntries(encoder, edgeExplorer, edgeExplorer, osmReader);
assertEquals(1, result.size());
iter = result.iterator();
entry = iter.next();
assertEquals(4, entry.edgeFrom);
assertEquals(3, entry.edgeTo);
assertEquals(3, entry.nodeVia);
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class GenericWeightingTest method setUp.
@Before
public void setUp() {
ReaderWay way = new ReaderWay(27l);
way.setTag("highway", "primary");
way.setTag("maxspeed", "10");
way.setTag("maxheight", "4.4");
graph = new GraphBuilder(em).create();
// 0-1
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, 1, 0));
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class PrincetonReaderTest method testRead.
@Test
public void testRead() {
Graph graph = new GraphBuilder(encodingManager).create();
new PrincetonReader(graph).setStream(PrincetonReader.class.getResourceAsStream("tinyEWD.txt")).read();
assertEquals(8, graph.getNodes());
EdgeExplorer explorer = graph.createEdgeExplorer(carOutEdges);
assertEquals(2, count(explorer.setBaseNode(0)));
assertEquals(3, count(explorer.setBaseNode(6)));
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class EdgeBasedRoutingAlgorithmTest method createStorage.
private GraphHopperStorage createStorage(EncodingManager em) {
GraphHopperStorage ghStorage = new GraphBuilder(em).create();
tcs = ghStorage.getTurnCostStorage();
return ghStorage;
}
Aggregations