private void checkNonChMaxWaypointDistance(List<GHPoint> points) { if (nonChMaxWaypointDistance == Integer.MAX_VALUE) { return; } GHPoint lastPoint = points.get(0); GHPoint point; double dist; DistanceCalc calc = DIST_3D; for (int i = 1; i < points.size(); i++) { point = points.get(i); dist = calc.calcDist(lastPoint.getLat(), lastPoint.getLon(), point.getLat(), point.getLon()); if (dist > nonChMaxWaypointDistance) { Map<String, Object> detailMap = new HashMap<>(2); detailMap.put("from", i - 1); detailMap.put("to", i); throw new PointDistanceExceededException("Point " + i + " is too far from Point " + (i - 1) + ": " + point, detailMap); } lastPoint = point; } }
/** * This method fills the edgeIds hash with edgeIds found close (exact match) to the specified point */ public void findClosestEdgeToPoint(GHIntHashSet edgeIds, GHPoint point, EdgeFilter filter) { findClosestEdge(edgeIds, point.getLat(), point.getLon(), filter); }
@Override public SpatialRule lookupRule(GHPoint point) { return lookupRule(point.getLat(), point.getLon()); }
private QueryResult generateValidPoint(GHPoint from, double distanceInMeters, double heading, EdgeFilter edgeFilter) { int tryCount = 0; while (true) { GHPoint generatedPoint = Helper.DIST_EARTH.projectCoordinate(from.getLat(), from.getLon(), distanceInMeters, heading); QueryResult qr = locationIndex.findClosest(generatedPoint.getLat(), generatedPoint.getLon(), edgeFilter); if (qr.isValid()) return qr; tryCount++; distanceInMeters *= 0.95; if (tryCount >= maxRetries) return null; } }
/** * Returns an edge that has more or less in the same orientation as the prevEdge, but is not the currentEdge. * If there is one, this indicates that we might need an instruction to help finding the correct edge out of the different choices. * If there is none, return null. */ public EdgeIteratorState getOtherContinue(double prevLat, double prevLon, double prevOrientation) { int tmpSign; for (EdgeIteratorState edge : allowedOutgoingEdges) { GHPoint point = InstructionsHelper.getPointForOrientationCalculation(edge, nodeAccess); tmpSign = InstructionsHelper.calculateSign(prevLat, prevLon, point.getLat(), point.getLon(), prevOrientation); if (Math.abs(tmpSign) <= 1) { return edge; } } return null; }
private void checkIfPointsAreInBounds(List<GHPoint> points) { BBox bounds = getGraphHopperStorage().getBounds(); for (int i = 0; i < points.size(); i++) { GHPoint point = points.get(i); if (!bounds.contains(point.getLat(), point.getLon())) { throw new PointOutOfBoundsException("Point " + i + " is out of bounds: " + point, i); } } }
private String buildUrl(GHGeocodingRequest request) { String url = routeServiceUrl + "?"; if (request.isReverse()) { if (!request.getPoint().isValid()) throw new IllegalArgumentException("For reverse geocoding you have to pass valid lat and long values"); url += "reverse=true"; } else { if (request.getQuery() == null) throw new IllegalArgumentException("For forward geocoding you have to a string for the query"); url += "reverse=false"; url += "&q=" + request.getQuery(); } if (request.getPoint().isValid()) url += "&point=" + request.getPoint().getLat() + "," + request.getPoint().getLon(); url += "&limit=" + request.getLimit(); url += "&locale=" + request.getLocale(); url += "&provider=" + request.getProvider(); if (!key.isEmpty()) { url += "&key=" + WebHelper.encodeURL(key); } return url; }
polygon.contains(center.getLat() - checkDiff, center.getLon() - checkDiff) || polygon.contains(center.getLat() - checkDiff, center.getLon() + checkDiff) || polygon.contains(center.getLat() + checkDiff, center.getLon() - checkDiff) || polygon.contains(center.getLat() + checkDiff, center.getLon() + checkDiff)) {
@Test public void testCrossingPointToEdge() { DistanceCalc2D distanceCalc = new DistanceCalc2D(); GHPoint point = distanceCalc.calcCrossingPointToEdge(0, 10, 0, 0, 10, 10); Assert.assertEquals(5, point.getLat(), 0); Assert.assertEquals(5, point.getLon(), 0); }
private int getTurn(EdgeIteratorState edge, int baseNode, int prevNode, int adjNode, InstructionAnnotation annotation, String name) { GHPoint point = InstructionsHelper.getPointForOrientationCalculation(edge, nodeAccess); double lat = point.getLat(); double lon = point.getLon(); prevOrientation = Helper.ANGLE_CALC.calcOrientation(doublePrevLat, doublePrevLon, prevLat, prevLon); || !outgoingEdgesAreSlower) { GHPoint tmpPoint = InstructionsHelper.getPointForOrientationCalculation(otherContinue, nodeAccess); double otherDelta = InstructionsHelper.calculateOrientationDelta(prevLat, prevLon, tmpPoint.getLat(), tmpPoint.getLon(), prevOrientation);
QueryResult qr = locationIndex.findClosest(center.getLat(), center.getLon(), filter);
double lat = point.getLat(); double lon = point.getLon(); double currentOrientation = Helper.ANGLE_CALC.calcOrientation(prevLat, prevLon, lat, lon, false);
/** * This method fills the edgeIds hash with edgeIds found close (exact match) to the specified point */ public void findClosestEdgeToPoint(GHIntHashSet edgeIds, GHPoint point, EdgeFilter filter) { findClosestEdge(edgeIds, point.getLat(), point.getLon(), filter); }
/** * This method fills the edgeIds hash with edgeIds found close (exact match) to the specified point */ public void findClosestEdgeToPoint(GHIntHashSet edgeIds, GHPoint point, EdgeFilter filter) { findClosestEdge(edgeIds, point.getLat(), point.getLon(), filter); }
private QueryResult[] queryPositions(GHPoint[] points, List<QueryResult> validResults) { QueryResult[] queryResults = new QueryResult[points.length]; for (int i = 0; i < points.length; i++) { queryResults[i] = createSnapToResult(points[i].getLat(), points[i].getLon()); if (queryResults[i].isValid()) { validResults.add(queryResults[i]); } } return queryResults; }
@Override public SpatialRule lookupRule(GHPoint point) { return lookupRule(point.getLat(), point.getLon()); }
/** * Returns an edge that has more or less in the same orientation as the prevEdge, but is not the currentEdge. * If there is one, this indicates that we might need an instruction to help finding the correct edge out of the different choices. * If there is none, return null. */ public EdgeIteratorState getOtherContinue(double prevLat, double prevLon, double prevOrientation) { int tmpSign; for (EdgeIteratorState edge : allowedOutgoingEdges) { GHPoint point = InstructionsHelper.getPointForOrientationCalculation(edge, nodeAccess); tmpSign = InstructionsHelper.calculateSign(prevLat, prevLon, point.getLat(), point.getLon(), prevOrientation); if (Math.abs(tmpSign) <= 1) { return edge; } } return null; }
private QueryResult generateValidPoint(GHPoint from, double distanceInMeters, double heading, EdgeFilter edgeFilter) { int tryCount = 0; while (true) { GHPoint generatedPoint = Helper.DIST_EARTH.projectCoordinate(from.getLat(), from.getLon(), distanceInMeters, heading); QueryResult qr = locationIndex.findClosest(generatedPoint.getLat(), generatedPoint.getLon(), edgeFilter); if (qr.isValid()) return qr; tryCount++; distanceInMeters *= 0.95; if (tryCount >= maxRetries) return null; } }
private void checkIfPointsAreInBounds(List<GHPoint> points) { BBox bounds = getGraphHopperStorage().getBounds(); for (int i = 0; i < points.size(); i++) { GHPoint point = points.get(i); if (!bounds.contains(point.getLat(), point.getLon())) { throw new PointOutOfBoundsException("Point " + i + " is ouf of bounds: " + point, i); } } }
private void checkIfPointsAreInBounds(List<GHPoint> points) { BBox bounds = getGraphHopperStorage().getBounds(); for (int i = 0; i < points.size(); i++) { GHPoint point = points.get(i); if (!bounds.contains(point.getLat(), point.getLon())) { throw new PointOutOfBoundsException("Point " + i + " is out of bounds: " + point, i); } } }