EMAPI.Bounds

This class instances represent rectangles limiting a map.

Examples of use

bounds = new EMAPI.Bounds();
bounds.extend(new EMAPI.LonLat(4,5));
bounds.extend(new EMAPI.LonLat(5,6));
bounds.toBBOX(); // returns 4,5,5,6
Summary
EMAPI.BoundsThis class instances represent rectangles limiting a map.
Properties
left{Float} Smaller horizontal coordinate.
bottom{Float} Smaller vertical coordinate.
right{Float} Bigger horizontal coordinate.
top{Float} Bigger vertical coordinate.
Functions
EMAPI.BoundsConstructs a new object of EMAPI.Bounds class.
cloneCreates a copy of a rectangle.
equalsCompares two rectangles, the current one with the one passed in a parameter.
toStringReturns the rectangle coordinates in a text form.
toArrayReturns the rectangle’s coordinates as an array.
toBBOXReturns the rectangle coordinates in the simplified text form.
getWidthReturns the width of the rectangle.
getHeightReturns the height of the rectangle.
getSizeReturns the size of the rectangle.
getCenterPixelReturns the screen center of the rectangle.
getCenterLonLatReturns the geographical point of the rectangle.
addCreates a copy of the rectangle with the shifted coordinates.
extendExtends the rectangle if it’s necessary to contain chosen point or another rectangle.
containsLonLatChecks whether a geographic point is contained in a rectangle.
containsPixelChecks whether a screen point is contained in the rectangle.
containsChecks whether a point with the given coordinates is contained in the rectangle.
intersectsBoundsChecks whether any other rectangle has any part common with current rectangle.
containsBoundsChecks whether another rectangle is contained in the rectangle.
determineQuadrantDetermines in which part of a rectangle a geographical point is located.
fromStringAn alternative method constructing EMAPI.Bounds class objects basing on coordinates in a text form.
fromArrayAn alternative method constructing EMAPI.Bounds class objects basing on coordinates array.
fromSizeAn alternative method constructing EMAPI.Bounds> class objects basing on EMAPI.Size object.

Properties

left

{Float} Smaller horizontal coordinate.

bottom

{Float} Smaller vertical coordinate.

right

{Float} Bigger horizontal coordinate.

top

{Float} Bigger vertical coordinate.

Functions

EMAPI.Bounds

Constructs a new object of EMAPI.Bounds class.

Parameters

left{Float} The left rectangle limit.  It should be less than the right one.
bottom{Float} Bottom rectangle limit.  It should be larger than upper one.
right{Float} The right rectangle limit.
top{Float} Top rectangle limit.

clone

clone:function()

Creates a copy of a rectangle.

Result

{EMAPI.Bounds} New EMAPI.Bounds object with the same coordinates.

equals

equals:function(bounds)

Compares two rectangles, the current one with the one passed in a parameter.

Parameters

bounds{EMAPI.Bounds} A rectangle to compare with the current.

Result

{Boolean} The information if the rectangles are the same.

toString

toString:function()

Returns the rectangle coordinates in a text form.

Result

{String} Textual representation of the rectangle (i.a.  “left-bottom=(5,42) right-top=(10,45)”).

toArray

toArray: function()

Returns the rectangle’s coordinates as an array.

Result

{Array(Float)} An array contain the coordinates in order [left, bottom, right, top].

toBBOX

toBBOX:function(decimal)

Returns the rectangle coordinates in the simplified text form.

Parameters

decimal{Integer} Number of significant digits in the returned coordinates (by default 6)

Result

{String} Shortened text representation of EMAPI.Bounds object (i.a.  “5,42,10,45”).

getWidth

getWidth:function()

Returns the width of the rectangle.

Result

{Float} The width of the rectangle.

getHeight

getHeight:function()

Returns the height of the rectangle.

Result

{Float} The height of the rectangle.

getSize

getSize:function()

Returns the size of the rectangle.

Result

{EMAPI.Size} Size of a rectangle in a form of EMAPI.Size class object.

getCenterPixel

getCenterPixel:function()

Returns the screen center of the rectangle.

Result

{EMAPI.Pixel} Screen center point of the rectangle.

getCenterLonLat

getCenterLonLat:function()

Returns the geographical point of the rectangle.

Result

{EMAPI.LonLat} The geographic midpoint of the rectangle.

add

add:function(x,
y)

Creates a copy of the rectangle with the shifted coordinates.

x{Float} Horizontal shift.  Parameters:
y{Float} Vertical shift.

Result

{EMAPI.Bounds} New shifted EMAPI.Bounds object.

extend

extend:function(object)

Extends the rectangle if it’s necessary to contain chosen point or another rectangle.

Parameters

object{EMAPI.LonLat or EMAPI.Bounds} Object must be contained in the new rectangle.

containsLonLat

containsLonLat:function(ll,
inclusive)

Checks whether a geographic point is contained in a rectangle.

Parameters

