Synchronize entities

We have an application where all the entities have a SampledPositionProperty to define the position of the entity in every timestamp. It works fine.

We also know the time stamps when the entities have passed for the same point (in a different moment) and we would like to synchronize all the entities from this point.

e.g: think in a cycling tour, a time trial. All the competitors start in a different moment from the same start point. We would like to synchronize all the position times to see the time trial like a a "normal cycling race where all the competitors have the same start time".

The first idea that we have is: we could just update the SampledPositionProperty with the "synchronized times". The problem here is that we don't want to keep in memory the two sets of SampledPositionProperties.

Is there other way to synchronize two SampledPositionProperties in a timestamp?

While there’s no out of the box support for offsets, you could keep one copy of the SampledPositionProperties in memory and wrap it with a custom property that adds (or subtracts) a provided offset to any values it returns. You would just need to determine the offsets ahead of time to make all positions the same at the synchronized point of reference.

Something like the below might do the trick (note I haven’t actually ran/tested this so it probably requires some tweaks but hopefully you get the idea).

var OffsetPositionProperty = function (referenceProperty, offset) {

this.offset = offset;

this._referenceProperty = referenceProperty;

};

Cesium.defineProperties(OffsetPositionProperty.prototype, {

isConstant: {

get: function () {

return this._referenceProperty.isConstant;

}

},

definitionChanged: {

get: function () {

return this._referenceProperty.definitionChanged;

}

},

referenceFrame: {

get: function () {

return this._referenceProperty.referenceFrame;

}

}

});

var scratch = new Cesium.JulianDate();

OffsetPositionProperty.prototype.getValue = function (time, result) {

var newTime = Cesium.JulianDate.addSeconds(time, this.offset, scratch);

return this._referenceProperty.getValue(newTime, result);

};

OffsetPositionProperty.prototype.getValueInReferenceFrame = function (time, referenceFrame, result) {

var newTime = Cesium.JulianDate.addSeconds(time, this.offset, scratch);

return this._referenceProperty.getValueInReferenceFrame(newTime, referenceFrame, result);

};

OffsetPositionProperty.prototype.equals = function (other) {

return this === other ||

(other instanceof OffsetPositionProperty &&

this.offset === other.offset &&

this._referenceProperty.equals(other._referenceProperty));

};

Hi Matthew

The solution that you have suggested works perfectly and now I'm able to synchronize all the competitors at the same place.

Thanks a lot for your help!!!