public class Bounds extends java.lang.Object
to represent invalid areas.
Modifier and Type | Class and Description |
---|---|
static class |
Bounds.ParseMethod
The method used by the
Bounds(String, String, ParseMethod) constructor |
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
Bounds(Bounds other)
Creates new
Bounds from an existing one. |
Bounds(double... coords)
Constructs bounds out of two points.
|
Bounds(double[] coords,
boolean roundToOsmPrecision)
Constructs bounds out of two points.
|
Bounds(double lat,
double lon,
boolean roundToOsmPrecision)
Single point Bounds defined by point [lat,lon].
|
Bounds(double minlat,
double minlon,
double maxlat,
double maxlon)
Constructs bounds out of two points.
|
Bounds(double minlat,
double minlon,
double maxlat,
double maxlon,
boolean roundToOsmPrecision)
Constructs bounds out of two points.
|
Bounds(LatLon b)
Constructs bounds out a single point.
|
Bounds(LatLon b,
boolean roundToOsmPrecision)
Single point Bounds defined by lat/lon
b . |
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)
Constructs bounds out of two points.
|
Bounds(java.awt.geom.Rectangle2D rect)
Creates new
Bounds from a rectangle. |
Bounds(java.lang.String asString,
java.lang.String separator)
Parse the bounds in order
Bounds.ParseMethod.MINLAT_MINLON_MAXLAT_MAXLON |
Bounds(java.lang.String asString,
java.lang.String separator,
Bounds.ParseMethod parseMethod)
Parse the bounds from a given string and round to OSM precision
|
Bounds(java.lang.String asString,
java.lang.String separator,
Bounds.ParseMethod parseMethod,
boolean roundToOsmPrecision)
Parse the bounds from a given string
|
Modifier and Type | Method and Description |
---|---|
java.awt.geom.Rectangle2D.Double |
asRect()
Converts the lat/lon bounding box to an object of type Rectangle2D.Double
|
boolean |
contains(ILatLon ll)
Determines if the given point
ll is within these bounds. |
boolean |
contains(LatLon ll)
Determines if the given point
ll is within these bounds. |
boolean |
crosses180thMeridian()
Determines if this Bounds object crosses the 180th Meridian.
|
java.lang.String |
encodeAsString(java.lang.String separator)
Encodes this as a string so that it may be parsed using the
Bounds.ParseMethod.MINLAT_MINLON_MAXLAT_MAXLON order |
boolean |
equals(java.lang.Object obj) |
void |
extend(Bounds b)
Extends this bounds to enclose an other bounding box
|
void |
extend(double lat,
double lon)
Extend the bounds if necessary to include the given point [lat,lon].
|
void |
extend(LatLon ll)
Extend the bounds if necessary to include the given point.
|
double |
getArea()
Gets the area of this bounds (in lat/lon space)
|
LatLon |
getCenter() |
LatLon |
getMax()
Gets the point that has both the maximum lat and lon coordinate
|
double |
getMaxLat()
Returns max latitude of bounds.
|
double |
getMaxLon()
Returns max longitude of bounds.
|
LatLon |
getMin()
Gets the point that has both the minimal lat and lon coordinate
|
double |
getMinLat()
Returns min latitude of bounds.
|
double |
getMinLon()
Returns min longitude of bounds.
|
private double |
getWidth() |
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()
Determines if these bounds are out of the world.
|
void |
normalize()
Clamp the bounds to be inside the world.
|
BBox |
toBBox()
Creates BBox with same coordinates.
|
java.lang.String |
toShortString(java.text.DecimalFormat format)
Converts this bounds to a human readable short string
|
java.lang.String |
toString() |
private double minLat
private double minLon
private double maxLat
private double maxLon
public Bounds(LatLon min, LatLon max)
min
- min lat/lonmax
- max lat/lonpublic Bounds(LatLon min, LatLon max, boolean roundToOsmPrecision)
min
- min lat/lonmax
- max lat/lonroundToOsmPrecision
- defines if lat/lon will be roundedpublic Bounds(LatLon b)
b
- lat/lonpublic Bounds(LatLon b, boolean roundToOsmPrecision)
b
.
Coordinates will be rounded to osm precision if roundToOsmPrecision
is true.b
- lat/lon of given point.roundToOsmPrecision
- defines if lat/lon will be rounded.public Bounds(double lat, double lon, boolean roundToOsmPrecision)
roundToOsmPrecision
is true.lat
- latitude of given point.lon
- longitude of given point.roundToOsmPrecision
- defines if lat/lon will be rounded.public Bounds(double minlat, double minlon, double maxlat, double maxlon)
minlat
- min latminlon
- min lonmaxlat
- max latmaxlon
- max lonpublic Bounds(double minlat, double minlon, double maxlat, double maxlon, boolean roundToOsmPrecision)
minlat
- min latminlon
- min lonmaxlat
- max latmaxlon
- max lonroundToOsmPrecision
- defines if lat/lon will be roundedpublic Bounds(double... coords)
coords
- exactly 4 values: min lat, min lon, max lat, max lonjava.lang.IllegalArgumentException
- if coords does not contain 4 double valuespublic Bounds(double[] coords, boolean roundToOsmPrecision)
coords
- exactly 4 values: min lat, min lon, max lat, max lonroundToOsmPrecision
- defines if lat/lon will be roundedjava.lang.IllegalArgumentException
- if coords does not contain 4 double valuespublic Bounds(java.lang.String asString, java.lang.String separator)
Bounds.ParseMethod.MINLAT_MINLON_MAXLAT_MAXLON
asString
- The stringseparator
- The separation regexpublic Bounds(java.lang.String asString, java.lang.String separator, Bounds.ParseMethod parseMethod)
asString
- The stringseparator
- The separation regexparseMethod
- The order of the numberspublic Bounds(java.lang.String asString, java.lang.String separator, Bounds.ParseMethod parseMethod, boolean roundToOsmPrecision)
asString
- The stringseparator
- The separation regexparseMethod
- The order of the numbersroundToOsmPrecision
- Whether to round to OSM precisionpublic Bounds(Bounds other)
Bounds
from an existing one.other
- The bounds to copypublic Bounds(java.awt.geom.Rectangle2D rect)
Bounds
from a rectangle.rect
- The rectanglepublic Bounds(LatLon center, double latExtent, double lonExtent)
center
. The
new bounds shall have an extension in latitude direction of latExtent
,
and in longitude direction of lonExtent
.center
- the center coordinate pair. Must not be null.latExtent
- the latitude extent. > 0 required.lonExtent
- the longitude extent. > 0 required.java.lang.IllegalArgumentException
- if center is nulljava.lang.IllegalArgumentException
- if latExtent <= 0java.lang.IllegalArgumentException
- if lonExtent <= 0public LatLon getMin()
public double getMinLat()
getMin().lat()
.public double getMinLon()
getMin().lon()
.public LatLon getMax()
public double getMaxLat()
getMax().lat()
.public double getMaxLon()
getMax().lon()
.protected static double initLat(double value, boolean roundToOsmPrecision)
protected static double initLon(double value, boolean roundToOsmPrecision)
public BBox toBBox()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toShortString(java.text.DecimalFormat format)
format
- The number format to usepublic void extend(LatLon ll)
ll
- The point to include into these boundspublic void extend(double lat, double lon)
lat
- Latitude of point to include into these boundslon
- Longitude of point to include into these boundspublic void extend(Bounds b)
b
- The other bounds to enclosepublic boolean contains(LatLon ll)
ll
is within these bounds.
Points with unknown coordinates are always outside the coordinates.
ll
- The lat/lon to checktrue
if ll
is within these bounds, false
otherwisepublic boolean contains(ILatLon ll)
ll
is within these bounds.
Points with unknown coordinates are always outside the coordinates.
ll
- The lat/lon to checktrue
if ll
is within these bounds, false
otherwiseprivate static boolean intersectsLonCrossing(Bounds crossing, Bounds notCrossing)
public boolean intersects(Bounds b)
b
- other boundstrue
if the two bounds intersectpublic boolean crosses180thMeridian()
public java.awt.geom.Rectangle2D.Double asRect()
private double getWidth()
public double getArea()
public java.lang.String encodeAsString(java.lang.String separator)
Bounds.ParseMethod.MINLAT_MINLON_MAXLAT_MAXLON
orderseparator
- The separatorpublic boolean isCollapsed()
Replies true, if this bounds are collapsed, i.e. if the min and the max corner are equal.
public boolean isOutOfTheWorld()
public void normalize()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object