net.rim.device.api.lbs.maps
Class LatLonRectangle

java.lang.Object
  extended by net.rim.device.api.lbs.maps.LatLonRectangle
All Implemented Interfaces:
Persistable

public class LatLonRectangle
extends Object
implements Persistable

Represents a geographic rectangle that is oriented along the latitudinal and longitudinal lines.

Within this class, the term normalize refers to the "normal" region of the atlas: -90 < lat < 90 degrees, and -180 < lon < 180.

See Also:
Axis-Aligned Bounding Box
Since:
BlackBerry API 6.0.0

Constructor Summary
LatLonRectangle()
          Constructs a new LatLonRectangle instance.
LatLonRectangle(double top, double bottom, double left, double right)
          Constructs a new LatLonRectangle instance using the coordinates of the box.
LatLonRectangle(LatLonRectangle copyFrom)
          Constructs a copy of a LatLonRectangle instance.
 
Method Summary
 boolean contains(double lat, double lon)
          Determines if the specified point is within this rectangle.
 boolean contains(LatLonRectangle other)
          Determines if the given parameter is completely within this rectangle.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one.
 double getBottom()
          Gets the coordinate of the bottom of the box.
 int getHeight()
          Gets the height of this rectangle in degrees x 10^5.
 double getLeft()
          Gets the coordinate of the left of the box.
 MapPoint getMidpoint()
          Gets the midpoint of the rectangle.
 double getRight()
          Gets the coordinate of the right of the box.
 double getTop()
          Gets the coordinate of the top of the box.
 int getWidth()
          Gets the width of this rectangle in degrees x 10^5.
 int hashCode()
          Returns a hash code value for the object.
 boolean intersects(LatLonRectangle outerBox)
          Determines if any part of this rectangle and the parameter share the same space.
 void setBottom(double bottom)
          Sets the coordinate of the bottom of the box.
 void setLeft(double left)
          Sets the coordinate of the left of the box.
 void setRight(double right)
          Sets the coordinate of the right of the box.
 void setTop(double top)
          Sets the coordinate of the top of the box.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 



Constructor Detail

LatLonRectangle

public LatLonRectangle()
Constructs a new LatLonRectangle instance.

Since:
BlackBerry API 6.0.0

LatLonRectangle

public LatLonRectangle(double top,
                       double bottom,
                       double left,
                       double right)
Constructs a new LatLonRectangle instance using the coordinates of the box. If the top and bottom are reversed, this method will automatically switch the two values. The same procedure is performed for left and right values. For example, top is the maximum value of both top and bottom , while bottom is the minimum value of both top and bottom.

Parameters:
top - top of the box (latitude)
bottom - bottom of the box (latitude)
left - left edge of the box (longitude)
right - right edge of the box (longitude)
Since:
BlackBerry API 6.0.0

LatLonRectangle

public LatLonRectangle(LatLonRectangle copyFrom)
Constructs a copy of a LatLonRectangle instance.

Parameters:
copyFrom - The rectangle to copy information from.
Since:
BlackBerry API 6.0.0


Method Detail

hashCode

public int hashCode()
Description copied from class: Object
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.hashCode()
Since:
BlackBerry API 6.0.0

equals

public boolean equals(Object obj)
Description copied from class: Object
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation:

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.equals(Object)
Since:
BlackBerry API 6.0.0

getTop

public double getTop()
Gets the coordinate of the top of the box.

Returns:
Coordinate for the top of the box.
Since:
BlackBerry API 6.0.0

setTop

public void setTop(double top)
Sets the coordinate of the top of the box.

Parameters:
top - The coordinate for the top of the box.
Since:
BlackBerry API 6.0.0

getBottom

public double getBottom()
Gets the coordinate of the bottom of the box.

Returns:
Coordinate for the bottom of the box.
Since:
BlackBerry API 6.0.0

setBottom

public void setBottom(double bottom)
Sets the coordinate of the bottom of the box.

Parameters:
bottom - The coordinate for the bottom of the box.
Since:
BlackBerry API 6.0.0

getLeft

public double getLeft()
Gets the coordinate of the left of the box.

Returns:
Coordinate for the left of the box.
Since:
BlackBerry API 6.0.0

setLeft

public void setLeft(double left)
Sets the coordinate of the left of the box.

Parameters:
left - The coordinate for the left of the box.
Since:
BlackBerry API 6.0.0

getRight

public double getRight()
Gets the coordinate of the right of the box.

Returns:
Coordinate for the right of the box.
Since:
BlackBerry API 6.0.0

setRight

public void setRight(double right)
Sets the coordinate of the right of the box.

Parameters:
right - The coordinate for the right of the box.
Since:
BlackBerry API 6.0.0

intersects

public boolean intersects(LatLonRectangle outerBox)
Determines if any part of this rectangle and the parameter share the same space.

Parameters:
outerBox - The rectangle to compare with this rectangle.
Returns:
true if any part of this rectangle intersects with the parameter, false otherwise.
Since:
BlackBerry API 6.0.0

contains

public boolean contains(LatLonRectangle other)
Determines if the given parameter is completely within this rectangle.

Note: if A contains B, then A intersects B.

Parameters:
other - The rectangle to compare against.
Returns:
true if the parameter is completely within this rectangle, false otherwise.
Since:
BlackBerry API 6.0.0

contains

public boolean contains(double lat,
                        double lon)
Determines if the specified point is within this rectangle.

Parameters:
lat - The latitude of a point.
lon - The longitude of a point.
Returns:
true if the point is within this rectangle, false otherwise.
Since:
BlackBerry API 6.0.0

getMidpoint

public MapPoint getMidpoint()
Gets the midpoint of the rectangle.

Returns:
The midpoint of the rectangle.
Since:
BlackBerry API 6.0.0

getHeight

public int getHeight()
Gets the height of this rectangle in degrees x 10^5.

Returns:
The height of the rectangle (in degrees x 10^5).
Since:
BlackBerry API 6.0.0

getWidth

public int getWidth()
Gets the width of this rectangle in degrees x 10^5.

Returns:
The width of the rectangle (in degrees x 10^5).
Since:
BlackBerry API 6.0.0

toString

public String toString()
Description copied from class: Object
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.
See Also:
Object.toString()
Since:
BlackBerry API 6.0.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.