use of com.graphhopper.util.EdgeExplorer in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method testRemoveNode.
@Test
public void testRemoveNode() {
FlagEncoder carEncoder = new CarFlagEncoder();
BikeFlagEncoder bikeEncoder = new BikeFlagEncoder();
EncodingManager em2 = new EncodingManager(carEncoder, bikeEncoder);
GraphHopperStorage g = createSubnetworkTestStorage2(em2);
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, em2.fetchEdgeEncoders());
EdgeExplorer edgeExplorer = g.createEdgeExplorer();
assertFalse(instance.detectNodeRemovedForAllEncoders(edgeExplorer, 4));
assertFalse(instance.detectNodeRemovedForAllEncoders(edgeExplorer, 5));
assertFalse(instance.detectNodeRemovedForAllEncoders(edgeExplorer, 6));
// mark certain edges inaccessible for all encoders
for (EdgeIteratorState edge : Arrays.asList(GHUtility.getEdge(g, 5, 6), GHUtility.getEdge(g, 4, 5), GHUtility.getEdge(g, 4, 6))) {
for (FlagEncoder encoders : em2.fetchEdgeEncoders()) {
edge.setFlags(encoders.setAccess(0, false, false));
}
}
assertTrue(instance.detectNodeRemovedForAllEncoders(edgeExplorer, 4));
assertTrue(instance.detectNodeRemovedForAllEncoders(edgeExplorer, 5));
assertTrue(instance.detectNodeRemovedForAllEncoders(edgeExplorer, 6));
}
use of com.graphhopper.util.EdgeExplorer in project graphhopper by graphhopper.
the class PrepareRoutingSubnetworksTest method testRemoveSubnetworkWhenMultipleVehicles.
@Test
public void testRemoveSubnetworkWhenMultipleVehicles() {
FlagEncoder carEncoder = new CarFlagEncoder();
BikeFlagEncoder bikeEncoder = new BikeFlagEncoder();
EncodingManager em2 = new EncodingManager(carEncoder, bikeEncoder);
GraphHopperStorage g = createSubnetworkTestStorage2(em2);
GHUtility.getEdge(g, 3, 4).setFlags(carEncoder.setProperties(10, false, false) | bikeEncoder.setProperties(5, true, true));
PrepareRoutingSubnetworks instance = new PrepareRoutingSubnetworks(g, em2.fetchEdgeEncoders());
instance.setMinNetworkSize(5);
instance.doWork();
g.optimize();
// remove nothing because of two vehicles with different subnetworks
assertEquals(9, g.getNodes());
EdgeExplorer carExplorer = g.createEdgeExplorer(new DefaultEdgeFilter(carEncoder));
assertEquals(GHUtility.asSet(7, 2, 1), GHUtility.getNeighbors(carExplorer.setBaseNode(3)));
EdgeExplorer bikeExplorer = g.createEdgeExplorer(new DefaultEdgeFilter(bikeEncoder));
assertEquals(GHUtility.asSet(7, 2, 1, 4), GHUtility.getNeighbors(bikeExplorer.setBaseNode(3)));
GHUtility.getEdge(g, 3, 4).setFlags(carEncoder.setProperties(10, false, false) | bikeEncoder.setProperties(5, false, false));
instance = new PrepareRoutingSubnetworks(g, em2.fetchEdgeEncoders());
instance.setMinNetworkSize(5);
instance.doWork();
g.optimize();
assertEquals(6, g.getNodes());
}
Aggregations