use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class QueryGraphTest method testInternalAPIOriginalTraversalKey.
@Test
public void testInternalAPIOriginalTraversalKey() {
initGraph(g);
EdgeExplorer explorer = g.createEdgeExplorer();
QueryGraph queryGraph = new QueryGraph(g);
EdgeIterator iter = explorer.setBaseNode(1);
assertTrue(iter.next());
int origEdgeId = iter.getEdge();
QueryResult res = createLocationResult(2, 1.5, iter, 1, PILLAR);
queryGraph.lookup(Arrays.asList(res));
assertEquals(new GHPoint(1.5, 1.5), res.getSnappedPoint());
assertEquals(3, res.getClosestNode());
EdgeExplorer qGraphExplorer = queryGraph.createEdgeExplorer();
iter = qGraphExplorer.setBaseNode(3);
assertTrue(iter.next());
assertEquals(0, iter.getAdjNode());
assertEquals(GHUtility.createEdgeKey(1, 0, origEdgeId, false), ((VirtualEdgeIteratorState) queryGraph.getEdgeIteratorState(iter.getEdge(), 0)).getOriginalTraversalKey());
assertTrue(iter.next());
assertEquals(1, iter.getAdjNode());
assertEquals(GHUtility.createEdgeKey(0, 1, origEdgeId, false), ((VirtualEdgeIteratorState) queryGraph.getEdgeIteratorState(iter.getEdge(), 1)).getOriginalTraversalKey());
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class QueryGraphTest method testOneWay.
@Test
public void testOneWay() {
NodeAccess na = g.getNodeAccess();
na.setNode(0, 0, 0);
na.setNode(1, 0, 1);
g.edge(0, 1, 10, false);
EdgeIteratorState edge = GHUtility.getEdge(g, 0, 1);
QueryResult res1 = createLocationResult(0.1, 0.1, edge, 0, EDGE);
QueryResult res2 = createLocationResult(0.1, 0.9, edge, 0, EDGE);
QueryGraph queryGraph = new QueryGraph(g);
queryGraph.lookup(Arrays.asList(res2, res1));
assertEquals(2, res1.getClosestNode());
assertEquals(new GHPoint(0, 0.1), res1.getSnappedPoint());
assertEquals(3, res2.getClosestNode());
assertEquals(new GHPoint(0, 0.9), res2.getSnappedPoint());
assertEquals(2, getPoints(queryGraph, 0, 2).getSize());
assertEquals(2, getPoints(queryGraph, 2, 3).getSize());
assertEquals(2, getPoints(queryGraph, 3, 1).getSize());
assertNull(GHUtility.getEdge(queryGraph, 3, 0));
assertNull(GHUtility.getEdge(queryGraph, 2, 1));
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class GraphHopperIT method testMonacoMaxVisitedNodes.
@Test
public void testMonacoMaxVisitedNodes() {
GHPoint from = new GHPoint(43.741069, 7.426854);
GHPoint to = new GHPoint(43.744445, 7.429483);
GHRequest req = new GHRequest().addPoint(from).addPoint(to).setVehicle(vehicle).setWeighting("fastest");
req.getHints().put(Routing.MAX_VISITED_NODES, 5);
GHResponse rsp = hopper.route(req);
assertTrue(rsp.hasErrors());
req = new GHRequest().addPoint(from).addPoint(to).setVehicle(vehicle).setWeighting("fastest");
rsp = hopper.route(req);
assertFalse(rsp.hasErrors());
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class LocationIndexTreeTest method testSnappedPointAndGeometry.
@Test
public void testSnappedPointAndGeometry() {
Graph graph = createTestGraph(encodingManager);
LocationIndex index = createIndex(graph, -1);
// query directly the tower node
QueryResult res = index.findClosest(-0.4, 0.9, EdgeFilter.ALL_EDGES);
assertTrue(res.isValid());
assertEquals(new GHPoint(-0.4, 0.9), res.getSnappedPoint());
res = index.findClosest(-0.6, 1.6, EdgeFilter.ALL_EDGES);
assertTrue(res.isValid());
assertEquals(new GHPoint(-0.6, 1.6), res.getSnappedPoint());
// query the edge (1,3). The edge (0,4) has 27674 as distance
res = index.findClosest(-0.2, 0.3, EdgeFilter.ALL_EDGES);
assertTrue(res.isValid());
assertEquals(26936, res.getQueryDistance(), 1);
assertEquals(new GHPoint(-0.441624, 0.317259), res.getSnappedPoint());
}
use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.
the class DistanceCalcEarthTest method testPrecisionBug2.
@Test
public void testPrecisionBug2() {
DistanceCalc distCalc = new DistancePlaneProjection();
double queryLat = 55.818994, queryLon = 37.595354;
double tmpLat = 55.81777239183573, tmpLon = 37.59598350366913;
double wayLat = 55.818839128736535, wayLon = 37.5942968784488;
assertEquals(68.25, distCalc.calcDist(wayLat, wayLon, queryLat, queryLon), .1);
assertEquals(60.88, distCalc.calcDenormalizedDist(distCalc.calcNormalizedEdgeDistance(queryLat, queryLon, tmpLat, tmpLon, wayLat, wayLon)), .1);
assertEquals(new GHPoint(55.81863, 37.594626), distCalc.calcCrossingPointToEdge(queryLat, queryLon, tmpLat, tmpLon, wayLat, wayLon));
}
Aggregations