All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.cesium.TimeInterval.kt Maven / Gradle / Ivy

There is a newer version: 1.90.0-10
Show newest version
// Automatically generated - do not modify!

@file:Suppress(
    "NON_EXTERNAL_DECLARATION_IN_INAPPROPRIATE_FILE",
)

package cesium

/**
 * 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.
 * var 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)
 * });
 * ```
 * ```
 * // Create two instances from ISO 8601 intervals with associated numeric data
 * // then compute their intersection, summing the data they contain.
 * var left = TimeInterval.fromIso8601({
 *     iso8601 : '2000/2010',
 *     data : 2
 * });
 *
 * var right = TimeInterval.fromIso8601({
 *     iso8601 : '1995/2005',
 *     data : 3
 * });
 *
 * //The result of the below intersection will be an interval equivalent to
 * //var intersection = TimeInterval.fromIso8601({
 * //  iso8601 : '2000/2005',
 * //  data : 5
 * //});
 * var intersection = new TimeInterval();
 * TimeInterval.intersect(left, right, intersection, function(leftData, rightData) {
 *     return leftData + rightData;
 * });
 * ```
 * ```
 * // Check if an interval contains a specific time.
 * var dateToCheck = JulianDate.fromIso8601('1982-09-08T11:30:00Z');
 * var containsDate = TimeInterval.contains(timeInterval, dateToCheck);
 * ```
 * @see Online Documentation
 */
