public QueryResult createLocationResult(double lat, double lon, EdgeIteratorState edge, int wayIndex, QueryResult.Position pos) { if (edge == null) throw new IllegalStateException("Specify edge != null"); QueryResult tmp = new QueryResult(lat, lon); tmp.setClosestEdge(edge); tmp.setWayIndex(wayIndex); tmp.setSnappedPosition(pos); tmp.calcSnappedPoint(new DistanceCalcEarth()); return tmp; }
QueryResult createQR(double lat, double lon, int wayIndex, EdgeIteratorState edge) { QueryResult res = new QueryResult(lat, lon); res.setClosestEdge(edge); res.setWayIndex(wayIndex); res.setSnappedPosition(QueryResult.Position.EDGE); res.calcSnappedPoint(Helper.DIST_PLANE); return res; }
private QueryResult fakeEdgeQueryResult(EdgeIteratorState edge, double lat, double lon, int wayIndex) { QueryResult qr = new QueryResult(lat, lon); qr.setClosestEdge(edge); qr.setWayIndex(wayIndex); qr.setSnappedPosition(EDGE); qr.calcSnappedPoint(new DistanceCalc2D()); return qr; }
qr.calcSnappedPoint(distCalc); } else { throw new IllegalStateException("Invalid QueryResult should not happen here: " + qr);
closestMatch.calcSnappedPoint(distCalc);
/** * Creates query result on edge (node1-node2) very close to node1. */ QueryResult newQR(Graph graph, int node1, int node2) { EdgeIteratorState edge = GHUtility.getEdge(graph, node1, node2); if (edge == null) throw new IllegalStateException("edge not found? " + node1 + "-" + node2); NodeAccess na = graph.getNodeAccess(); double lat = na.getLatitude(edge.getBaseNode()); double lon = na.getLongitude(edge.getBaseNode()); double latAdj = na.getLatitude(edge.getAdjNode()); double lonAdj = na.getLongitude(edge.getAdjNode()); // calculate query point near the base node but not directly on it! QueryResult res = new QueryResult(lat + (latAdj - lat) * .1, lon + (lonAdj - lon) * .1); res.setClosestNode(edge.getBaseNode()); res.setClosestEdge(edge); res.setWayIndex(0); res.setSnappedPosition(QueryResult.Position.EDGE); res.calcSnappedPoint(distCalc); return res; }
qr.setClosestEdge(edge); qr.setWayIndex(1); qr.calcSnappedPoint(new DistanceCalc2D());
@Test public void testUseMeanElevation() { g.close(); g = new GraphHopperStorage(new RAMDirectory(), encodingManager, true, new GraphExtension.NoOpExtension()).create(100); NodeAccess na = g.getNodeAccess(); na.setNode(0, 0, 0, 0); na.setNode(1, 0, 0.0001, 20); EdgeIteratorState edge = g.edge(0, 1); EdgeIteratorState edgeReverse = edge.detach(true); DistanceCalc2D distCalc = new DistanceCalc2D(); QueryResult qr = new QueryResult(0, 0.00005); qr.setClosestEdge(edge); qr.setWayIndex(0); qr.setSnappedPosition(EDGE); qr.calcSnappedPoint(distCalc); assertEquals(10, qr.getSnappedPoint().getEle(), 1e-1); qr = new QueryResult(0, 0.00005); qr.setClosestEdge(edgeReverse); qr.setWayIndex(0); qr.setSnappedPosition(EDGE); qr.calcSnappedPoint(distCalc); assertEquals(10, qr.getSnappedPoint().getEle(), 1e-1); }
@Test public void testLoopStreet_Issue151() { // do query at x should result in ignoring only the bottom edge 1-3 not the upper one => getNeighbors are 0, 5, 3 and not only 0, 5 // // 0--1--3--4 // | | // x--- // g.edge(0, 1, 10, true); g.edge(1, 3, 10, true); g.edge(3, 4, 10, true); EdgeIteratorState edge = g.edge(1, 3, 20, true).setWayGeometry(Helper.createPointList(-0.001, 0.001, -0.001, 0.002)); AbstractRoutingAlgorithmTester.updateDistancesFor(g, 0, 0, 0); AbstractRoutingAlgorithmTester.updateDistancesFor(g, 1, 0, 0.001); AbstractRoutingAlgorithmTester.updateDistancesFor(g, 3, 0, 0.002); AbstractRoutingAlgorithmTester.updateDistancesFor(g, 4, 0, 0.003); QueryResult qr = new QueryResult(-0.0005, 0.001); qr.setClosestEdge(edge); qr.setWayIndex(1); qr.calcSnappedPoint(new DistanceCalc2D()); QueryGraph qg = new QueryGraph(g); qg.lookup(Arrays.asList(qr)); EdgeExplorer ee = qg.createEdgeExplorer(); assertEquals(GHUtility.asSet(0, 5, 3), GHUtility.getNeighbors(ee.setBaseNode(1))); }
vqr.setSnappedPosition(qr.getSnappedPosition()); vqr.setClosestEdge(qr.getClosestEdge()); vqr.calcSnappedPoint(distanceCalc); GPXExtension candidate = new GPXExtension(gpxEntry, vqr, incomingVirtualEdge, outgoingVirtualEdge);
vqr.setSnappedPosition(qr.getSnappedPosition()); vqr.setClosestEdge(qr.getClosestEdge()); vqr.calcSnappedPoint(distanceCalc); GPXExtension candidate = new GPXExtension(gpxEntry, vqr, incomingVirtualEdge, outgoingVirtualEdge);
qr.calcSnappedPoint(distCalc); } else { throw new IllegalStateException("invalid query result should not happen here: " + qr);
qr.calcSnappedPoint(distCalc); } else { throw new IllegalStateException("Invalid QueryResult should not happen here: " + qr);
closestMatch.calcSnappedPoint(distCalc);
closestMatch.calcSnappedPoint(distCalc);
closestMatch.calcSnappedPoint(distCalc);