ScalaCZML a CZML library in scala

This library ScalaCZML reads and writes CZML JSON entities and presents them as Scala objects.

Cesium is a JavaScript library for creating 3D globes and 2D maps in a web browser without a plugin. It uses WebGL for hardware-accelerated graphics, and is cross-platform, cross-browser, and tuned for dynamic-data visualization.

CZML is a JSON schema for describing a time-dynamic graphical scene, primarily for display in a web browser running Cesium. It describes lines, points, billboards (markers), models and other graphical primitives, and specifies how they change with time.

ScalaCZML makes the CZML JSON entities available as Scala objects. The library follows the specifications of reference 1. Typically ScalaCZML is for server side application development.

There is also the Cesium library in Scala, CesiumScala for client side development.


  1. CZML guide

  2. CZML content

  3. CZML structure


Using Scala and the Play-JSON library of the Play Framework

Installation and packaging

To use the last release add the following dependency to your build.sbt:

libraryDependencies += "com.github.workingDog" %% "scalaczml" % "0.5"

To compile and generate a jar file from the source:

sbt package

The jar file (scalaczml_2.11-0.6-SNAPSHOT.jar) will be in the "./target/scala-2.11/" directory.


To generate the ScalaCZML API documentation, type "sbt doc". The documentation will be generated in /target/scala-2.11/api directory. ScalaCZML mostly follows reference 2 documentation.


object Example1 {
 def main(args: Array[String]) {
     // read a CZML document from a file
     val jsonDoc = Source.fromFile("/.....test4.czml").mkString
     // create a czml object from the json document
     val czml = CZML[CZMLPacket](jsonDoc)
     // create a position property
     val pos = CzmlPositions(9.3, 8.2, 7.1)
     // create a billboard property with image uri and scale fields
     val bb = new Billboard(image = "http://localhost/img.png", scale = 0.7)
     // create a czml packet
     val packet = new CZMLPacket("test packet", HashSet[CzmlProperty](pos, bb))
     // add the packet to the existing czml object
     czml.add(packet) // or czml.packets += packet
     // convert the czml object to json
     val jsczml = Json.toJson(czml)
     // write the czml as a json document to file (here to System.out)
     // alternatively
     //  Util.writeJsToFile(Json.prettyPrint(jsczml))