Class GeoPoint

java.lang.Object
org.apache.lucene.spatial3d.geom.Vector
org.apache.lucene.spatial3d.geom.GeoPoint
All Implemented Interfaces:
SerializableObject

public class GeoPoint extends Vector implements SerializableObject
This class represents a point on the surface of a sphere or ellipsoid.
WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • magnitude

      protected volatile double magnitude
      This is the lazily-evaluated magnitude. Some constructors include it, but others don't, and we try not to create extra computation by always computing it. Does not need to be synchronized for thread safety, because depends wholly on immutable variables of this class.
    • latitude

      protected volatile double latitude
      Lazily-evaluated latitude. Does not need to be synchronized for thread safety, because depends wholly on immutable variables of this class.
    • longitude

      protected volatile double longitude
      Lazily-evaluated longitude. Does not need to be synchronized for thread safety, because depends wholly on immutable variables of this class.
  • Constructor Details

    • GeoPoint

      public GeoPoint(PlanetModel planetModel, double sinLat, double sinLon, double cosLat, double cosLon, double lat, double lon)
      Construct a GeoPoint from the trig functions of a lat and lon pair.
      Parameters:
      planetModel - is the planetModel to put the point on.
      sinLat - is the sin of the latitude.
      sinLon - is the sin of the longitude.
      cosLat - is the cos of the latitude.
      cosLon - is the cos of the longitude.
      lat - is the latitude.
      lon - is the longitude.
    • GeoPoint

      public GeoPoint(PlanetModel planetModel, double sinLat, double sinLon, double cosLat, double cosLon)
      Construct a GeoPoint from the trig functions of a lat and lon pair.
      Parameters:
      planetModel - is the planetModel to put the point on.
      sinLat - is the sin of the latitude.
      sinLon - is the sin of the longitude.
      cosLat - is the cos of the latitude.
      cosLon - is the cos of the longitude.
    • GeoPoint

      public GeoPoint(PlanetModel planetModel, double lat, double lon)
      Construct a GeoPoint from a latitude/longitude pair.
      Parameters:
      planetModel - is the planetModel to put the point on.
      lat - is the latitude.
      lon - is the longitude.
    • GeoPoint

      public GeoPoint(PlanetModel planetModel, InputStream inputStream) throws IOException
      Construct a GeoPoint from an input stream.
      Parameters:
      planetModel - is the planet model
      inputStream - is the input stream
      Throws:
      IOException
    • GeoPoint

      public GeoPoint(InputStream inputStream) throws IOException
      Construct a GeoPoint from an input stream with no planet model.
      Parameters:
      inputStream - is the input stream
      Throws:
      IOException
    • GeoPoint

      public GeoPoint(double lat, double lon, double x, double y, double z)
      Construct a GeoPoint from five unchecked parameters: lat, lon, x, y, z. This is primarily used for deserialization, but can also be used to fully initialize a point externally.
      Parameters:
      lat - is the latitude in radians
      lon - is the longitude in radians
      x - is the unit x value
      y - is the unit y value
      z - is the unit z value
    • GeoPoint

      public GeoPoint(double magnitude, double x, double y, double z, double lat, double lon)
      Construct a GeoPoint from a unit (x,y,z) vector and a magnitude.
      Parameters:
      magnitude - is the desired magnitude, provided to put the point on the ellipsoid.
      x - is the unit x value.
      y - is the unit y value.
      z - is the unit z value.
      lat - is the latitude.
      lon - is the longitude.
    • GeoPoint

      public GeoPoint(double magnitude, double x, double y, double z)
      Construct a GeoPoint from a unit (x,y,z) vector and a magnitude.
      Parameters:
      magnitude - is the desired magnitude, provided to put the point on the ellipsoid.
      x - is the unit x value.
      y - is the unit y value.
      z - is the unit z value.
    • GeoPoint

      public GeoPoint(double x, double y, double z)
      Construct a GeoPoint from an (x,y,z) value. The (x,y,z) tuple must be on the desired ellipsoid.
      Parameters:
      x - is the ellipsoid point x value.
      y - is the ellipsoid point y value.
      z - is the ellipsoid point z value.
  • Method Details

    • write

      public void write(OutputStream outputStream) throws IOException
      Description copied from interface: SerializableObject
      Serialize to output stream.
      Specified by:
      write in interface SerializableObject
      Parameters:
      outputStream - is the output stream to write to.
      Throws:
      IOException
    • arcDistance

      public double arcDistance(Vector v)
      Compute an arc distance between two points. Note: this is an angular distance, and not a surface distance, and is therefore independent of planet model. For surface distance, see PlanetModel.surfaceDistance(GeoPoint, GeoPoint)
      Parameters:
      v - is the second point.
      Returns:
      the angle, in radians, between the two points.
    • arcDistance

      public double arcDistance(double x, double y, double z)
      Compute an arc distance between two points.
      Parameters:
      x - is the x part of the second point.
      y - is the y part of the second point.
      z - is the z part of the second point.
      Returns:
      the angle, in radians, between the two points.
    • getLatitude

      public double getLatitude()
      Compute the latitude for the point.
      Returns:
      the latitude.
    • getLongitude

      public double getLongitude()
      Compute the longitude for the point.
      Returns:
      the longitude value. Uses 0.0 if there is no computable longitude.
    • magnitude

      public double magnitude()
      Compute the linear magnitude of the point.
      Overrides:
      magnitude in class Vector
      Returns:
      the magnitude.
    • isIdentical

      public boolean isIdentical(GeoPoint p)
      Compute whether point matches another.
      Parameters:
      p - is the other point.
      Returns:
      true if the same.
    • isIdentical

      public boolean isIdentical(double x, double y, double z)
      Compute whether point matches another.
      Parameters:
      x - is the x value
      y - is the y value
      z - is the z value
      Returns:
      true if the same.
    • toString

      public String toString()
      Overrides:
      toString in class Vector