Skip to content

KBE3D / KBCore / Cesium / TimeInterval

类: 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.

Examples

ts
// 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)
});
ts
// 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;
});
ts
// 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);

参数

Object with the following properties:

参数

The start time of the interval.

参数

The stop time of the interval.

参数

<code>true</code> if <code>options.start</code> is included in the interval, <code>false</code> otherwise.

参数

<code>true</code> if <code>options.stop</code> is included in the interval, <code>false</code> otherwise.

参数

Arbitrary data associated with this interval.

属性

EMPTY

readonly static EMPTY: TimeInterval

An immutable empty interval.


start

start: JulianDate

Gets or sets the start time of this interval.


stop

stop: JulianDate

Gets or sets the stop time of this interval.


data

data: any

Gets or sets the data associated with this interval.


isStartIncluded

isStartIncluded: boolean

Gets or sets whether or not the start time is included in this interval.


isStopIncluded

isStopIncluded: boolean

Gets or sets whether or not the stop time is included in this interval.


isEmpty

readonly isEmpty: boolean

Gets whether or not this interval is empty.

方法

fromIso8601()

static fromIso8601(options: { iso8601: string; isStartIncluded?: boolean; isStopIncluded?: boolean; data?: any; }, result?: TimeInterval): TimeInterval

Creates a new instance from a ISO 8601

interval.

参数

options

Object with the following properties:

iso8601

string

An ISO 8601 interval.

isStartIncluded?

boolean

<code>true</code> if <code>options.start</code> is included in the interval, <code>false</code> otherwise.

isStopIncluded?

boolean

<code>true</code> if <code>options.stop</code> is included in the interval, <code>false</code> otherwise.

data?

any

Arbitrary data associated with this interval.

result?

TimeInterval

An existing instance to use for the result.

返回

TimeInterval

The modified result parameter or a new instance if none was provided.


toIso8601()

static toIso8601(timeInterval: TimeInterval, precision?: number): string

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.

返回

string

The ISO8601 representation of the provided interval.


clone()

static clone(timeInterval?: TimeInterval, result?: TimeInterval): TimeInterval

Duplicates the provided instance.

参数

timeInterval?

TimeInterval

The instance to clone.

result?

TimeInterval

An existing instance to use for the result.

返回

TimeInterval

The modified result parameter or a new instance if none was provided.


equals()

static equals(left?: TimeInterval, right?: TimeInterval, dataComparer?: DataComparer): boolean

Compares two instances and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

left?

TimeInterval

The first instance.

TimeInterval

The second instance.

dataComparer?

DataComparer

A function which compares the data of the two intervals. If omitted, reference equality is used.

返回

boolean

true if the dates are equal; otherwise, false.


equalsEpsilon()

static equalsEpsilon(left?: TimeInterval, right?: TimeInterval, epsilon?: number, dataComparer?: DataComparer): boolean

Compares two instances and returns <code>true</code> if they are within <code>epsilon</code> seconds of each other. That is, in order for the dates to be considered equal (and for this function to return <code>true</code>), the absolute value of the difference between them, in seconds, must be less than <code>epsilon</code>.

参数

left?

TimeInterval

The first instance.

right?

TimeInterval

The second instance.

epsilon?

number

The maximum number of seconds that should separate the two instances.

dataComparer?

DataComparer

A function which compares the data of the two intervals. If omitted, reference equality is used.

返回

boolean

true if the two dates are within epsilon seconds of each other; otherwise false.


intersect()

static intersect(left: TimeInterval, right?: TimeInterval, result?: TimeInterval, mergeCallback?: 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?

MergeCallback

A function which merges the data of the two intervals. If omitted, the data from the left interval will be used.

返回

TimeInterval

The modified result parameter.


contains()

static contains(timeInterval: TimeInterval, julianDate: JulianDate): boolean

Checks if the specified date is inside the provided interval.

参数

timeInterval

TimeInterval

The interval.

julianDate

JulianDate

The date to check.

返回

boolean

true if the interval contains the specified date, false otherwise.


clone()

clone(result?: TimeInterval): TimeInterval

Duplicates this instance.

参数

result?

TimeInterval

An existing instance to use for the result.

返回

TimeInterval

The modified result parameter or a new instance if none was provided.


equals()

equals(right?: TimeInterval, dataComparer?: DataComparer): boolean

Compares this instance against the provided instance componentwise and returns <code>true</code> if they are equal, <code>false</code> otherwise.

参数

right?

TimeInterval

The right hand side interval.

dataComparer?

DataComparer

A function which compares the data of the two intervals. If omitted, reference equality is used.

返回

boolean

true if they are equal, false otherwise.


equalsEpsilon()

equalsEpsilon(right?: TimeInterval, epsilon?: number, dataComparer?: DataComparer): boolean

Compares this instance against the provided instance componentwise and returns <code>true</code> if they are within the provided epsilon, <code>false</code> otherwise.

参数

right?

TimeInterval

The right hand side interval.

epsilon?

number

The epsilon to use for equality testing.

dataComparer?

DataComparer

A function which compares the data of the two intervals. If omitted, reference equality is used.

返回

boolean

true if they are within the provided epsilon, false otherwise.


toString()

toString(): string

Creates a string representing this TimeInterval in ISO8601 format.

返回

string

A string representing this TimeInterval in ISO8601 format.

构造函数

构造函数

new TimeInterval(options?: { start?: JulianDate; stop?: JulianDate; isStartIncluded?: boolean; isStopIncluded?: boolean; data?: any; }): TimeInterval

参数

options?
start?

JulianDate

stop?

JulianDate

isStartIncluded?

boolean

isStopIncluded?

boolean

data?

any

返回

TimeInterval

KBE3D @3.0.0 Copyright © 2024-present KBE3D