TimeInterval
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.
// Create an instance that spans August 1st, 1980 and is associated
// with a Cartesian position.
const timeInterval = new TimeInterval({
start : JulianDate.fromIso8601('1980-08-01T00:00:00Z'),
stop : JulianDate.fromIso8601('1980-08-02T00:00:00Z'),
isStartIncluded : true,
isStopIncluded : false,
data : Cartesian3.fromDegrees(39.921037, -75.170082)
});
Content copied to clipboard
// Create two instances from ISO 8601 intervals with associated numeric data
// then compute their intersection, summing the data they contain.
const left = TimeInterval.fromIso8601({
iso8601 : '2000/2010',
data : 2
});
const right = TimeInterval.fromIso8601({
iso8601 : '1995/2005',
data : 3
});
//The result of the below intersection will be an interval equivalent to
//const intersection = TimeInterval.fromIso8601({
// iso8601 : '2000/2005',
// data : 5
//});
const intersection = new TimeInterval();
TimeInterval.intersect(left, right, intersection, function(leftData, rightData) {
return leftData + rightData;
});
Content copied to clipboard
// Check if an interval contains a specific time.
const dateToCheck = JulianDate.fromIso8601('1982-09-08T11:30:00Z');
const containsDate = TimeInterval.contains(timeInterval, dateToCheck);
Content copied to clipboard
See also
Properties
Link copied to clipboard
Gets or sets whether or not the start time is included in this interval.
Link copied to clipboard
Gets or sets whether or not the stop time is included in this interval.
Link copied to clipboard
Gets or sets the start time of this interval.
Link copied to clipboard
Gets or sets the stop time of this interval.
Functions
Link copied to clipboard
Duplicates this instance.
Link copied to clipboard
fun equals(right: TimeInterval? = definedExternally, dataComparer: DataComparer? = definedExternally): Boolean
Compares this instance against the provided instance componentwise and returns true
if they are equal, false
otherwise.
Link copied to clipboard
fun equalsEpsilon(right: TimeInterval? = definedExternally, epsilon: Double? = definedExternally, dataComparer: DataComparer? = definedExternally): Boolean
Compares this instance against the provided instance componentwise and returns true
if they are within the provided epsilon, false
otherwise.