com.javadocmd.simplelatlng.window
Class RectangularWindow

java.lang.Object
  extended by com.javadocmd.simplelatlng.window.LatLngWindow<RectangularWindow>
      extended by com.javadocmd.simplelatlng.window.RectangularWindow

public class RectangularWindow
extends LatLngWindow<RectangularWindow>

A "pseudo-rectangular" window bounded by a minimum and maximum latitude and a minimum and maximum longitude. (The larger the window, the less rectangular this window actually is.) Naturally a window cannot span more than 180 degrees latitude or 360 degrees longitude.

Note: the latitude span provided when creating this window is not a guarantee. If you create a latitude whose center is (90, 0) (the geographic North Pole) and whose latitude span is 10 degrees, the resulting window has a maximum latitude of 90 and a minimum latitude of 85. Thus, windows are "squashed" if they hit the poles.

Author:
Tyler Coles

Constructor Summary
RectangularWindow(LatLng center, double deltaLat, double deltaLng)
          Creates a pseudo-rectangular window.
RectangularWindow(LatLng center, double width, double height, LengthUnit unit)
          Creates a psuedo-rectangular window.
RectangularWindow(LatLng center, double widthHeight, LengthUnit unit)
          Creates a psuedo-square window.
RectangularWindow(LatLng northeast, LatLng southwest)
          Creates a pseudo-rectangular window.
 
Method Summary
 boolean contains(LatLng point)
          Tests to see if the given point falls within this window.
 boolean crosses180thMeridian()
          If this window spans the 180 degree longitude meridian, this method returns true.
 LatLng getCenter()
          Returns the center point of the window.
 double getHeight(LengthUnit unit)
          Returns the height of the window.
 double getLatitudeDelta()
           
 double getLeftLongitude()
           
 double getLongitudeDelta()
           
 double getMaxLatitude()
           
 double getMinLatitude()
           
 double getRightLongitude()
           
 double getWidth(LengthUnit unit)
          Returns the width at the mid-line of the window.
 boolean overlaps(RectangularWindow window)
          Test if this window overlaps the given window.
 void setWindow(LatLng center, double deltaLat, double deltaLng)
          Sets the bounds of this window.
 String toString()
           
 
Methods inherited from class com.javadocmd.simplelatlng.window.LatLngWindow
filter, filterCopy, latitudeDeltaToLength, lengthToLatitudeDelta, lengthToLongitudeDelta, longitudeDeltaToLength
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RectangularWindow

public RectangularWindow(LatLng center,
                         double deltaLat,
                         double deltaLng)
Creates a pseudo-rectangular window.

Parameters:
center - the center point.
deltaLat - the span of the window in latitude in degrees.
deltaLng - the span of the window in longitude in degrees.

RectangularWindow

public RectangularWindow(LatLng northeast,
                         LatLng southwest)
Creates a pseudo-rectangular window. Note: this constructor must not be used with polar coordinates, where the notions of east and west are invalid.

Parameters:
northeast - the northeastern corner of this window.
southwest - the southwestern corner of this window.
Throws:
IllegalArgumentException - if either northeast or southwest are polar coordinates, also if the northeast point is south of the southwest point.

RectangularWindow

public RectangularWindow(LatLng center,
                         double width,
                         double height,
                         LengthUnit unit)
Creates a psuedo-rectangular window. The height will include the all latitudes within height/2 North and South, while the width will include all longitudes within width/2 East and West of the center point. This is an approximation that will work fine for small window away from the poles, but keep in mind that, for example in the northern hemisphere, the top of the rectangle is narrower than the bottom of the rectangle, with the middle of the rectangle's width being somewhere in between.

Parameters:
center - the center point of the window.
width - the approximate width of the window in LengthUnits.
height - the height of the window in LenghtUnits.
unit - the units for width and height.

RectangularWindow

public RectangularWindow(LatLng center,
                         double widthHeight,
                         LengthUnit unit)
Creates a psuedo-square window. This is a convenience method for creating a window with the same height and width as in RectangularWindow(LatLng, double, double, LengthUnit).

Parameters:
center - the center point of the window.
widthHeight - the approximate height and width of the window in LengthUnits.
unit - the units for widthHeight.
Method Detail

setWindow

public void setWindow(LatLng center,
                      double deltaLat,
                      double deltaLng)
Sets the bounds of this window.

Parameters:
center - the center point.
deltaLat - the span of the window in latitude in degrees.
deltaLng - the span of the window in longitude in degrees.

contains

public boolean contains(LatLng point)
Description copied from class: LatLngWindow
Tests to see if the given point falls within this window.

Specified by:
contains in class LatLngWindow<RectangularWindow>
Parameters:
point - the point to test.
Returns:
true if the window contains the point, false otherwise or if we cannot determine because the point is ill-defined.

overlaps

public boolean overlaps(RectangularWindow window)
Description copied from class: LatLngWindow
Test if this window overlaps the given window.

Specified by:
overlaps in class LatLngWindow<RectangularWindow>
Parameters:
window - the window to test against this one.
Returns:
true if the windows overlap.

getHeight

public double getHeight(LengthUnit unit)
Returns the height of the window.

Parameters:
unit - the length units to return.
Returns:
the height of the window in the desired units.

getWidth

public double getWidth(LengthUnit unit)
Returns the width at the mid-line of the window.

Parameters:
unit - the length units to return.
Returns:
the width of the window's mid-line in the desired units

getCenter

public LatLng getCenter()
Description copied from class: LatLngWindow
Returns the center point of the window.

Specified by:
getCenter in class LatLngWindow<RectangularWindow>
Returns:
the window's center point.

crosses180thMeridian

public boolean crosses180thMeridian()
If this window spans the 180 degree longitude meridian, this method returns true. Logic that uses this window in calculations may need to handle it specially. In this case, minLatitude is the negative-degree meridian and maxLatitude is the positive-degree meridian and the window should extend from both lines to the 180 degree meridian. So instead of testing whether a point lies between the min/max-longitude, you would have to test if a point lay outside the min/max-longitude.

Returns:
true if this window spans the 180th meridian.

getLatitudeDelta

public double getLatitudeDelta()

getLongitudeDelta

public double getLongitudeDelta()

getMinLatitude

public double getMinLatitude()

getMaxLatitude

public double getMaxLatitude()

getLeftLongitude

public double getLeftLongitude()

getRightLongitude

public double getRightLongitude()

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2013. All Rights Reserved.