com.mapquest.android.maps
Class BoundingBox

java.lang.Object
  extended by com.mapquest.android.maps.BoundingBox

public class BoundingBox
extends java.lang.Object

Simple rectangle object based on geo-coordinates Useful for determining geographical intersections, for example, determining whether a GeoPoint is within a geographical rectangle by using the static methods contains(GeoPoint)


Field Summary
 GeoPoint lr
           
 GeoPoint ul
           
 
Constructor Summary
BoundingBox()
          Initialize an empty Bounding Box You will have to manually set the ul and lr values for this to be a proper BoundingBox
BoundingBox(GeoPoint ul, GeoPoint lr)
          Initialize a Bounding Box
 
Method Summary
static BoundingBox calculateBoundingBoxGeoPoint(java.util.List<GeoPoint> locations)
          Helper method that given a List of GeoPoints, provides the smallest bounding box that contains all of them
 boolean contains(BoundingBox bbox)
          Convenience method to determine if the supplied bounding box is entirely contained within this bounding box
 boolean contains(GeoPoint gp)
          Convenience method to determine if the supplied lat/lng is entirely contained within
 GeoPoint getCenter()
           
static boolean intersect(BoundingBox b1, BoundingBox b2)
          Helper method to determine if two bounding boxes' areas intersect each other at any point
 java.lang.String toString()
          Helper method to output the values of the bounding box in the format:
ul lat, ul lng, lr lat, lr lng
 java.lang.String toString(boolean latFirst)
          Helper method to output the values of the bounding box
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ul

public GeoPoint ul

lr

public GeoPoint lr
Constructor Detail

BoundingBox

public BoundingBox()
Initialize an empty Bounding Box You will have to manually set the ul and lr values for this to be a proper BoundingBox


BoundingBox

public BoundingBox(GeoPoint ul,
                   GeoPoint lr)
Initialize a Bounding Box

Parameters:
ul - the upper-left GeoPoint of this bounding box
lr - the lower-right GeoPoint of this bounding box
Method Detail

getCenter

public GeoPoint getCenter()
Returns:
center point, or null if ul or ur are null

contains

public boolean contains(BoundingBox bbox)
Convenience method to determine if the supplied bounding box is entirely contained within this bounding box

Parameters:
bbox -
Returns:
true if bounding box contains the supplied bounding box

contains

public boolean contains(GeoPoint gp)
Convenience method to determine if the supplied lat/lng is entirely contained within

Parameters:
gp -
Returns:
true if the bounding box contains the supplied GeoPoint

toString

public java.lang.String toString(boolean latFirst)
Helper method to output the values of the bounding box

Parameters:
latFirst - if true, the format is:
ul lat, ul lng, lr lat, lr lng
if false, the format is:
ul lng, ul lat, lr lng, lr lat

toString

public java.lang.String toString()
Helper method to output the values of the bounding box in the format:
ul lat, ul lng, lr lat, lr lng

Overrides:
toString in class java.lang.Object

intersect

public static boolean intersect(BoundingBox b1,
                                BoundingBox b2)
Helper method to determine if two bounding boxes' areas intersect each other at any point

Parameters:
b1 - first bounding box
b2 - second bounding box
Returns:
true if bounding boxes intersect each other

calculateBoundingBoxGeoPoint

public static BoundingBox calculateBoundingBoxGeoPoint(java.util.List<GeoPoint> locations)
Helper method that given a List of GeoPoints, provides the smallest bounding box that contains all of them

Parameters:
locations - List of GeoPoints to construct bounding box
Returns:
smallest BoundingBox that contains all provided GeoPoints