com.bbn.openmap.proj.coords
Class LatLonPoint

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by com.bbn.openmap.proj.coords.LatLonPoint
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
LatLonPoint.Double, LatLonPoint.Float

public abstract class LatLonPoint
extends java.awt.geom.Point2D
implements java.lang.Cloneable, java.io.Serializable

A Point2D representation of LatLonPoints, used integrate with the Projections. These LatLonPoints wrap their internal decimal degree values so the latitude are between -90 and 90 and the longitudes are between -180 and 180. Radian values are precalculated and held within the object.

The LatLonPoint is an abstract class and can't be instantiated directly. You need to create a Float or Double version of a LatLonPoint, much like the Point2D object.

Author:
dietrick
See Also:
Serialized Form

Nested Class Summary
static class LatLonPoint.Double
          Double precision version of LatLonPoint.
static class LatLonPoint.Float
          The Float version of a LatLonPoint, where coordinates are held to float precision.
 
Field Summary
static double DATELINE
           
static double LON_RANGE
           
static double NORTH_POLE
           
static double SOUTH_POLE
           
 
Constructor Summary
protected LatLonPoint()
           
 
Method Summary
 double azimuth(LatLonPoint toPoint)
          Find the azimuth to another point, based on the spherical earth model.
 double distance(LatLonPoint toPoint)
          Find the distance to another LatLonPoint, based on a earth spherical model.
 boolean equals(java.lang.Object obj)
          Determines whether two LatLonPoints are equal.
static LatLonPoint getDouble(java.awt.geom.Point2D pt2D)
          Factory method that will create a LatLonPoint.Double from a Point2D object.
static LatLonPoint getFloat(java.awt.geom.Point2D pt2D)
          Factory method that will create a LatLonPoint.Float from a Point2D object.
abstract  float getLatitude()
           
abstract  float getLongitude()
           
 LatLonPoint getPoint(double distance, double azimuth)
          Get a new LatLonPoint a distance and azimuth from another point, based on the spherical earth model.
abstract  double getRadLat()
           
abstract  double getRadLon()
           
static boolean isInvalidLatitude(double lat)
          Check if latitude is bogus.
static boolean isInvalidLongitude(double lon)
          Check if longitude is bogus.
static double normalizeLatitude(double lat)
          Sets latitude to something sane.
static float normalizeLatitude(float lat)
          Ensure latitude is between the poles.
abstract  void setLatitude(double lat)
          Set decimal degree latitude.
abstract  void setLatLon(double lat, double lon)
          Set the latitude, longitude for this point.
abstract  void setLatLon(double lat, double lon, boolean isRadians)
          Set the latitude, longitude for this point, with the option of noting whether the values are in degrees or radians.
 void setLatLon(LatLonPoint llp)
          Set location values from another lat/lon point.
abstract  void setLongitude(double lon)
          Set decimal degree longitude.
static double wrapLongitude(double lon)
          Sets longitude to something sane.
static float wrapLongitude(float lon)
          Ensure the longitude is between the date line.
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, getX, getY, hashCode, setLocation, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NORTH_POLE

public static final double NORTH_POLE
See Also:
Constant Field Values

SOUTH_POLE

public static final double SOUTH_POLE
See Also:
Constant Field Values

DATELINE

public static final double DATELINE
See Also:
Constant Field Values

LON_RANGE

public static final double LON_RANGE
See Also:
Constant Field Values
Constructor Detail

LatLonPoint

protected LatLonPoint()
Method Detail

getFloat

public static LatLonPoint getFloat(java.awt.geom.Point2D pt2D)
Factory method that will create a LatLonPoint.Float from a Point2D object. If pt2D is already a LatLonPoint.Float object, it is simply returned.

Parameters:
pt2D -
Returns:
a LatLonPoint.Float object.

getDouble

