由开始时间和停止时间定义的间隔;可选地包括这些时间作为间隔的一部分。任意数据可以选择与每个实例关联以用于 An interval defined by a start and a stop time; optionally including those times as part of the interval. Arbitrary data can optionally be associated with each instance for used with
TimeIntervalCollection.
| 名称 Name | 类型 Type | 说明 Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
可选 optional
具有以下属性的对象: Object with the following properties:
|
示例: Examples:
// Create an instance that spans August 1st, 1980 and is associated
// with a Cartesian position.
const timeInterval = new Cesium.TimeInterval({
start : Cesium.JulianDate.fromIso8601('1980-08-01T00:00:00Z'),
stop : Cesium.JulianDate.fromIso8601('1980-08-02T00:00:00Z'),
isStartIncluded : true,
isStopIncluded : false,
data : Cesium.Cartesian3.fromDegrees(39.921037, -75.170082)
});
// Create two instances from ISO 8601 intervals with associated numeric data
// then compute their intersection, summing the data they contain.
const left = Cesium.TimeInterval.fromIso8601({
iso8601 : '2000/2010',
data : 2
});
const right = Cesium.TimeInterval.fromIso8601({
iso8601 : '1995/2005',
data : 3
});
//The result of the below intersection will be an interval equivalent to
//const intersection = Cesium.TimeInterval.fromIso8601({
// iso8601 : '2000/2005',
// data : 5
//});
const intersection = new Cesium.TimeInterval();
Cesium.TimeInterval.intersect(left, right, intersection, function(leftData, rightData) {
return leftData + rightData;
});
// Check if an interval contains a specific time.
const dateToCheck = Cesium.JulianDate.fromIso8601('1982-09-08T11:30:00Z');
const containsDate = Cesium.TimeInterval.contains(timeInterval, dateToCheck);
成员 Members
static constant Cesium.TimeInterval.EMPTY : TimeInterval
不可变的空区间。 An immutable empty interval.
获取或设置与此间隔关联的数据。 Gets or sets the data associated with this interval.
获取此区间是否为空。 Gets whether or not this interval is empty.
获取或设置开始时间是否包含在此间隔中。 Gets or sets whether or not the start time is included in this interval.
-
默认值: Default Value:
true
获取或设置此间隔中是否包含停止时间。 Gets or sets whether or not the stop time is included in this interval.
-
默认值: Default Value:
true
获取或设置此间隔的开始时间。 Gets or sets the start time of this interval.
获取或设置该间隔的停止时间。 Gets or sets the stop time of this interval.
方法 Methods
static Cesium.TimeInterval.clone(timeInterval, result) → TimeInterval
Duplicates the provided instance.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
timeInterval |
TimeInterval | 可选 optional 要克隆的实例。 The instance to clone. |
result |
TimeInterval | 可选 optional 用于结果的现有实例。 An existing instance to use for the result. |
返回: Returns:
修改后的结果参数或新实例(如果未提供)。 The modified result parameter or a new instance if none was provided.
检查指定日期是否在提供的时间间隔内。 Checks if the specified date is inside the provided interval.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
timeInterval |
TimeInterval | 间隔。 The interval. |
julianDate |
JulianDate | 要检查的日期。 The date to check. |
返回: Returns:
true 如果间隔包含指定日期, if the interval contains the specified date, false otherwise.
比较两个实例并返回 Compares two instances and returns
true 如果它们相等, if they are equal, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
left |
TimeInterval | 可选 optional 第一个例子。 The first instance. |
right |
TimeInterval | 可选 optional 第二个例子。 The second instance. |
dataComparer |
TimeInterval.DataComparer | 可选 optional 比较两个间隔的数据的函数。如果省略,则使用引用相等。 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回: Returns:
true 如果日期相同;否则, if the dates are equal; otherwise, false.
比较两个实例并返回 Compares two instances and returns
true 如果他们在 if they are within epsilon 彼此的秒数。也就是说,为了使日期被认为是相等的(并且该函数返回 seconds of each other. That is, in order for the dates to be considered equal (and for this function to return true),它们之间的差的绝对值(以秒为单位)必须小于 ), the absolute value of the difference between them, in seconds, must be less than epsilon.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
left |
TimeInterval | 可选 optional 第一个例子。 The first instance. | |
right |
TimeInterval | 可选 optional 第二个例子。 The second instance. | |
epsilon |
number |
0
|
可选 optional 两个实例之间应间隔的最大秒数。 The maximum number of seconds that should separate the two instances. |
dataComparer |
TimeInterval.DataComparer | 可选 optional 比较两个间隔的数据的函数。如果省略,则使用引用相等。 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回: Returns:
true 如果两个日期在 if the two dates are within epsilon 彼此的秒数;否则 seconds of each other; otherwise false.
static Cesium.TimeInterval.fromIso8601(options, result) → TimeInterval
从创建一个新实例 Creates a new instance from a ISO 8601 interval.
| 名称 Name | 类型 Type | 说明 Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象: Object with the following properties:
|
||||||||||||||||||||
result |
TimeInterval | 可选 optional 用于结果的现有实例。 An existing instance to use for the result. |
返回: Returns:
修改后的结果参数或新实例(如果未提供)。 The modified result parameter or a new instance if none was provided.
抛出: Throws:
-
如果 options.iso8601 与正确的格式不匹配,则会出现 DeveloperError。 DeveloperError if options.iso8601 does not match proper formatting.
static Cesium.TimeInterval.intersect(left, right, result, mergeCallback) → TimeInterval
计算两个区间的交集,可以选择合并它们的数据。 Computes the intersection of two intervals, optionally merging their data.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
left |
TimeInterval | 第一个间隔。 The first interval. |
right |
TimeInterval | 可选 optional 第二个区间。 The second interval. |
result |
TimeInterval | 可选 optional 用于结果的现有实例。 An existing instance to use for the result. |
mergeCallback |
TimeInterval.MergeCallback | 可选 optional 合并两个区间数据的函数。如果省略,将使用左侧间隔的数据。 A function which merges the data of the two intervals. If omitted, the data from the left interval will be used. |
返回: Returns:
修改后的结果参数。 The modified result parameter.
创建所提供间隔的 ISO8601 表示形式。 Creates an ISO8601 representation of the provided interval.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
timeInterval |
TimeInterval | 要转换的区间。 The interval to be converted. |
precision |
number | 可选 optional 用于表示秒部分的小数位数。默认情况下,使用最精确的表示形式。 The number of fractional digits used to represent the seconds component. By default, the most precise representation is used. |
返回: Returns:
所提供间隔的 ISO8601 表示形式。 The ISO8601 representation of the provided interval.
clone(result) → TimeInterval
复制此实例。 Duplicates this instance.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
result |
TimeInterval | 可选 optional 用于结果的现有实例。 An existing instance to use for the result. |
返回: Returns:
修改后的结果参数或新实例(如果未提供)。 The modified result parameter or a new instance if none was provided.
将此实例与提供的实例按组件进行比较并返回 Compares this instance against the provided instance componentwise and returns
true 如果它们相等, if they are equal, false otherwise.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
right |
TimeInterval | 可选 optional 右侧间隔。 The right hand side interval. |
dataComparer |
TimeInterval.DataComparer | 可选 optional 比较两个间隔的数据的函数。如果省略,则使用引用相等。 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回: Returns:
true 如果它们相等, if they are equal, false otherwise.
将此实例与提供的实例按组件进行比较并返回 Compares this instance against the provided instance componentwise and returns
true 如果它们在提供的 epsilon 范围内, if they are within the provided epsilon,
false otherwise.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
right |
TimeInterval | 可选 optional 右侧间隔。 The right hand side interval. | |
epsilon |
number |
0
|
可选 optional 用于相等性测试的 epsilon。 The epsilon to use for equality testing. |
dataComparer |
TimeInterval.DataComparer | 可选 optional 比较两个间隔的数据的函数。如果省略,则使用引用相等。 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回: Returns:
true 如果它们在提供的 epsilon 范围内, if they are within the provided epsilon, false otherwise.
创建一个以 ISO8601 格式表示此 TimeInterval 的字符串。 Creates a string representing this TimeInterval in ISO8601 format.
返回: Returns:
以 ISO8601 格式表示此 TimeInterval 的字符串。 A string representing this TimeInterval in ISO8601 format.
类型定义 Type Definitions
用于比较区间数据的函数接口。 Function interface for comparing interval data.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
leftData |
* | 第一个数据实例。 The first data instance. |
rightData |
* | 第二个数据实例。 The second data instance. |
返回: Returns:
true 如果提供的实例相等, if the provided instances are equal, false otherwise.
合并区间数据的函数接口。 Function interface for merging interval data.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
leftData |
* | 第一个数据实例。 The first data instance. |
rightData |
* | 第二个数据实例。 The second data instance. |
返回: Returns:
合并两个数据实例的结果。 The result of merging the two data instances.
