示例#1
0
 /// <summary>
 /// Writes a <see cref="UnitSpherical"/> value as an array in Clock, Cone order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteUnitSpherical(CesiumOutputStream output, UnitSpherical value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Clock);
     output.WriteValue(value.Cone);
     output.WriteEndSequence();
 }
示例#2
0
        /// <summary>
        /// Writes the time-tagged <see cref="UnitQuaternion"/> collection as an array in
        /// [Time, X, Y, Z, W] order.
        /// Times are epoch seconds since an epoch that is determined from the first date to be written.
        /// The epoch property is written as well.
        /// </summary>
        /// <param name="output">The stream to which to write the array.</param>
        /// <param name="propertyName">The name of the property to write.</param>
        /// <param name="dates">The dates at which the value is specified.</param>
        /// <param name="values">The corresponding value for each date.</param>
        /// <param name="startIndex">The index of the first element to use in the <paramref name="values"/> collection.</param>
        /// <param name="length">The number of elements to use from the <paramref name="values"/> collection.</param>
        public static void WriteUnitQuaternion(CesiumOutputStream output, string propertyName, IList <JulianDate> dates, IList <UnitQuaternion> values, int startIndex, int length)
        {
            if (dates.Count != values.Count)
            {
                throw new ArgumentException(CesiumLocalization.MismatchedNumberOfDatesAndValues, "values");
            }

            JulianDate epoch = GetAndWriteEpoch(output, dates, startIndex, length);

            output.WritePropertyName(propertyName);
            output.WriteStartSequence();
            int last = startIndex + length;

            for (int i = startIndex; i < last; ++i)
            {
                output.WriteValue(epoch.SecondsDifference(dates[i]));
                UnitQuaternion quaternion = values[i];
                output.WriteValue(quaternion.X);
                output.WriteValue(quaternion.Y);
                output.WriteValue(quaternion.Z);
                output.WriteValue(quaternion.W);
                output.WriteLineBreak();
            }

            output.WriteEndSequence();
        }
示例#3
0
        /// <summary>
        /// Writes time-tagged <see cref="Cartographic"/> values as an array in [Time, Longitude, Latitude, Height] order.
        /// Times are epoch seconds since an epoch that is determined from the first date to be written.
        /// The epoch property is written as well.
        /// </summary>
        /// <param name="output">The stream to which to write the array.</param>
        /// <param name="propertyName">The name of the property to write.</param>
        /// <param name="dates">The dates at which the value is specified.</param>
        /// <param name="values">The corresponding value for each date.</param>
        /// <param name="startIndex">The index of the first element to use in the <paramref name="values"/> collection.</param>
        /// <param name="length">The number of elements to use from the <paramref name="values"/> collection.</param>
        public static void WriteCartographic(CesiumOutputStream output, string propertyName, IList <JulianDate> dates, IList <Cartographic> values, int startIndex, int length)
        {
            if (dates.Count != values.Count)
            {
                throw new ArgumentException(CesiumLocalization.MismatchedNumberOfDatesAndValues, "values");
            }

            JulianDate epoch = GetAndWriteEpoch(output, dates, startIndex, length);

            output.WritePropertyName(propertyName);
            output.WriteStartSequence();
            int last = startIndex + length;

            for (int i = startIndex; i < last; ++i)
            {
                output.WriteValue(epoch.SecondsDifference(dates[i]));
                Cartographic value = values[i];
                output.WriteValue(value.Longitude);
                output.WriteValue(value.Latitude);
                output.WriteValue(value.Height);
                output.WriteLineBreak();
            }

            output.WriteEndSequence();
        }
示例#4
0
 /// <summary>
 /// Writes a <see cref="Rectangular"/> value as an array in X, Y order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian2(CesiumOutputStream output, Rectangular value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteEndSequence();
 }
示例#5
0
        public void AvailabilityValueWritesAvailabilityProperty()
        {
            JulianDate start = new JulianDate(new GregorianDate(2012, 4, 2, 1, 2, 3));
            JulianDate stop  = new JulianDate(new GregorianDate(2012, 4, 3, 1, 2, 3));

            m_output.WriteStartSequence();
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_output))
            {
                packet.WriteAvailability(start, stop);
            }
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_output))
            {
                packet.WriteAvailability(new TimeInterval(start, stop));
            }
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_output))
            {
                var intervals = new List <TimeInterval>();
                intervals.Add(new TimeInterval(start, stop));
                intervals.Add(new TimeInterval(start.AddDays(2.0), stop.AddDays(2.0)));
                packet.WriteAvailability(intervals);
            }
            m_output.WriteEndSequence();

            Assert.AreEqual("[{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                            "{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                            "{\"availability\":[\"20120402T010203Z/20120403T010203Z\",\"20120404T010203Z/20120405T010203Z\"]}]",
                            m_sw.ToString());
        }
示例#6
0
        /// <summary>
        /// Writes time-tagged <see cref="Motion&lt;Cartesian&gt;"/> values as an array in [Time, X, Y, Z, vX, vY, vZ] order.
        /// Times are epoch seconds since an epoch that is determined from the first date to be written.
        /// The epoch property is written as well.
        /// </summary>
        /// <param name="output">The stream to which to write the array.</param>
        /// <param name="propertyName">The name of the property to write.</param>
        /// <param name="dates">The dates at which the value is specified.</param>
        /// <param name="values">The corresponding value for each date.</param>
        /// <param name="startIndex">The index of the first element to use in the <paramref name="values"/> collection.</param>
        /// <param name="length">The number of elements to use from the <paramref name="values"/> collection.</param>
        public static void WriteCartesian3Velocity(CesiumOutputStream output, string propertyName, IList <JulianDate> dates, IList <Motion <Cartesian> > values, int startIndex, int length)
        {
            if (dates.Count != values.Count)
            {
                throw new ArgumentException(CesiumLocalization.MismatchedNumberOfDatesAndValues, "values");
            }

            JulianDate epoch = GetAndWriteEpoch(output, dates, startIndex, length);

            output.WritePropertyName(propertyName);
            output.WriteStartSequence();
            int last = startIndex + length;

            for (int i = startIndex; i < last; ++i)
            {
                output.WriteValue(epoch.SecondsDifference(dates[i]));
                Cartesian value    = values[i].Value;
                Cartesian velocity = values[i].FirstDerivative;
                output.WriteValue(value.X);
                output.WriteValue(value.Y);
                output.WriteValue(value.Z);
                output.WriteValue(velocity.X);
                output.WriteValue(velocity.Y);
                output.WriteValue(velocity.Z);
                output.WriteLineBreak();
            }

            output.WriteEndSequence();
        }
 /// <summary>
 /// Writes a <see cref="Rectangular"/> value as an array in X, Y order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian2(CesiumOutputStream output, Rectangular value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteEndSequence();
 }
