Class: Rectangle

Rectangle

new Rectangle(west, south, east, north)

A two-dimensional area specified by latitude and longitude coordinates.

Name Type Default Description
west Number 0.0 optional

The westernmost longitude within the range of [- Pi, Pi], measured in radians

south Number 0.0 optional

The southernmost latitude, measured in radians, is within the range of [- Pi/2, Pi/2].

east Number 0.0 optional

The easternmost longitude within the range of [- Pi, Pi], measured in radians.

north Number 0.0 optional

The northernmost latitude, measured in radians, falls within the range of [- Pi/2, Pi/2].

See:
  • Packable

Members

(static, constant) MAX_VALUERectangle

The largest rectangle.

static packedLengthNumber

The number of elements used to package objects into an array.

eastNumber

The easternmost longitude in radians within the range of [- Pi, Pi].

Default Value:
0.0

heightNumber

Obtain the height of a rectangle in radians.

northNumber

The northernmost latitude in radians within the range of [- Pi/2, Pi/2].

Default Value:
0.0

southNumber

The southernmost latitude in radians within the range of [- Pi/2, Pi/2].

Default Value:
0.0

westNumber

The westernmost longitude in radians within the range of [- Pi, Pi].

Default Value:
0.0

widthNumber

Get the width of a rectangle in radians.

Methods

static center(rectangle, result){Cartographic}

Calculate the center point of the rectangle.

Name Type Description
rectangle Rectangle

Find the rectangle with the center point.

result Cartographic optional

The object that stores the results.

Returns:
Type Description
Cartographic The modified result parameters, or a new projection instance (if not provided).

static clone(rectangle, result){Rectangle}

Copy a rectangle.

Name Type Description
rectangle Rectangle

The rectangle to be copied.

result Rectangle optional

The object for storing results is undefined if a new instance needs to be created.

Returns:
Type Description
Rectangle If not provided, it will be the modified result parameter or a new Rectangle instance. (If the rectangle is undefined, return undefined)

static computeHeight(rectangle){Number}

Calculate the height of a rectangle in radians.

Name Type Description
rectangle Rectangle

A rectangle that requires height calculation.

Returns:
Type Description
Number Height.

static computeWidth(rectangle){Number}

Calculate the width of a rectangle in radians.

Name Type Description
rectangle Rectangle

A rectangle that requires width calculation.

Returns:
Type Description
Number Width.

static contains(rectangle, cartographic){Boolean}

If the map is projected onto or inside a rectangle, return true; Otherwise, return false.

Name Type Description
rectangle Rectangle

Rectangle.

cartographic Cartographic

The map projection to be tested.

Returns:
Type Description
Boolean If the provided map projection is inside a rectangle, it is true; Otherwise, it is false.

static equals(left, right){Boolean}

Compare the provided rectangles, return true if they are equal, otherwise return false.

Name Type Description
left Rectangle optional

The first rectangle.

right Rectangle optional

The second rectangle.

Returns:
Type Description
Boolean If two rectangles are equal, it is true; otherwise, it is false.

static equalsEpsilon(left, right, epsilon){Boolean}

Compare the provided rectangle with this rectangle, return true if they are within the provided epsilon range, otherwise return false.

Name Type Description
left Rectangle optional

The rectangle to be compared.

right Rectangle optional

Another rectangle to compare.

epsilon Number

Tolerance values used for equation testing.

Returns:
Type Description
Boolean If the rectangle is within the provided epsilon, it is true; otherwise, it is false.

static expand(rectangle, cartographic, result){Rectangle}

Calculate the rectangle by expanding it to include the provided map.

Name Type Description
rectangle Rectangle

The rectangle to be unfolded.

cartographic Cartographic

The map projection to be included within the rectangle.

result Rectangle optional

The object that stores the results.

Returns:
Type Description
Rectangle The modified result parameters, or a new rectangular instance (if not provided).

static fromCartesianArray(cartesians, ellipsoid, result){Rectangle}

Create the smallest rectangle that surrounds all positions in the provided array.

Name Type Default Description
cartesians Array.<Cartesian>

