BoundingBox class

A GeoJSON BoundingBox object - an array that defines a shape whose edges follow lines of constant longitude, latitude, and elevation. All axes of the most southwesterly point are followed by all axes of the more northeasterly point. The axes order of the BoundingBox follows the axes order of geometries. The full description is detailed in RFC 7946.

Extends

Array<number>

Constructors

BoundingBox(number[])

Constructs a BoundingBox

BoundingBox(Position, Position)

Constructs a BoundingBox.

Properties

Array
length

Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.

Methods

concat(ConcatArray<number>[])

Combines two or more arrays.

concat(T | ConcatArray<T>[])

Combines two or more arrays.

containsPosition(BoundingBox, Position)

Determines if a position is within a bounding box.

crossesAntimeridian(BoundingBox)

Returns a boolean indicating if the bounding box crosses the antimeridian or not.

every((value: number, index: number, array: number[]) => unknown, any)

Determines whether all the members of an array satisfy the specified test.

filter((value: number, index: number, array: number[]) => unknown, any)

Returns the elements of an array that meet the condition specified in a callback function.

filter<S>((value: number, index: number, array: number[]) => boolean, any)

Returns the elements of an array that meet the condition specified in a callback function.

forEach((value: number, index: number, array: number[]) => void, any)

Performs the specified action for each element in an array.

fromBoundingBox(BoundingBox)

Clones a bounding box.

fromData(FeatureCollection | Feature<Geometry, any> | Geometry | Shape | Array<FeatureCollection | Feature<Geometry, any> | Geometry>)

Calculates the bounding box of a FeatureCollection, Feature, Geometry, Shape or array of these objects.

fromDimensions(Position, number, number)

Constructs a BoundingBox from the specified dimensions.

fromEdges(number, number, number, number)

Constructs a BoundingBox from the specified edges.

fromLatLngs(Array<object | number[]>)

Creates a BoundingBox from any array of objects that contain coordinate information. Each object is either an array in the format; [lat, lng] or [lat, lng, elv], or an object with the any combination of the following properties: Longitude: lng, longitude, lon, x Latitude: lat, latitude, y Elevation: elv, elevation, alt, altitude, z

fromPositions(Position[])

Creates a BoundingBox that contains all provided Position objects.

getCenter(BoundingBox)

Calculates the center of a bounding box.

getEast(BoundingBox)

Returns the east position value of the bounding box.

getHeight(BoundingBox)

Gets the height of a bounding box in degrees.

getNorth(BoundingBox)

Returns the north position value of the bounding box.

getNorthEast(BoundingBox)

Returns the north east position of the bounding box.

getNorthWest(BoundingBox)

Returns the north west position of the bounding box.

getSouth(BoundingBox)

Returns the south position value of the bounding box.

getSouthEast(BoundingBox)

Returns the south east position of the bounding box.

getSouthWest(BoundingBox)

Returns the south west position of the bounding box.

getWest(BoundingBox)

Returns the west position value of the bounding box.

getWidth(BoundingBox)

Gets the width of a bounding box in degrees.

indexOf(number, number)

Returns the index of the first occurrence of a value in an array.

intersect(BoundingBox, BoundingBox)

Determines is two bounding boxes intersect.

join(string)

Adds all the elements of an array separated by the specified separator string.

lastIndexOf(number, number)

Returns the index of the last occurrence of a specified value in an array.

map<U>((value: number, index: number, array: number[]) => U, any)

Calls a defined callback function on each element of an array, and returns an array that contains the results.

merge(BoundingBox, BoundingBox)

Merges two bounding boxes together.

pop()

Removes the last element from an array and returns it.

push(number[])

Appends new elements to an array, and returns the new length of the array.