示例#8
0
 /// <summary>
 /// Writes a <see cref="UnitCartesian"/> value as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteUnitCartesian3(CesiumOutputStream output, UnitCartesian value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteValue(value.Z);
     output.WriteEndSequence();
 }
示例#9
0
 /// <summary>
 /// Writes a <see cref="Cartographic"/> value as an array in Longitude, Latitude, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartographic(CesiumOutputStream output, Cartographic value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Longitude);
     output.WriteValue(value.Latitude);
     output.WriteValue(value.Height);
     output.WriteEndSequence();
 }
示例#10
0
 /// <summary>
 /// Writes a color value as an array in Red, Green, Blue, Alpha order as floating-point values.
 /// </summary>
 /// <param name="output">The stream to which to write the color.</param>
 /// <param name="red">The red component in the range 0.0-1.0.</param>
 /// <param name="green">The green component in the range 0.0-1.0.</param>
 /// <param name="blue">The blue component in the range 0.0-1.0.</param>
 /// <param name="alpha">The alpha component in the range 0.0-1.0.</param>
 public static void WriteRgbaf(CesiumOutputStream output, double red, double green, double blue, double alpha)
 {
     output.WriteStartSequence();
     output.WriteValue(red);
     output.WriteValue(green);
     output.WriteValue(blue);
     output.WriteValue(alpha);
     output.WriteEndSequence();
 }
示例#11
0
 /// <summary>
 /// Writes a list of <see cref="double"/> values as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteDoubleList(CesiumOutputStream output, IEnumerable <double> values)
 {
     output.WriteStartSequence();
     foreach (double value in values)
     {
         output.WriteValue(value);
     }
     output.WriteEndSequence();
 }
示例#12
0
 /// <summary>
 /// Writes a <see cref="NearFarScalar"/> value as an array in Clock, Cone, Magnitude order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteNearFarScalar(CesiumOutputStream output, NearFarScalar value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.NearDistance);
     output.WriteValue(value.NearValue);
     output.WriteValue(value.FarDistance);
     output.WriteValue(value.FarValue);
     output.WriteEndSequence();
 }
示例#13
0
 /// <summary>
 /// Writes a <see cref="BoundingRectangle"/> value as an array in X, Y, Width, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteBoundingRectangle(CesiumOutputStream output, BoundingRectangle value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Left);
     output.WriteValue(value.Bottom);
     output.WriteValue(value.Width);
     output.WriteValue(value.Height);
     output.WriteEndSequence();
 }
示例#14
0
 /// <summary>
 /// Writes a <see cref="CartographicExtent"/> value as an array in WestLongitude, SouthLatitude, EastLongitude, NorthLatitude order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartographicExtent(CesiumOutputStream output, CartographicExtent value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.WestLongitude);
     output.WriteValue(value.SouthLatitude);
     output.WriteValue(value.EastLongitude);
     output.WriteValue(value.NorthLatitude);
     output.WriteEndSequence();
 }
 /// <summary>
 /// Writes a <see cref="BoundingRectangle"/> value as an array in X, Y, Width, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteBoundingRectangle(CesiumOutputStream output, BoundingRectangle value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Left);
     output.WriteValue(value.Bottom);
     output.WriteValue(value.Width);
     output.WriteValue(value.Height);
     output.WriteEndSequence();
 }
示例#16
0
 /// <summary>
 /// Writes a color value as an array in Red, Green, Blue, Alpha order.
 /// </summary>
 /// <param name="output">The stream to which to write the color.</param>
 /// <param name="red">The red component in the range 0.0-1.0.</param>
 /// <param name="green">The green component in the range 0.0-1.0.</param>
 /// <param name="blue">The blue component in the range 0.0-1.0.</param>
 /// <param name="alpha">The alpha component in the range 0.0-1.0.</param>
 public static void WriteRgbaf(CesiumOutputStream output, float red, float green, float blue, float alpha)
 {
     output.WriteStartSequence();
     output.WriteValue(red);
     output.WriteValue(green);
     output.WriteValue(blue);
     output.WriteValue(alpha);
     output.WriteEndSequence();
 }
示例#17
0
 /// <summary>
 /// Writes a list of references.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="references">The list of references.</param>
 public static void WriteReferences(CesiumOutputStream output, IEnumerable <Reference> references)
 {
     output.WriteStartSequence();
     foreach (var reference in references)
     {
         output.WriteValue(reference.Value);
     }
     output.WriteEndSequence();
 }
示例#18
0
 /// <summary>
 /// Writes a <see cref="UnitQuaternion"/> as an array in [X, Y, Z, W] order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteUnitQuaternion(CesiumOutputStream output, UnitQuaternion value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteValue(value.Z);
     output.WriteValue(value.W);
     output.WriteEndSequence();
 }
示例#19
0
 /// <summary>
 /// Writes a list of <see cref="UnitSpherical"/> values as an array in Clock, Cone order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteUnitSphericalList(CesiumOutputStream output, IEnumerable <UnitSpherical> values)
 {
     output.WriteStartSequence();
     foreach (UnitSpherical value in values)
     {
         output.WriteValue(value.Clock);
         output.WriteValue(value.Cone);
     }
     output.WriteEndSequence();
 }
