net.agmodel.physical
Class Location2D

java.lang.Object
  |
  +--net.agmodel.physical.Location2D
All Implemented Interfaces:
Comparable, Serializable
Direct Known Subclasses:
Location

public class Location2D
extends Object
implements Serializable, Comparable

A location is simply a point on the planet. There may not be a weather station at this point. This abstraction is intended to support GIS type applications where data must be synthesised over a regular grid, irrespective of the location of individual stations. A 2D location does not hold any altitude information

See Also:
Serialized Form

Field Summary
protected  double latitude
           
protected  double longitude
           
protected static NumberFormat nf
           
static Location2D UNKNOWN
           
 
Constructor Summary
Location2D(double latitude, double longitude)
          Creates a Location2D object, ensuring latitude and longitude are within the standard ranges
Location2D(double latitude, double longitude, boolean strict)
          Creates a Location2D object, optionally clipping latitude to the range +/-90 and remapping longitude into the range +/-180
 
Method Summary
 int compareTo(Object a)
          More northerly locations sort first.
 boolean equals(Object o)
          Tests whether two objects represent the same 2D Location.
 double getLatitude()
           
 double getLongitude()
           
 int hashCode()
           
 boolean isUnknown()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

nf

protected static NumberFormat nf

UNKNOWN

public static final Location2D UNKNOWN

latitude

protected double latitude

longitude

protected double longitude
Constructor Detail

Location2D

public Location2D(double latitude,
                  double longitude)
Creates a Location2D object, ensuring latitude and longitude are within the standard ranges

Parameters:
latitude - degrees from the equator + north, - south (from +90 to -90)
longitude - degrees from Greenwich + east of Greenwich, - west of Greenwich (from +180 to -180)

Location2D

public Location2D(double latitude,
                  double longitude,
                  boolean strict)
Creates a Location2D object, optionally clipping latitude to the range +/-90 and remapping longitude into the range +/-180

Parameters:
latitude - degrees from the equator + north, - south
longitude - degrees from Greenwich + east of Greenwich, - west of Greenwich
strict - if true, ensure that latitude is in range, otherwise clip and remap as above
Method Detail

toString

public String toString()
Overrides:
toString in class Object

getLongitude

public double getLongitude()

getLatitude

public double getLatitude()

isUnknown

public boolean isUnknown()

compareTo

public int compareTo(Object a)
More northerly locations sort first. If latitude is the same, more more westerly (lesser longitude) locations sort first.

Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object o)
Tests whether two objects represent the same 2D Location.

Overrides:
equals in class Object
Parameters:
o - the other object
Returns:
true if the other object is a Location2D with the same latitude and longitude

hashCode

public int hashCode()
Overrides:
hashCode in class Object