SampledProperty

new Cesium.SampledProperty(type, derivativeTypes)

一个 Property,其值在给定时间内从 提供样本集和指定的插值算法和度数。
Name Type Description
type number | Packable 属性的类型。
derivativeTypes Array.<Packable> optional 提供时,表示样本将包含指定类型的衍生信息。
Examples:
//Create a linearly interpolated Cartesian2
const property = new Cesium.SampledProperty(Cesium.Cartesian2);

//Populate it with data
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:00:00.00Z'), new Cesium.Cartesian2(0, 0));
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-02T00:00:00.00Z'), new Cesium.Cartesian2(4, 7));

//Retrieve an interpolated value
const result = property.getValue(Cesium.JulianDate.fromIso8601('2012-08-01T12:00:00.00Z'));
//Create a simple numeric SampledProperty that uses third degree Hermite Polynomial Approximation
const property = new Cesium.SampledProperty(Number);
property.setInterpolationOptions({
    interpolationDegree : 3,
    interpolationAlgorithm : Cesium.HermitePolynomialApproximation
});

//Populate it with data
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:00:00.00Z'), 1.0);
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:01:00.00Z'), 6.0);
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:02:00.00Z'), 12.0);
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:03:30.00Z'), 5.0);
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:06:30.00Z'), 2.0);

//Samples can be added in any order.
property.addSample(Cesium.JulianDate.fromIso8601('2012-08-01T00:00:30.00Z'), 6.2);

//Retrieve an interpolated value
const result = property.getValue(Cesium.JulianDate.fromIso8601('2012-08-01T00:02:34.00Z'));
See:

Members

backwardExtrapolationDuration : number

获取或设置向后推断的时间量 之前。 值 0 将永远外推。
Default Value: 0
获取或设置当值 在任何可用样品之前请求。
Default Value: ExtrapolationType.NONE
获取此属性的定义发生更改时引发的事件。 如果对 getValue 的调用会返回 getValue,则认为定义已更改 同一时间的不同结果。
获取此属性使用的派生类型。

forwardExtrapolationDuration : number

获取或设置之前向前推断的时间量 属性变为 undefined。 值 0 将永远外推。
Default Value: 0
获取或设置当值 在任何可用样品之后请求。
Default Value: ExtrapolationType.NONE
获取检索值时要使用的插值算法。
Default Value: LinearApproximation
获取检索值时要执行的插值度数。
Default Value: 1

readonly isConstant : boolean

获取一个值,该值指示此属性是否为 constant。 将属性视为 常量(如果 getValue 始终为当前定义返回相同的结果)。
获取属性的类型。

Methods

addSample(time, value, derivatives)

添加新样本。
Name Type Description
time JulianDate 采样时间。
value Packable 提供的时间的值。
derivatives Array.<Packable> optional 在提供的时间的衍生数组。

addSamples(times, values, derivativeValues)

添加样本数组。
Name Type Description
times Array.<JulianDate> 一个 JulianDate 实例的数组,其中每个索引都是一个采样时间。
values Array.<Packable> 值数组,其中每个值对应于提供的 times 索引。
derivativeValues Array.<Array> optional 一个数组,其中每个项目都是等效时间索引处的导数数组。
Throws:

addSamplesPackedArray(packedSamples, epoch)

将样本添加为单个打包数组,其中每个新样本都表示为日期, 后跟相应值和导数的打包表示形式。
Name Type Description
packedSamples Array.<number> 打包样本数组。
epoch JulianDate optional 如果 packedSamples 中的任何日期是数字,则它们被视为与该纪元的偏移量(以秒为单位)。
将此属性与提供的属性进行比较,并返回 true,否则为 false
Name Type Description
other Property optional 另一个属性。
Returns:
true如果左和右相等,否则false
将样本添加为单个打包数组,其中每个新样本都表示为日期, 后跟相应值和导数的 packed 表示形式。
Name Type Description
index number 样本索引列表。
Returns:
样本的 JulianDate 时间,如果失败,则为 undefined。

getValue(time, result)object

获取属性在提供的时间的值。
Name Type Default Description
time JulianDate JulianDate.now() optional 检索值的时间。如果省略,则使用当前系统时间。
result object optional 要将值存储到的对象,如果省略,则创建并返回一个新实例。
Returns:
修改后的结果参数或新实例(如果未提供 result 参数)。

removeSample(time)boolean

在给定时间删除样本(如果存在)。
Name Type Description
time JulianDate 采样时间。
Returns:
true if a sample at time was removed, 否则 false
删除给定时间间隔内的所有样本。
Name Type Description
time TimeInterval 删除所有样本的时间间隔。

setInterpolationOptions(options)

设置插值时要使用的算法和度数。
Name Type Description
options object optional 对象,具有以下属性:
Name Type Description
interpolationAlgorithm InterpolationAlgorithm optional 新的插值算法。 如果未定义,则 existing 属性将保持不变。
interpolationDegree number optional 新的插值度数。 如果未定义,则 existing 属性将保持不变。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.