示例#20
0
 /// <summary>
 /// Writes a list of references.
 /// </summary>
 /// <param name="output">The stream to which to write.</param>
 /// <param name="references">The list of references to write.</param>
 public static void WriteReferences(CesiumOutputStream output, IEnumerable <string> references)
 {
     output.WriteStartSequence();
     foreach (string reference in references)
     {
         output.WriteValue(reference);
         output.WriteLineBreak();
     }
     output.WriteEndSequence();
 }
示例#21
0
 /// <summary>
 /// Writes a <see cref="Motion&lt;Cartesian&gt;"/> value as an array in X, Y, Z, vX, vY, vZ order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian3Velocity(CesiumOutputStream output, Motion <Cartesian> value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Value.X);
     output.WriteValue(value.Value.Y);
     output.WriteValue(value.Value.Z);
     output.WriteValue(value.FirstDerivative.X);
     output.WriteValue(value.FirstDerivative.Y);
     output.WriteValue(value.FirstDerivative.Z);
     output.WriteEndSequence();
 }
示例#22
0
 /// <summary>
 /// Writes a list of <see cref="UnitCartesian"/> values as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteUnitCartesian3List(CesiumOutputStream output, IEnumerable <UnitCartesian> values)
 {
     output.WriteStartSequence();
     foreach (UnitCartesian value in values)
     {
         output.WriteValue(value.X);
         output.WriteValue(value.Y);
         output.WriteValue(value.Z);
     }
     output.WriteEndSequence();
 }
示例#23
0
 /// <summary>
 /// Writes a list of <see cref="Cartographic"/> values as an array in Longitude, Latitude, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteCartographicList(CesiumOutputStream output, IEnumerable <Cartographic> values)
 {
     output.WriteStartSequence();
     foreach (Cartographic value in values)
     {
         output.WriteValue(value.Longitude);
         output.WriteValue(value.Latitude);
         output.WriteValue(value.Height);
     }
     output.WriteEndSequence();
 }
示例#24
0
        public void SuccessiveCallsToNewPacketReturnSameInstance()
        {
            m_output.WriteStartSequence();
            PacketCesiumWriter packet1 = m_writer.OpenPacket(m_output);

            packet1.Close();
            PacketCesiumWriter packet2 = m_writer.OpenPacket(m_output);

            packet2.Close();
            m_output.WriteEndSequence();
            Assert.AreSame(packet1, packet2);
        }
示例#25
0
 /// <summary>
 /// Writes a list of <see cref="TimeInterval">TimeIntervals</see>.  If the collection has a single
 /// interval, the interval is written as an ISO 8601 interval string.  If it has multiple intervals,
 /// it is written as an array of ISO 8601 interval strings.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="intervals">The intervals to write.</param>
 public static void WriteTimeIntervalCollection(CesiumOutputStream output, IList <TimeInterval> intervals)
 {
     if (intervals.Count == 1)
     {
         TimeInterval interval = intervals[0];
         WriteTimeInterval(output, interval);
     }
     else
     {
         output.WriteStartSequence();
         foreach (TimeInterval interval in intervals)
         {
             WriteTimeInterval(output, interval);
         }
         output.WriteEndSequence();
     }
 }
示例#26
0
 /// <summary>
 /// Writes a list of <see cref="TimeInterval">TimeIntervals</see>.  If the collection has a single
 /// interval, the interval is written as an ISO 8601 interval string.  If it has multiple intervals,
 /// it is written as an array of ISO 8601 interval strings.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="intervals">The intervals to write.</param>
 public static void WriteTimeIntervalCollection(CesiumOutputStream output, IList<TimeInterval> intervals)
 {
     if (intervals.Count == 1)
     {
         TimeInterval interval = intervals[0];
         WriteTimeInterval(output, interval);
     }
     else
     {
         output.WriteStartSequence();
         foreach (TimeInterval interval in intervals)
         {
             WriteTimeInterval(output, interval);
         }
         output.WriteEndSequence();
     }
 }
示例#27
0
        /// <summary>
        /// Writes time-tagged <see cref="Rectangular"/> values as an array in [Time, X, Y] order.
        /// Times are epoch seconds since an epoch that is determined from the first date to be written.
        /// The epoch property is written as well.
        /// </summary>
        /// <param name="output">The stream to which to write the array.</param>
        /// <param name="propertyName">The name of the property to write.</param>
        /// <param name="dates">The dates at which the value is specified.</param>
        /// <param name="values">The corresponding value for each date.</param>
        /// <param name="startIndex">The index of the first element to use in the <paramref name="values"/> collection.</param>
        /// <param name="length">The number of elements to use from the <paramref name="values"/> collection.</param>
        public static void WriteCartesian2(CesiumOutputStream output, string propertyName, IList<JulianDate> dates, IList<Rectangular> values, int startIndex, int length)
        {
            if (dates.Count != values.Count)
                throw new ArgumentException(CesiumLocalization.MismatchedNumberOfDatesAndValues, "values");

            JulianDate epoch = GetAndWriteEpoch(output, dates, startIndex, length);

            output.WritePropertyName(propertyName);
            output.WriteStartSequence();
            int last = startIndex + length;
            for (int i = startIndex; i < last; ++i)
            {
                output.WriteValue(epoch.SecondsDifference(dates[i]));
                Rectangular value = values[i];
                output.WriteValue(value.X);
                output.WriteValue(value.Y);
                output.WriteLineBreak();
            }

            output.WriteEndSequence();
        }
示例#28
0
        public void TestAvailabilityProperty()
        {
            JulianDate start = new GregorianDate(2012, 4, 2, 1, 2, 3).ToJulianDate();
            JulianDate stop  = new GregorianDate(2012, 4, 3, 1, 2, 3).ToJulianDate();

            m_outputStream.WriteStartSequence();
            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_outputStream))
            {
                packet.WriteAvailability(start, stop);
            }

            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_outputStream))
            {
                packet.WriteAvailability(new TimeInterval(start, stop));
            }

            using (PacketCesiumWriter packet = m_writer.OpenPacket(m_outputStream))
            {
                var intervals = new List <TimeInterval>
                {
                    new TimeInterval(start, stop),
                    new TimeInterval(start.AddDays(2.0), stop.AddDays(2.0))
                };
                packet.WriteAvailability(intervals);
            }

            m_outputStream.WriteEndSequence();

            const string expected =
                "[" +
                "{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                "{\"availability\":\"20120402T010203Z/20120403T010203Z\"}," +
                "{\"availability\":[\"20120402T010203Z/20120403T010203Z\",\"20120404T010203Z/20120405T010203Z\"]}" +
                "]";

            Assert.AreEqual(expected, m_stringWriter.ToString());
        }