ll{EMAPI.LonLat} The geographical point.
inclusive{Boolean} Information if take into consideration the edge of the rectangle (by default true).

Result

{Boolean} Information about including the point into the rectangle.

containsPixel

containsPixel:function(px,
inclusive)

Checks whether a screen point is contained in the rectangle.

Parameters

px{EMAPI.Pixel} The screen point.
inclusive{Boolean} Information if take into consideration the edge of the rectangle (by default true).

Result

{Boolean} Information about including the point into the rectangle.

contains

contains:function(x,
y,
inclusive)

Checks whether a point with the given coordinates is contained in the rectangle.

Parameters

x{Float} Coordinate x.
y{Float} Coordinate y.
inclusive{Boolean} Information if take into consideration the edge of the rectangle (by default true).

Result

{Boolean} Information about including the point into the rectangle.

intersectsBounds

intersectsBounds:function(bounds,
inclusive)

Checks whether any other rectangle has any part common with current rectangle.

Parameters

bounds{EMAPI.Bounds} The rectangle’s data checked.
inclusive{Boolean} Information if take into consideration the edge of the rectangle (by default true).

Result

{Boolean} Information about overlapping of rectangles.

containsBounds

containsBounds:function(bounds,
partial,
inclusive)

Checks whether another rectangle is contained in the rectangle.

bounds{EMAPI.Bounds} The rectangle’s data checked.
partial{Boolean} Information if a whole rectangle must be contained in a chosen rectangle or only a part of it (by default false).
inclusive{Boolean} Information if take into consideration the edge of the rectangle (by default true).

Result

{Boolean} Information about including of rectangles.

determineQuadrant

determineQuadrant: function(lonlat)

Determines in which part of a rectangle a geographical point is located.

Parameters

lonlat{EMAPI.LonLat} The geographical point.

Result

{String} The part of the rectangle (“br”, “tr”, “tl”, “bl”), where the point contains.

fromString

E.Bounds.fromString = function(str)

An alternative method constructing EMAPI.Bounds class objects basing on coordinates in a text form.

Parameters

str{String} The rectangle’s coordinate values separated by a comma (i.a.  “5,42,10,45”).

Result

{EMAPI.Bounds} The new EMAPI.Bounds object based on the string that is passed in the parameter.

fromArray

E.Bounds.fromArray = function(bbox)

An alternative method constructing EMAPI.Bounds class objects basing on coordinates array.

Parameters

bbox{Array(Float)} The rectangle’s array coordinates (i.a.  [5,42,10,45]).

Result

{EMAPI.Bounds} Constructed a new EMAPI.Bounds object based on an array in parameter.

fromSize

E.Bounds.fromSize = function(size)

An alternative method constructing EMAPI.Bounds> class objects basing on EMAPI.Size object.

Parameters

size{EMAPI.Size} EMAPI.Size object to create a rectangle.

Result

{EMAPI.Bounds} Constructed a new EMAPI.Bounds object based on EMAPI.Size parameter.

clone:function()
Creates a copy of a rectangle.
equals:function(bounds)
Compares two rectangles, the current one with the one passed in a parameter.
toString:function()
Returns the rectangle coordinates in a text form.
toArray: function()
Returns the rectangle’s coordinates as an array.
toBBOX:function(decimal)
Returns the rectangle coordinates in the simplified text form.
getWidth:function()
Returns the width of the rectangle.
getHeight:function()
Returns the height of the rectangle.
getSize:function()
Returns the size of the rectangle.
getCenterPixel:function()
Returns the screen center of the rectangle.
getCenterLonLat:function()
Returns the geographical point of the rectangle.
add:function(x,
y)
Creates a copy of the rectangle with the shifted coordinates.
extend:function(object)
Extends the rectangle if it’s necessary to contain chosen point or another rectangle.
containsLonLat:function(ll,
inclusive)
Checks whether a geographic point is contained in a rectangle.
containsPixel:function(px,
inclusive)
Checks whether a screen point is contained in the rectangle.
contains:function(x,
y,
inclusive)
Checks whether a point with the given coordinates is contained in the rectangle.
intersectsBounds:function(bounds,
inclusive)
Checks whether any other rectangle has any part common with current rectangle.
containsBounds:function(bounds,
partial,
inclusive)
Checks whether another rectangle is contained in the rectangle.
determineQuadrant: function(lonlat)
Determines in which part of a rectangle a geographical point is located.
E.Bounds.fromString = function(str)
An alternative method constructing EMAPI.Bounds class objects basing on coordinates in a text form.
E.Bounds.fromArray = function(bbox)
An alternative method constructing EMAPI.Bounds class objects basing on coordinates array.
Constructs a new object of EMAPI.Bounds class.
E.Bounds.fromSize = function(size)
An alternative method constructing EMAPI.Bounds> class objects basing on EMAPI.Size object.
Instances of this class represent a pair of width / height.
A class representing the screen point.
A class representing the geographic coordinates in the form of latitude and longitude.
Close