public class Bounds extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Bounds.ParseMethod |
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) |
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) |
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(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) |
boolean |
equals(java.lang.Object obj) |
void |
extend(Bounds b) |
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() |
LatLon |
getCenter() |
LatLon |
getMax() |
double |
getMaxLat()
Returns max latitude of bounds.
|
double |
getMaxLon()
Returns max longitude of bounds.
|
LatLon |
getMin() |
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() |
void |
normalize() |
BBox |
toBBox()
Creates BBox with same coordinates.
|
java.lang.String |
toShortString(java.text.DecimalFormat format) |
java.lang.String |
toString() |
void |
visitEdge(Projection projection,
java.util.function.Consumer<LatLon> visitor)
Visit points along the edge of this bounds instance.
|
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)
public Bounds(java.lang.String asString, java.lang.String separator, Bounds.ParseMethod parseMethod)
public Bounds(java.lang.String asString, java.lang.String separator, Bounds.ParseMethod parseMethod, boolean roundToOsmPrecision)
public 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 double getMinLat()
getMin().lat()
.public double getMinLon()
getMin().lon()
.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)
public 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 boolean contains(LatLon ll)
ll
is within these bounds.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)
public 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 void visitEdge(Projection projection, java.util.function.Consumer<LatLon> visitor)
projection
- The projection that should be used to determine how often the edge should be split along a given corner.visitor
- A function to call for the points on the edge.public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object