Rectangle

A two dimensional region specified as longitude and latitude coordinates.

new Cesium.Rectangle(west, south, east, north)

Name Type Default Description
west number 0.0 optional 最西侧的经度(弧度),范围 [-Pi, Pi]。
south number 0.0 optional 最南侧的纬度(弧度),范围 [-Pi/2, Pi/2]。
east number 0.0 optional 最东侧的经度(弧度),范围 [-Pi, Pi]。
north number 0.0 optional 最北侧的纬度(弧度),范围 [-Pi/2, Pi/2]。
See:

Members

static constant Cesium.Rectangle.MAX_VALUE : Rectangle

可能的最大矩形。

static Cesium.Rectangle.packedLength : number

将该对象打包进数组所使用的元素数量。
最东侧的经度(弧度),范围 [-Pi, Pi]。
Default Value: 0.0

readonly height : number

获取矩形在弧度下的高度。
最北侧的纬度(弧度),范围 [-Pi/2, Pi/2]。
Default Value: 0.0
最南侧的纬度(弧度),范围 [-Pi/2, Pi/2]。
Default Value: 0.0
最西侧的经度(弧度),范围 [-Pi, Pi]。
Default Value: 0.0

readonly width : number

获取矩形在弧度下的宽度。

Methods

static Cesium.Rectangle.center(rectangle, result)Cartographic

计算矩形的中心。
Name Type Description
rectangle Rectangle 要求其中心的矩形
result Cartographic optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Cartographic 实例。

static Cesium.Rectangle.clone(rectangle, result)Rectangle

复制一个 Rectangle。
Name Type Description
rectangle Rectangle 要克隆的矩形。
result Rectangle optional 用于存储结果的对象,如果应创建新实例则为 undefined。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。(如果 rectangle 为 undefined 则返回 undefined)

static Cesium.Rectangle.computeHeight(rectangle)number

计算矩形在弧度下的高度。
Name Type Description
rectangle Rectangle 要计算高度的矩形。
Returns:
高度。

static Cesium.Rectangle.computeWidth(rectangle)number

计算矩形在弧度下的宽度。
Name Type Description
rectangle Rectangle 要计算宽度的矩形。
Returns:
宽度。

static Cesium.Rectangle.contains(rectangle, cartographic)boolean

如果 cartographic 在矩形上或矩形内则返回 true,否则返回 false。
Name Type Description
rectangle Rectangle 矩形
cartographic Cartographic 要测试的 cartographic。
Returns:
如果提供的 cartographic 在矩形内则为 true,否则为 false。

static Cesium.Rectangle.equals(left, right)boolean

比较提供的矩形,如果它们相等则返回 true, 否则返回 false
Name Type Description
left Rectangle optional 第一个 Rectangle。
right Rectangle optional 第二个 Rectangle。
Returns:
如果 left 和 right 相等则为 true,否则为 false

static Cesium.Rectangle.equalsEpsilon(left, right, absoluteEpsilon)boolean

逐分量比较提供的矩形,如果它们通过绝对或相对容差测试则返回 true, 否则返回 false
Name Type Default Description
left Rectangle optional 第一个 Rectangle。
right Rectangle optional 第二个 Rectangle。
absoluteEpsilon number 0 optional 用于相等性测试的绝对 epsilon 容差。
Returns:
如果 left 和 right 在提供的 epsilon 范围内则为 true,否则为 false

static Cesium.Rectangle.expand(rectangle, cartographic, result)Rectangle

通过扩大提供的矩形直到其包含提供的 cartographic,计算出一个矩形。
Name Type Description
rectangle Rectangle 要扩展的矩形。
cartographic Cartographic 要包含在矩形中的 cartographic。
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

static Cesium.Rectangle.fromBoundingSphere(boundingSphere, ellipsoid, result)Rectangle

从包围球创建矩形,忽略高度。
Name Type Default Description
boundingSphere BoundingSphere 包围球。
ellipsoid Ellipsoid Ellipsoid.default optional 椭球体。
result Rectangle optional 用于存储结果的对象,如果应创建新实例则为 undefined。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

static Cesium.Rectangle.fromCartesianArray(cartesians, ellipsoid, result)Rectangle

创建包含提供数组中所有位置的最小可能 Rectangle。
Name Type Default Description
cartesians Array.<Cartesian3> Cartesian 实例的列表。
ellipsoid Ellipsoid Ellipsoid.default optional cartesians 所在的椭球体。
result Rectangle optional 用于存储结果的对象,如果应创建新实例则为 undefined。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

static Cesium.Rectangle.fromCartographicArray(cartographics, result)Rectangle

创建包含提供数组中所有位置的最小可能 Rectangle。
Name Type Description
cartographics Array.<Cartographic> Cartographic 实例的列表。
result Rectangle optional 用于存储结果的对象,如果应创建新实例则为 undefined。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

static Cesium.Rectangle.fromDegrees(west, south, east, north, result)Rectangle

根据边界经纬度(以度为单位)创建矩形。
Name Type Default Description
west number 0.0 optional 最西侧的经度(度),范围 [-180.0, 180.0]。
south number 0.0 optional 最南侧的纬度(度),范围 [-90.0, 90.0]。
east number 0.0 optional 最东侧的经度(度),范围 [-180.0, 180.0]。
north number 0.0 optional 最北侧的纬度(度),范围 [-90.0, 90.0]。
result Rectangle optional 用于存储结果的对象,如果应创建新实例则为 undefined。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。
Example:
const rectangle = Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0);

static Cesium.Rectangle.fromRadians(west, south, east, north, result)Rectangle