@JsName("\$cesium__TimeInterval")
external class TimeInterval {
    /**
     * Gets or sets the start time of this interval.
     * @see Online Documentation
     */
    var start: JulianDate

    /**
     * Gets or sets the stop time of this interval.
     * @see Online Documentation
     */
    var stop: JulianDate

    /**
     * Gets or sets the data associated with this interval.
     * @see Online Documentation
     */
    var data: Any

    /**
     * Gets or sets whether or not the start time is included in this interval.
     * @see Online Documentation
     */
    var isStartIncluded: Boolean

    /**
     * Gets or sets whether or not the stop time is included in this interval.
     * @see Online Documentation
     */
    var isStopIncluded: Boolean

    /**
     * Gets whether or not this interval is empty.
     * @see Online Documentation
     */
    val isEmpty: Boolean

    /**
     * Duplicates this instance.
     * @param [result] An existing instance to use for the result.
     * @return The modified result parameter or a new instance if none was provided.
     * @see Online Documentation
     */
    fun clone(result: TimeInterval? = definedExternally): TimeInterval

    /**
     * Compares this instance against the provided instance componentwise and returns
     * `true` if they are equal, `false` otherwise.
     * @param [right] The right hand side interval.
     * @param [dataComparer] A function which compares the data of the two intervals.  If omitted, reference equality is used.
     * @return `true` if they are equal, `false` otherwise.
     * @see Online Documentation
     */
    fun equals(
        right: TimeInterval? = 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.
     * @param [right] The right hand side interval.
     * @param [epsilon] The epsilon to use for equality testing.
     *   Default value - `0`
     * @param [dataComparer] A function which compares the data of the two intervals.  If omitted, reference equality is used.
     * @return `true` if they are within the provided epsilon, `false` otherwise.
     * @see Online Documentation
     */
    fun equalsEpsilon(
        right: TimeInterval? = definedExternally,
        epsilon: Double? = definedExternally,
        dataComparer: DataComparer? = definedExternally,
    ): Boolean

    companion object {
        /**
         * Creates a new instance from a [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) interval.
         * @param [result] An existing instance to use for the result.
         * @return The modified result parameter or a new instance if none was provided.
         * @see Online Documentation
         */
        fun fromIso8601(
            options: FromIso8601Options,
            result: TimeInterval? = definedExternally,
        ): TimeInterval

        /**
         * @property [iso8601] An ISO 8601 interval.
         * @property [isStartIncluded] `true` if `options.start` is included in the interval, `false` otherwise.
         *   Default value - `true`
         * @property [isStopIncluded] `true` if `options.stop` is included in the interval, `false` otherwise.
         *   Default value - `true`
         * @property [data] Arbitrary data associated with this interval.
         */
        interface FromIso8601Options {
            var iso8601: String
            var isStartIncluded: Boolean?
            var isStopIncluded: Boolean?
            var data: Any?
        }

        /**
         * Creates an ISO8601 representation of the provided interval.
         * @param [timeInterval] The interval to be converted.
         * @param [precision] The number of fractional digits used to represent the seconds component.  By default, the most precise representation is used.
         * @return The ISO8601 representation of the provided interval.
         * @see Online Documentation
         */
        fun toIso8601(
            timeInterval: TimeInterval,
            precision: Double? = definedExternally,
        ): String

        /**
         * Duplicates the provided instance.
         * @param [timeInterval] The instance to clone.
         * @param [result] An existing instance to use for the result.
         * @return The modified result parameter or a new instance if none was provided.
         * @see Online Documentation
         */
        fun clone(
            timeInterval: TimeInterval? = definedExternally,
            result: TimeInterval? = definedExternally,
        ): TimeInterval

        /**
         * Compares two instances and returns `true` if they are equal, `false` otherwise.
         * @param [left] The first instance.
         * @param [right] The second instance.
         * @param [dataComparer] A function which compares the data of the two intervals.  If omitted, reference equality is used.
         * @return `true` if the dates are equal; otherwise, `false`.
         * @see Online Documentation
         */
        fun equals(
            left: TimeInterval? = definedExternally,
            right: TimeInterval? = definedExternally,
            dataComparer: DataComparer? = definedExternally,
        ): Boolean

        /**
         * 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`.
         * @param [left] The first instance.
         * @param [right] The second instance.
         * @param [epsilon] The maximum number of seconds that should separate the two instances.
         *   Default value - `0`
         * @param [dataComparer] A function which compares the data of the two intervals.  If omitted, reference equality is used.
         * @return `true` if the two dates are within `epsilon` seconds of each other; otherwise `false`.
         * @see Online Documentation
         */
        fun equalsEpsilon(
            left: TimeInterval? = definedExternally,
            right: TimeInterval? = definedExternally,
            epsilon: Double? = definedExternally,
            dataComparer: DataComparer? = definedExternally,
        ): Boolean

        /**
         * Computes the intersection of two intervals, optionally merging their data.
         * @param [left] The first interval.
         * @param [right] The second interval.
         * @param [result] An existing instance to use for the result.
         * @param [mergeCallback] A function which merges the data of the two intervals. If omitted, the data from the left interval will be used.
         * @return The modified result parameter.
         * @see Online Documentation
         */
        fun intersect(
            left: TimeInterval,
            right: TimeInterval? = definedExternally,
            result: TimeInterval? = definedExternally,
            mergeCallback: MergeCallback? = definedExternally,
        ): TimeInterval

        /**
         * Checks if the specified date is inside the provided interval.
         * @param [timeInterval] The interval.
         * @param [julianDate] The date to check.
         * @return `true` if the interval contains the specified date, `false` otherwise.
         * @see Online Documentation
         */
        fun contains(
            timeInterval: TimeInterval,
            julianDate: JulianDate,
        ): Boolean

        /**
         * An immutable empty interval.
         * @see Online Documentation
         */
        val EMPTY: TimeInterval
    }
}

/**
 * Function interface for merging interval data.
 * @param [leftData] The first data instance.
 * @param [rightData] The second data instance.
 * @see Online Documentation
 */
typealias MergeCallback = (leftData: Any, rightData: Any) -> Any

/**
 * Function interface for comparing interval data.
 * @param [leftData] The first data instance.
 * @param [rightData] The second data instance.
 * @see Online Documentation
 */
typealias DataComparer = (leftData: Any, rightData: Any) -> Boolean




© 2015 - 2024 Weber Informatics LLC | Privacy Policy