new TimeInterval(options)
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.
var timeInterval = new Cesium.TimeInterval({
start : Cesium.JulianDate.fromIso8601('1980-08-01T00:00:00Z'),
stop : Cesium.JulianDate.fromIso8601('1980-08-02T00:00:00Z'),
isStartTimeIncluded : true,
iSStopTimeIncluded : 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.
var left = Cesium.TimeInterval.fromIso8601({
iso8601 : '2000/2010',
data : 2
});
var right = Cesium.TimeInterval.fromIso8601({
iso8601 : '1995/2005',
data : 3
});
//The result of the below intersection will be an interval equivalent to
//var intersection = Cesium.TimeInterval.fromIso8601({
// iso8601 : '2000/2005',
// data : 5
//});
var intersection = new Cesium.TimeInterval();
Cesium.TimeInterval.intersect(left, right, intersection, function(leftData, rightData) {
return leftData + rightData;
});
// Check if an interval contains a specific time.
var dateToCheck = Cesium.JulianDate.fromIso8601('1982-09-08T11:30:00Z');
var containsDate = Cesium.TimeInterval.contains(timeInterval, dateToCheck);
Source:
Core/TimeInterval.js, line 71
Members
-
staticconstantTimeInterval.EMPTY :TimeInterval
-
An immutable empty interval.Source: Core/TimeInterval.js, line 396
-
data :Object
-
Gets or sets the data associated with this interval.Source: Core/TimeInterval.js, line 89
-
readonlyisEmpty :Boolean
-
Gets whether or not this interval is empty.Source: Core/TimeInterval.js, line 113
-
isStartIncluded :Boolean
-
Gets or sets whether or not the start time is included in this interval.
-
Default Value:
trueSource: Core/TimeInterval.js, line 96 -
isStopIncluded :Boolean
-
Gets or sets whether or not the stop time is included in this interval.
-
Default Value:
trueSource: Core/TimeInterval.js, line 103 -
start :JulianDate
-
Gets or sets the start time of this interval.Source: Core/TimeInterval.js, line 77
-
stop :JulianDate
-
Gets or sets the stop time of this interval.Source: Core/TimeInterval.js, line 83
Methods
-
staticTimeInterval.clone(timeInterval, result) → TimeInterval
-
Duplicates the provided instance.
Name Type Description timeIntervalTimeInterval optional The instance to clone. resultTimeInterval optional An existing instance to use for the result. Returns:
The modified result parameter or a new instance if none was provided.Source: Core/TimeInterval.js, line 198 -
staticTimeInterval.contains(timeInterval, julianDate) → Boolean
-
Checks if the specified date is inside the provided interval.
Name Type Description timeIntervalTimeInterval The interval. julianDateJulianDate The date to check. Returns:
trueif the interval contains the specified date,falseotherwise.Source: Core/TimeInterval.js, line 318 -
staticTimeInterval.equals(left, right, dataComparer) → Boolean
-
Compares two instances and returns
trueif they are equal,falseotherwise.Name Type Description leftTimeInterval optional The first instance. rightTimeInterval optional The second instance. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif the dates are equal; otherwise,false.Source: Core/TimeInterval.js, line 221 -
staticTimeInterval.equalsEpsilon(left, right, epsilon, dataComparer) → Boolean
-
Compares two instances and returns
trueif they are withinepsilonseconds of each other. That is, in order for the dates to be considered equal (and for this function to returntrue), the absolute value of the difference between them, in seconds, must be less thanepsilon.Name Type Description leftTimeInterval optional The first instance. rightTimeInterval optional The second instance. epsilonNumber The maximum number of seconds that should separate the two instances. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif the two dates are withinepsilonseconds of each other; otherwisefalse.Source: Core/TimeInterval.js, line 244 -
staticTimeInterval.fromIso8601(options, result) → TimeInterval
-
Creates a new instance from an ISO 8601 interval.
Name Type Description optionsObject Object with the following properties: Name Type Default Description iso8601String An ISO 8601 interval. isStartIncludedBoolean trueoptional trueifoptions.startis included in the interval,falseotherwise.isStopIncludedBoolean trueoptional trueifoptions.stopis included in the interval,falseotherwise.dataObject optional Arbitrary data associated with this interval. resultTimeInterval optional An existing instance to use for the result. Returns:
The modified result parameter or a new instance if none was provided.Source: Core/TimeInterval.js, line 140 -
staticTimeInterval.intersect(left, right, result, mergeCallback) → TimeInterval
-
Computes the intersection of two intervals, optionally merging their data.
Name Type Description leftTimeInterval The first interval. rightTimeInterval optional The second interval. resultTimeInterval An existing instance to use for the result. mergeCallbackTimeInterval~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.Source: Core/TimeInterval.js, line 270 -
staticTimeInterval.toIso8601(timeInterval, precision) → String
-
Creates an ISO8601 representation of the provided interval.
Name Type Description timeIntervalTimeInterval The interval to be converted. precisionNumber optional The number of fractional digits used to represent the seconds component. By default, the most precise representation is used. Returns:
The ISO8601 representation of the provided interval.Source: Core/TimeInterval.js, line 181 -
clone(result) → TimeInterval
-
Duplicates this instance.
Name Type Description resultTimeInterval optional An existing instance to use for the result. Returns:
The modified result parameter or a new instance if none was provided.Source: Core/TimeInterval.js, line 351 -
equals(right, dataComparer) → Boolean
-
Compares this instance against the provided instance componentwise and returns
trueif they are equal,falseotherwise.Name Type Description rightTimeInterval optional The right hand side interval. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif they are equal,falseotherwise.Source: Core/TimeInterval.js, line 363 -
equalsEpsilon(right, epsilon, dataComparer) → Boolean
-
Compares this instance against the provided instance componentwise and returns
trueif they are within the provided epsilon,falseotherwise.Name Type Description rightTimeInterval optional The right hand side interval. epsilonNumber The epsilon to use for equality testing. dataComparerTimeInterval~DataComparer optional A function which compares the data of the two intervals. If omitted, reference equality is used. Returns:
trueif they are within the provided epsilon,falseotherwise.Source: Core/TimeInterval.js, line 377 -
toString() → String
-
Creates a string representing this TimeInterval in ISO8601 format.
Returns:
A string representing this TimeInterval in ISO8601 format.Source: Core/TimeInterval.js, line 386
Type Definitions
-
DataComparer(leftData, rightData) → Boolean
-
Function interface for comparing interval data.
Name Type Description leftDataObject The first data instance. rightDataObject The second data instance. Returns:
trueif the provided instances are equal,falseotherwise.Source: Core/TimeInterval.js, line 412 -
MergeCallback(leftData, rightData) → Object
-
Function interface for merging interval data.
Name Type Description leftDataObject The first data instance. rightDataObject The second data instance. Returns:
The result of merging the two data instances.Source: Core/TimeInterval.js, line 403
