/** * Returns the distance (in radian) of 'the center of this approximation' to a given (lat, lon) point. * * @param lat The latitude. * @param lon The longitude. * * @return the distance (in radian). */ public double getDistance(double lat, double lon) { return calculator.distance(lon, lat); }
private static double maxDistance(final double[][] data, double centerLon, double centerLat) { final DistanceMeasure distanceMeasure = new CosineDistance(centerLon, centerLat); double maxDistance = 0.0; for (final double[] p : data) { final double d = distanceMeasure.distance(p[LON], p[LAT]); if (d > maxDistance) { maxDistance = d; } } return maxDistance; }
public Result invoke(int otherX, int otherY) { if (maskData == null || maskData.getSample(otherX, otherY, 0) != 0) { final double lon = lonData.getSampleDouble(otherX, otherY, 0); final double lat = latData.getSampleDouble(otherX, otherY, 0); final double d = distanceMeasure.distance(lon, lat); if (d < distance) { x = otherX; y = otherY; distance = d; found = found || d < tolerance; } } return this; } }
@Test public void testDistance() { final DistanceMeasure distanceMeasure = new SphericalDistance(0.0, 0.0); assertEquals(0.0, distanceMeasure.distance(0.0, 0.0), 0.0); assertEquals(1.0, Math.toDegrees(distanceMeasure.distance(1.0, 0.0)), 1.0e-10); assertEquals(1.0, Math.toDegrees(distanceMeasure.distance(0.0, 1.0)), 1.0e-10); } }
final double lon = GeoApproximation.normalizeLon(getSampleDouble(x0, y0, lonImage)); final double lat = getSampleDouble(x0, y0, latImage); minDistance = dc.distance(lon, lat); } else { minDistance = Double.POSITIVE_INFINITY; final double lon = GeoApproximation.normalizeLon(getSampleDouble(x, y, lonImage)); final double lat = getSampleDouble(x, y, latImage); final double d = dc.distance(lon, lat); if (d < minDistance) { x1 = x;
@Override public Dimension2D getPixelDimension(PlanarImage lonImage, PlanarImage latImage, PlanarImage maskImage) { final int w = latImage.getWidth(); final int h = latImage.getHeight(); double pixelSizeX = Double.NaN; for (int i = 5; i > 2; i--) { if (Double.isNaN(pixelSizeX)) { final int x0 = w / i; final int y0 = h / i; if (maskImage == null || getSampleBoolean(maskImage, x0, y0)) { final double lat0 = getSampleDouble(latImage, x0, y0, -90.0, 90.0); final double lon0 = getSampleDouble(lonImage, x0, y0, -180.0, 180.0); final DistanceMeasure calculator = new SphericalDistance(lon0, lat0); final int x1 = ((i - 1) * w) / i; if (maskImage == null || getSampleBoolean(maskImage, x1, y0)) { final double latX = getSampleDouble(latImage, x1, y0, -90.0, 90.0); final double lonX = getSampleDouble(lonImage, x1, y0, -180.0, 180.0); pixelSizeX = Math.toDegrees(calculator.distance(lonX, latX)) / ((w * (i - 2)) / i); } } } } return new PixelDimension(pixelSizeX); }