List of map projection instances.

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

The ellipsoid in which the Cartesian coordinate system is located.

result Rectangle optional

The object for storing results is undefined if a new instance needs to be created.

Returns:
Type Description
Rectangle The modified result parameters, or a new rectangular instance (if not provided).

static fromCartographicArray(cartographics, result){Rectangle}

Create the smallest rectangle that surrounds all positions in the provided array.

Name Type Description
cartographics Array.<Cartographic>

List of map projection instances.

result Rectangle optional

The object for storing results is undefined if a new instance needs to be created.

Returns:
Type Description
Rectangle The modified result parameters, or a new rectangular instance (if not provided).

static fromDegrees(west, south, east, north, result){Rectangle}

Create a rectangle based on the longitude and latitude (in degrees) of the boundary.

Name Type Default Description
west Number 0.0 optional

The westernmost longitude, measured in degrees, with a range of [-180.0, 180.0].

south Number 0.0 optional

The southernmost latitude, measured in degrees, with a range of [-90.0, 90.0].

east Number 0.0 optional

The easternmost longitude in degrees within the range of [-180.0180.0].

north Number 0.0 optional

The northernmost latitude within the latitude range of [-90.0, 90.0].

result Rectangle optional

The object on which the results are to be stored is undefined if a new instance is to be created.

Returns:
Type Description
Rectangle If not provided, it will be the modified result parameter or a new Rectangle instance.
Example
var rectangle = SuperMap3D.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0);

static fromRadians(west, south, east, north, result){Rectangle}

Create a rectangle with given boundary longitude and latitude (in radians).

Name Type Default Description
west Number 0.0 optional

The westernmost longitude in radians within the range. π, Math.PI]。

south Number 0.0 optional

The southernmost latitude within the range measured in radians [- mathematics]. π/ 2, Math.PI / 2)。

east Number 0.0 optional

The easternmost longitude in radians within the range. π, Math.PI]。

north Number 0.0 optional

The northernmost latitude in radians within the range [- mathematics]. π/ 2, Math.PI / 2)。

result Rectangle optional

The object for storing results is undefined if a new instance needs to be created.

Returns:
Type Description
Rectangle The modified result parameters, or a new rectangular instance (if not provided).
Example
var rectangle = SuperMap3D.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);

static intersection(rectangle, otherRectangle, result){Rectangle|undefined}

Calculate the intersection point of two rectangles. This function assumes that the coordinates of the rectangle are longitude and latitude in radians, and takes into account factors such as multiple values for the same angle and the longitude envelope at the meridian to generate the correct intersection point. For a simple intersection that ignores these factors and can be used to project coordinates, please refer to Rectangle. implementaIntersection.

Name Type Description
rectangle Rectangle

Find the intersection point on the rectangle.

otherRectangle Rectangle

Intersection point of another rectangle

result Rectangle optional

The object that stores the results.

Returns:
Type Description
Rectangle | undefined The modified result parameter, if not provided, is a new rectangular instance; If there is no intersection, it is undefined.

static northeast(rectangle, result){Cartographic}

Calculate the northeast corner of the rectangle.

Name Type Description
rectangle Rectangle

Find a rectangle with corners.

result Cartographic optional

The object that stores the results.

Returns:
Type Description
Cartographic The modified result parameters, or a new projection instance (if not provided).

static northwest(rectangle, result){Cartographic}

Calculate the northwest corner of the rectangle.

Name Type Description
rectangle Rectangle

Find a rectangle with corners.

result Cartographic optional

The object that stores the results.

Returns:
Type Description
Cartographic The modified result parameters, or a new projection instance (if not provided).

static pack(value, array, startingIndex){Array.<Number>}

Store the provided instance in the provided array.

Name Type Default Description
value Rectangle

The value to be packaged.

array Array.<Number>

The array to be loaded.

startingIndex Number 0 optional

Start packaging the index of the array of elements.

Returns:
Type Description
Array.<Number> The array that has been loaded.

static simpleIntersection(rectangle, otherRectangle, result){Rectangle|undefined}

