OpenSpace.MapBounds

Instances of this class represent bounding boxes.  Data stored as left, bottom, right, top floats.  All values are initialized to null, however, you should make sure you set them before using the bounds for anything.

Possible use case

bounds = new OpenSpace.MapBounds();
bounds.extend(new OpenSpace.MapPoint(40,50));
bounds.extend(new OpenSpace.MapPoint(50,60));
bounds.toBBOX(); // returns 40,50,50,60

Inherits

  • <OpenLayers.Bounds>
Summary
OpenSpace.MapBoundsInstances of this class represent bounding boxes.
Properties
srs{Number} The spatial reference system
Constructor
OpenSpace.MapBoundsConstruct a new map bounds object.
Functions
cloneCreate a cloned instance of this bounds.
equalsTest a two bounds for equivalence.
toString{String} String representation of bounds object.
toArray{Array} array of left, bottom, right, top
toBBOX
getWidth{Float} The width of the bounds
getHeight{Float} The height of the bounds (top minus bottom).
getSize{OpenSpace.MapSize} The size of the box.
getCenterLonLat{OpenSpace.MapPoint} The center of the bounds in map space.
add
extendExtend the bounds to include the point, map point, or bounds specified.
containsLonLat
contains
intersectsBounds
containsBounds
determineQuadrant
oppositeQuadrantGet the opposite quadrant for a given quadrant string.

Properties

srs

{Number} The spatial reference system

Constructor

OpenSpace.MapBounds

Construct a new map bounds object.

Parameters

left{Float} The left bounds of the box.  Note that for width calculations, this is assumed to be less than the right value.
bottom{Float} The bottom bounds of the box.  Note that for height calculations, this is assumed to be more than the top value.
right{Float} The right bounds.
top{Float} The top bounds.

Functions

clone

clone:function()

Create a cloned instance of this bounds.

Returns

{OpenSpace.MapBounds} A fresh copy of the bounds

equals

equals:function(bounds)

Test a two bounds for equivalence.

Parameters

bounds{OpenSpace.MapBounds}

Returns

{Boolean} The passed-in bounds object has the same left, right, top, bottom components as this.  Note that if bounds passed in is null, returns false.

toString

toString:function()

Returns

{String} String representation of bounds object.  (ex.<i>”left-bottom=(5,42) right-top=(10,45)”</i>)

toArray

toArray: function()

Returns

{Array} array of left, bottom, right, top

toBBOX

toBBOX:function(decimal)

Parameters

decimal{Integer} How many significant digits in the bbox coords?  Default is 6

Returns

{String} Simple String representation of bounds object.  (ex.  <i>”5,42,10,45”</i>)

getWidth

getWidth:function()

Returns

{Float} The width of the bounds

getHeight

getHeight:function()

Returns

{Float} The height of the bounds (top minus bottom).

getSize

getSize:function()

Returns

{OpenSpace.MapSize} The size of the box.

getCenterLonLat

Returns

{OpenSpace.MapPoint} The center of the bounds in map space.

add

add:function(x,
y)

Parameters

x{Float}
y{Float}

Returns

{OpenSpace.MapBounds} A new bounds whose coordinates are the same as this, but shifted by the passed-in x and y values.

extend

extend:function(object)

Extend the bounds to include the point, map point, or bounds specified.  Note, this function assumes that left < right and bottom < top.

Parameters

object{Object} Can be MapPoint, Point, or Bounds

containsLonLat

containsLonLat:function(ll,
inclusive)

Parameters

ll{OpenSpace.MapPoint}
inclusive{Boolean} Whether or not to include the border.  Default is true.

Returns

{Boolean} The passed-in lonlat is within this bounds.

contains

contains:function(x,
y,
inclusive)

Parameters

x{Float}
y{Float}
inclusive{Boolean} Whether or not to include the border.  Default is true.

Returns

{Boolean} Whether or not the passed-in coordinates are within this bounds.

intersectsBounds

intersectsBounds:function(bounds,
inclusive)

Parameters

bounds{<OpenLayers.Bounds>}
inclusive{<Boolean>} Whether or not to include the border.  Default is true.

Returns

{Boolean} The passed-in OpenLayers.Bounds object intersects this bounds.  Simple math just check if either contains the other, allowing for partial.

containsBounds

containsBounds:function(bounds,
partial,
inclusive)
bounds{<OpenLayers.Bounds>}
partial{<Boolean>} If true, only part of passed-in bounds needs be within this bounds.  If false, the entire passed-in bounds must be within.  Default is false
inclusive{<Boolean>} Whether or not to include the border.  Default is true.

Returns

{Boolean} The passed-in bounds object is contained within this bounds.

determineQuadrant

determineQuadrant: function(lonlat)

Parameters

lonlat{<OpenLayers.LonLat>}

Returns

{String} The quadrant (“br” “tr” “tl” “bl”) of the bounds in which the coordinate lies.

oppositeQuadrant

OpenSpace.MapBounds.oppositeQuadrant = function(quadrant)

Get the opposite quadrant for a given quadrant string.

Parameters

quadrant{String} two character quadrant shortstring

Returns

{String} The opposing quadrant (“br” “tr” “tl” “bl”).  For Example, if you pass in “bl” it returns “tr”, if you pass in “br” it returns “tl”, etc.

clone:function()
Create a cloned instance of this bounds.
equals:function(bounds)
Test a two bounds for equivalence.
toString:function()
{String} String representation of bounds object.
toArray: function()
{Array} array of left, bottom, right, top
toBBOX:function(decimal)
getWidth:function()
{Float} The width of the bounds
getHeight:function()
{Float} The height of the bounds (top minus bottom).
getSize:function()
{OpenSpace.MapSize} The size of the box.
Instances of this class represent a width/height pair in map units
This class represents an eastings and northings pair of coordinates in British National Grid (BNG) format
add:function(x,
y)
extend:function(object)
Extend the bounds to include the point, map point, or bounds specified.
containsLonLat:function(ll,
inclusive)
contains:function(x,
y,
inclusive)
intersectsBounds:function(bounds,
inclusive)
containsBounds:function(bounds,
partial,
inclusive)
determineQuadrant: function(lonlat)
OpenSpace.MapBounds.oppositeQuadrant = function(quadrant)
Get the opposite quadrant for a given quadrant string.
Construct a new map bounds object.
Close