use of com.graphhopper.routing.weighting.FastestWeighting in project graphhopper by graphhopper.
the class LandmarkStorageTest method testWithSubnetworks.
@Test
public void testWithSubnetworks() {
ghStorage.edge(0, 1, 10, true);
ghStorage.edge(1, 2, 10, true);
ghStorage.edge(2, 4).setFlags(encoder.setAccess(0, false, false));
ghStorage.edge(4, 5, 10, true);
ghStorage.edge(5, 6, 10, false);
LandmarkStorage storage = new LandmarkStorage(ghStorage, new RAMDirectory(), 2, new FastestWeighting(encoder), TraversalMode.NODE_BASED);
storage.setMinimumNodes(2);
storage.createLandmarks();
assertEquals(3, storage.getSubnetworksWithLandmarks());
assertEquals("[2, 0]", Arrays.toString(storage.getLandmarks(1)));
assertEquals("[6, 4]", Arrays.toString(storage.getLandmarks(2)));
}
use of com.graphhopper.routing.weighting.FastestWeighting in project graphhopper by graphhopper.
the class LandmarkStorageTest method testInfinitWeight.
@Test
public void testInfinitWeight() {
Directory dir = new RAMDirectory();
EdgeIteratorState edge = ghStorage.edge(0, 1);
int res = new LandmarkStorage(ghStorage, dir, 8, new FastestWeighting(encoder) {
@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
return Integer.MAX_VALUE * 2L;
}
}, TraversalMode.NODE_BASED).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false);
assertEquals(Integer.MAX_VALUE, res);
dir = new RAMDirectory();
res = new LandmarkStorage(ghStorage, dir, 8, new FastestWeighting(encoder) {
@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
return Double.POSITIVE_INFINITY;
}
}, TraversalMode.NODE_BASED).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false);
assertEquals(Integer.MAX_VALUE, res);
}
Aggregations