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 booleancontains(EastNorth en)Check, if a point is within the bounds.voidextend(EastNorth e)Extends bounds to include pointe.voidextend(ProjectionBounds b)Extends bounds to include boundsb.EastNorthgetCenter()Returns the center east/north.private doublegetDeltaEast()private doublegetDeltaNorth()EastNorthgetMax()Returns the max east/north.EastNorthgetMin()Returns the min east/north.doublegetScale(int width, int height)Computes the scale of this bounds with respect to the given width/height.booleanhasExtend()Determines if the bounds area is not nullbooleanintersects(ProjectionBounds b)The two bounds intersect? Compared to java Shape.intersects, if does not use the interior but the closure.java.lang.StringtoString()
-
-
-
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 theProjectionBoundsinstance and make it valid.Uninitialized
ProjectionBoundsmust 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:
toStringin 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:
trueif 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
enis within the bounds
-
hasExtend
public boolean hasExtend()
Determines if the bounds area is not null- Returns:
trueif 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()
-
-