use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NameSimilarityEdgeFilterTest method testAccept.
@Test
public void testAccept() {
EdgeFilter edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Laufamholzstraße 154 Nürnberg");
EdgeIteratorState edge = createTestEdgeIterator("Laufamholzstraße, ST1333");
assertTrue(edgeFilter.accept(edge));
edge = createTestEdgeIterator("Hauptstraße");
assertFalse(edgeFilter.accept(edge));
edge = createTestEdgeIterator("Lorem Ipsum");
assertFalse(edgeFilter.accept(edge));
edge = createTestEdgeIterator("");
assertFalse(edgeFilter.accept(edge));
edge = createTestEdgeIterator(null);
assertFalse(edgeFilter.accept(edge));
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), null);
edge = createTestEdgeIterator("Laufamholzstraße, ST1333");
assertTrue(edgeFilter.accept(edge));
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "");
edge = createTestEdgeIterator("Laufamholzstraße, ST1333");
assertTrue(edgeFilter.accept(edge));
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Johannesstraße, 99636, Rastenberg, Deutschland");
edge = createTestEdgeIterator("Laufamholzstraße, ST1333");
assertFalse(edgeFilter.accept(edge));
edge = createTestEdgeIterator("Johannesstraße");
assertTrue(edgeFilter.accept(edge));
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Hauptstraße, 39025, Naturns, Italien");
edge = createTestEdgeIterator("Teststraße");
assertFalse(edgeFilter.accept(edge));
edge = createTestEdgeIterator("Hauptstraße");
assertTrue(edgeFilter.accept(edge));
edge = createTestEdgeIterator("Hauptstrasse");
assertTrue(edgeFilter.accept(edge));
edge = createTestEdgeIterator("Hauptstr.");
assertTrue(edgeFilter.accept(edge));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class NameSimilarityEdgeFilterTest method testAcceptMashup.
@Test
public void testAcceptMashup() {
EdgeFilter edgeFilter;
EdgeIteratorState edge;
edge = createTestEdgeIterator("Augustine Street");
// Google Maps
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Augustine St, Hunters Hill NSW 2110, Australia");
assertTrue(edgeFilter.accept(edge));
// Opencagedata
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Augustine Street, Sydney Neusüdwales 2110, Australien");
assertTrue(edgeFilter.accept(edge));
// Nominatim
edgeFilter = new NameSimilarityEdgeFilter(new DefaultEdgeFilter(new CarFlagEncoder()), "Augustine Street, Sydney, Municipality of Hunters Hill, Neusüdwales, 2111, Australien");
assertTrue(edgeFilter.accept(edge));
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class DijkstraOneToManyTest method testDifferentEdgeFilter.
@Test
public void testDifferentEdgeFilter() {
GraphHopperStorage g = new GraphBuilder(encodingManager).setCHGraph(new FastestWeighting(carEncoder)).create();
g.edge(4, 3, 10, true);
g.edge(3, 6, 10, true);
g.edge(4, 5, 10, true);
g.edge(5, 6, 10, true);
DijkstraOneToMany algo = (DijkstraOneToMany) createAlgo(g);
algo.setEdgeFilter(new EdgeFilter() {
@Override
public boolean accept(EdgeIteratorState iter) {
return iter.getAdjNode() != 5;
}
});
Path p = algo.calcPath(4, 6);
assertEquals(Helper.createTList(4, 3, 6), p.calcNodes());
// important call!
algo.clear();
algo.setEdgeFilter(new EdgeFilter() {
@Override
public boolean accept(EdgeIteratorState iter) {
return iter.getAdjNode() != 3;
}
});
p = algo.calcPath(4, 6);
assertEquals(Helper.createTList(4, 5, 6), p.calcNodes());
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class AbstractEdgeElevationInterpolator method gatherOuterAndInnerNodeIds.
public void gatherOuterAndInnerNodeIds(final EdgeExplorer edgeExplorer, final EdgeIteratorState interpolatableEdge, final GHBitSet visitedEdgesIds, final IntSet outerNodeIds, final GHIntHashSet innerNodeIds) {
final BreadthFirstSearch gatherOuterAndInnerNodeIdsSearch = new BreadthFirstSearch() {
@Override
protected boolean checkAdjacent(EdgeIteratorState edge) {
visitedEdgesIds.add(edge.getEdge());
final int baseNodeId = edge.getBaseNode();
boolean isInterpolatableEdge = isInterpolatableEdge(edge);
if (!isInterpolatableEdge) {
innerNodeIds.remove(baseNodeId);
outerNodeIds.add(baseNodeId);
} else if (!outerNodeIds.contains(baseNodeId)) {
innerNodeIds.add(baseNodeId);
}
return isInterpolatableEdge;
}
};
gatherOuterAndInnerNodeIdsSearch.start(edgeExplorer, interpolatableEdge.getBaseNode());
}
use of com.graphhopper.util.EdgeIteratorState in project graphhopper by graphhopper.
the class LocationIndexTreeCHTest method testCHGraph.
@Test
public void testCHGraph() {
GraphHopperStorage ghStorage = createGHStorage(new RAMDirectory(), encodingManager, false);
CHGraph lg = ghStorage.getGraph(CHGraph.class);
// 0
// 1
// 2
// 3
// 4
NodeAccess na = ghStorage.getNodeAccess();
na.setNode(0, 1, 0);
na.setNode(1, 0.5, 0);
na.setNode(2, 0, 0);
na.setNode(3, -1, 1);
na.setNode(4, -2, 2);
EdgeIteratorState iter1 = ghStorage.edge(0, 1, 10, true);
EdgeIteratorState iter2 = ghStorage.edge(1, 2, 10, true);
EdgeIteratorState iter3 = ghStorage.edge(2, 3, 14, true);
EdgeIteratorState iter4 = ghStorage.edge(3, 4, 14, true);
// create shortcuts
ghStorage.freeze();
FlagEncoder car = encodingManager.getEncoder("car");
long flags = car.setProperties(60, true, true);
CHEdgeIteratorState iter5 = lg.shortcut(0, 2);
iter5.setDistance(20).setFlags(flags);
iter5.setSkippedEdges(iter1.getEdge(), iter2.getEdge());
CHEdgeIteratorState iter6 = lg.shortcut(2, 4);
iter6.setDistance(28).setFlags(flags);
iter6.setSkippedEdges(iter3.getEdge(), iter4.getEdge());
CHEdgeIteratorState tmp = lg.shortcut(0, 4);
tmp.setDistance(40).setFlags(flags);
tmp.setSkippedEdges(iter5.getEdge(), iter6.getEdge());
LocationIndex index = createIndex(ghStorage, -1);
assertEquals(2, findID(index, 0, 0.5));
}
Aggregations