Looking through the client implementation of Entity one can add and remove arbitrary properties. Is there a mechanism to do the same via the cesiumlanguagewriter? I need to append additional useful information in the entity objects but can not see a mechanism to do so?
To write custom properties, simply construct an instance of the writer for the appropriate type of data. Here’s a C# example I put together based on another example posted here a few days ago.
https://gist.github.com/shunter/7fa5107bfe6e4008b0bf
In order to load your custom properties on the Cesium side, you’ll need to add code to tell it how to process the custom properties that you want to be loaded.
Here’s an example that can be pasted in Sandcastle, based on some previous code I’ve posted here, but updated for the current version of Cesium:
Thank you for the reply.
I have the following working server side:
StringCesiumWriter stringCesiumWriter = new StringCesiumWriter("customProperty");
stringCesiumWriter.open(cesiumOutputStream);
CesiumIntervalListWriter<StringCesiumWriter> customPropertyList = stringCesiumWriter.openMultipleIntervals();
for(CustomPropInterval customPropInterval : CustomPropIntervals) {
StringCesiumWriter customProperty = customPropertyList.openInterval(customPropInterval.start, customPropInterval.end);
customProperty.writeString(customPropInterval.id);
customProperty.close();
}
customPropertyList.close();
stringCesiumWriter.close();
However, on the client I am getting an exception trying to create the String objects.
As best as I can tell, calling processPacketData is iterating over the individual items in the TimeIntervalCollectionProperty calling processProperty when in reality I need it to call processProperty with the array of intervals to be unwrapped.
Instead of calling the built in processPacketData I just did the following
CzmlDataSource.addUpdater(new CzmlDataSource.Updater() {
@Override
public void processProperty(Entity entity, JavaScriptObject packet, JavaScriptObject dynamicObjectCollection, String sourceUri) {
JavaScriptObject cotMessageId = JSOHelper.getAttributeAsJavaScriptObject(packet, "cotMessageId");
if(cotMessageId != null) {
CotEntity cot = entity.cast();
if(cot.getCotMessageId() == null) {
cot.addProperty("cotMessageId");
cot.setCotMessageId(TimeIntervalCollectionProperty.create());
}
if(!Cesium.isArray(cotMessageId)) {
SC.logWarn("Expected cotMessageId to be a TimeIntervalCollectionProperty");
return;
}
JsArray<NumberIntervalPacket> intervals = cotMessageId.cast();
for(int i = 0; i < intervals.length(); i++) {
NumberIntervalPacket intervalPacket = intervals.get(i);
TimeInterval interval = TimeInterval.fromIso8601(intervalPacket.getInterval());
interval.setData(intervalPacket.getNumber());
cot.getCotMessageId().intervals().addInterval(interval);
}
}
}
});