AnalyticalGraphicsInc/czml-writer

Ability to write an interval with a property

Closed this issue · 1 comments

Here is my problem,
I am using Java to take a message passed in from a server and use that to write changes to CZML. we have our orientation property working fine, but we are using colors to determine a models temperature.

The czml writer will write the color property with and epoch and dates following, but the colors are interpolated and we need them to be changed immediately (time is of the essence, and colors are blue and red no aqua).

I have noticed there is no time interval with say color properties. I need to be able to write:

 "color": [
{
"interval" : "2012-08-04T16:00:00Z/2012-08-04T16:05:00Z",
"rgbaf" : [1, 0, 0, 1]
}, {
"interval" : "2012-08-04T16:01:00Z/2012-08-04T16:05:00Z",
"rgbaf" : [0, 1, 0, 1]
}, {
"interval" : "2012-08-04T16:02:00Z/2012-08-04T16:05:00Z",
"rgbaf" : [0, 0, 1, 1]
},
],

could this be done given a list of intervals and a list of colors?? i.e
IntervalWithProperty(List dates, List);
OR
IntervalWithProperty(List dates, PropertyType type, List value);

Or is there a workaround that I can do to make this work?

This is done by opening a IntervalListWriter, then opening each interval and writing the value for that interval. In Java:

try (ModelCesiumWriter model = packet.openModelProperty()) {
	try (ColorCesiumWriter color = model.openColorProperty()) {
		try (CesiumIntervalListWriter<ColorCesiumWriter> intervals = color.openMultipleIntervals()) {
			try (ColorCesiumWriter interval = intervals.openInterval()) {
				JulianDate start = new GregorianDate(2012, 8, 4, 16, 0, 0).toJulianDate();
				JulianDate stop = new GregorianDate(2012, 8, 4, 16, 1, 0).toJulianDate();
				interval.writeInterval(start, stop);
				interval.writeRgbaf(Color.RED);
			}
			try (ColorCesiumWriter interval = intervals.openInterval()) {
				JulianDate start = new GregorianDate(2012, 8, 4, 16, 1, 0).toJulianDate();
				JulianDate stop = new GregorianDate(2012, 8, 4, 16, 2, 0).toJulianDate();
				interval.writeInterval(start, stop);
				interval.writeRgbaf(Color.GREEN);
			}
		}
	}
}

this produces:

{
  "model":{
    "color":[
      {
        "interval":"2012-08-04T16:00:00Z/2012-08-04T16:01:00Z",
        "rgbaf":[
          1,0,0,1
        ]
      },
      {
        "interval":"2012-08-04T16:01:00Z/2012-08-04T16:02:00Z",
        "rgbaf":[
          0,1,0,1
        ]
      }
    ]
  }
}