ucar.unidata.geoloc
Class LatLonPointImpl

java.lang.Object
  extended by ucar.unidata.geoloc.LatLonPointImpl
All Implemented Interfaces:
Serializable, LatLonPoint

public class LatLonPointImpl
extends Object
implements LatLonPoint, Serializable

Standard implementation of LatLonPoint. Longitude is always between -180 and +180 deg. Latitude is always between -90 and +90 deg.

Author:
Russ Rew, John Caron
See Also:
LatLonPoint, Serialized Form

Constructor Summary
LatLonPointImpl()
          Default constructor with values 0,0.
LatLonPointImpl(double lat, double lon)
          Creates a LatLonPoint from component latitude and longitude values.
LatLonPointImpl(LatLonPoint pt)
          Copy Constructor.
 
Method Summary
static boolean betweenLon(double lon, double lonBeg, double lonEnd)
          Deprecated.  
 boolean equals(LatLonPoint pt)
          Check for equality with another point.
 boolean equals(Object obj)
          Check for equality with another object.
static double getClockwiseDistanceTo(double from, double to)
           
 double getLatitude()
          Returns the latitude, in degrees.
 double getLongitude()
          Returns the longitude, in degrees.
static double latNormal(double lat)
          Normalize the latitude to lie between +/-90
static String latToString(double lat, int sigDigits)
          Make a nicely formatted representation of a latitude, eg 40.34N or 12.9S.
static double lonNormal(double lon)
          Normalize the longitude to lie between +/-180
static double lonNormal(double lon, double center)
          put longitude into the range [center +/- 180] deg
static double lonNormal360(double lon)
          put longitude into the range [0, 360] deg
static double lonNormalFrom(double lon, double start)
          put longitude into the range [start, start+360] deg
static String lonToString(double lon, int sigDigits)
          Make a nicely formatted representation of a longitude, eg 120.3W or 99.99E.
static double range180(double lon)
          put longitude into the range [-180, 180] deg
 void set(double lat, double lon)
          set lat, lon using double values
 void set(float lat, float lon)
          set lat, lon using float values
 void set(LatLonPoint pt)
          set lat, lon using values of pt
 void setLatitude(double lat)
          Set the latitude, in degrees.
 void setLongitude(double lon)
          Set the longitude, in degrees.
 String toString()
          Default string representation
 String toString(int sigDigits)
          String representation in the form, eg 40.23N 105.1W
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LatLonPointImpl

public LatLonPointImpl()
Default constructor with values 0,0.


LatLonPointImpl

public LatLonPointImpl(LatLonPoint pt)
Copy Constructor.

Parameters:
pt - point to copy

LatLonPointImpl

public LatLonPointImpl(double lat,
                       double lon)
Creates a LatLonPoint from component latitude and longitude values. The longitude is adjusted to be in the range [-180.,180.].

Parameters:
lat - north latitude in degrees
lon - east longitude in degrees
Method Detail

betweenLon

public static boolean betweenLon(double lon,
                                 double lonBeg,
                                 double lonEnd)
Deprecated. 

Test if point lies between two longitudes, deal with wrapping.

Parameters:
lon - point to test
lonBeg - beginning longitude
lonEnd - ending longitude
Returns:
true if lon is between lonBeg and lonEnd.

getClockwiseDistanceTo

public static double getClockwiseDistanceTo(double from,
                                            double to)

range180

public static double range180(double lon)
put longitude into the range [-180, 180] deg

Parameters:
lon - lon to normalize
Returns:
longitude in range [-180, 180] deg

lonNormal360

public static double lonNormal360(double lon)
put longitude into the range [0, 360] deg

Parameters:
lon - lon to normalize
Returns:
longitude into the range [0, 360] deg

lonNormal

public static double lonNormal(double lon,
                               double center)
put longitude into the range [center +/- 180] deg

Parameters:
lon - lon to normalize
center - center point
Returns:
longitude into the range [center +/- 180] deg

lonNormalFrom

public static double lonNormalFrom(double lon,
                                   double start)
put longitude into the range [start, start+360] deg

Parameters:
lon - lon to normalize
start - starting point
Returns:
longitude into the range [center +/- 180] deg

lonNormal

public static double lonNormal(double lon)
Normalize the longitude to lie between +/-180

Parameters:
lon - east latitude in degrees
Returns:
normalized lon

latNormal

public static double latNormal(double lat)
Normalize the latitude to lie between +/-90

Parameters:
lat - north latitude in degrees
Returns:
normalized lat

latToString

public static String latToString(double lat,
                                 int sigDigits)
Make a nicely formatted representation of a latitude, eg 40.34N or 12.9S.

Parameters:
lat - the latitude.
sigDigits - numer of significant digits to display.
Returns:
String representation.

lonToString

public static String lonToString(double lon,
                                 int sigDigits)
Make a nicely formatted representation of a longitude, eg 120.3W or 99.99E.

Parameters:
lon - the longitude.
sigDigits - numer of significant digits to display.
Returns:
String representation.

getLongitude

public double getLongitude()
Returns the longitude, in degrees.

Specified by:
getLongitude in interface LatLonPoint
Returns:
the longitude, in degrees

getLatitude

public double getLatitude()
Returns the latitude, in degrees.

Specified by:
getLatitude in interface LatLonPoint
Returns:
the latitude, in degrees

set

public void set(LatLonPoint pt)
set lat, lon using values of pt

Parameters:
pt - point to use

set

public void set(double lat,
                double lon)
set lat, lon using double values

Parameters:
lat - lat value
lon - lon value

set

public void set(float lat,
                float lon)
set lat, lon using float values

Parameters:
lat - lat value
lon - lon value

setLongitude

public void setLongitude(double lon)
Set the longitude, in degrees. It is normalized to +/-180.

Parameters:
lon - east longitude in degrees

setLatitude

public void setLatitude(double lat)
Set the latitude, in degrees. Must lie beween +/-90

Parameters:
lat - north latitude in degrees

equals

public boolean equals(Object obj)
Check for equality with another object.

Overrides:
equals in class Object
Parameters:
obj - object to check
Returns:
true if this represents the same point as pt

equals

public boolean equals(LatLonPoint pt)
Check for equality with another point.

Specified by:
equals in interface LatLonPoint
Parameters:
pt - point to check
Returns:
true if this represents the same point as pt

toString

public String toString()
Default string representation

Overrides:
toString in class Object
Returns:
string representing this point

toString

public String toString(int sigDigits)
String representation in the form, eg 40.23N 105.1W

Parameters:
sigDigits - significant digits
Returns:
String representation


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.