public class BBox extends java.lang.Object
Bounds
object, a BBox can represent an invalid (empty) area.Modifier and Type | Field and Description |
---|---|
protected double |
xmax |
protected double |
xmin |
protected double |
ymax |
protected double |
ymin |
Constructor and Description |
---|
BBox()
Constructs a new (invalid) BBox
|
BBox(BBox copy)
Constructs a new
BBox from another one. |
BBox(double x,
double y)
Constructs a new
BBox defined by a single point. |
BBox(double x,
double y,
double r)
Creates bbox around the coordinate (x, y).
|
BBox(double ax,
double ay,
double bx,
double by)
Create minimal BBox so that
this.bounds(ax,ay) and this.bounds(bx,by) will both return true |
BBox(ILatLon ll)
Create BBox for a given latlon.
|
BBox(INode n)
Create BBox for a node.
|
BBox(IWay<?> w)
Create BBox for all nodes of the way with known coordinates.
|
BBox(LatLon a,
LatLon b)
Constructs a new
BBox defined by points a and b . |
Modifier and Type | Method and Description |
---|---|
void |
add(BBox other)
Extends this bbox to include the bbox other.
|
void |
add(double x,
double y)
Extends this bbox to include the point (x, y)
|
void |
add(ILatLon c)
Add a point to an existing BBox.
|
void |
add(LatLon c)
Add a point to an existing BBox.
|
void |
addPrimitive(OsmPrimitive primitive,
double extraSpace)
Extends this bbox to include the bbox of the primitive extended by extraSpace.
|
static boolean |
bboxesAreFunctionallyEqual(BBox bbox1,
BBox bbox2,
java.lang.Double maxDifference)
Check if bboxes are functionally equal
|
boolean |
bboxIsFunctionallyEqual(BBox other,
java.lang.Double maxDifference)
Check if bboxes are functionally equal
|
boolean |
bounds(BBox b)
Tests, whether the bbox
b lies completely inside this bbox. |
boolean |
bounds(LatLon c)
Tests, whether the Point
c lies within the bbox. |
boolean |
equals(java.lang.Object o) |
LatLon |
getBottomRight()
Returns the bottom-right point.
|
double |
getBottomRightLat()
Returns the latitude of bottom-right point.
|
double |
getBottomRightLon()
Returns the longitude of bottom-right point.
|
LatLon |
getCenter()
Gets the center of this BBox.
|
(package private) byte |
getIndex(int level) |
LatLon |
getTopLeft()
Returns the top-left point.
|
double |
getTopLeftLat()
Returns the latitude of top-left point.
|
double |
getTopLeftLon()
Returns the longitude of top-left point.
|
int |
hashCode() |
double |
height()
Gets the height of the bbox.
|
boolean |
intersects(BBox b)
Tests, whether two BBoxes intersect as an area.
|
boolean |
isInWorld() |
boolean |
isValid() |
java.awt.geom.Rectangle2D |
toRectangle()
Converts the bounds to a rectangle
|
java.lang.String |
toString() |
java.lang.String |
toStringCSV(java.lang.String separator)
Creates a CSV string for this bbox
|
double |
width()
Gets the width of the bbox.
|
protected double xmin
protected double xmax
protected double ymin
protected double ymax
public BBox()
public BBox(double x, double y)
BBox
defined by a single point.x
- X coordinatey
- Y coordinatepublic BBox(LatLon a, LatLon b)
BBox
defined by points a
and b
.
Result is minimal BBox containing both points if they are both valid, else undefineda
- first pointb
- second pointpublic BBox(BBox copy)
BBox
from another one.copy
- the BBox to copypublic BBox(double x, double y, double r)
x
- X coordinatey
- Y coordinater
- sizepublic BBox(double ax, double ay, double bx, double by)
this.bounds(ax,ay)
and this.bounds(bx,by)
will both return trueax
- left or right X value (-180 .. 180)ay
- top or bottom Y value (-90 .. 90)bx
- left or right X value (-180 .. 180)by
- top or bottom Y value (-90 .. 90)public BBox(IWay<?> w)
w
- the waypublic BBox(INode n)
n
- the nodepublic final void add(LatLon c)
c
- a LatLon pointpublic final void add(ILatLon c)
null
, this call is ignored.c
- a LatLon point.public final void add(double x, double y)
x
- X coordinatey
- Y coordinatepublic final void add(BBox other)
other
- a bboxpublic void addPrimitive(OsmPrimitive primitive, double extraSpace)
primitive
- an OSM primitiveextraSpace
- the value to extend the primitives bbox. Unit is in LatLon degrees.public double height()
public double width()
public boolean bounds(BBox b)
b
lies completely inside this bbox.b
- bounding boxtrue
if b
lies completely inside this bboxpublic boolean bounds(LatLon c)
c
lies within the bbox.c
- pointtrue
if c
lies within the bboxpublic boolean intersects(BBox b)
b
- other bounding boxtrue
if this bbox intersects with the otherpublic LatLon getTopLeft()
public double getTopLeftLat()
public double getTopLeftLon()
public LatLon getBottomRight()
public double getBottomRightLat()
public double getBottomRightLon()
byte getIndex(int level)
public java.awt.geom.Rectangle2D toRectangle()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public boolean bboxIsFunctionallyEqual(BBox other, java.lang.Double maxDifference)
other
- The other bbox to compare withmaxDifference
- The maximum difference (in degrees) between the bboxes. May be null.public static boolean bboxesAreFunctionallyEqual(BBox bbox1, BBox bbox2, java.lang.Double maxDifference)
bbox1
- A bbox to compare with another bboxbbox2
- The other bbox to compare withmaxDifference
- The maximum difference (in degrees) between the bboxes. May be null.public boolean isValid()
public boolean isInWorld()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toStringCSV(java.lang.String separator)
separator
- The separator to use