net.agmodel.physical
Class GeographicalBox

java.lang.Object
  extended bynet.agmodel.physical.GeographicalBox
All Implemented Interfaces:
Comparable, GeographicalArea, Serializable

public class GeographicalBox
extends Object
implements GeographicalArea, Comparable, Serializable

A 2-dimensional space using latitude, and longitude.

Author:
Matthew Laurenson
See Also:
Serialized Form

Field Summary
static GeographicalBox EVERYWHERE
           
static GeographicalBox UNKNOWN
           
 
Fields inherited from interface net.agmodel.physical.GeographicalArea
EVEREST, METRESPERDEGREEOFLATITUDE, METRESPERDEGREEOFLONGATEQUATOR, METRESPERPIXEL
 
Constructor Summary
GeographicalBox(Location2D northWestBound, Location2D southEastBound)
           
 
Method Summary
 int compareTo(Object another)
          Lets GeographicalBoxes be sorted based on their northwest corners
 boolean contains(GeographicalArea anotherArea)
          Indicate whether the area passed falls entirely within this area
 boolean contains(Location2D point)
          Indicate whether a point is within the area
 boolean equals(Object o)
          Tests whether two objects represent the same GeographicalBox.
 GeographicalBox getBoundingBox()
          Return a box which bounds the area.
 Location2D getCenter()
           
 double getDistanceEW()
          Returns the length of an East-West arc between the eastern and western boundaries of the box running through the center of the box.
 double getDistanceNS()
          Returns the length of a North-South arc between the northern and southern boundaries of the box.
 double getLatitudeRange()
          Returns the difference in latitude between the northern and southern extremes (always positive)
 double getLongitudeRange()
          Returns the difference in longitude between the eastern and western extremes (always positive)
 Location2D getNorthWestBound()
           
 double getRelativeLat(double latitude)
          Returns the latitude of a location relative to the box.
 double getRelativeLong(double longitude)
          Returns the longitude of a location relative to the box.
 Location2D getSouthEastBound()
           
 int hashCode()
           
 boolean isUnknown()
          Indicates whether the bounds of this area are unknown.
static double metresPerDegreeOfLongitude(double latitude)
           
 boolean overlapsWith(GeographicalArea area)
          Indicate whether the supplied area overlaps with this area.
 boolean spansDateline()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EVERYWHERE

public static final GeographicalBox EVERYWHERE

UNKNOWN

public static final GeographicalBox UNKNOWN
Constructor Detail

GeographicalBox

public GeographicalBox(Location2D northWestBound,
                       Location2D southEastBound)
Method Detail

metresPerDegreeOfLongitude

public static double metresPerDegreeOfLongitude(double latitude)

getBoundingBox

public GeographicalBox getBoundingBox()
Description copied from interface: GeographicalArea
Return a box which bounds the area. This can be used as the basis of approximate implementations of overlapsWith for arbitrary shapes. If isUnknown() returns true for the area, then returns GeographicalBox.UNKNOWN

Specified by:
getBoundingBox in interface GeographicalArea
Returns:
a 3 dimensional bounding box

toString

public String toString()

contains

public boolean contains(Location2D point)
Description copied from interface: GeographicalArea
Indicate whether a point is within the area

Specified by:
contains in interface GeographicalArea
Parameters:
point - the point of interest
Returns:
true if it is, and false if it isn't

overlapsWith

public boolean overlapsWith(GeographicalArea area)
Description copied from interface: GeographicalArea
Indicate whether the supplied area overlaps with this area. See getBoundingBox for a way of approximately implementing this for arbitrary shapes. Suggestions for improvement welcome. If isUnknown() returns true for either or both areas, the result is false;

Specified by:
overlapsWith in interface GeographicalArea
Parameters:
area - the area of interest

compareTo

public int compareTo(Object another)
Lets GeographicalBoxes be sorted based on their northwest corners

Specified by:
compareTo in interface Comparable

getNorthWestBound

public Location2D getNorthWestBound()

getSouthEastBound

public Location2D getSouthEastBound()

getLatitudeRange

public double getLatitudeRange()
Returns the difference in latitude between the northern and southern extremes (always positive)


getLongitudeRange

public double getLongitudeRange()
Returns the difference in longitude between the eastern and western extremes (always positive)


getCenter

public Location2D getCenter()

spansDateline

public boolean spansDateline()

getRelativeLat

public double getRelativeLat(double latitude)
Returns the latitude of a location relative to the box.

Parameters:
latitude -
Returns:
0 if the point is at the northern extreme of the box, 1 if on the southern extreme or a relative value otherwise.

getRelativeLong

public double getRelativeLong(double longitude)
Returns the longitude of a location relative to the box.

Parameters:
longitude -
Returns:
0 if the point is at the western extreme of the box, 1 if on the eastern extreme or a relative value otherwise.

getDistanceNS

public double getDistanceNS()
Returns the length of a North-South arc between the northern and southern boundaries of the box.

Returns:
the distance in metres

getDistanceEW

public double getDistanceEW()
Returns the length of an East-West arc between the eastern and western boundaries of the box running through the center of the box.

Returns:
the distance in metres

contains

public boolean contains(GeographicalArea anotherArea)
Description copied from interface: GeographicalArea
Indicate whether the area passed falls entirely within this area

Specified by:
contains in interface GeographicalArea
Parameters:
anotherArea - the area of interest
Returns:
true if both areas are known, and the other area is entirely within the bounds of this area, false otherwise

isUnknown

public boolean isUnknown()
Description copied from interface: GeographicalArea
Indicates whether the bounds of this area are unknown.

Specified by:
isUnknown in interface GeographicalArea
Returns:
true if the bounds are unknown.

equals

public boolean equals(Object o)
Tests whether two objects represent the same GeographicalBox.

Parameters:
o - the other object
Returns:
true if the other object is a GeographicalBox with corners in the same 2D Locations

hashCode

public int hashCode()


Copyright (C) NARC 2001 All Rights Reserved.