reduce((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number)

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reduce((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, number)
reduce<U>((previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, U)

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reduceRight((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number)

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reduceRight((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, number)
reduceRight<U>((previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, U)

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reverse()

Reverses the elements in an Array.

shift()

Removes the first element from an array and returns it.

slice(number, number)

Returns a section of an array.

some((value: number, index: number, array: number[]) => unknown, any)

Determines whether the specified callback function returns true for any element of an array.

sort((a: number, b: number) => number)

Sorts an array.

splice(number, number)

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

splice(number, number, number[])

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

splitOnAntimeridian(BoundingBox)

Splits a BoundingBox that crosses the Antimeridian into two BoundingBox's. One entirely west of the Antimerdian and another entirely east of the Antimerdian.

toLocaleString()

Returns a string representation of an array. The elements are converted to string using their toLocalString methods.

toString()

Returns a string representation of an array.

unshift(number[])

Inserts new elements at the start of an array.

Constructor Details

BoundingBox(number[])

Constructs a BoundingBox

new BoundingBox(positions: number[])

Parameters

positions

number[]

Can be either [west, south, east, north] or [west, south, elevation1, east, north, elevation2]

BoundingBox(Position, Position)

Constructs a BoundingBox.

new BoundingBox(southwestPosition: Position, northeastPosition: Position)

Parameters

southwestPosition
Position

The southwestern most position of the bounding box.

northeastPosition
Position

The northeastern most position of the bounding box.

Property Details

Array

static Array: ArrayConstructor

Property Value

ArrayConstructor

length

Gets or sets the length of the array. This is a number one higher than the highest element defined in an array.

length: number

Property Value

number

Method Details

concat(ConcatArray<number>[])

Combines two or more arrays.

function concat(items: ConcatArray<number>[])

Parameters

items

ConcatArray<number>[]

Additional items to add to the end of array1.

Returns

number[]

concat(T | ConcatArray<T>[])

Combines two or more arrays.

function concat(items: T | ConcatArray<T>[])

Parameters

items

T | ConcatArray<T>[]

Additional items to add to the end of array1.

Returns

number[]

containsPosition(BoundingBox, Position)

Determines if a position is within a bounding box.

static function containsPosition(bounds: BoundingBox, position: Position)

Parameters

bounds
BoundingBox

The bounding box to see if the position is in.

position
Position

The position to see if it is in the bounding box.

Returns

boolean

True if the position is within the bounding box.

crossesAntimeridian(BoundingBox)

Returns a boolean indicating if the bounding box crosses the antimeridian or not.

static function crossesAntimeridian(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to check.

Returns

boolean

A boolean indicating if the bounding box crosses the antimeridian or not.

every((value: number, index: number, array: number[]) => unknown, any)

Determines whether all the members of an array satisfy the specified test.

function every(callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any)

Parameters

callbackfn

(value: number, index: number, array: number[]) => unknown

A function that accepts up to three arguments. The every method calls the callbackfn function for each element in array1 until the callbackfn returns false, or until the end of the array.

thisArg

any

An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

boolean

filter((value: number, index: number, array: number[]) => unknown, any)

Returns the elements of an array that meet the condition specified in a callback function.

function filter(callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any)

Parameters

callbackfn

(value: number, index: number, array: number[]) => unknown

A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.

thisArg

any

An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

number[]

filter<S>((value: number, index: number, array: number[]) => boolean, any)

Returns the elements of an array that meet the condition specified in a callback function.

function filter<S>(callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any)

Parameters

callbackfn

(value: number, index: number, array: number[]) => boolean

A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.

thisArg

any

An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

S[]

forEach((value: number, index: number, array: number[]) => void, any)

Performs the specified action for each element in an array.

function forEach(callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any)

Parameters

callbackfn

(value: number, index: number, array: number[]) => void

A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.

thisArg

any

An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

fromBoundingBox(BoundingBox)

Clones a bounding box.

static function fromBoundingBox(boundingBox: BoundingBox)

Parameters

boundingBox
BoundingBox

The bounding box to clone.

Returns

fromData(FeatureCollection | Feature<Geometry, any> | Geometry | Shape | Array<FeatureCollection | Feature<Geometry, any> | Geometry>)

Calculates the bounding box of a FeatureCollection, Feature, Geometry, Shape or array of these objects.

static function fromData(data: FeatureCollection | Feature<Geometry, any> | Geometry | Shape | Array<FeatureCollection | Feature<Geometry, any> | Geometry>)

Parameters

data

FeatureCollection | Feature<Geometry, any> | Geometry | Shape | Array<FeatureCollection | Feature<Geometry, any> | Geometry>

The FeatureCollection, Feature, Geometry, Shape or array of these objects to calculate the bounding box for.

Returns

A bounding box in the format [minLon, minLat, maxLon, maxLat].

fromDimensions(Position, number, number)

Constructs a BoundingBox from the specified dimensions.

static function fromDimensions(center: Position, width: number, height: number)

Parameters

center
Position

The center position of the bounding box.

width

number

The width of the bounding box.

height

number

The height of the bounding box.

Returns

fromEdges(number, number, number, number)

Constructs a BoundingBox from the specified edges.

static function fromEdges(west: number, south: number, east: number, north: number)

Parameters

west

number

The west edge of the bounding box.

south

number

The south edge of the bounding box.

east

number

The east edge of the bounding box.

north

number

The north edge of the bounding box.

Returns

fromLatLngs(Array<object | number[]>)

Creates a BoundingBox from any array of objects that contain coordinate information. Each object is either an array in the format; [lat, lng] or [lat, lng, elv], or an object with the any combination of the following properties: Longitude: lng, longitude, lon, x Latitude: lat, latitude, y Elevation: elv, elevation, alt, altitude, z

static function fromLatLngs(latLngs: Array<object | number[]>)

Parameters

latLngs

Array<object | number[]>

The objects that contain coordinate information.

Returns

A BoundingBox that contains all the provided coordinate information.

fromPositions(Position[])

Creates a BoundingBox that contains all provided Position objects.

static function fromPositions(positions: Position[])

Parameters

positions

Position[]

An array of locations to use to generate the bounding box.

Returns

A bounding box that contains all given positions.

getCenter(BoundingBox)

Calculates the center of a bounding box.

static function getCenter(bounds: BoundingBox)

Parameters

bounds
BoundingBox

A bounding box to calculate the center of.

Returns

A position that represents the center of the bounding box.

getEast(BoundingBox)

Returns the east position value of the bounding box.

static function getEast(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

number

The east position value of the bounding box.

getHeight(BoundingBox)

Gets the height of a bounding box in degrees.

static function getHeight(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to check.

Returns

number

The height of the bounding box in degrees.

getNorth(BoundingBox)

Returns the north position value of the bounding box.

static function getNorth(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

number

The north position value of the bounding box.

getNorthEast(BoundingBox)

Returns the north east position of the bounding box.

static function getNorthEast(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

The north east position of the bounding box.

getNorthWest(BoundingBox)

Returns the north west position of the bounding box.

static function getNorthWest(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

The north west position of the bounding box.

getSouth(BoundingBox)

Returns the south position value of the bounding box.

static function getSouth(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

number

The south position value of the bounding box.

getSouthEast(BoundingBox)

Returns the south east position of the bounding box.

static function getSouthEast(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

The south east position of the bounding box.

getSouthWest(BoundingBox)

Returns the south west position of the bounding box.

static function getSouthWest(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

The south west position of the bounding box.

getWest(BoundingBox)

Returns the west position value of the bounding box.

static function getWest(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to get the position from.

Returns

number

The west position value of the bounding box.

getWidth(BoundingBox)

Gets the width of a bounding box in degrees.

static function getWidth(bounds: BoundingBox)

Parameters

bounds
BoundingBox

The bounding box to check.

Returns

number

The width of the bounding box in degrees.

indexOf(number, number)

Returns the index of the first occurrence of a value in an array.

function indexOf(searchElement: number, fromIndex?: number)

Parameters

searchElement

number

The value to locate in the array.

fromIndex

number

The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.

Returns

number

intersect(BoundingBox, BoundingBox)

Determines is two bounding boxes intersect.

static function intersect(bounds1: BoundingBox, bounds2: BoundingBox)

Parameters

bounds1
BoundingBox

The first bounding box to compare with.

bounds2
BoundingBox

The second bounding box to compare with.

Returns

boolean

true if the provided bounding boxes intersect.

join(string)

Adds all the elements of an array separated by the specified separator string.

function join(separator?: string)

Parameters

separator

string

A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma.

Returns

string

lastIndexOf(number, number)

Returns the index of the last occurrence of a specified value in an array.

function lastIndexOf(searchElement: number, fromIndex?: number)

Parameters

searchElement

number

The value to locate in the array.

fromIndex

number

The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.

Returns

number

map<U>((value: number, index: number, array: number[]) => U, any)

Calls a defined callback function on each element of an array, and returns an array that contains the results.

function map<U>(callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any)

Parameters

callbackfn

(value: number, index: number, array: number[]) => U

A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

thisArg

any

An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

U[]

merge(BoundingBox, BoundingBox)

Merges two bounding boxes together.

static function merge(bounds1: BoundingBox, bounds2: BoundingBox)

Parameters

bounds1
BoundingBox

The first bounding box to merge with.

bounds2
BoundingBox

The second bounding box to merge with.

Returns

A bounding box in the format [minLon, minLat, maxLon, maxLat].

pop()

Removes the last element from an array and returns it.

function pop()

Returns

number | undefined

push(number[])

Appends new elements to an array, and returns the new length of the array.

function push(items: number[])

Parameters

items

number[]

New elements of the Array.

Returns

number

reduce((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number)

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

function reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number)

Parameters

callbackfn

(previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number

A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

Returns

number

reduce((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, number)

function reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number)

Parameters

callbackfn

(previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number

initialValue

number

Returns

number

reduce<U>((previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, U)

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

function reduce<U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U)

Parameters

callbackfn

(previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U

A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.

initialValue

U

If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

Returns

U

reduceRight((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number)

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

function reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number)

Parameters

callbackfn

(previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number

A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

Returns

number

reduceRight((previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, number)

function reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number, initialValue: number)

Parameters

callbackfn

(previousValue: number, currentValue: number, currentIndex: number, array: number[]) => number

initialValue

number

Returns

number

reduceRight<U>((previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, U)

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

function reduceRight<U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U, initialValue: U)

Parameters

callbackfn

(previousValue: U, currentValue: number, currentIndex: number, array: number[]) => U

A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.

initialValue

U

If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.

Returns

U

reverse()

Reverses the elements in an Array.

function reverse()

Returns

number[]

shift()

Removes the first element from an array and returns it.

function shift()

Returns

number | undefined

slice(number, number)

Returns a section of an array.

function slice(start?: number, end?: number)

Parameters

start

number

The beginning of the specified portion of the array.

end

number

The end of the specified portion of the array.

Returns

number[]

some((value: number, index: number, array: number[]) => unknown, any)

Determines whether the specified callback function returns true for any element of an array.

function some(callbackfn: (value: number, index: number, array: number[]) => unknown, thisArg?: any)

Parameters

callbackfn

(value: number, index: number, array: number[]) => unknown

A function that accepts up to three arguments. The some method calls the callbackfn function for each element in array1 until the callbackfn returns true, or until the end of the array.

thisArg

any

An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

Returns

boolean

sort((a: number, b: number) => number)

Sorts an array.

function sort(compareFn?: (a: number, b: number) => number)

Parameters

compareFn

(a: number, b: number) => number

The name of the function used to determine the order of the elements. If omitted, the elements are sorted in ascending, ASCII character order.

Returns

this

splice(number, number)

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

function splice(start: number, deleteCount?: number)

Parameters

start

number

The zero-based location in the array from which to start removing elements.

deleteCount

number

The number of elements to remove.

Returns

number[]

splice(number, number, number[])

Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.

function splice(start: number, deleteCount: number, items: number[])

Parameters

start

number

The zero-based location in the array from which to start removing elements.

deleteCount

number

The number of elements to remove.

items

number[]

Elements to insert into the array in place of the deleted elements.

Returns

number[]

splitOnAntimeridian(BoundingBox)

Splits a BoundingBox that crosses the Antimeridian into two BoundingBox's. One entirely west of the Antimerdian and another entirely east of the Antimerdian.

static function splitOnAntimeridian(bounds: BoundingBox)

Parameters

bounds
BoundingBox

Returns

toLocaleString()

Returns a string representation of an array. The elements are converted to string using their toLocalString methods.

function toLocaleString()

Returns

string

toString()

Returns a string representation of an array.

function toString()

Returns

string

unshift(number[])

Inserts new elements at the start of an array.

function unshift(items: number[])

Parameters

items

number[]

Elements to insert at the start of the Array.

Returns

number