Package org.openstreetmap.josm.data
Class ProjectionBounds
- java.lang.Object
-
- org.openstreetmap.josm.data.ProjectionBounds
-
public class ProjectionBounds extends java.lang.Object
This is a simple data class for "rectangular" areas of the world, given in east/north min/max values.
-
-
Constructor Summary
Constructors Constructor Description ProjectionBounds()
Construct uninitialized bounds.ProjectionBounds(double minEast, double minNorth, double maxEast, double maxNorth)
Construct bounds out of two points.ProjectionBounds(EastNorth p)
Construct bounds out of a single point.ProjectionBounds(EastNorth center, double east, double north)
Construct bounds out of a center point and east/north dimensions.ProjectionBounds(EastNorth min, EastNorth max)
Construct bounds out of two points.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(EastNorth en)
Check, if a point is within the bounds.void
extend(EastNorth e)
Extends bounds to include pointe
.void
extend(ProjectionBounds b)
Extends bounds to include boundsb
.EastNorth
getCenter()
Returns the center east/north.private double
getDeltaEast()
private double
getDeltaNorth()
EastNorth
getMax()
Returns the max east/north.EastNorth
getMin()
Returns the min east/north.double
getScale(int width, int height)
Computes the scale of this bounds with respect to the given width/height.boolean
hasExtend()
Determines if the bounds area is not nullboolean
intersects(ProjectionBounds b)
The two bounds intersect? Compared to java Shape.intersects, if does not use the interior but the closure.java.lang.String
toString()
-
-
-
Constructor Detail
-
ProjectionBounds
public ProjectionBounds(EastNorth min, EastNorth max)
Construct bounds out of two points.- Parameters:
min
- min east/northmax
- max east/north
-
ProjectionBounds
public ProjectionBounds(EastNorth p)
Construct bounds out of a single point.- Parameters:
p
- east/north
-
ProjectionBounds
public ProjectionBounds(EastNorth center, double east, double north)
Construct bounds out of a center point and east/north dimensions.- Parameters:
center
- center east/northeast
- east dimensionnorth
- north dimension
-
ProjectionBounds
public ProjectionBounds(double minEast, double minNorth, double maxEast, double maxNorth)
Construct bounds out of two points.- Parameters:
minEast
- min eastminNorth
- min northmaxEast
- max eastmaxNorth
- max north
-
ProjectionBounds
public ProjectionBounds()
Construct uninitialized bounds.At least one call to
extend(EastNorth)
orextend(ProjectionBounds)
is required immediately after construction to initialize theProjectionBounds
instance and make it valid.Uninitialized
ProjectionBounds
must not be passed to other methods or used in any way other than initializing it.
-
-
Method Detail
-
extend
public void extend(EastNorth e)
Extends bounds to include pointe
.- Parameters:
e
- east/north to include
-
extend
public void extend(ProjectionBounds b)
Extends bounds to include boundsb
.- Parameters:
b
- bounds to include- Since:
- 11774
-
getCenter
public EastNorth getCenter()
Returns the center east/north.- Returns:
- the center east/north
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
intersects
public boolean intersects(ProjectionBounds b)
The two bounds intersect? Compared to java Shape.intersects, if does not use the interior but the closure. (">=" instead of ">")- Parameters:
b
- projection bounds- Returns:
true
if the two bounds intersect
-
contains
public boolean contains(EastNorth en)
Check, if a point is within the bounds.- Parameters:
en
- the point- Returns:
- true, if
en
is within the bounds
-
hasExtend
public boolean hasExtend()
Determines if the bounds area is not null- Returns:
true
if the area is not null
-
getScale
public double getScale(int width, int height)
Computes the scale of this bounds with respect to the given width/height.- Parameters:
width
- the widthheight
- the height- Returns:
- the computed scale
-
getDeltaNorth
private double getDeltaNorth()
-
getDeltaEast
private double getDeltaEast()
-
-