/** * Set the precision use o make suggestions * * @param precision * precision value * @param unit * {@link DistanceUnit} to use * @return this */ public Builder precision(double precision, DistanceUnit unit) { return precision(unit.toMeters(precision)); }
/** * Set the precision use o make suggestions * * @param precision * precision value * @param unit * {@link DistanceUnit} to use * @return this */ public Builder precision(double precision, DistanceUnit unit) { return precision(unit.toMeters(precision)); }
/** * Set the precision use o make suggestions * * @param precision * precision value * @param unit * {@link DistanceUnit} to use * @return this */ public Builder precision(double precision, DistanceUnit unit) { return precision(unit.toMeters(precision)); }
/** * Set the precision use o make suggestions * * @param precision * precision value * @param unit * {@link DistanceUnit} to use * @return this */ public Builder precision(double precision, DistanceUnit unit) { return precision(unit.toMeters(precision)); }
/** * Set the precision use o make suggestions * * @param precision * precision value * @param unit * {@link DistanceUnit} to use * @return this */ public Builder precision(double precision, DistanceUnit unit) { return precision(unit.toMeters(precision)); }
public static DistanceBoundingCheck distanceBoundingCheck(double sourceLatitude, double sourceLongitude, double distance, DistanceUnit unit) { // angular distance in radians on a great circle // assume worst-case: use the minor axis double radDist = unit.toMeters(distance) / GeoUtils.EARTH_SEMI_MINOR_AXIS; double radLat = Math.toRadians(sourceLatitude); double radLon = Math.toRadians(sourceLongitude); double minLat = radLat - radDist; double maxLat = radLat + radDist; double minLon, maxLon; if (minLat > MIN_LAT && maxLat < MAX_LAT) { double deltaLon = Math.asin(Math.sin(radDist) / Math.cos(radLat)); minLon = radLon - deltaLon; if (minLon < MIN_LON) minLon += 2d * Math.PI; maxLon = radLon + deltaLon; if (maxLon > MAX_LON) maxLon -= 2d * Math.PI; } else { // a pole is within the distance minLat = Math.max(minLat, MIN_LAT); maxLat = Math.min(maxLat, MAX_LAT); minLon = MIN_LON; maxLon = MAX_LON; } GeoPoint topLeft = new GeoPoint(Math.toDegrees(maxLat), Math.toDegrees(minLon)); GeoPoint bottomRight = new GeoPoint(Math.toDegrees(minLat), Math.toDegrees(maxLon)); if (minLon > maxLon) { return new Meridian180DistanceBoundingCheck(topLeft, bottomRight); } return new SimpleDistanceBoundingCheck(topLeft, bottomRight); }
return precision(unit.toMeters(precision));
@Override public double getDistance() { String geohash = (String)((ElasticsearchDocument)getDocument()).getSource().get(geoPointField); GeoPoint dstPoint = GeoPoint.fromGeohash(geohash); double unitDist = GeoDistance.ARC.calculate(srcPoint.getLat(), srcPoint.getLon(), dstPoint.getLat(), dstPoint.getLon(), unit); double distance; if (GEOF.UOM_METRE.equals(units)) { distance = unit.toMeters(unitDist); } else if (GEOF.UOM_DEGREE.equals(units)) { distance = unitDist / unit.getDistancePerDegree(); } else if (GEOF.UOM_RADIAN.equals(units)) { distance = DistanceUtils.dist2Radians(unit.convert(unitDist, DistanceUnit.KILOMETERS), DistanceUtils.EARTH_MEAN_RADIUS_KM); } else if (GEOF.UOM_UNITY.equals(units)) { distance = unit.convert(unitDist, DistanceUnit.KILOMETERS) / (Math.PI * DistanceUtils.EARTH_MEAN_RADIUS_KM); } else { throw new UnsupportedOperationException("Unsupported units: " + units); } return distance; } }
if (vFrom != null) { if (vFrom instanceof Number) { from = unit.toMeters(((Number) vFrom).doubleValue()); } else { from = DistanceUnit.parse((String) vFrom, unit, DistanceUnit.DEFAULT); to = unit.toMeters(((Number) vTo).doubleValue()); } else { to = DistanceUnit.parse((String) vTo, unit, DistanceUnit.DEFAULT);
if (from != null) { if (from instanceof Number) { fromValue = unit.toMeters(((Number) from).doubleValue()); } else { fromValue = DistanceUnit.parse((String) from, unit, DistanceUnit.DEFAULT); toValue = unit.toMeters(((Number) to).doubleValue()); } else { toValue = DistanceUnit.parse((String) to, unit, DistanceUnit.DEFAULT);