示例#29
0
 /// <summary>
 /// Writes a list of <see cref="Cartographic"/> values as an array in Longitude, Latitude, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteCartographicList(CesiumOutputStream output, IEnumerable<Cartographic> values)
 {
     output.WriteStartSequence();
     foreach (Cartographic value in values)
     {
         output.WriteValue(value.Longitude);
         output.WriteValue(value.Latitude);
         output.WriteValue(value.Height);
     }
     output.WriteEndSequence();
 }
示例#30
0
 /// <summary>
 /// Writes a <see cref="Cartographic"/> value as an array in Longitude, Latitude, Height order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartographic(CesiumOutputStream output, Cartographic value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Longitude);
     output.WriteValue(value.Latitude);
     output.WriteValue(value.Height);
     output.WriteEndSequence();
 }
示例#31
0
 /// <summary>
 /// Writes a <see cref="UnitSpherical"/> value as an array in Clock, Cone order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteUnitSpherical(CesiumOutputStream output, UnitSpherical value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Clock);
     output.WriteValue(value.Cone);
     output.WriteEndSequence();
 }
示例#32
0
 /// <summary>
 /// Writes a <see cref="UnitCartesian"/> value as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteUnitCartesian3(CesiumOutputStream output, UnitCartesian value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteValue(value.Z);
     output.WriteEndSequence();
 }
 /// <summary>
 /// Writes a <see cref="CartographicExtent"/> value as an array in WestLongitude, SouthLatitude, EastLongitude, NorthLatitude order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartographicExtent(CesiumOutputStream output, CartographicExtent value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.WestLongitude);
     output.WriteValue(value.SouthLatitude);
     output.WriteValue(value.EastLongitude);
     output.WriteValue(value.NorthLatitude);
     output.WriteEndSequence();
 }
示例#34
0
 /// <summary>
 /// Writes a list of <see cref="UnitCartesian"/> values as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteUnitCartesian3List(CesiumOutputStream output, IEnumerable<UnitCartesian> values)
 {
     output.WriteStartSequence();
     foreach (UnitCartesian value in values)
     {
         output.WriteValue(value.X);
         output.WriteValue(value.Y);
         output.WriteValue(value.Z);
     }
     output.WriteEndSequence();
 }
示例#35
0
 /// <summary>
 /// Writes a <see cref="UnitQuaternion"/> as an array in [X, Y, Z, W] order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteUnitQuaternion(CesiumOutputStream output, UnitQuaternion value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.X);
     output.WriteValue(value.Y);
     output.WriteValue(value.Z);
     output.WriteValue(value.W);
     output.WriteEndSequence();
 }