public static LatLonPoint getDouble(java.awt.geom.Point2D pt2D)
Factory method that will create a LatLonPoint.Double from a Point2D object. If pt2D is already a LatLonPoint.Double object, it is simply returned.

Parameters:
pt2D -
Returns:
a LatLonPoint.Double object.

setLatLon

public abstract void setLatLon(double lat,
                               double lon)
Set the latitude, longitude for this point.

Parameters:
lat - decimal degree latitude
lon - decimal degree longitude.

setLatLon

public abstract void setLatLon(double lat,
                               double lon,
                               boolean isRadians)
Set the latitude, longitude for this point, with the option of noting whether the values are in degrees or radians.

Parameters:
lat - latitude
lon - longitude.
isRadians - true of values are radians.

getLongitude

public abstract float getLongitude()
Returns:
decimal degree longitude as a float.

getLatitude

public abstract float getLatitude()
Returns:
decimal degree latitude as a float.

getRadLon

public abstract double getRadLon()
Returns:
radian longitude value.

getRadLat

public abstract double getRadLat()
Returns:
radian latitude value.

setLatitude

public abstract void setLatitude(double lat)
Set decimal degree latitude.


setLongitude

public abstract void setLongitude(double lon)
Set decimal degree longitude.


setLatLon

public void setLatLon(LatLonPoint llp)
Set location values from another lat/lon point.

Parameters:
llp -

normalizeLatitude

public static final float normalizeLatitude(float lat)
Ensure latitude is between the poles.

Parameters:
lat -
Returns:
latitude greater than or equal to -90 and less than or equal to 90.

normalizeLatitude

public static final double normalizeLatitude(double lat)
Sets latitude to something sane.

Parameters:
lat - latitude in decimal degrees
Returns:
float normalized latitude in decimal degrees (−90° ≤ φ ≤ 90°)

wrapLongitude

public static final float wrapLongitude(float lon)
Ensure the longitude is between the date line.

Parameters:
lon -
Returns:
longitude that is smaller than or equal to 180 and greater than or equal to -180

wrapLongitude

public static final double wrapLongitude(double lon)
Sets longitude to something sane.

Parameters:
lon - longitude in decimal degrees
Returns:
float wrapped longitude in decimal degrees (−180° ≤ λ ≤ 180°)

isInvalidLatitude

public static boolean isInvalidLatitude(double lat)
Check if latitude is bogus. Latitude is invalid if lat > 90° or if lat < −90°.

Parameters:
lat - latitude in decimal degrees
Returns:
boolean true if latitude is invalid

isInvalidLongitude

public static boolean isInvalidLongitude(double lon)
Check if longitude is bogus. Longitude is invalid if lon > 180° or if lon < −180°.

Parameters:
lon - longitude in decimal degrees
Returns:
boolean true if longitude is invalid

equals

public boolean equals(java.lang.Object obj)
Determines whether two LatLonPoints are equal.

Overrides:
equals in class java.awt.geom.Point2D
Parameters:
obj - Object
Returns:
Whether the two points are equal up to a tolerance of 10 -5 degrees in latitude and longitude.

distance

public double distance(LatLonPoint toPoint)
Find the distance to another LatLonPoint, based on a earth spherical model.

Parameters:
toPoint - LatLonPoint
Returns:
distance, in radians. You can use an com.bbn.openmap.proj.Length to convert the radians to other units.

azimuth

public double azimuth(LatLonPoint toPoint)
Find the azimuth to another point, based on the spherical earth model.

Parameters:
toPoint - LatLonPoint
Returns:
the azimuth `Az' east of north from this point bearing toward the one provided as an argument.(-PI <= Az <= PI).

getPoint

public LatLonPoint getPoint(double distance,
                            double azimuth)
Get a new LatLonPoint a distance and azimuth from another point, based on the spherical earth model.

Parameters:
distance - radians
azimuth - radians
Returns:
LatLonPoint that is distance and azimuth away from this one.


Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details