Search code examples
node.jsdynamic-datacesiumjsczml

Generate dynamic CZML data using NodeJS


Cesium has the ability to render dynamic data that originates from a czml file. They have an example on their website showing how use the czml data on the client-side.

I'd like to generate czml data dynamically on the server-side using nodejs. Are there any pointers or examples on how that can be achieved?


Solution

  • There's an official czml-writer for C# and Java, and a 3rd-party czml writer for Python, but I'm not aware of any yet available for NodeJS.

    It seems like one could easily output CZML from NodeJS just by calling JSON.stringify on an array of CZML packets (specially-formatted JavaScript objects). For dates and intervals, one could even import Cesium (or Cesium Core) into NodeJS for access to JulianDate and related time interval classes, to store in the appropriate fields.

    You'll need to make sure the first element in the array is the "id" : "document" packet (as shown in the guide) with the settings for the rest of the CZML data, and that each subsequent packet provides a unique id of its own. After that just push some entity description packets into the array, and you should be good to go.