/** * This is a wrapper to build a reverse geocoding request */ public GHGeocodingRequest(double lat, double lon, String locale, int limit) { this(true, new GHPoint(lat, lon), null, locale, limit, "default", -1); }
/** * Set routing request from specified startPlace (fromLat, fromLon) to endPlace (toLat, toLon) * with a preferred start and end heading. Headings are north based azimuth (clockwise) in (0, * 360) or NaN for equal preference. */ public GHRequest(double fromLat, double fromLon, double toLat, double toLon, double startHeading, double endHeading) { this(new GHPoint(fromLat, fromLon), new GHPoint(toLat, toLon), startHeading, endHeading); }
private GHPoint getCoordinatesForIndex(int x, int y) { double lon = bounds.minLon + x * resolution + resolution / 2; double lat = bounds.minLat + y * resolution + resolution / 2; return new GHPoint(lat, lon); }
@Override public GHPoint getCenter() { return new GHPoint(lat, lon); }
@Override public GHPoint getCenter() { return new GHPoint((maxLat + minLat) / 2, (maxLon + minLon) / 2); }
public GHGeocodingRequest(boolean reverse, GHPoint point, String query, String locale, int limit, String provider, long timeout) { this.reverse = reverse; if (point == null) { this.point = new GHPoint(); } else { this.point = point; } this.query = query; this.locale = locale; this.limit = limit; this.provider = provider; this.timeout = timeout; }
@Override public GHPoint getCenter() { return new GHPoint((maxLat + minLat) / 2, (maxLon + minLon) / 2); }
public QueryResult(double queryLat, double queryLon) { queryPoint = new GHPoint(queryLat, queryLon); }
public static GHPoint fromJson(double[] xy) { return new GHPoint(xy[1], xy[0]); }
public static GHPoint create(Point point) { return new GHPoint(point.getY(), point.getX()); }
public static PointList fromLineString(LineString lineString) { final PointList pointList = new PointList(); for (Coordinate coordinate : lineString.getCoordinates()) { pointList.add(new GHPoint(coordinate.y, coordinate.x)); } return pointList; }
public static PointList from(LineString lineString) { final PointList pointList = new PointList(); for (Coordinate coordinate : lineString.getCoordinates()) { pointList.add(new GHPoint(coordinate.y, coordinate.x)); } return pointList; }
private static GHPoint createPoint(Graph graph, int nodeId) { return new GHPoint(graph.getNodeAccess().getLatitude(nodeId), graph.getNodeAccess().getLongitude(nodeId)); }
static GHPoint getPointForOrientationCalculation(EdgeIteratorState edgeIteratorState, NodeAccess nodeAccess) { double tmpLat; double tmpLon; PointList tmpWayGeo = edgeIteratorState.fetchWayGeometry(3); if (tmpWayGeo.getSize() <= 2) { tmpLat = nodeAccess.getLatitude(edgeIteratorState.getAdjNode()); tmpLon = nodeAccess.getLongitude(edgeIteratorState.getAdjNode()); } else { tmpLat = tmpWayGeo.getLatitude(1); tmpLon = tmpWayGeo.getLongitude(1); } return new GHPoint(tmpLat, tmpLon); } }
@Test public void testNoFurtherIterationIfBitsIs1() { SpatialKeyAlgo algo = new SpatialKeyAlgo(4).setBounds(0, 5, 0, 5); // 1001 GHPoint coord = new GHPoint(); algo.decode(9, coord); assertEquals(3.125, coord.lat, 1e-4); assertEquals(1.875, coord.lon, 1e-4); }
@Test public void testEdgesShareOneNode() { initGraph(g); EdgeIteratorState iter = GHUtility.getEdge(g, 0, 2); QueryResult res1 = createLocationResult(0.5, 0, iter, 0, EDGE); iter = GHUtility.getEdge(g, 1, 0); QueryResult res2 = createLocationResult(1.5, 2, iter, 0, EDGE); QueryGraph queryGraph = new QueryGraph(g); queryGraph.lookup(Arrays.asList(res1, res2)); assertEquals(new GHPoint(0.5, 0), res1.getSnappedPoint()); assertEquals(new GHPoint(1.300019, 1.899962), res2.getSnappedPoint()); assertNotNull(GHUtility.getEdge(queryGraph, 0, 4)); assertNotNull(GHUtility.getEdge(queryGraph, 0, 3)); }
@Test public void testDifferentInitialBounds() { SpatialKeyAlgo algo = new SpatialKeyAlgo(8).setBounds(0, 5, 0, 5); assertEquals(1, algo.encode(0, 0.5)); assertEquals(5, algo.encode(0, 1)); GHPoint coord = new GHPoint(); algo.decode(5, coord); assertEquals(5, algo.encode(coord)); algo.decode(1, coord); assertEquals(1, algo.encode(coord)); }
@Test public void testOddBits() { GHPoint coord = new GHPoint(); SpatialKeyAlgo algo = new SpatialKeyAlgo(8); long key = algo.encode(5, 30); assertEquals("11000001", BitUtil.BIG.toLastBitString(key, 8)); algo.decode(key, coord); assertEquals(5.63, coord.lat, 1e-2); assertEquals(33.75, coord.lon, 1e-2); algo = new SpatialKeyAlgo(7); key = algo.encode(11.11, 40.66); assertEquals("01100000", BitUtil.BIG.toLastBitString(key, 8)); assertEquals(5.63, coord.lat, 1e-2); assertEquals(33.75, coord.lon, 1e-2); }