MetadataClassProperty 是 CesiumJS 中的类,它表示元数据类的一个属性。
new Cesium.MetadataClassProperty(options)
参数:
options :一个对象,描述元数据类中的一个属性。
id :一个字符串,表示元数据属性的名称。name :一个字符串,表示元数据属性的显示名称。可选,默认为 id。description :一个字符串,表示元数据属性的说明。可选,默认为空字符串。type :一个字符串,表示元数据属性的类型。可选,默认为 undefined。maxOccurs :一个数字或字符串,表示元数据属性的最大出现次数。可选,默认为 1。value :元数据属性的值。可选,默认为 undefined。const soilDataClass = new Cesium.MetadataClass({
id: 'SoilData',
name: 'Soil Data',
classification: 'classification',
properties: {
clayContent: new Cesium.MetadataClassProperty({
id: 'clayContent',
name: 'Clay Content',
description: 'The percentage of clay in the soil.',
type: 'number',
maxOccurs: 1,
value: 20
}),
sandContent: new Cesium.MetadataClassProperty({
id: 'sandContent',
name: 'Sand Content',
description: 'The percentage of sand in the soil.',
type: 'number',
maxOccurs: 1,
value: 60
}),
organicContent: new Cesium.MetadataClassProperty({
id: 'organicContent',
name: 'Organic Content',
description: 'The percentage of organic matter in the soil.',
type: 'number',
maxOccurs: 1,
value: 10
})
}
})
在上面的示例中,我们创建了一个名为 SoilData 的元数据类,并定义了三个属性分别为 clayContent、sandContent、organicContent。每个属性都是 MetadataClassProperty 的实例对象。
getId()返回元数据属性的 id。
const id = soilDataClass.properties.clayContent.getId()
getName()返回元数据属性的显示名称 name。
const name = soilDataClass.properties.clayContent.getName()
getDescription()返回元数据属性的说明 description。
const desc = soilDataClass.properties.clayContent.getDescription()
getType()返回元数据属性的类型 type。
const type = soilDataClass.properties.clayContent.getType()
getMaxOccurs()返回元数据属性的最大出现次数 maxOccurs。
const maxOccurs = soilDataClass.properties.clayContent.getMaxOccurs()
getValue()返回元数据属性的值 value。
const value = soilDataClass.properties.clayContent.getValue()
setValue(value)设置元数据属性的值 value。
参数:
value :元数据属性的值。soilDataClass.properties.clayContent.setValue(25)
元数据属性可以通过 getValue() 和 setValue(value) 方法来获取和设置它的值。如果 maxOccurs 等于 1,则可以使用 getValue() 和 setValue(value) 方法;如果 maxOccurs 大于 1,则可以使用 getValues() 和 setValues(values) 方法。