Calculate the simple intersection of two rectangles. Unlike Rectangle. intersection, this function does not attempt to place angular coordinates within a consistent range, nor does it consider crossing the anti meridian. Therefore, it can be used for rectangles whose coordinates are not simply latitude and longitude (i.e. projected coordinates).

Name Type Description
rectangle Rectangle

Find the intersection point on the rectangle

otherRectangle Rectangle

Intersection point of another rectangle

result Rectangle optional

The object that stores the results.

Returns:
Type Description
Rectangle | undefined The modified result parameter, if not provided, is a new rectangular instance; If there is no intersection, it is undefined.

static southeast(rectangle, result){Cartographic}

Calculate the southeast corner of the rectangle.

Name Type Description
rectangle Rectangle

Find a rectangle with corners.

result Cartographic optional

The object that stores the results.

Returns:
Type Description
Cartographic The modified result parameters, or a new projection instance (if not provided).

static southwest(rectangle, result){Cartographic}

Calculate the southwest corner of the rectangle.

Name Type Description
rectangle Rectangle

Find a rectangle with corners.

result Cartographic optional

The object that stores the results.

Returns:
Type Description
Cartographic The modified result parameters, or a new projection instance (if not provided).

static subsample(rectangle, ellipsoid, surfaceHeight, result){Array.<Cartesian3>}

Sample the rectangle to include a list of Cartesian points suitable for passing to Boundingsphere # from Points. To explain a rectangle that covers both poles or crosses the equator.

Name Type Default Description
rectangle Rectangle

The rectangular area of the sub sample.

ellipsoid Ellipsoid Ellipsoid.WGS84 optional

The ellipsoid to be used.

surfaceHeight Number 0.0 optional

The height of a rectangle above an ellipsoid.

result Array.<Cartesian3> optional

The Cartesian array used to store results.

Returns:
Type Description
Array.<Cartesian3> The modified result parameters, or a new Cartesian instance array (if not provided).

static union(rectangle, otherRectangle, result){Rectangle}

Calculate the rectangle formed by merging two rectangles.

Name Type Description
rectangle Rectangle

A rectangle enclosed within a rectangle.

otherRectangle Rectangle

Another rectangle enclosed within a rectangle.

result Rectangle optional

The object that stores the results.

Returns:
Type Description
Rectangle If not provided, it will be the modified result parameter or a new Rectangle instance.

static unpack(array, startingIndex, result){Rectangle}

Retrieve instances from the packaged array.

Name Type Default Description
array Array.<Number>

Package the array.

startingIndex Number 0 optional

The starting index of the element to be decompressed.

result Rectangle optional

The object that stores the results.

Returns:
Type Description
Rectangle The modified result parameters, or a new rectangular instance (if not provided).

static validate(rectangle)

Check the properties of the rectangle and throw it if it is not within the valid range.

Name Type Description
rectangle Rectangle

The rectangle to be verified.

Throws:
  • North must be within the interval [- Pi/2, Pi/2].

    Type
    DeveloperError
  • South must be within the interval [- Pi/2, Pi/2].

    Type
    DeveloperError
  • The east must be within the interval [- Pi, Pi].

    Type
    DeveloperError
  • West must be within the interval [- Pi, Pi].

    Type
    DeveloperError

clone(result){Rectangle}

Copy this rectangle.

Name Type Description
result Rectangle optional

The object that stores the results.

Returns:
Type Description
Rectangle The modified result parameters, or a new rectangular instance (if not provided).

equals(other){Boolean}

Compare the provided rectangle with its components. If they are equal, return true; otherwise, return false.

Name Type Description
other Rectangle optional

The rectangle to be compared.

Returns:
Type Description
Boolean If two rectangles are equal, it is true; otherwise, it is false.

equalsEpsilon(other, epsilon){Boolean}

Compare the provided rectangle with this rectangle, return true if they are within the provided epsilon range, otherwise return false.

Name Type Description
other Rectangle optional

The rectangle to be compared.

epsilon Number

Tolerance values used for equation testing.

Returns:
Type Description
Boolean If the rectangle is within the provided epsilon, it is true; otherwise, it is false.