/** * 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); }
public static GHPoint fromString(String str) { return fromString(str, false); }
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; }
@Override public String toString() { return super.toString() + "," + ele; }
@Override public int hashCode() { int hash = 59 * super.hashCode() + (int) (Double.doubleToLongBits(this.ele) ^ (Double.doubleToLongBits(this.ele) >>> 32)); return hash; }
@Override public String toString() { String res = ""; for (GHPoint point : points) { if (res.isEmpty()) { res = point.toString(); } else { res += "; " + point.toString(); } } if (!algo.isEmpty()) res += " (" + algo + ")"; if (!pathDetails.isEmpty()) res += " (PathDetails: " + pathDetails + ")"; if (!hints.isEmpty()) res += " (Hints:" + hints + ")"; return res; } }
@Override public int hashCode() { int hash = 59 * super.hashCode() + (int) (Double.doubleToLongBits(this.ele) ^ (Double.doubleToLongBits(this.ele) >>> 32)); return hash; }
/** * 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); }
@Override public String toString() { return super.toString() + "," + ele; }
public static GHPoint fromStringLonLat(String str) { return fromString(str, true); }
@Override public int hashCode() { int hash = 59 * super.hashCode() + (int) (Double.doubleToLongBits(this.ele) ^ (Double.doubleToLongBits(this.ele) >>> 32)); return hash; }
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; } }
@Override public String toString() { return super.toString() + "," + ele; }
@Override public T fromString(String value) { try { return (T) GHPoint.fromString(value); } catch (IllegalArgumentException ex) { throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST) .entity(new MultiException(ex)) .build()); } }
@Override public int hashCode() { int hash = 59 * super.hashCode() + (int) (Double.doubleToLongBits(this.ele) ^ (Double.doubleToLongBits(this.ele) >>> 32)); return hash; }
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; } }
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); }