示例#36
0
        /// <summary>
        /// This handles the HTTP request by writing some example CZML into the response.
        /// </summary>
        /// <param name="context">The current HttpContext</param>
        public void ProcessRequest(HttpContext context)
        {
            // A more complex example could examine context.Request here for
            // inputs coming from the client-side application.

            // Set the response type for CZML, which is JSON.
            context.Response.ContentType = "application/json";

            // Create an output stream writer for the response.
            using (var outputStream = new StreamWriter(context.Response.OutputStream))
            {
                var cesiumWriter = new CesiumStreamWriter();
                var output       = new CesiumOutputStream(outputStream)
                {
                    // Since this is a demo, turning on PrettyFormatting makes the response easier to view
                    // with web browser developer tools.  It just adds whitespace and newlines to the response,
                    // so production environments would typically leave this turned off.
                    PrettyFormatting = true
                };

                // The whole body of CZML must be wrapped in a JSON array, opened here.
                output.WriteStartSequence();

                // The first packet (JSON object) of CZML must be the document packet.
                using (var entity = cesiumWriter.OpenPacket(output))
                {
                    entity.WriteId("document");
                    entity.WriteVersion("1.0");
                }

                // Now we generate some sample points and send them down.
                for (int y = -3; y <= 3; ++y)
                {
                    double lat = y * 10.0;
                    for (int x = -18; x <= 18; ++x)
                    {
                        double lon = x * 9.99999999;

                        // Open a new CZML packet for each point.
                        using (var entity = cesiumWriter.OpenPacket(output))
                        {
                            entity.WriteId("point " + (x * 10) + " " + (y * 10));

                            using (var position = entity.OpenPositionProperty())
                            {
                                position.WriteCartographicDegrees(new Cartographic(lon, lat, 0.0));
                            }

                            using (var point = entity.OpenPointProperty())
                            {
                                point.WritePixelSizeProperty(10.0);
                                point.WriteColorProperty(Color.Yellow);
                            }

                            // Click any dot in Cesium Viewer to read its description.
                            using (var description = entity.OpenDescriptionProperty())
                            {
                                description.WriteString($@"
<table class=""cesium-infoBox-defaultTable"">
<tbody>
 <tr>
  <td>Longitude</td>
  <td>{lon:0} degrees</td>
 </tr>
 <tr>
  <td>Latitude</td>
  <td>{lat:0} degrees</td>
 </tr>
</tbody></table>");
                            }
                        }
                    }
                }

                // Close the JSON array that wraps the entire CZML document.
                output.WriteEndSequence();
            }
        }
 /// <summary>
 /// Writes a list of references.
 /// </summary>
 /// <param name="output">The stream to which to write.</param>
 /// <param name="references">The list of references to write.</param>
 public static void WriteReferences(CesiumOutputStream output, IEnumerable<string> references)
 {
     output.WriteStartSequence();
     foreach (string reference in references)
     {
         output.WriteValue(reference);
         output.WriteLineBreak();
     }
     output.WriteEndSequence();
 }
示例#38
0
        public static void Main(string[] args)
        {
            // use a fixed seed so repeated invocations use the same colors
            var rng = new Random(0);

            var files = new[]
            {
                @"ISS11_07_image_data.csv",
                @"ISS11_11_image_data.csv",
                @"ISS12_01_image_data.csv",
                @"ISS12_07_2_image_data.csv",
                @"ISS12_11_image_data.csv",
                @"ISS13_01_image_data.csv",
                @"ISS11_04_image_data.csv"
            };

            List <KeyValuePair <string, string> > missions = new List <KeyValuePair <string, string> >();

            foreach (var fileName in files)
            {
                string   csvFile = Path.Combine(AssetsDirectory, "CSV", fileName);
                string[] lines   = File.ReadAllLines(csvFile);

                string czmlFile = Path.Combine(AssetsDirectory, "CZML", Path.ChangeExtension(fileName, ".czml"));
                string jsonFile = Path.Combine(AssetsDirectory, "JSON", Path.ChangeExtension(fileName, ".json"));

                using (StreamWriter czmlWriter = new StreamWriter(czmlFile))
                    using (StreamWriter jsonWriter = new StreamWriter(jsonFile))
                        using (CesiumOutputStream czmlOutputStream = new CesiumOutputStream(czmlWriter))
                        {
                            czmlOutputStream.PrettyFormatting = false;
                            czmlOutputStream.WriteStartSequence();

                            List <string> ID          = new List <string>();
                            List <string> Time        = new List <string>();
                            List <string> School      = new List <string>();
                            List <string> ImageUrl    = new List <string>();
                            List <string> LensSize    = new List <string>();
                            List <string> OrbitNumber = new List <string>();
                            List <string> FrameWidth  = new List <string>();
                            List <string> FrameHeight = new List <string>();
                            List <string> Page        = new List <string>();
                            List <string> CZML        = new List <string>();

                            GregorianDate start = new GregorianDate();
                            for (int i = 1; i < lines.Length; i++)
                            {
                                string   line   = lines[i];
                                string[] tokens = line.Split(',');
                                for (int q = 0; q < tokens.Length; q++)
                                {
                                    tokens[q] = tokens[q].Trim('"').Trim();
                                }

                                if (i == 1)
                                {
                                    start = GregorianDate.Parse(tokens[17]);
                                    missions.Add(new KeyValuePair <string, string>(Path.ChangeExtension(fileName, null), tokens[18]));
                                }
                                else if (i == lines.Length - 1)
                                {
                                    Console.WriteLine(Path.GetFileNameWithoutExtension(fileName));
                                    Console.WriteLine(start.ToJulianDate().TotalDays + " JDate");
                                    var stop = GregorianDate.Parse(tokens[17]);
                                    Console.WriteLine(stop.ToJulianDate().TotalDays + " JDate");
                                    Console.WriteLine();
                                    //Console.WriteLine((stop.ToJulianDate() - start.ToJulianDate()).TotalDays);
                                }

                                var writer = new CesiumStreamWriter();
                                using (var packet = writer.OpenPacket(czmlOutputStream))
                                {
                                    packet.WriteId(tokens[0]);
                                    using (var vertexPositions = packet.OpenVertexPositionsProperty())
                                    {
                                        var points = new Cartographic[] {
                                            new Cartographic(double.Parse(tokens[5]), double.Parse(tokens[6]), 0),
                                            new Cartographic(double.Parse(tokens[7]), double.Parse(tokens[8]), 0),
                                            new Cartographic(double.Parse(tokens[9]), double.Parse(tokens[10]), 0),
                                            new Cartographic(double.Parse(tokens[11]), double.Parse(tokens[12]), 0)
                                        };
                                        vertexPositions.WriteCartographicDegrees(points);
                                    }
                                    using (var polygon = packet.OpenPolygonProperty())
                                    {
                                        polygon.WriteShowProperty(true);
                                        using (var material = polygon.OpenMaterialProperty())
                                        {
                                            using (var color = material.OpenSolidColorProperty())
                                            {
                                                color.WriteColorProperty(Color.FromArgb(255, (int)(rng.NextDouble() * 255), (int)(rng.NextDouble() * 255), (int)(rng.NextDouble() * 255)));
                                            }
                                        }
                                    }
                                }

                                for (int q = 0; q < tokens.Length; q++)
                                {
                                    tokens[q] = tokens[q].Replace("\"", "\\\"");
                                }

                                ID.Add(tokens[0]);
                                Time.Add(GregorianDate.Parse(tokens[17]).ToIso8601String(Iso8601Format.Compact));
                                School.Add(tokens[23]);
                                ImageUrl.Add(tokens[21].Split(new[] { '=' })[2]);
                                LensSize.Add(tokens[14]);
                                OrbitNumber.Add(tokens[19]);
                                FrameWidth.Add(tokens[15]);
                                FrameHeight.Add(tokens[16]);
                                Page.Add(tokens[20].Split(new[] { '=' })[1]);
                            }

                            czmlOutputStream.WriteEndSequence();

                            jsonWriter.WriteLine("{");
                            writeJsonArray(jsonWriter, "ID", ID);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "Time", Time);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "School", School);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "ImageUrl", ImageUrl);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "LensSize", LensSize);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "OrbitNumber", OrbitNumber);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "FrameWidth", FrameWidth);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "FrameHeight", FrameHeight);
                            jsonWriter.WriteLine(",");
                            writeJsonArray(jsonWriter, "Page", Page);
                            jsonWriter.WriteLine();
                            jsonWriter.WriteLine("}");
                        }
            }

            using (StreamWriter missionsJsonWriter = new StreamWriter(Path.Combine(AssetsDirectory, "missions.json")))
            {
                missionsJsonWriter.Write("[");
                for (int i = 0; i < missions.Count; ++i)
                {
                    missionsJsonWriter.Write("{{\"file\":\"{0}\",\"name\":\"{1}\"}}", missions[i].Key, missions[i].Value);
                    if (i != missions.Count - 1)
                    {
                        missionsJsonWriter.Write(",");
                    }
                }
                missionsJsonWriter.Write("]");
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            using (var outputStream = new StreamWriter(context.Response.OutputStream))
            {
                var cesiumWriter = new CesiumStreamWriter();
                var output       = new CesiumOutputStream(outputStream);

                output.PrettyFormatting = true;

                // The whole body of CZML must be wrapped in a JSON array, opened here.
                output.WriteStartSequence();

                // The first packet (JSON object) of CZML must be the document packet.
                using (var entity = cesiumWriter.OpenPacket(output))
                {
                    entity.WriteId("document");
                    entity.WriteVersion("1.0");
                }


                // write an entity for each rocket launch phase

                var rocketData = new RocketTrajectoryData();

                var entities = rocketData.GetBetterRocketData();

                // get each phase


                foreach (var stage in entities.stages)
                {
                    var cartesianVelocitySet = GenerateCartesianVelocitySet(stage);

                    var clr   = GetNextColour();
                    var count = 0;
                    foreach (var positions in cartesianVelocitySet.Item2)
                    {
                        count++;

                        if (count % 100 == 0)
                        {
                            using (var packet = cesiumWriter.OpenPacket(output))
                            {
                                using (var point = packet.OpenPointProperty())
                                {
                                    point.WriteColorProperty(Color.Yellow);
                                    point.WritePixelSizeProperty(10.0);
                                }

                                using (var desc = packet.OpenDescriptionProperty())
                                {
                                    desc.WriteString("x,y,z:" + positions.Value.ToString());
                                }
                                using (var position = packet.OpenPositionProperty())
                                {
                                    position.WriteCartesian(positions.Value);
                                }
                            }
                        }
                    }



                    using (var packet = cesiumWriter.OpenPacket(output))
                    {
                        packet.WriteId("RocketLaunch");
                        using (var position = packet.OpenPositionProperty())
                        {
                            position.WriteCartesianVelocity(cartesianVelocitySet.Item1, cartesianVelocitySet.Item2);
                        }
                        using (var description = packet.OpenDescriptionProperty())
                        {
                            description.WriteString("This is the description of this element");
                        }

                        using (var path = packet.OpenPathProperty())
                        {
                            using (var material = path.OpenMaterialProperty())
                            {
                                using (var outline = material.OpenSolidColorProperty())
                                {
                                    using (var colour = outline.OpenColorProperty())
                                    {
                                        colour.WriteRgba(Color.DarkGoldenrod);
                                    }
                                }
                            }
                            path.WriteWidthProperty(8);
                            path.WriteLeadTimeProperty(10);
                            path.WriteTrailTimeProperty(1000);
                            path.WriteResolutionProperty(5);
                        }
                    }
                }

                output.WriteEndSequence();
            }
        }
 /// <summary>
 /// Writes a <see cref="NearFarScalar"/> value as an array in Clock, Cone, Magnitude order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteNearFarScalar(CesiumOutputStream output, NearFarScalar value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.NearDistance);
     output.WriteValue(value.NearValue);
     output.WriteValue(value.FarDistance);
     output.WriteValue(value.FarValue);
     output.WriteEndSequence();
 }
 /// <summary>
 /// Writes a color value as an array in Red, Green, Blue, Alpha order as floating-point values.
 /// </summary>
 /// <param name="output">The stream to which to write the color.</param>
 /// <param name="red">The red component in the range 0.0-1.0.</param>
 /// <param name="green">The green component in the range 0.0-1.0.</param>
 /// <param name="blue">The blue component in the range 0.0-1.0.</param>
 /// <param name="alpha">The alpha component in the range 0.0-1.0.</param>
 public static void WriteRgbaf(CesiumOutputStream output, double red, double green, double blue, double alpha)
 {
     output.WriteStartSequence();
     output.WriteValue(red);
     output.WriteValue(green);
     output.WriteValue(blue);
     output.WriteValue(alpha);
     output.WriteEndSequence();
 }
示例#42
0
 /// <summary>
 /// Writes a color value as an array in Red, Green, Blue, Alpha order.
 /// </summary>
 /// <param name="output">The stream to which to write the color.</param>
 /// <param name="red">The red component in the range 0.0-1.0.</param>
 /// <param name="green">The green component in the range 0.0-1.0.</param>
 /// <param name="blue">The blue component in the range 0.0-1.0.</param>
 /// <param name="alpha">The alpha component in the range 0.0-1.0.</param>
 public static void WriteRgbaf(CesiumOutputStream output, float red, float green, float blue, float alpha)
 {
     output.WriteStartSequence();
     output.WriteValue(red);
     output.WriteValue(green);
     output.WriteValue(blue);
     output.WriteValue(alpha);
     output.WriteEndSequence();
 }
示例#43
0
 /// <summary>
 /// Writes a list of <see cref="UnitSpherical"/> values as an array in Clock, Cone order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteUnitSphericalList(CesiumOutputStream output, IEnumerable<UnitSpherical> values)
 {
     output.WriteStartSequence();
     foreach (UnitSpherical value in values)
     {
         output.WriteValue(value.Clock);
         output.WriteValue(value.Cone);
     }
     output.WriteEndSequence();
 }
示例#44
0
 /// <summary>
 /// Writes a list of references.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="references">The list of references.</param>
 public static void WriteReferences(CesiumOutputStream output, IEnumerable<Reference> references)
 {
     output.WriteStartSequence();
     foreach (var reference in references)
     {
         output.WriteValue(reference.Value);
     }
     output.WriteEndSequence();
 }
示例#45
0
 /// <summary>
 /// Writes a <see cref="Motion&lt;Cartesian&gt;"/> value as an array in X, Y, Z, vX, vY, vZ order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteCartesian3Velocity(CesiumOutputStream output, Motion<Cartesian> value)
 {
     output.WriteStartSequence();
     output.WriteValue(value.Value.X);
     output.WriteValue(value.Value.Y);
     output.WriteValue(value.Value.Z);
     output.WriteValue(value.FirstDerivative.X);
     output.WriteValue(value.FirstDerivative.Y);
     output.WriteValue(value.FirstDerivative.Z);
     output.WriteEndSequence();
 }
