Is there any example of using czmlwriter C# version?

234 views
Skip to first unread message

Chris Wang

unread,
Oct 23, 2015, 10:55:15 PM10/23/15
to cesium-dev
Hi

I just started  to learning the czml writer.  If there is any example code or tutorial, that will help a lot.

thank you.

Chris

Scott Reynolds

unread,
Oct 25, 2015, 9:37:03 PM10/25/15
to cesium-dev
Here's a little code that should give you an idea how it works.

Scott

            StringWriter sw = new StringWriter();
            CesiumOutputStream czOutputStream = new CesiumOutputStream(sw);
            czOutputStream.PrettyFormatting = true;
            CesiumStreamWriter czStreamWriter = new CesiumStreamWriter();

            // A CZML file contains an array of objects which the following opens.
            czOutputStream.WriteStartSequence();

            // Create the document czPacket
            PacketCesiumWriter czPacket = czStreamWriter.OpenPacket(czOutputStream);
            czPacket.WriteId("document");
            czPacket.WriteVersion("1.0");
            czPacket.Close();

            // Create packet for an object
            czPacket = czStreamWriter.OpenPacket(czOutputStream);
            czPacket.WriteId("ID_0001");
            czPacket.WriteName("Name_0001");

            // Add position to object's packet
            PositionCesiumWriter czPosition = czPacket.OpenPositionProperty();
            czPosition.WriteCartographicDegrees(
                new Cartographic(-75.5966, 40.0386, 0.0));
            czPosition.Close();

            // Add label to object's packet
            LabelCesiumWriter czLabel = czPacket.OpenLabelProperty();
            czLabel.WriteTextProperty("Exton");
            czLabel.Close();

            // Add point to object's packet
            PointCesiumWriter czPoint = czPacket.OpenPointProperty();
            czPoint.WritePixelSizeProperty(5.0);
            czPoint.WriteOutlineWidthProperty(2.0);
            czPoint.WriteColorProperty(Color.DodgerBlue);
            czPoint.WriteOutlineColorProperty(Color.White);
            czPoint.Close();

            // Close the object's packet
            czPacket.Close();

            // Closes the array
            czOutputStream.WriteEndSequence();

            sw.Close();

Chris Wang

unread,
Oct 26, 2015, 2:59:31 AM10/26/15
to cesium-dev
Thanks Scott. That helps a lot.

在 2015年10月26日星期一 UTC+8上午9:37:03,Scott Reynolds写道:
Reply all
Reply to author
Forward
0 new messages