This is a Java library to writer CZML, which based on czml-writer, and this is more simple to generate czml.
Apache 2.0. aurora-cesium is free for both commercial and non-commercial use.
- Everything in aurora-cesium is
property
orgraphics
. - Every
property
orgraphics
has aninterface
. - Every
interface
has a method callednewBuilder()
, which to build property or graphics. - Many interfaces have method like
from()/fromXXX()/default()/defaultXXX()
, these methods are shortcuts tonewBuilder()
. - Finally, you can use
CzmlGenerator
to generate czml. - Example
6.1 to create a position, a position is a property, and the interface calledPositionProperty
, we can build position with cartesian(CartesianProperty
)/cartographicDegrees(CartographicDegreesProperty
)/cartographicRadians(CartographicRadiansProperty
)
// first create a cartesian
CartesianProperty cartesianProperty;
// use builder
cartesianProperty = CartesianProperty.newBuilder().withValue(new Cartesian(0, 0, 0)).build();
// or use shortcut
cartesianProperty = CartesianProperty.from(new Cartesian(0, 0, 0));
// or create a cartographicDegrees/cartographicRadians
CartographicDegreesProperty cartographicDegreesProperty;
// use builder
cartographicDegreesProperty = CartographicDegreesProperty.newBuilder().withValue(new Cartographic(114, 30, 0)).build();
// or use shortcut
cartographicDegreesProperty = CartographicDegreesProperty.from(new Cartographic(114, 30, 0));
// let's create postition
PositionProperty positionProperty;
positionProperty = PositionProperty.newBuilder().withCartesian(CartesianProperty.from(new Cartesian(0, 0, 0))).build();
// or use shortcut
positionProperty = PositionProperty.from(cartesianProperty);
// or use shortcut
positionProperty = PositionProperty.fromCartesian(new Cartesian(0, 0, 0));
6.2 to create a point(PointGraphics
)
PointGraphics pointGraphics = PointGraphics.newBuilder()
.withColor(ColorProperty.fromRgba(new Color(255, 255, 255, 255)))
.withPixelSize(DoubleProperty.from(20D))
.withShow(BooleanProperty.from(true))
.build();
6.3 to create an Entity(Entity
)
Entity entity = Entity.newBuilder()
.withId("Entity")
.withName("Entity")
.withPosition(positionProperty)
.withPoint(pointGraphics)
.build();
6.4 to creat a czml(Czml
)
Czml czml = Czml.create();
czml.setDocument(Document.defaultDocument("CZML"));
czml.push(entity);
6.5 generate it
String result = CzmlGenerator.on(true).generate(czml, new StringWriter()).toString();
6.6 print it
System.out.println(result);
[
{
"id":"document",
"name":"CZML",
"version":"1.0"
},
{
"id":"Entity",
"name":"Entity",
"position":{
"cartesian":[
0,0,0
]
},
"point":{
"color":{
"rgba":[
255,255,255,255
]
},
"pixelSize":20,
"show":true
}
}
]