Package org.openstreetmap.josm.data.osm
Class BBox
java.lang.Object
org.openstreetmap.josm.data.osm.BBox
- All Implemented Interfaces:
IBounds
- Direct Known Subclasses:
BBox.Immutable,QuadBuckets.QBLevel
A BBox represents an area in lat/lon space. It is used for the quad tree.
In contrast to a
Bounds object, a BBox can represent an invalid (empty) area.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBBox()Constructs a new (invalid) BBoxBBox(double x, double y) Constructs a newBBoxdefined 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 thatthis.bounds(ax,ay)andthis.bounds(bx,by)will both return trueCreate BBox for a given latlon.Constructs a newBBoxdefined by pointsaandb.Constructs a newBBoxfrom another one.Create BBox for a node.Create BBox for all nodes of the way with known coordinates. -
Method Summary
Modifier and TypeMethodDescriptionfinal voidadd(double x, double y) Extends this bbox to include the point (x, y)final voidAdd a point to an existing BBox.final voidAdd a point to an existing BBox.final voidExtends this bbox to include the bbox other.voidExtends this bbox to include the bbox of the primitive extended by extraSpace.voidaddPrimitive(IPrimitive primitive, double extraSpace) Extends this bbox to include the bbox of the primitive extended by extraSpace.voidaddPrimitive(OsmPrimitive primitive, double extraSpace) Extends this bbox to include the bbox of the primitive extended by extraSpace.doublearea()Gets the area of the bbox.static booleanbboxesAreFunctionallyEqual(BBox bbox1, BBox bbox2, Double maxDifference) Check if bboxes are functionally equalbooleanbboxIsFunctionallyEqual(BBox other, Double maxDifference) Check if bboxes are functionally equalbooleanTests, whether the Pointclies within the bbox.booleanTests, whether the bboxblies completely inside this bbox.final booleanReturns the bottom-right point.doubleReturns the latitude of bottom-right point.doubleReturns the longitude of bottom-right point.Gets the center of this BBox.doubleReturns the bounds width.(package private) bytegetIndex(int level) doubleReturns max latitude of bounds.doubleReturns max longitude of bounds.doubleReturns min latitude of bounds.doubleReturns min longitude of bounds.Returns the top-left point.doubleReturns the latitude of top-left point.doubleReturns the longitude of top-left point.doublegetWidth()Returns the bounds width.final inthashCode()doubleheight()Gets the height of the bbox.booleanintersects(BBox b) Tests, whether two BBoxes intersect as an area.booleanDetermines if the bbox is valid and covers a part of the planet surface.booleanisValid()Determines if the bbox covers a part of the planet surface.protected voidset(double xmin, double xmax, double ymin, double ymax) Returns an immutable version of this bbox, i.e., modifying calls throw anUnsupportedOperationException.Converts the bounds to a rectangletoString()toStringCSV(String separator) Creates a CSV string for this bboxdoublewidth()Gets the width of the bbox.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openstreetmap.josm.data.IBounds
contains, contains, crosses180thMeridian, getArea, getMax, getMin, intersects
-
Field Details
-
xmin
-
xmax
-
ymin
-
ymax
-
-
Constructor Details
-
BBox
public BBox()Constructs a new (invalid) BBox -
BBox
Constructs a newBBoxdefined by a single point.- Parameters:
x- X coordinatey- Y coordinate- Since:
- 6203
-
BBox
Constructs a newBBoxdefined by pointsaandb. Result is minimal BBox containing both points if they are both valid, else undefined- Parameters:
a- first pointb- second point
-
BBox
Constructs a newBBoxfrom another one.- Parameters:
copy- the BBox to copy
-
BBox
Creates bbox around the coordinate (x, y). Coordinate defines center of bbox, its edge will be 2*r.- Parameters:
x- X coordinatey- Y coordinater- size- Since:
- 13140
-
BBox
Create minimal BBox so thatthis.bounds(ax,ay)andthis.bounds(bx,by)will both return true- Parameters:
ax- 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)
-
BBox
Create BBox for all nodes of the way with known coordinates. If no node has a known coordinate, an invalid BBox is returned.- Parameters:
w- the way
-
BBox
Create BBox for a node. An invalid BBox is returned if the coordinates are not known.- Parameters:
n- the node
-
BBox
Create BBox for a given latlon. An invalid BBox is returned if the coordinates are not known.- Parameters:
ll- The lat lon position
-
-
Method Details
-
add
Add a point to an existing BBox. Extends this bbox if necessary so that this.bounds(c) will return true if c is a valid LatLon instance. Kept for binary compatibility- Parameters:
c- a LatLon point
-
add
Add a point to an existing BBox. Extends this bbox if necessary so that this.bounds(c) will return true if c is a valid LatLon instance. If it is invalid ornull, this call is ignored.- Parameters:
c- a LatLon point.
-
add
Extends this bbox to include the point (x, y)- Parameters:
x- X coordinatey- Y coordinate
-
add
Extends this bbox to include the bbox other. Does nothing if other is not valid.- Parameters:
other- a bbox
-
set
-
addPrimitive
Extends this bbox to include the bbox of the primitive extended by extraSpace.- Parameters:
primitive- an OSM primitiveextraSpace- the value to extend the primitives bbox. Unit is in LatLon degrees.
-
addPrimitive
Extends this bbox to include the bbox of the primitive extended by extraSpace.- Parameters:
primitive- an primitiveextraSpace- the value to extend the primitives bbox. Unit is in LatLon degrees.- Since:
- 17862
-
addLatLon
Extends this bbox to include the bbox of the primitive extended by extraSpace.- Parameters:
latLon- a LatLonextraSpace- the value to extend the primitives bbox. Unit is in LatLon degrees.- Since:
- 15877
-
height
Gets the height of the bbox.- Returns:
- The difference between ymax and ymin. 0 for invalid bboxes.
-
getHeight
Description copied from interface:IBoundsReturns the bounds width. -
width
Gets the width of the bbox.- Returns:
- The difference between xmax and xmin. 0 for invalid bboxes.
-
getWidth
Description copied from interface:IBoundsReturns the bounds width. -
area
Gets the area of the bbox. -
bounds
Tests, whether the bboxblies completely inside this bbox.- Parameters:
b- bounding box- Returns:
trueifblies completely inside this bbox
-
bounds
Tests, whether the Pointclies within the bbox.- Parameters:
c- point- Returns:
trueifclies within the bbox
-
intersects
Tests, whether two BBoxes intersect as an area. I.e. whether there exists a point that lies in both of them.- Parameters:
b- other bounding box- Returns:
trueif this bbox intersects with the other
-
getTopLeft
Returns the top-left point.- Returns:
- The top-left point
-
getTopLeftLat
Returns the latitude of top-left point.- Returns:
- The latitude of top-left point
- Since:
- 6203
-
getMaxLat
Description copied from interface:IBoundsReturns max latitude of bounds. Efficient shortcut forgetMax().lat(). -
getTopLeftLon
Returns the longitude of top-left point.- Returns:
- The longitude of top-left point
- Since:
- 6203
-
getMinLon
Description copied from interface:IBoundsReturns min longitude of bounds. Efficient shortcut forgetMin().lon(). -
getBottomRight
Returns the bottom-right point.- Returns:
- The bottom-right point
-
getBottomRightLat
Returns the latitude of bottom-right point.- Returns:
- The latitude of bottom-right point
- Since:
- 6203
-
getMinLat
Description copied from interface:IBoundsReturns min latitude of bounds. Efficient shortcut forgetMin().lat(). -
getBottomRightLon
Returns the longitude of bottom-right point.- Returns:
- The longitude of bottom-right point
- Since:
- 6203
-
getMaxLon
Description copied from interface:IBoundsReturns max longitude of bounds. Efficient shortcut forgetMax().lon(). -
getCenter
Gets the center of this BBox. -
getIndex
-
toRectangle
Converts the bounds to a rectangle- Returns:
- The rectangle in east/north space.
-
hashCode
-
equals
-
bboxIsFunctionallyEqual
Check if bboxes are functionally equal- Parameters:
other- The other bbox to compare withmaxDifference- The maximum difference (in degrees) between the bboxes. May be null.- Returns:
- true if they are functionally equivalent
- Since:
- 15486
-
bboxesAreFunctionallyEqual
Check if bboxes are functionally equal- Parameters:
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.- Returns:
- true if they are functionally equivalent
- Since:
- 15483
-
isValid
Determines if the bbox covers a part of the planet surface. -
isInWorld
Determines if the bbox is valid and covers a part of the planet surface.- Returns:
- true if the bbox is valid and covers a part of the planet surface
- Since:
- 11269
-
toString
-
toStringCSV
Creates a CSV string for this bbox- Parameters:
separator- The separator to use- Returns:
- A string
-
toImmutable
Returns an immutable version of this bbox, i.e., modifying calls throw anUnsupportedOperationException.- Returns:
- an immutable version of this bbox
- Since:
- 17862 (interface)
-