@Override Double getDistance(final Point center) { return center.getDistanceTo( latitude, longitude ); } }
@Override Double getDistance(final Point center) { return center.getDistanceTo( latitude, longitude ); } }
/** * Compute distance between two points * * @param other a {@link org.hibernate.search.spatial.impl.Point} object. * @return the distance between points * @see <a href="http://www.movable-type.co.uk/scripts/latlong.html">Distance haversine formula</a> */ public double getDistanceTo(Point other) { return getDistanceTo( other.getLatitude(), other.getLongitude() ); }
/** * Compute distance between two points * * @param other a {@link org.hibernate.search.spatial.impl.Point} object. * @return the distance between points * @see <a href="http://www.movable-type.co.uk/scripts/latlong.html">Distance haversine formula</a> */ public double getDistanceTo(Point other) { return getDistanceTo( other.getLatitude(), other.getLongitude() ); }
private double distanceTo(final int doc) { if ( docsWithLatitude.get( doc ) && docsWithLongitude.get( doc ) ) { return center.getDistanceTo( coordinate( latitudeValues, doc ), coordinate( longitudeValues, doc ) ); } else { return Double.MAX_VALUE; } }
private double distanceTo(final int doc) { if ( docsWithLatitude.get( doc ) && docsWithLongitude.get( doc ) ) { return center.getDistanceTo( coordinate( latitudeValues, doc ), coordinate( longitudeValues, doc ) ); } else { return Double.MAX_VALUE; } }
double minimumLongitude, maximumLongitude; if ( radius > center.getDistanceTo( GeometricConstants.NORTH_POLE ) ) { maximumLatitude = GeometricConstants.LATITUDE_DEGREE_MAX; if ( radius > center.getDistanceTo( GeometricConstants.SOUTH_POLE ) ) { minimumLatitude = GeometricConstants.LATITUDE_DEGREE_MIN;
double minimumLongitude, maximumLongitude; if ( radius > center.getDistanceTo( GeometricConstants.NORTH_POLE ) ) { maximumLatitude = GeometricConstants.LATITUDE_DEGREE_MAX; if ( radius > center.getDistanceTo( GeometricConstants.SOUTH_POLE ) ) { minimumLatitude = GeometricConstants.LATITUDE_DEGREE_MIN;
@Override public boolean matches() throws IOException { lazyInit(); int docID = approximation().docID(); if ( docsWithLatitude.get( docID ) && docsWithLongitude.get( docID ) ) { double lat = coordinate( latitudeValues, docID ); double lon = coordinate( longitudeValues, docID ); if ( center.getDistanceTo( lat, lon ) <= radius ) { return true; } } return false; }
@Override public boolean matches() throws IOException { lazyInit(); int docID = approximation().docID(); if ( docsWithLatitude.get( docID ) && docsWithLongitude.get( docID ) ) { double lat = coordinate( latitudeValues, docID ); double lon = coordinate( longitudeValues, docID ); if ( center.getDistanceTo( lat, lon ) <= radius ) { return true; } } return false; }
@Test public void distanceToPoint() { Point point = Point.fromDegrees( 45, 4 ); Point point2 = Point.fromDegrees( 46, 14 ); double distance = point.getDistanceTo( point2 ); Assert.assertEquals( 786.7, distance, 0.1 ); } }