use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class AlternativeRouteCHTest method createTestGraph.
public GraphHopperStorage createTestGraph(EncodingManager tmpEM) {
final GraphHopperStorage graph = new GraphBuilder(tmpEM).create();
/*
9 11
/\ / \
1 2-3-4-10-12
\ / \
5--6-7---8
*/
// Make all edges the length of T, the distance around v than an s->v->t path
// has to be locally-shortest to be considered.
// So we get all three alternatives.
GHUtility.setSpeed(60, 60, carFE, graph.edge(5, 6).setDistance(10000), graph.edge(6, 3).setDistance(10000), graph.edge(3, 4).setDistance(10000), graph.edge(4, 10).setDistance(10000), graph.edge(6, 7).setDistance(10000), graph.edge(7, 8).setDistance(10000), graph.edge(8, 4).setDistance(10000), graph.edge(5, 1).setDistance(10000), graph.edge(1, 9).setDistance(10000), graph.edge(9, 2).setDistance(10000), graph.edge(2, 3).setDistance(10000), graph.edge(4, 11).setDistance(9000), graph.edge(11, 12).setDistance(9000), graph.edge(12, 10).setDistance(10000));
graph.freeze();
return graph;
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class HeadingResolverTest method straightEdges.
@Test
public void straightEdges() {
// 0 1 2
// \|/
// 7 -- 8 --- 3
// /|\
// 6 5 4
FlagEncoder encoder = new CarFlagEncoder();
EncodingManager em = EncodingManager.create(encoder);
GraphHopperStorage graph = new GraphBuilder(em).create();
NodeAccess na = graph.getNodeAccess();
na.setNode(0, 49.5073, 1.5545);
na.setNode(1, 49.5002, 2.3895);
na.setNode(2, 49.4931, 3.3013);
na.setNode(3, 48.8574, 3.2025);
na.setNode(4, 48.2575, 3.0651);
na.setNode(5, 48.2393, 2.2576);
na.setNode(6, 48.2246, 1.2249);
na.setNode(7, 48.8611, 1.2194);
na.setNode(8, 48.8538, 2.3950);
// edge 0
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 0).setDistance(10));
// edge 1
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 1).setDistance(10));
// edge 2
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 2).setDistance(10));
// edge 3
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 3).setDistance(10));
// edge 4
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 4).setDistance(10));
// edge 5
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 5).setDistance(10));
// edge 6
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 6).setDistance(10));
// edge 7
GHUtility.setSpeed(60, true, true, encoder, graph.edge(8, 7).setDistance(10));
HeadingResolver resolver = new HeadingResolver(graph);
// using default tolerance
assertEquals(IntArrayList.from(7, 6, 0), resolver.getEdgesWithDifferentHeading(8, 90));
assertEquals(IntArrayList.from(7, 6, 0), resolver.setTolerance(100).getEdgesWithDifferentHeading(8, 90));
assertEquals(IntArrayList.from(7, 6, 5, 4, 2, 1, 0), resolver.setTolerance(10).getEdgesWithDifferentHeading(8, 90));
assertEquals(IntArrayList.from(7, 6, 5, 1, 0), resolver.setTolerance(60).getEdgesWithDifferentHeading(8, 90));
assertEquals(IntArrayList.from(1), resolver.setTolerance(170).getEdgesWithDifferentHeading(8, 180));
assertEquals(IntArrayList.from(2, 1, 0), resolver.setTolerance(130).getEdgesWithDifferentHeading(8, 180));
assertEquals(IntArrayList.from(5, 4, 3), resolver.setTolerance(90).getEdgesWithDifferentHeading(8, 315));
assertEquals(IntArrayList.from(6, 5, 4, 3, 2), resolver.setTolerance(50).getEdgesWithDifferentHeading(8, 315));
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class EdgeElevationInterpolatorTest method setUp.
@SuppressWarnings("resource")
@BeforeEach
public void setUp() {
graph = new GraphBuilder(encodingManager = new EncodingManager.Builder().add(new CarFlagEncoder()).add(new FootFlagEncoder()).build()).set3D(true).create();
roadEnvEnc = encodingManager.getEnumEncodedValue(RoadEnvironment.KEY, RoadEnvironment.class);
edgeElevationInterpolator = createEdgeElevationInterpolator();
relFlags = encodingManager.createRelationFlags();
interpolatableWay = createInterpolatableWay();
normalWay = new ReaderWay(0);
normalWay.setTag("highway", "primary");
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class RoundTripRoutingTest method createSquareGraph.
private Graph createSquareGraph() {
// simple square
// 1 | 0 1 2
// 0 | 7 3
// -1 | 6 5 4
// ---|------
// |-1 0 1
GraphHopperStorage graph = new GraphBuilder(em).create();
for (int i = 0; i < 8; ++i) {
GHUtility.setSpeed(60, true, true, carFE, graph.edge(i, (i + 1) % 8).setDistance(1));
}
updateDistancesFor(graph, 0, 1, -1);
updateDistancesFor(graph, 1, 1, 0);
updateDistancesFor(graph, 2, 1, 1);
updateDistancesFor(graph, 3, 0, 1);
updateDistancesFor(graph, 4, -1, 1);
updateDistancesFor(graph, 5, -1, 0);
updateDistancesFor(graph, 6, -1, -1);
updateDistancesFor(graph, 7, 0, -1);
return graph;
}
use of com.graphhopper.storage.GraphBuilder in project graphhopper by graphhopper.
the class RoundTripRoutingTest method createTestGraph.
private Graph createTestGraph() {
Graph graph = new GraphBuilder(em).withTurnCosts(true).create();
AlternativeRouteTest.initTestGraph(graph, carFE);
return graph;
}
Aggregations