Czml writer example for creating Path's trailing/leading time intervals

Can you give me a snippet of java code example of how to create an array of intervals in the Path’s trail/leadTime similar to the simple.czml using the java czml writer API? I was able to generate an interval but cannot seem to find a way to generate an array of intervals.

Thanks,
Thu

Hi Thu,

I don’t have example code handy, but you should be able to just call openMultipleIntervals on the trail/leadTime’s DoubleCesiumWriter to start an array of intervals, and then openInterval to open each interval. Let me know if that doesn’t work for you.

Kevin

Hi Kevin,
Thank you for such a quick reply! I was able to generate the intervals per your direction. However, the “epoch” and “number” for each interval for both trail/lead times don’t seem to look like the ones
in simple.czml, and the lead/trail time don’t have the closing ] for the array. I have attached the java test codes that I have written. Can you see what I am doing wrong?

“leadTime”:[
{
“interval”:“2013-02-06T14:34:18.530000000000655Z/2013-02-06T14:35:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:35:18.530000000000655Z/2013-02-06T14:36:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:36:18.530000000000655Z/2013-02-06T14:37:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:37:18.530000000000655Z/2013-02-06T14:38:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:38:18.530000000000655Z/2013-02-06T14:39:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:39:18.530000000000655Z/2013-02-06T14:40:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:40:18.530000000000655Z/2013-02-06T14:41:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:41:18.530000000000655Z/2013-02-06T14:42:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:42:18.530000000000655Z/2013-02-06T14:43:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:34:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
“trailTime”:[
{
“interval”:“2013-02-06T14:34:18.530000000000655Z/2013-02-06T14:35:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:35:18.530000000000655Z/2013-02-06T14:36:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:36:18.530000000000655Z/2013-02-06T14:37:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:37:18.530000000000655Z/2013-02-06T14:38:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:38:18.530000000000655Z/2013-02-06T14:39:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:39:18.530000000000655Z/2013-02-06T14:40:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:40:18.530000000000655Z/2013-02-06T14:41:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:41:18.530000000000655Z/2013-02-06T14:42:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
},
{
“interval”:“2013-02-06T14:42:18.530000000000655Z/2013-02-06T14:43:18.530000000000655Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2013-02-06T14:36:18.530000000000655Z”,
“number”:[
0.0,60.0,
60.0,60.0
]
}

Thanks,
Thu

cmzlTest.java (7.78 KB)

Hi Thu,

When using the CZML writers, it’s important that you close everything you open. So add a call to leadIntervalList.close() before the call to leadTimeWriter.close(). That should fix the closing ] for the array.

Regarding the epoch and number properties, those look ok to me. What looks wrong about them to you?

Kevin

HI Kevin,
I guess I don’t quite understand what to pass to the DoubleCesiumWriter.writeNumber(java.util.List<cesiumlanguagewriter.JulianDate> dates, java.util.List<java.lang.Double> values, int startIndex, int length). The dates parameter I understand, but what am I suppose to pass in for values, startIndex, and length? Looking at the simple.czml, the intervals for trailTime and leadTime look like this:
“trailTime”:[
{
“interval”:“2012-03-15T10:00:00Z/2012-03-15T10:44:56.1031157730031Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2012-03-15T10:00:00Z”,
“number”:[
0.0,0.0,
2696.103115773003,2696.103115773003
]
},

How do I get my stuff to mimic the format [0.0, 0.0, 2696.103115773003,2696.103115773003] for number?

and similarly for leadTime
“leadTime”:[
{
“interval”:“2012-03-15T10:00:00Z/2012-03-15T10:44:56.1031157730031Z”,
“interpolationAlgorithm”:“LINEAR”,
“interpolationDegree”:1,
“epoch”:“2012-03-15T10:00:00Z”,
“number”:[
0.0,2696.103115773003,
2696.103115773003,0.0
]
},

How do I get my stuff to mimic the format [ 0.0,2696.103115773003,2696.103115773003,0.0] for number?

Again, thanks alot for all your help!
-Thu

Thu,

I’m confused because, in the output you showed, your stuff is already mimicking that format. How is this (from your output):

“number”:[
0.0,60.0,
60.0,60.0
]

Different from this (from your excerpt of simple.czml):

“number”:[

        0.0,0.0,
        2696.103115773003,2696.103115773003
      ]

Other than the numbers are different, of course. The format is the same.

When you call that overload of writeNumber, you’re specifying that the value of the property changes over time. ‘dates’ and ‘values’ are parallel collections, so the value at index 0 in the ‘values’ collection specifies the value of the property at the date specified at index 0 in the ‘dates’ collection. And so on for index 1, 2, 3, etc. The startIndex and length parameters allow you to specify that only a subset of the collection be written.

Kevin

Hi Kevin,
I am so new to this, so sorry if I am asking silly questions. :slight_smile: I am confused as what to put for the “number”. What does it mean when you have

“number”:[

        0.0,0.0,
        2696.103115773003,2696.103115773003
      ]

What does 0.0 and 2696.103115773003 mean?

Thanks,
Thu

Hey Thu,

The “number” property is specifying the value of whatever property its inside of. In your case, it is the lead or trail time, in seconds, as described here:

Search for “Path.LeadTime”. In the table under that, you see the “number” property, and is described like this:

The floating-point value. The value may be a single number, in which case the value is constant over the interval, or it may be an array. If it is an array and the array has one element, the value is constant over the interval. If it has two or more elements, they are time-tagged samples arranged as [Time, Value, Time, Value, …], where Time is an ISO 8601 date and time string or seconds since epoch.

So in your example:

“number”:[

        0.0,0.0,
        2696.103115773003,2696.103115773003
      ]

The value is an array, and it has four elements. That means it is a list of time-tagged samples, arranged as [Time, Value, Time, Value, Time, Value, etc.]. So at time 0.0, the value is 0.0. At time 2696.103115773003, the value is 2696.103115773003. Times are seconds since the time specified on the “epoch” property. And the value is the value of the “lead time” at that animation time. Essentially, this lets you show longer or shorter tails on objects at different animation times.

When the Cesium animation time is in between two samples, it uses interpolation to find the value at that time. The other properties (like “intepolationDegree”) control how the interpolation is performed.

If you haven’t seen these pages yet, they’re definitely worth a read:

And this one is the reference guide for all the possible properties in CZML:

I hope this helps,

Kevin