use of com.graphhopper.storage.GraphHopperStorage in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method test481.
@Test
public void test481() {
// 0->1->3->4->5->6
// 2 7<--/
GraphHopperStorage g = createStorage(em);
g.edge(0, 1, 1, false);
g.edge(1, 2, 1, false);
g.edge(2, 0, 1, false);
g.edge(1, 3, 1, false);
g.edge(3, 4, 1, false);
g.edge(4, 5, 1, false);
g.edge(5, 6, 1, false);
g.edge(6, 7, 1, false);
g.edge(7, 4, 1, false);
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, Collections.singletonList(carFlagEncoder)).setMinOneWayNetworkSize(2).setMinNetworkSize(4);
instance.doWork();
// only one remaining network
List<IntArrayList> components = instance.findSubnetworks(new PrepEdgeFilter(carFlagEncoder));
assertEquals(1, components.size());
}
use of com.graphhopper.storage.GraphHopperStorage in project graphhopper by graphhopper.
the class EngineWarmUp method warmUpNonCHSubNetwork.
private static void warmUpNonCHSubNetwork(final GraphHopper graphHopper, int iterations) {
GraphHopperStorage ghStorage = graphHopper.getGraphHopperStorage();
Random rand = new Random(0);
EdgeExplorer explorer = ghStorage.getBaseGraph().createEdgeExplorer();
for (int i = 0; i < iterations; i++) {
BreadthFirstSearch bfs = new BreadthFirstSearch() {
int counter = 0;
@Override
public boolean goFurther(int nodeId) {
counter++;
return counter < graphHopper.getMaxVisitedNodes();
}
};
int startNode = rand.nextInt(ghStorage.getBaseGraph().getNodes() + 1);
bfs.start(explorer, startNode);
}
}
use of com.graphhopper.storage.GraphHopperStorage in project graphhopper by graphhopper.
the class EngineWarmUp method warmUpCHSubNetwork.
private static void warmUpCHSubNetwork(GraphHopper graphHopper, int iterations) {
GraphHopperStorage ghStorage = graphHopper.getGraphHopperStorage();
Random rand = new Random(0);
for (int i = 0; i < iterations; i++) {
int startNode = rand.nextInt(graphHopper.getMaxVisitedNodes() + 1);
int endNode = rand.nextInt(graphHopper.getMaxVisitedNodes() + 1);
double fromLatitude = ghStorage.getNodeAccess().getLatitude(startNode);
double fromLongitude = ghStorage.getNodeAccess().getLongitude(startNode);
double toLatitude = ghStorage.getNodeAccess().getLatitude(endNode);
double toLongitude = ghStorage.getNodeAccess().getLongitude(endNode);
GHRequest request = new GHRequest(fromLatitude, fromLongitude, toLatitude, toLongitude);
graphHopper.route(request);
}
}
use of com.graphhopper.storage.GraphHopperStorage in project graphhopper by graphhopper.
the class EdgeBasedRoutingAlgorithmTest method testTurnCostsBug_991.
@Test
public void testTurnCostsBug_991() {
final GraphHopperStorage g = createStorage(createEncodingManager(false));
initGraph(g);
TurnCostExtension tcs = (TurnCostExtension) g.getExtension();
long tflags = carEncoder.getTurnFlags(false, 2);
tcs.addTurnInfo(getEdge(g, 5, 2).getEdge(), 2, getEdge(g, 2, 3).getEdge(), tflags);
tcs.addTurnInfo(getEdge(g, 2, 0).getEdge(), 0, getEdge(g, 0, 1).getEdge(), tflags);
tcs.addTurnInfo(getEdge(g, 5, 6).getEdge(), 6, getEdge(g, 6, 3).getEdge(), tflags);
tflags = carEncoder.getTurnFlags(false, 1);
tcs.addTurnInfo(getEdge(g, 6, 7).getEdge(), 7, getEdge(g, 7, 4).getEdge(), tflags);
Path p = createAlgo(g, AlgorithmOptions.start().weighting(new TurnWeighting(new FastestWeighting(carEncoder), tcs) {
@Override
public double calcTurnWeight(int edgeFrom, int nodeVia, int edgeTo) {
if (edgeFrom >= 0)
assertNotNull("edge " + edgeFrom + " to " + nodeVia + " does not exist", g.getEdgeIteratorState(edgeFrom, nodeVia));
if (edgeTo >= 0)
assertNotNull("edge " + edgeTo + " to " + nodeVia + " does not exist", g.getEdgeIteratorState(edgeTo, nodeVia));
return super.calcTurnWeight(edgeFrom, nodeVia, edgeTo);
}
}.setDefaultUTurnCost(40)).traversalMode(TraversalMode.EDGE_BASED_2DIR).build()).calcPath(5, 1);
assertEquals(Helper.createTList(5, 6, 7, 4, 3, 1), p.calcNodes());
assertEquals(301, p.getTime(), .1);
}
use of com.graphhopper.storage.GraphHopperStorage in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method createDeadEndUnvisitedNetworkStorage.
GraphHopperStorage createDeadEndUnvisitedNetworkStorage(EncodingManager em) {
GraphHopperStorage g = createStorage(em);
// 0 <-> 1 <-> 2 <-> 3 <-> 4 <- 5 <-> 6
g.edge(0, 1, 1, true);
g.edge(1, 2, 1, true);
g.edge(2, 3, 1, true);
g.edge(3, 4, 1, true);
g.edge(5, 4, 1, false);
g.edge(5, 6, 1, true);
// 7 -> 8 <-> 9 <-> 10
g.edge(7, 8, 1, false);
g.edge(8, 9, 1, true);
g.edge(9, 10, 1, true);
return g;
}
Aggregations