use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeContractorTest method testContractNode_bidirected_shortcutsRequired.
@Test
public void testContractNode_bidirected_shortcutsRequired() {
// 0 -- 1 -- 2
final EdgeIteratorState edge1 = graph.edge(0, 1, 1, true);
final EdgeIteratorState edge2 = graph.edge(1, 2, 2, true);
graph.freeze();
setMaxLevelOnAllNodes();
createNodeContractor().contractNode(1);
checkShortcuts(expectedShortcut(0, 2, edge2, edge1, true, true));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NodeContractorTest method testDirectedGraph.
@Test
public void testDirectedGraph() {
// 5 6 7
// \|/
// 4-3_1<-\ 10
// \_|/
// 0___2_11
graph.edge(0, 2, 2, true);
graph.edge(10, 2, 2, true);
graph.edge(11, 2, 2, true);
// create a longer one directional edge => no longish one-dir shortcut should be created
final EdgeIteratorState edge2to1bidirected = graph.edge(2, 1, 2, true);
final EdgeIteratorState edge2to1directed = graph.edge(2, 1, 10, false);
final EdgeIteratorState edge1to3 = graph.edge(1, 3, 2, true);
graph.edge(3, 4, 2, true);
graph.edge(3, 5, 2, true);
graph.edge(3, 6, 2, true);
graph.edge(3, 7, 2, true);
graph.freeze();
setMaxLevelOnAllNodes();
// find all shortcuts if we contract node 1
NodeContractor nodeContractor = createNodeContractor();
nodeContractor.contractNode(1);
checkShortcuts(expectedShortcut(2, 3, edge1to3, edge2to1bidirected, true, true), expectedShortcut(2, 3, edge2to1directed, edge1to3, true, false));
}
use of com.graphhopper.util.EdgeIteratorState 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, new FastestWeighting(encoder) {
@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
return Integer.MAX_VALUE * 2L;
}
}, 8).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false);
assertEquals(Integer.MAX_VALUE, res);
dir = new RAMDirectory();
res = new LandmarkStorage(ghStorage, dir, new FastestWeighting(encoder) {
@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
return Double.POSITIVE_INFINITY;
}
}, 8).setMaximumWeight(LandmarkStorage.PRECISION).calcWeight(edge, false);
assertEquals(Integer.MAX_VALUE, res);
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NameSimilarityEdgeFilterTest method testAcceptFromNominatim.
/**
* With Nominatim you should not use the "placename" for best results, otherwise the length difference becomes too big
*/
@Test
public void testAcceptFromNominatim() {
EdgeFilter edgeFilter;
EdgeIteratorState edge;
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Wentworth Street, Caringbah South");
edge = createTestEdgeIterator("Wentworth Street");
assertTrue(edgeFilter.accept(edge));
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Zum Toffental, Altdorf bei Nürnnberg");
edge = createTestEdgeIterator("Zum Toffental");
assertTrue(edgeFilter.accept(edge));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class GenericWeightingTest method testCalcTime.
@Test
public void testCalcTime() {
GenericWeighting weighting = new GenericWeighting(encoder, new HintsMap());
EdgeIteratorState edge = graph.getEdgeIteratorState(0, 1);
assertEquals(edgeWeight, weighting.calcMillis(edge, false, EdgeIterator.NO_EDGE), .1);
}
Aggregations