use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testRoutingRequestFails_issue665.
@Test
public void testRoutingRequestFails_issue665() {
GraphHopper hopper = new GraphHopperOSM().setDataReaderFile(getClass().getResource(file7).getFile()).setEncodingManager(new EncodingManager("car,motorcycle")).setGraphHopperLocation(dir);
hopper.getCHFactoryDecorator().setEnabled(false);
hopper.importOrLoad();
GHRequest req = new GHRequest(48.977277, 8.256896, 48.978876, 8.254884).setWeighting("curvature").setVehicle("motorcycle");
GHResponse ghRsp = hopper.route(req);
assertFalse(ghRsp.getErrors().toString(), ghRsp.hasErrors());
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testWayReferencesNotExistingAdjNode.
@Test
public void testWayReferencesNotExistingAdjNode() {
GraphHopper hopper = new GraphHopperFacade(file4).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
assertEquals(2, graph.getNodes());
int n10 = AbstractGraphStorageTester.getIdOf(graph, 51.2492152);
int n30 = AbstractGraphStorageTester.getIdOf(graph, 51.2);
assertEquals(GHUtility.asSet(n30), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n10)));
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testTurnRestrictions.
@Test
public void testTurnRestrictions() {
GraphHopper hopper = new GraphHopperFacade(fileTurnRestrictions, true).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
assertEquals(15, graph.getNodes());
assertTrue(graph.getExtension() instanceof TurnCostExtension);
TurnCostExtension tcStorage = (TurnCostExtension) graph.getExtension();
int n1 = AbstractGraphStorageTester.getIdOf(graph, 50, 10);
int n2 = AbstractGraphStorageTester.getIdOf(graph, 52, 10);
int n3 = AbstractGraphStorageTester.getIdOf(graph, 52, 11);
int n4 = AbstractGraphStorageTester.getIdOf(graph, 52, 12);
int n5 = AbstractGraphStorageTester.getIdOf(graph, 50, 12);
int n6 = AbstractGraphStorageTester.getIdOf(graph, 51, 11);
int n8 = AbstractGraphStorageTester.getIdOf(graph, 54, 11);
int edge1_6 = GHUtility.getEdge(graph, n1, n6).getEdge();
int edge2_3 = GHUtility.getEdge(graph, n2, n3).getEdge();
int edge3_4 = GHUtility.getEdge(graph, n3, n4).getEdge();
int edge3_8 = GHUtility.getEdge(graph, n3, n8).getEdge();
int edge3_2 = GHUtility.getEdge(graph, n3, n2).getEdge();
int edge4_3 = GHUtility.getEdge(graph, n4, n3).getEdge();
int edge8_3 = GHUtility.getEdge(graph, n8, n3).getEdge();
// (2-3)->(3-4) only_straight_on = (2-3)->(3-8) restricted
// (4-3)->(3-8) no_right_turn = (4-3)->(3-8) restricted
assertTrue(carEncoder.getTurnCost(tcStorage.getTurnCostFlags(edge2_3, n3, edge3_8)) > 0);
assertTrue(carEncoder.getTurnCost(tcStorage.getTurnCostFlags(edge4_3, n3, edge3_8)) > 0);
assertFalse(carEncoder.isTurnRestricted(tcStorage.getTurnCostFlags(edge2_3, n3, edge3_4)));
assertFalse(carEncoder.isTurnRestricted(tcStorage.getTurnCostFlags(edge2_3, n3, edge3_2)));
assertFalse(carEncoder.isTurnRestricted(tcStorage.getTurnCostFlags(edge2_3, n3, edge3_4)));
assertFalse(carEncoder.isTurnRestricted(tcStorage.getTurnCostFlags(edge4_3, n3, edge3_2)));
assertFalse(carEncoder.isTurnRestricted(tcStorage.getTurnCostFlags(edge8_3, n3, edge3_2)));
// u-turn restriction for (6-1)->(1-6) but not for (1-6)->(6-1)
assertTrue(carEncoder.getTurnCost(tcStorage.getTurnCostFlags(edge1_6, n1, edge1_6)) > 0);
assertFalse(carEncoder.isTurnRestricted(tcStorage.getTurnCostFlags(edge1_6, n6, edge1_6)));
int edge4_5 = GHUtility.getEdge(graph, n4, n5).getEdge();
int edge5_6 = GHUtility.getEdge(graph, n5, n6).getEdge();
int edge5_1 = GHUtility.getEdge(graph, n5, n1).getEdge();
// (4-5)->(5-1) right_turn_only = (4-5)->(5-6) restricted
long costsFlags = tcStorage.getTurnCostFlags(edge4_5, n5, edge5_6);
assertFalse(carEncoder.isTurnRestricted(costsFlags));
assertTrue(carEncoder.getTurnCost(tcStorage.getTurnCostFlags(edge4_5, n5, edge5_1)) > 0);
// for bike
assertFalse(bikeEncoder.isTurnRestricted(costsFlags));
int n10 = AbstractGraphStorageTester.getIdOf(graph, 40, 10);
int n11 = AbstractGraphStorageTester.getIdOf(graph, 40, 11);
int n14 = AbstractGraphStorageTester.getIdOf(graph, 39, 11);
int edge10_11 = GHUtility.getEdge(graph, n10, n11).getEdge();
int edge11_14 = GHUtility.getEdge(graph, n11, n14).getEdge();
assertEquals(0, tcStorage.getTurnCostFlags(edge11_14, n11, edge10_11));
costsFlags = tcStorage.getTurnCostFlags(edge10_11, n11, edge11_14);
assertFalse(carEncoder.isTurnRestricted(costsFlags));
assertTrue(bikeEncoder.isTurnRestricted(costsFlags));
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testDataDateWithinPBF.
@Test
public void testDataDateWithinPBF() {
GraphHopper hopper = new GraphHopperFacade("test-osm6.pbf").importOrLoad();
GraphHopperStorage graph = hopper.getGraphHopperStorage();
assertEquals("2014-01-02T00:10:14Z", graph.getProperties().get("datareader.data.date"));
}
use of com.graphhopper.GraphHopper in project graphhopper by graphhopper.
the class OSMReaderTest method testBarriers.
@Test
public void testBarriers() {
GraphHopper hopper = new GraphHopperFacade(fileBarriers).setMinNetworkSize(0, 0).importOrLoad();
Graph graph = hopper.getGraphHopperStorage();
assertEquals(8, graph.getNodes());
int n10 = AbstractGraphStorageTester.getIdOf(graph, 51);
int n20 = AbstractGraphStorageTester.getIdOf(graph, 52);
int n30 = AbstractGraphStorageTester.getIdOf(graph, 53);
int n50 = AbstractGraphStorageTester.getIdOf(graph, 55);
// separate id
int new20 = 4;
assertNotEquals(n20, new20);
NodeAccess na = graph.getNodeAccess();
assertEquals(na.getLatitude(n20), na.getLatitude(new20), 1e-5);
assertEquals(na.getLongitude(n20), na.getLongitude(new20), 1e-5);
assertEquals(n20, findID(hopper.getLocationIndex(), 52, 9.4));
assertEquals(GHUtility.asSet(n20, n30), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n10)));
assertEquals(GHUtility.asSet(new20, n10, n50), GHUtility.getNeighbors(carOutExplorer.setBaseNode(n30)));
EdgeIterator iter = carOutExplorer.setBaseNode(n20);
assertTrue(iter.next());
assertEquals(n10, iter.getAdjNode());
assertFalse(iter.next());
iter = carOutExplorer.setBaseNode(new20);
assertTrue(iter.next());
assertEquals(n30, iter.getAdjNode());
assertFalse(iter.next());
}
Aggregations