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
.
参数名称 | 类型 | 描述信息 | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
可选
Object with the following properties:
|
使用示例s:
// 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);
成员(属性)
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.
-
默认值:
true
Gets or sets whether or not the stop time is included in this interval.
-
默认值:
true
Gets or sets the start time of this interval.
Gets or sets the stop time of this interval.
方法
static Cesium.TimeInterval.clone(timeInterval, result) → TimeInterval
Duplicates the provided instance.
参数名称 | 类型 | 描述信息 |
---|---|---|
timeInterval |
TimeInterval | 可选 The instance to clone. |
result |
TimeInterval | 可选 An existing instance to use for the result. |
返回值:
The modified result parameter or a new instance if none was provided.
Checks if the specified date is inside the provided interval.
参数名称 | 类型 | 描述信息 |
---|---|---|
timeInterval |
TimeInterval | The interval. |
julianDate |
JulianDate | The date to check. |
返回值:
true
if the interval contains the specified date, false
otherwise.
Compares two instances and returns
true
if they are equal, false
otherwise.
参数名称 | 类型 | 描述信息 |
---|---|---|
left |
TimeInterval | 可选 The first instance. |
right |
TimeInterval | 可选 The second instance. |
dataComparer |
TimeInterval.DataComparer | 可选 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回值:
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
.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
left |
TimeInterval | 可选 The first instance. | |
right |
TimeInterval | 可选 The second instance. | |
epsilon |
number |
0
|
可选 The maximum number of seconds that should separate the two instances. |
dataComparer |
TimeInterval.DataComparer | 可选 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回值:
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.
参数名称 | 类型 | 描述信息 | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Object with the following properties:
|
||||||||||||||||||||
result |
TimeInterval | 可选 An existing instance to use for the result. |
返回值:
The modified result parameter or a new instance if none was provided.
Throws:
-
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.
参数名称 | 类型 | 描述信息 |
---|---|---|
left |
TimeInterval | The first interval. |
right |
TimeInterval | 可选 The second interval. |
result |
TimeInterval | 可选 An existing instance to use for the result. |
mergeCallback |
TimeInterval.MergeCallback | 可选 A function which merges the data of the two intervals. If omitted, the data from the left interval will be used. |
返回值:
The modified result parameter.
Creates an ISO8601 representation of the provided interval.
参数名称 | 类型 | 描述信息 |
---|---|---|
timeInterval |
TimeInterval | The interval to be converted. |
precision |
number | 可选 The number of fractional digits used to represent the seconds component. By default, the most precise representation is used. |
返回值:
The ISO8601 representation of the provided interval.
clone(result) → TimeInterval
Duplicates this instance.
参数名称 | 类型 | 描述信息 |
---|---|---|
result |
TimeInterval | 可选 An existing instance to use for the result. |
返回值:
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.
参数名称 | 类型 | 描述信息 |
---|---|---|
right |
TimeInterval | 可选 The right hand side interval. |
dataComparer |
TimeInterval.DataComparer | 可选 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回值:
true
if they are equal, false
otherwise.
Compares this instance against the provided instance componentwise and returns
true
if they are within the provided epsilon,
false
otherwise.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
right |
TimeInterval | 可选 The right hand side interval. | |
epsilon |
number |
0
|
可选 The epsilon to use for equality testing. |
dataComparer |
TimeInterval.DataComparer | 可选 A function which compares the data of the two intervals. If omitted, reference equality is used. |
返回值:
true
if they are within the provided epsilon, false
otherwise.
Creates a string representing this TimeInterval in ISO8601 format.
返回值:
A string representing this TimeInterval in ISO8601 format.
定义的类型
Function interface for comparing interval data.
参数名称 | 类型 | 描述信息 |
---|---|---|
leftData |
* | The first data instance. |
rightData |
* | The second data instance. |
返回值:
true
if the provided instances are equal, false
otherwise.
Function interface for merging interval data.
参数名称 | 类型 | 描述信息 |
---|---|---|
leftData |
* | The first data instance. |
rightData |
* | The second data instance. |
返回值:
The result of merging the two data instances.