All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.locationtech.spatial4j.distance.DistanceCalculator Maven / Gradle / Ivy

Go to download

Spatial4j is a general purpose spatial / geospatial ASL licensed open-source Java library. It's core capabilities are 3-fold: to provide common geospatially-aware shapes, to provide distance calculations and other math, and to read shape formats like WKT and GeoJSON.

There is a newer version: 0.8
Show newest version
/*******************************************************************************
 * Copyright (c) 2015 Voyager Search and MITRE
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License, Version 2.0 which
 * accompanies this distribution and is available at
 *    http://www.apache.org/licenses/LICENSE-2.0.txt
 ******************************************************************************/

package org.locationtech.spatial4j.distance;

import org.locationtech.spatial4j.context.SpatialContext;
import org.locationtech.spatial4j.shape.Circle;
import org.locationtech.spatial4j.shape.Point;
import org.locationtech.spatial4j.shape.Rectangle;

/**
 * Performs calculations relating to distance, such as the distance between a pair of points.  A
 * calculator might be based on Euclidean space, or a spherical model, or theoretically something
 * else like an ellipsoid.
 */
public interface DistanceCalculator {

  /** The distance between from and to. */
  public double distance(Point from, Point to);

  /** The distance between from and Point(toX,toY). */
  public double distance(Point from, double toX, double toY);

  /** Returns true if the distance between from and to is <= distance. */
  public boolean within(Point from, double toX, double toY, double distance);

  /**
   * Calculates where a destination point is given an origin (from)
   * distance, and bearing (given in degrees -- 0-360).  If reuse is given, then
   * this method may reset() it and return it.
   */
  public Point pointOnBearing(Point from, double distDEG, double bearingDEG, SpatialContext ctx, Point reuse);

  /**
   * Calculates the bounding box of a circle, as specified by its center point
   * and distance.
   */
  public Rectangle calcBoxByDistFromPt(Point from, double distDEG, SpatialContext ctx, Rectangle reuse);

  /**
   * The Y coordinate of the horizontal axis of a circle that has maximum width. On a
   * 2D plane, this result is always from.getY() but, perhaps surprisingly, on a sphere
   * it is going to be slightly different.
   */
  public double calcBoxByDistFromPt_yHorizAxisDEG(Point from, double distDEG, SpatialContext ctx);

  public double area(Rectangle rect);

  public double area(Circle circle);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy