org.openstreetmap.josm.data
Class Bounds

java.lang.Object
  extended by org.openstreetmap.josm.data.Bounds
Direct Known Subclasses:
ImageryInfo.ImageryBounds

public class Bounds
extends java.lang.Object

This is a simple data class for "rectangular" areas of the world, given in lat/lon min/max values. The values are rounded to LatLon.OSM_SERVER_PRECISION


Nested Class Summary
static class Bounds.ParseMethod
           
 
Field Summary
private  double maxLat
          The minimum and maximum coordinates.
private  double maxLon
          The minimum and maximum coordinates.
private  double minLat
          The minimum and maximum coordinates.
private  double minLon
          The minimum and maximum coordinates.
 
Constructor Summary
Bounds(Bounds other)
           
Bounds(double[] coords)
           
Bounds(double[] coords, boolean roundToOsmPrecision)
           
Bounds(double minlat, double minlon, double maxlat, double maxlon)
           
Bounds(double minlat, double minlon, double maxlat, double maxlon, boolean roundToOsmPrecision)
           
Bounds(LatLon b)
           
Bounds(LatLon b, boolean roundToOsmPrecision)
           
Bounds(LatLon center, double latExtent, double lonExtent)
          Creates new bounds around a coordinate pair center.
Bounds(LatLon min, LatLon max)
          Construct bounds out of two points
Bounds(LatLon min, LatLon max, boolean roundToOsmPrecision)
           
Bounds(java.awt.geom.Rectangle2D rect)
           
Bounds(java.lang.String asString, java.lang.String separator)
           
Bounds(java.lang.String asString, java.lang.String separator, Bounds.ParseMethod parseMethod)
           
Bounds(java.lang.String asString, java.lang.String separator, Bounds.ParseMethod parseMethod, boolean roundToOsmPrecision)
           
 
Method Summary
 java.awt.geom.Rectangle2D.Double asRect()
          Converts the lat/lon bounding box to an object of type Rectangle2D.Double
 boolean contains(LatLon ll)
          Is the given point within this bounds?
 boolean crosses180thMeridian()
          Determines if this Bounds object crosses the 180th Meridian.
 java.lang.String encodeAsString(java.lang.String separator)
           
 boolean equals(java.lang.Object obj)
           
 void extend(Bounds b)
           
 void extend(LatLon ll)
          Extend the bounds if necessary to include the given point.
 double getArea()
           
 LatLon getCenter()
           
 LatLon getMax()
           
 LatLon getMin()
           
 int hashCode()
           
protected static double initLat(double value, boolean roundToOsmPrecision)
           
protected static double initLon(double value, boolean roundToOsmPrecision)
           
 boolean intersects(Bounds b)
          The two bounds intersect? Compared to java Shape.intersects, if does not use the interior but the closure.
private static boolean intersectsLonCrossing(Bounds crossing, Bounds notCrossing)
           
 boolean isCollapsed()
          Replies true, if this bounds are collapsed, i.e.
 boolean isOutOfTheWorld()
           
 void normalize()
           
 java.lang.String toShortString(java.text.DecimalFormat format)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

minLat

private double minLat
The minimum and maximum coordinates.


minLon

private double minLon
The minimum and maximum coordinates.


maxLat

private double maxLat
The minimum and maximum coordinates.


maxLon

private double maxLon
The minimum and maximum coordinates.

Constructor Detail

Bounds

public Bounds(LatLon min,
              LatLon max)
Construct bounds out of two points


Bounds

public Bounds(LatLon min,
              LatLon max,
              boolean roundToOsmPrecision)

Bounds

public Bounds(LatLon b)

Bounds

public Bounds(LatLon b,
              boolean roundToOsmPrecision)

Bounds

public Bounds(double minlat,
              double minlon,
              double maxlat,
              double maxlon)

Bounds

public Bounds(double minlat,
              double minlon,
              double maxlat,
              double maxlon,
              boolean roundToOsmPrecision)

Bounds

public Bounds(double[] coords)

Bounds

public Bounds(double[] coords,
              boolean roundToOsmPrecision)

Bounds

public Bounds(java.lang.String asString,
              java.lang.String separator)
       throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

Bounds

public Bounds(java.lang.String asString,
              java.lang.String separator,
              Bounds.ParseMethod parseMethod)
       throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

Bounds

public Bounds(java.lang.String asString,
              java.lang.String separator,
              Bounds.ParseMethod parseMethod,
              boolean roundToOsmPrecision)
       throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

Bounds

public Bounds(Bounds other)

Bounds

public Bounds(java.awt.geom.Rectangle2D rect)

Bounds

public Bounds(LatLon center,
              double latExtent,
              double lonExtent)
Creates new bounds around a coordinate pair center. The new bounds shall have an extension in latitude direction of latExtent, and in longitude direction of lonExtent.

Parameters:
center - the center coordinate pair. Must not be null.
latExtent - the latitude extent. > 0 required.
lonExtent - the longitude extent. > 0 required.
Throws:
java.lang.IllegalArgumentException - thrown if center is null
java.lang.IllegalArgumentException - thrown if latExtent <= 0
java.lang.IllegalArgumentException - thrown if lonExtent <= 0
Method Detail

getMin

public LatLon getMin()

getMax

public LatLon getMax()

initLat

protected static double initLat(double value,
                                boolean roundToOsmPrecision)

initLon

protected static double initLon(double value,
                                boolean roundToOsmPrecision)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString(java.text.DecimalFormat format)

getCenter

public LatLon getCenter()
Returns:
Center of the bounding box.

extend

public void extend(LatLon ll)
Extend the bounds if necessary to include the given point.


extend

public void extend(Bounds b)

contains

public boolean contains(LatLon ll)
Is the given point within this bounds?


intersectsLonCrossing

private static boolean intersectsLonCrossing(Bounds crossing,
                                             Bounds notCrossing)

intersects

public boolean intersects(Bounds b)
The two bounds intersect? Compared to java Shape.intersects, if does not use the interior but the closure. (">=" instead of ">")


crosses180thMeridian

public boolean crosses180thMeridian()
Determines if this Bounds object crosses the 180th Meridian. See http://wiki.openstreetmap.org/wiki/180th_meridian

Returns:
true if this Bounds object crosses the 180th Meridian.

asRect

public java.awt.geom.Rectangle2D.Double asRect()
Converts the lat/lon bounding box to an object of type Rectangle2D.Double

Returns:
the bounding box to Rectangle2D.Double

getArea

public double getArea()

encodeAsString

public java.lang.String encodeAsString(java.lang.String separator)

isCollapsed

public boolean isCollapsed()

Replies true, if this bounds are collapsed, i.e. if the min and the max corner are equal.

Returns:
true, if this bounds are collapsed

isOutOfTheWorld

public boolean isOutOfTheWorld()

normalize

public void normalize()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


JOSM