根据边界经纬度(以弧度为单位)创建矩形。
Name Type Default Description
west number 0.0 optional 最西侧的经度(弧度),范围 [-Math.PI, Math.PI]。
south number 0.0 optional 最南侧的纬度(弧度),范围 [-Math.PI/2, Math.PI/2]。
east number 0.0 optional 最东侧的经度(弧度),范围 [-Math.PI, Math.PI]。
north number 0.0 optional 最北侧的纬度(弧度),范围 [-Math.PI/2, Math.PI/2]。
result Rectangle optional 用于存储结果的对象,如果应创建新实例则为 undefined。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。
Example:
const rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);

static Cesium.Rectangle.intersection(rectangle, otherRectangle, result)Rectangle|undefined

计算两个矩形的交集。此函数假设矩形的坐标是经纬度(弧度),并会产生正确的交集,同时考虑以下事实: 同一个角度可以用多个值表示,以及经度在 对跖经线(anti-meridian)处的环绕。对于忽略这些因素、可用于投影坐标的 简单交集,请参见 Rectangle.simpleIntersection
Name Type Description
rectangle Rectangle 要求交集的一个矩形
otherRectangle Rectangle 要求交集的另一个矩形
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例,如果没有交集则为 undefined。

static Cesium.Rectangle.northeast(rectangle, result)Cartographic

计算矩形的东北角。
Name Type Description
rectangle Rectangle 要求其中角的矩形
result Cartographic optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Cartographic 实例。

static Cesium.Rectangle.northwest(rectangle, result)Cartographic

计算矩形的西北角。
Name Type Description
rectangle Rectangle 要求其中角的矩形
result Cartographic optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Cartographic 实例。

static Cesium.Rectangle.pack(value, array, startingIndex)Array.<number>

将提供的实例存入提供的数组。
Name Type Default Description
value Rectangle 要打包的值。
array Array.<number> 要打包进的数组。
startingIndex number 0 optional 数组中开始打包元素的索引。
Returns:
被打包进的数组

static Cesium.Rectangle.simpleIntersection(rectangle, otherRectangle, result)Rectangle|undefined

计算两个矩形的简单交集。与 Rectangle.intersection 不同,此函数 不会尝试将角度坐标放入一致的范围,也不会考虑跨越 对跖经线(anti-meridian)。因此,它可用于坐标并非单纯的经纬度 (即投影坐标)的矩形。
Name Type Description
rectangle Rectangle 要求交集的一个矩形
otherRectangle Rectangle 要求交集的另一个矩形
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例,如果没有交集则为 undefined。

static Cesium.Rectangle.southeast(rectangle, result)Cartographic

计算矩形的东南角。
Name Type Description
rectangle Rectangle 要求其中角的矩形
result Cartographic optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Cartographic 实例。

static Cesium.Rectangle.southwest(rectangle, result)Cartographic

计算矩形的西南角。
Name Type Description
rectangle Rectangle 要求其中角的矩形
result Cartographic optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Cartographic 实例。

static Cesium.Rectangle.subsample(rectangle, ellipsoid, surfaceHeight, result)Array.<Cartesian3>

对矩形进行采样,使其包含一个适合传给 BoundingSphere#fromPoints 的 Cartesian 点列表。采样是必要的,以考虑 覆盖极点或超过赤道的矩形。
Name Type Default Description
rectangle Rectangle 要重采样的矩形。
ellipsoid Ellipsoid Ellipsoid.default optional 要使用的椭球体。
surfaceHeight number 0.0 optional 矩形高于椭球体的高度。
result Array.<Cartesian3> optional 用于存储结果的 Cartesians 数组。
Returns:
修改后的 result 参数,如果未提供则为新的 Cartesians 实例数组。

static Cesium.Rectangle.subsection(rectangle, westLerp, southLerp, eastLerp, northLerp, result)Rectangle

从归一化坐标(范围 [0.0, 1.0])计算矩形的一个子区域。
Name Type Description
rectangle Rectangle 要分子区域的矩形。
westLerp number 西部插值因子,范围 [0.0, 1.0]。必须小于或等于 eastLerp。
southLerp number 南部插值因子,范围 [0.0, 1.0]。必须小于或等于 northLerp。
eastLerp number 东部插值因子,范围 [0.0, 1.0]。必须大于或等于 westLerp。
northLerp number 北部插值因子,范围 [0.0, 1.0]。必须大于或等于 southLerp。
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

static Cesium.Rectangle.union(rectangle, otherRectangle, result)Rectangle

计算两个矩形的并集矩形。
Name Type Description
rectangle Rectangle 要包含进矩形的矩形。
otherRectangle Rectangle 要包含在矩形中的矩形。
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

static Cesium.Rectangle.unpack(array, startingIndex, result)Rectangle

从已打包的数组中检索一个实例。
Name Type Default Description
array Array.<number> 已打包的数组。
startingIndex number 0 optional 要解包元素的起始索引。
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。
复制此 Rectangle。
Name Type Description
result Rectangle optional 用于存储结果的对象。
Returns:
修改后的 result 参数,如果未提供则为新的 Rectangle 实例。

equals(other)boolean

将此 Rectangle 与提供的 Rectangle 逐分量比较,如果它们相等则返回 true,否则返回 false
Name Type Description
other Rectangle optional 要比较的 Rectangle。
Returns:
如果矩形相等则为 true,否则为 false

equalsEpsilon(other, epsilon)boolean

将此 Rectangle 与提供的 Rectangle 逐分量比较,如果它们在提供的 epsilon 范围内则返回 true, 否则返回 false
Name Type Default Description
other Rectangle optional 要比较的 Rectangle。
epsilon number 0 optional 用于相等性测试的 epsilon。
Returns:
如果矩形在提供的 epsilon 范围内则为 true,否则为 false
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。