Rectangle

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:
修改后的结果参数或如果未提供结果参数则返回新的 Cartographic 实例。

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

复制一个矩形。
Name Type Description
rectangle Rectangle 要克隆的矩形。
result Rectangle optional 存储结果的对象,或如果应创建新实例则为 undefined。
Returns:
修改后的结果参数或如果未提供结果参数则返回的新 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

如果地理坐标在矩形内或刚好位于矩形上,则返回 true;否则返回 false。
Name Type Description
rectangle Rectangle 矩形。
cartographic Cartographic 要测试的地理坐标。
Returns:
如果提供的地理坐标在矩形内,则返回 true;否则返回 false。

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

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

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

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

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

通过扩展提供的矩形,直到它包含提供的地理坐标来计算一个矩形。
Name Type Description
rectangle Rectangle 要扩展的矩形。
cartographic Cartographic 要包含在矩形中的地理坐标。
result Rectangle optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回的新 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:
修改后的结果参数或如果未提供结果参数则返回的新 Rectangle 实例。

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

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

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

创建包含提供数组中所有位置的最小矩形。
Name Type Description
cartographics Array.<Cartographic> Cartographic 实例的列表。
result Rectangle optional 存储结果的对象,或如果应创建新实例则为 undefined。
Returns:
修改后的结果参数或如果未提供结果参数则返回的新 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:
修改后的结果参数或如果未提供结果参数则返回的新 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:
修改后的结果参数或如果未提供结果参数则返回的新 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

计算两个矩形的交集。此函数假设矩形的坐标为 以弧度表示的纬度和经度,并产生正确的交集,考虑到 相同的角度可以用多个值表示,以及在反子午线处的经度换行。 对于忽略这些因素并可以与投影坐标一起使用的简单交集,请参见 Rectangle.simpleIntersection
Name Type Description
rectangle Rectangle 要查找交集的一个矩形。
otherRectangle Rectangle 要查找交集的另一个矩形。
result Rectangle optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新 Rectangle 实例,如果没有交集则返回 undefined。

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

计算矩形的东北角。
Name Type Description
rectangle Rectangle 要查找角落的矩形。
result Cartographic optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回新的 Cartographic 实例。

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

计算矩形的西北角。
Name Type Description
rectangle Rectangle 要查找角落的矩形。
result Cartographic optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回新的 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 不同,此函数 不试图将角坐标放入一致范围内,也不考虑交叉 反子午线。因此,它可以用于坐标不只是纬度 和经度的矩形(即投影坐标)。
Name Type Description
rectangle Rectangle 要查找交集的一个矩形。
otherRectangle Rectangle 要查找交集的另一个矩形。
result Rectangle optional 存储结果的对象。
Returns:
修改后的结果参数,如果未提供则返回新 Rectangle 实例,如果没有交集则返回 undefined。

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

计算矩形的东南角。
Name Type Description
rectangle Rectangle 要查找角落的矩形。
result Cartographic optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回新的 Cartographic 实例。

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

计算矩形的西南角。
Name Type Description
rectangle Rectangle 要查找角落的矩形。
result Cartographic optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回新的 Cartographic 实例。

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

采样一个矩形,以便包括一组适合传递给 BoundingSphere#fromPoints 的笛卡尔点。采样是必要的,以考虑 覆盖极地或跨越赤道的矩形。
Name Type Default Description
rectangle Rectangle 要进行子采样的矩形。
ellipsoid Ellipsoid Ellipsoid.default optional 要使用的椭球体。
surfaceHeight number 0.0 optional 矩形相对于椭球体的高度。
result Array.<Cartesian3> optional 存储结果的笛卡尔坐标数组。
Returns:
修改后的结果参数或如果未提供则返回新的笛卡尔坐标实例数组。

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:
修改后的结果参数或如果未提供则返回新的 Rectangle 实例。

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

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

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

从打包数组中检索实例。
Name Type Default Description
array Array.<number> 压缩数组。
startingIndex number 0 optional 需要解包的元素的起始索引。
result Rectangle optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回的新 Rectangle 实例。

static deprecated Cesium.Rectangle.validate(rectangle)

检查矩形的属性并在它们不在有效范围内时抛出异常。
Name Type Description
rectangle Rectangle 要验证的矩形。
Throws:

Deprecated: 此函数已弃用,并将在 Cesium 1.124 中移除。请参见 问题 4921

复制此矩形。
Name Type Description
result Rectangle optional 存储结果的对象。
Returns:
修改后的结果参数或如果未提供结果参数则返回的新 Rectangle 实例。

equals(other)boolean

按分量比较提供的矩形与此矩形并返回 如果相等则为 true,否则返回 false
Name Type Description
other Rectangle optional 要比较的矩形。
Returns:
如果两个矩形相等,则返回 true;否则返回 false

equalsEpsilon(other, epsilon)boolean

按分量比较提供的矩形与此矩形,并返回 如果它们在提供的 epsilon 范围内,则返回 true, 否则返回 false
Name Type Default Description
other Rectangle optional 要比较的矩形。
epsilon number 0 optional 用于相等测试的 epsilon 值。
Returns:
如果矩形在提供的 epsilon 范围内,则返回 true;否则返回 false
需要帮助?获得答案的最快方法是来自社区和团队 Cesium Forum.