示例#46
0
        public ActionResult Info(int ID, Int64 lastdataid = 0)
        {
            var          flightmapdatas = db.FlightMapDatas.Where(x => x.FlightID == ID && (x.Altitude > 0 || x.Speed > 0) && x.FlightMapDataID > lastdataid).OrderBy(x => x.FlightMapDataID).ToList();
            int          count          = flightmapdatas.Count();
            MemoryStream ms             = new MemoryStream();
            var          outputStream   = new StreamWriter(ms);
            var          cesiumWriter   = new CesiumStreamWriter();
            var          output         = new CesiumOutputStream(outputStream)
            {
                // Since this is a demo, turning on PrettyFormatting makes the response easier to view
                // with web browser developer tools.  It just adds whitespace and newlines to the response,
                // so production environments would typically leave this turned off.
                PrettyFormatting = true
            };

            if (count > 0)
            {
                // The whole body of CZML must be wrapped in a JSON array, opened here.
                output.WriteStartSequence();

                FlightMapData firstItem = db.FlightMapDatas.Where(x => x.FlightID == ID && (x.Altitude > 0 || x.Speed > 0)).OrderBy(x => x.FlightMapDataID).ToList().Take(1).FirstOrDefault();

                FlightMapData       LastItem  = db.FlightMapDatas.Where(x => x.FlightID == ID && (x.Altitude > 0 || x.Speed > 0)).OrderBy(x => x.FlightMapDataID).ToList().LastOrDefault();
                JulianDate          StartTime = new JulianDate(firstItem.ReadTime.Value);
                JulianDate          EndTime   = new JulianDate(LastItem.ReadTime.Value);
                string              curFile   = @"C:\Cesium\test.czml";
                FileInfo            info      = new FileInfo(curFile);
                List <Cartographic> pList     = new List <Cartographic>();
                List <JulianDate>   JList     = new List <JulianDate>();
                List <Double>       HList     = new List <Double>();
                List <Double>       PList     = new List <Double>();
                List <Double>       RList     = new List <Double>();



                // The first packet (JSON object) of CZML must be the document packet.
                using (var entity = cesiumWriter.OpenPacket(output))
                {
                    entity.WriteId("document");
                    entity.WriteVersion("1.0");
                    using (var clock = entity.OpenClockProperty())
                    {
                        clock.WriteInterval(new TimeInterval(StartTime, EndTime));
                        if (lastdataid == 0)
                        {
                            clock.WriteCurrentTime(StartTime);
                        }
                        else
                        {
                            clock.WriteCurrentTime(EndTime);
                        }

                        clock.WriteMultiplier(2);
                        clock.WriteStep(ClockStep.SystemClockMultiplier);
                    }
                    //}
                }
                // Open a new CZML packet for each point.
                using (var entity = cesiumWriter.OpenPacket(output))
                {
                    entity.WriteId("Aircraft");
                    entity.WriteVersion("1.0");

                    entity.WriteAvailability(new TimeInterval(StartTime, EndTime));



                    using (var path = entity.OpenPathProperty())
                    {
                        using (var show = path.OpenShowProperty())
                        {
                            //if(lastdataid==0)
                            // show.WriteInterval(new TimeInterval(StartTime, EndTime));

                            show.WriteBoolean(true);
                        }

                        path.WriteWidthProperty(2);
                        using (var material = path.OpenMaterialProperty())
                        {
                            using (var sol = material.OpenSolidColorProperty())
                            {
                                sol.WriteColorProperty(0, 255, 255, 255);
                            }
                        }
                        path.WriteResolutionProperty(1200);
                    }



                    using (var position = entity.OpenPositionProperty())
                    {
                        foreach (FlightMapData fmp in flightmapdatas)
                        {
                            double       lat = Convert.ToDouble(fmp.Latitude);
                            double       lon = Convert.ToDouble(fmp.Longitude);
                            double       alt = Convert.ToDouble(fmp.Altitude);
                            Cartographic nC  = new Cartographic(lon, lat, alt);
                            pList.Add(nC);
                            JulianDate jd = new JulianDate(fmp.ReadTime.Value);
                            JList.Add(jd);
                            var heading = Convert.ToDouble(fmp.Heading);
                            HList.Add(heading);
                            var pitch = Convert.ToDouble(fmp.Pitch);
                            PList.Add(pitch);

                            var roll = Convert.ToDouble(fmp.Roll);
                            RList.Add(roll);
                        }
                        position.WriteCartographicDegrees(JList, pList);
                    }
                }

                // Now we generate some sample points and send them down.
                // Close the JSON array that wraps the entire CZML document.

                using (var entity = cesiumWriter.OpenPacket(output))
                {
                    entity.WriteId("Custom");
                    entity.WriteVersion("1.0");
                    entity.WriteAvailability(new TimeInterval(StartTime, EndTime));
                    var custom = entity.OpenPropertiesProperty();
                    CustomPropertyCesiumWriter newpro = custom.OpenCustomPropertyProperty("heading");
                    newpro.AsNumber();
                    newpro.WriteNumber(JList, HList);
                    newpro.Close();

                    CustomPropertyCesiumWriter newroll = custom.OpenCustomPropertyProperty("roll");
                    newroll.AsNumber();

                    newroll.WriteNumber(JList, RList);
                    newroll.Close();
                    CustomPropertyCesiumWriter newpitch = custom.OpenCustomPropertyProperty("pitch");                    // newpitch.Open(output);
                    newpitch.AsNumber();

                    newpitch.WriteNumber(JList, PList);
                    newpitch.Close();
                    CustomPropertyCesiumWriter LastDataID = custom.OpenCustomPropertyProperty("lastdataid");

                    LastDataID.AsNumber();

                    LastDataID.WriteNumber(LastItem.FlightMapDataID);
                    LastDataID.Close();
                    custom.Close();
                }

                output.WriteEndSequence();

                //ms.Position = 0;

                //ms.Seek(0, SeekOrigin.Begin);
                outputStream.Flush();

                // }
            }

            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/json"));
        }
 /// <summary>
 /// Writes a list of <see cref="double"/> values as an array in X, Y, Z order.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="values">The values to write.</param>
 public static void WriteDoubleList(CesiumOutputStream output, IEnumerable<double> values)
 {
     output.WriteStartSequence();
     foreach (double value in values)
     {
         output.WriteValue(value);
     }
     output.WriteEndSequence();
 }
        public void CreateExampleFile()
        {
            using (var stringWriter = new StringWriter())
            {
                var output = new CesiumOutputStream(stringWriter, true);
                var writer = new CesiumStreamWriter();

                output.WriteStartSequence();

                using (var documentPacket = writer.OpenPacket(output))
                {
                    documentPacket.WriteId("document");
                    documentPacket.WriteVersion("1.0");
                    using (var clockWriter = documentPacket.OpenClockProperty())
                        using (var intervalClockWriter = clockWriter.OpenInterval(m_startDate, m_stopDate))
                        {
                            intervalClockWriter.WriteCurrentTime(m_startDate);
                        }
                }

                using (var packet = writer.OpenPacket(output))
                {
                    packet.WriteId("MyID");

                    using (var customPropertiesWriter = packet.OpenPropertiesProperty())
                    {
                        using (var customPropertyWriter = customPropertiesWriter.OpenCustomPropertyProperty("custom_boolean"))
                            using (var intervalListWriter = customPropertyWriter.OpenMultipleIntervals())
                            {
                                using (var intervalWriter = intervalListWriter.OpenInterval(m_startDate, m_startDate.AddSeconds(1)))
                                {
                                    intervalWriter.WriteBoolean(true);
                                }

                                using (var intervalWriter = intervalListWriter.OpenInterval(m_startDate.AddSeconds(1), m_startDate.AddSeconds(2)))
                                {
                                    intervalWriter.WriteBoolean(false);
                                }

                                using (var intervalWriter = intervalListWriter.OpenInterval(m_startDate.AddSeconds(2), m_stopDate))
                                {
                                    intervalWriter.WriteBoolean(true);
                                }
                            }

                        using (var customPropertyWriter = customPropertiesWriter.OpenCustomPropertyProperty("custom_cartesian"))
                        {
                            var dates  = new List <JulianDate>();
                            var values = new List <Cartesian>();

                            dates.Add(m_startDate);
                            values.Add(new Cartesian(1.0, 2.0, 3.0));

                            dates.Add(m_startDate.AddSeconds(60.0));
                            values.Add(new Cartesian(4.0, 5.0, 6.0));

                            dates.Add(m_startDate.AddSeconds(120.0));
                            values.Add(new Cartesian(7.0, 8.0, 9.0));

                            customPropertyWriter.WriteCartesian(dates, values);
                        }
                    }
                }

                output.WriteEndSequence();

                Console.WriteLine(stringWriter.ToString());
            }
        }
        public void TestExample()
        {
            var stringWriter = new StringWriter();
            var outputStream = new CesiumOutputStream(stringWriter)
            {
                PrettyFormatting = true
            };
            var writer = new CesiumStreamWriter();

            outputStream.WriteStartSequence();

            using (var packet = writer.OpenPacket(outputStream))
            {
                packet.WriteId("document");
                packet.WriteName("CZML Geometries: Polyline Volume");
                packet.WriteVersion("1.0");
            }

            using (var packet = writer.OpenPacket(outputStream))
            {
                packet.WriteId("greenBox");
                packet.WriteName("Green box with beveled corners and outline");

                using (var polylineVolume = packet.OpenPolylineVolumeProperty())
                {
                    using (var positions = polylineVolume.OpenPositionsProperty())
                    {
                        positions.WriteCartographicDegrees(new List <Cartographic>
                        {
                            new Cartographic(-90.0, 32.0, 0),
                            new Cartographic(-90.0, 36.0, 100000),
                            new Cartographic(-94.0, 36.0, 0),
                        });
                    }

                    using (var shape = polylineVolume.OpenShapeProperty())
                    {
                        shape.WriteCartesian2(new List <Rectangular>
                        {
                            new Rectangular(-50000, -50000),
                            new Rectangular(50000, -50000),
                            new Rectangular(50000, 50000),
                            new Rectangular(-50000, 50000),
                        });
                    }

                    polylineVolume.WriteCornerTypeProperty(CesiumCornerType.Beveled);

                    using (var material = polylineVolume.OpenMaterialProperty())
                    {
                        using (var solidColor = material.OpenSolidColorProperty())
                        {
                            solidColor.WriteColorProperty(Color.FromArgb(128, Color.Lime));
                        }
                    }

                    polylineVolume.WriteOutlineProperty(true);
                    polylineVolume.WriteOutlineColorProperty(Color.Black);
                }
            }

            using (var packet = writer.OpenPacket(outputStream))
            {
                packet.WriteId("blueStar");
                packet.WriteName("Blue star with mitered corners and outline");

                using (var polylineVolume = packet.OpenPolylineVolumeProperty())
                {
                    using (var positions = polylineVolume.OpenPositionsProperty())
                    {
                        positions.WriteCartographicDegrees(new List <Cartographic>
                        {
                            new Cartographic(-95.0, 32.0, 0),
                            new Cartographic(-95.0, 36.0, 100000),
                            new Cartographic(-99.0, 36.0, 200000),
                        });
                    }

                    using (var shape = polylineVolume.OpenShapeProperty())
                    {
                        const int    arms   = 7;
                        const double rOuter = 70000.0;
                        const double rInner = 50000.0;

                        const double angle    = Math.PI / arms;
                        var          vertices = new List <Rectangular>();
                        for (int i = 0; i < 2 * arms; i++)
                        {
                            double r = i % 2 == 0 ? rOuter : rInner;
                            vertices.Add(new Rectangular(Math.Cos(i * angle) * r, Math.Sin(i * angle) * r));
                        }

                        shape.WriteCartesian2(vertices);
                    }

                    polylineVolume.WriteCornerTypeProperty(CesiumCornerType.Mitered);

                    using (var material = polylineVolume.OpenMaterialProperty())
                    {
                        using (var solidColor = material.OpenSolidColorProperty())
                        {
                            solidColor.WriteColorProperty(Color.Blue);
                        }
                    }
                }
            }

            outputStream.WriteEndSequence();

            Console.WriteLine(stringWriter.ToString());
        }