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

获取或设置向后外推的时间量, 在该时间之后属性变为 undefined。值为 0 表示永远外推。
Default Value: 0
获取或设置在任何可用样本之前的时间请求值时 所执行的外推类型。
Default Value: ExtrapolationType.NONE
获取每当此属性的定义发生变化时引发的事件。 如果对 getValue 的调用对同一时间会返回 不同的结果,则认为定义已发生变化。
获取此属性使用的导数类型。

forwardExtrapolationDuration : number

获取或设置向前外推的时间量, 在该时间之后属性变为 undefined。值为 0 表示永远外推。
Default Value: 0
获取或设置在任何可用样本之后的时间请求值时 所执行的外推类型。
Default Value: ExtrapolationType.NONE
获取检索值时所使用的插值算法。
Default Value: LinearApproximation
获取检索值时所执行的插值阶数。
Default Value: 1

readonly isConstant : boolean

获取一个指示此属性是否为常量的标志。如果 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 另一个 property。
Returns:
如果 left 和 right 相等则为 true,否则为 false
检索与索引关联的所提供样本的时间。负索引会以逆序访问样本列表。
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 参数,如果未提供 result 参数则为新实例。

removeSample(time)boolean

如果存在,移除在给定时间的样本。
Name Type Description
time JulianDate 样本时间。
Returns:
如果位于 time 的样本已被移除则为 true,否则为 false
移除给定时间间隔内的所有样本。
Name Type Description
time TimeInterval 要移除所有样本的时间间隔。

setInterpolationOptions(options)

设置插值值时所使用的算法和阶数。
Name Type Description
options object optional Object with the following properties:
Name Type Description
interpolationAlgorithm InterpolationAlgorithm optional 新的插值算法。如果为 undefined,则现有属性保持不变。
interpolationDegree number optional 新的插值阶数。如果为 undefined,则现有属性保持不变。
需要帮助?获取答案的最快方式是在 Cesium 论坛 上向社区和团队提问。