/// <summary> /// Writes the polyline to its <see cref="CzmlDocument"/>. /// </summary> public override void Write() { PolylineShape polyline = (PolylineShape)m_shape; for (int i = 0; i < polyline.Count; i++) { ShapePart part = polyline[i]; using (PacketCesiumWriter packetWriter = m_document.CesiumStreamWriter.OpenPacket(m_document.CesiumOutputStream)) { packetWriter.WriteId(Guid.NewGuid().ToString()); using (PolylineCesiumWriter polylineWriter = packetWriter.OpenPolylineProperty()) { using (var materialWriter = polylineWriter.OpenMaterialProperty()) using (var colorWriter = materialWriter.OpenSolidColorProperty()) { colorWriter.WriteColorProperty(m_color); } List <Cartographic> positions = new List <Cartographic>(); for (int x = 0; x < part.Count; x++) { positions.Add(part[x]); } polylineWriter.WritePositionsPropertyCartographicRadians(positions); } } } }
/// <inheritdoc /> protected override void AddLineStyle(XElement lineElement) { XElement colorElement = lineElement.Element(Document.Namespace + "color"); PolylineCesiumWriter polyline = null; if (colorElement != null) { Color color = Utility.HexStringToColor(colorElement.Value); polyline = this.PacketWriter.OpenPolylineProperty(); polyline.WriteColorProperty(color); } XElement widthElement = lineElement.Element(Document.Namespace + "width"); if (widthElement != null) { if (polyline == null) { polyline = this.PacketWriter.OpenPolylineProperty(); } polyline.WriteWidthProperty(double.Parse(widthElement.Value)); polyline.WriteOutlineWidthProperty(0); } if (polyline != null) { polyline.Close(); } }
/// <inheritdoc/> protected override void AddLineStyle(XElement lineElement) { if (m_extrude) { using (PolylineCesiumWriter polyline = PacketWriter.OpenPolylineProperty()) { XElement colorElement = lineElement.Element(Document.Namespace + "color"); if (colorElement != null) { Color color = Utility.HexStringToColor(colorElement.Value); polyline.WriteColorProperty(color); } XElement widthElement = lineElement.Element(Document.Namespace + "width"); if (widthElement != null) { polyline.WriteWidthProperty(double.Parse(widthElement.Value)); } } } }
/// <summary> /// Writes a new polyline packet for each part of the shape. /// </summary> /// <param name="part">The <see cref="ShapePart"/> of the <see cref="PolylineShape"/> to write</param> private void WritePacket(ShapePart part) { using (PacketCesiumWriter packetWriter = m_document.CesiumStreamWriter.OpenPacket(m_document.CesiumOutputStream)) { packetWriter.WriteId(Guid.NewGuid().ToString()); using (PositionListCesiumWriter position = packetWriter.OpenVertexPositionsProperty()) { PolylineShape polyline = (PolylineShape)m_shape; List <Cartographic> positions = new List <Cartographic>(); for (int i = 0; i < part.Count; i++) { positions.Add(part[i]); } position.WriteCartographicRadians(positions); } using (PolylineCesiumWriter polylineWriter = packetWriter.OpenPolylineProperty()) { polylineWriter.WriteColorProperty(m_color); } } }
/// <summary> /// Writes the czml packet of the given coordinate in the series. /// </summary> /// <param name="index">The index of the coordinate to write as a packet.</param> public void WritePacket(int index) { if (index < m_coordinates.Length) { using (PacketCesiumWriter packetWriter = m_document.CesiumStreamWriter.OpenPacket(m_document.CesiumOutputStream)) { packetWriter.WriteId(m_id + index); using (PolylineCesiumWriter polyline = packetWriter.OpenPolylineProperty()) { polyline.WriteColorProperty(ColorFromHSV(0.6 - (m_coordinates[index].Height * 0.5), 1.0, 1.0)); } using (PositionListCesiumWriter vertexPositions = packetWriter.OpenVertexPositionsProperty()) { Cartographic[] positions = new Cartographic[] { new Cartographic(m_coordinates[index].Longitude, m_coordinates[index].Latitude, 0.0), new Cartographic(m_coordinates[index].Longitude, m_coordinates[index].Latitude, m_coordinates[index].Height * m_scalar) }; vertexPositions.WriteCartographicDegrees(positions); } } } }