Exemple #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();
 }
Exemple #2
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();
        }
 public void TestCesiumPropertyWriterSetUp()
 {
     StringWriter = new StringWriter();
     OutputStream = new CesiumOutputStream(StringWriter);
     Writer       = new CesiumStreamWriter();
     Packet       = Writer.OpenPacket(OutputStream);
 }
Exemple #4
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();
        }
Exemple #5
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();
        }
 /// <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();
 }
Exemple #7
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();
 }
        public void CreateExampleFile()
        {
            using (var stringWriter = new StringWriter())
            {
                var output = new CesiumOutputStream(stringWriter)
                {
                    PrettyFormatting = true
                };
                var writer = new CesiumStreamWriter();

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

                    var startDate = new JulianDate(new GregorianDate(2012, 4, 2, 12, 0, 0));
                    var stopDate  = new JulianDate(new GregorianDate(2012, 4, 2, 12, 1, 0));

                    using (var clockWriter = packet.OpenClockProperty())
                    {
                        using (var intervalClockWriter = clockWriter.OpenInterval(startDate, stopDate))
                        {
                            intervalClockWriter.WriteCurrentTime(startDate);
                        }
                    }

                    using (var modelWriter = packet.OpenModelProperty())
                    {
                        modelWriter.WriteGltfProperty(new Uri("example.gltf", UriKind.Relative), CesiumResourceBehavior.LinkTo);

                        using (var nodeTransformationsWriter = modelWriter.OpenNodeTransformationsProperty())
                        {
                            using (var nodeTransformationWriter = nodeTransformationsWriter.OpenNodeTransformationProperty("node1"))
                            {
                                nodeTransformationWriter.WriteScaleProperty(new Cartesian(1.0, 2.0, 3.0));
                                nodeTransformationWriter.WriteRotationProperty(UnitQuaternion.Identity);
                                nodeTransformationWriter.WriteTranslationProperty(new Cartesian(4.0, 5.0, 6.0));
                            }

                            using (var nodeTransformationWriter = nodeTransformationsWriter.OpenNodeTransformationProperty("node2"))
                            {
                                var dates = new List <JulianDate>
                                {
                                    startDate,
                                    stopDate
                                };
                                var values = new List <Cartesian>
                                {
                                    new Cartesian(1.0, 2.0, 3.0),
                                    new Cartesian(10.0, 12.0, 14.0)
                                };
                                nodeTransformationWriter.WriteScaleProperty(dates, values);
                            }
                        }
                    }
                }

                Console.WriteLine(stringWriter.ToString());
            }
        }
Exemple #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();
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CzmlDocument"/> class.
 /// </summary>
 public CzmlDocument(TextWriter outputWriter)
 {
     m_output              = new CesiumOutputStream(outputWriter);
     m_writer              = new CesiumStreamWriter();
     m_imageResolver       = new CachingCesiumUrlResolver(int.MaxValue);
     NamespaceDeclarations = new Dictionary <string, XNamespace>();
     Namespace             = "";
 }
Exemple #11
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();
 }
Exemple #12
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();
 }
Exemple #13
0
 /// <summary>
 /// Opens this writer on a given <see cref="CesiumOutputStream"/>.  A single writer can write to multiple
 /// streams over its lifetime.  Opening a writer on a stream may cause data to be written to the stream.
 /// </summary>
 /// <param name="output">The stream to which to write.</param>
 /// <exception cref="InvalidOperationException">The writer is already open on a stream.</exception>
 public void Open(CesiumOutputStream output)
 {
     if (m_output != null)
     {
         throw new InvalidOperationException(CesiumLocalization.WriterAlreadyOpen);
     }
     m_output = output;
     OnOpen();
 }
Exemple #14
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();
 }
 /// <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();
 }
 /// <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();
 }
Exemple #17
0
        public void CreateExampleFile()
        {
            using (var stringWriter = new StringWriter())
            {
                var output = new CesiumOutputStream(stringWriter)
                {
                    PrettyFormatting = true
                };
                var writer = new CesiumStreamWriter();

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

                    var startDate = new JulianDate(new GregorianDate(2012, 4, 2, 12, 0, 0));
                    var stopDate  = new JulianDate(new GregorianDate(2012, 4, 2, 12, 1, 0));

                    using (var clockWriter = packet.OpenClockProperty())
                    {
                        using (var intervalClockWriter = clockWriter.OpenInterval(startDate, stopDate))
                        {
                            intervalClockWriter.WriteCurrentTime(startDate);
                        }
                    }

                    using (var modelWriter = packet.OpenModelProperty())
                    {
                        modelWriter.WriteGltfProperty(new Uri("example.gltf", UriKind.Relative), CesiumResourceBehavior.LinkTo);

                        using (var articulationsWriter = modelWriter.OpenArticulationsProperty())
                        {
                            using (var articulationWriter = articulationsWriter.OpenArticulationProperty("articulation1 stage1"))
                            {
                                articulationWriter.WriteNumber(45);
                            }

                            using (var articulationWriter = articulationsWriter.OpenArticulationProperty("articulation1 stage2"))
                            {
                                var dates = new List <JulianDate>
                                {
                                    startDate,
                                    stopDate
                                };
                                var values = new List <double>
                                {
                                    1.0,
                                    10.0
                                };
                                articulationWriter.WriteNumber(dates, values);
                            }
                        }
                    }
                }

                Console.WriteLine(stringWriter.ToString());
            }
        }
 /// <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();
 }
 /// <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();
 }
 /// <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();
 }
Exemple #22
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();
 }
Exemple #23
0
 /// <summary>
 /// Closes this writer on a given stream, but does not close the underlying stream.  Closing a writer
 /// on a stream may cause data to be written to the stream.
 /// </summary>
 /// <exception cref="InvalidOperationException">The writer is not open on a stream.</exception>
 public void Close()
 {
     if (m_output == null)
     {
         throw new InvalidOperationException(CesiumLocalization.WriterAlreadyClosed);
     }
     OnClose();
     m_output = null;
 }
Exemple #24
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();
 }
Exemple #25
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();
 }
Exemple #26
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();
 }
Exemple #27
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();
 }
Exemple #28
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();
 }
Exemple #29
0
 /// <summary>
 /// Gets an appropriate epoch from a list of dates and writes it to the <see cref="CesiumOutputStream"/>
 /// as the "epoch" property.  If the <paramref name="dates"/> collection is empty, the <paramref name="startIndex"/>
 /// is past the end of the collection, or the <paramref name="length"/> is zero, this method does not write
 /// the "epoch" property and returns <see cref="JulianDate.MinValue"/>.
 /// </summary>
 /// <param name="output">The stream to which to write the epoch.</param>
 /// <param name="dates">The collection of dates from which to determine the epoch.</param>
 /// <param name="startIndex">The first index in the collection to use.</param>
 /// <param name="length">The number of items from the collection to use.</param>
 /// <returns>A suitable epoch determined from the collection.</returns>
 private static JulianDate GetAndWriteEpoch(CesiumOutputStream output, IList <JulianDate> dates, int startIndex, int length)
 {
     if (startIndex < dates.Count)
     {
         JulianDate epoch = dates[startIndex];
         output.WritePropertyName("epoch");
         output.WriteValue(CesiumFormattingHelper.ToIso8601(epoch, output.PrettyFormatting ? Iso8601Format.Extended : Iso8601Format.Compact));
         return(epoch);
     }
     else
     {
         return(JulianDate.MinValue);
     }
 }
Exemple #30
0
        public void RunExample()
        {
            var stringWriter = new StringWriter();
            var output       = new CesiumOutputStream(stringWriter)
            {
                PrettyFormatting = true
            };

            var stream = new CesiumStreamWriter();

            using (var packet = stream.OpenPacket(output))
            {
                packet.WriteId("Test");

                using (var billboard = packet.OpenBillboardProperty())
                {
                    billboard.WriteColorProperty(123, 67, 0, 255);
                    billboard.WriteImageProperty(new Uri("http://cesiumjs.org/images/CesiumHeaderLogo.png"), CesiumResourceBehavior.LinkTo);
                }

                using (var position = packet.OpenPositionProperty())
                {
                    position.WriteCartographicDegrees(new Cartographic(-75.0, 45.0, 100.0));
                }

                using (var model = packet.OpenModelProperty())
                    using (var color = model.OpenColorProperty())
                        using (var intervals = color.OpenMultipleIntervals())
                        {
                            var start = new GregorianDate(2012, 8, 4, 16, 0, 0).ToJulianDate();
                            var stop  = new GregorianDate(2012, 8, 4, 16, 1, 0).ToJulianDate();

                            using (var interval = intervals.OpenInterval(start, stop))
                            {
                                interval.WriteRgbaf(Color.Red);
                            }

                            start = new GregorianDate(2012, 8, 4, 16, 1, 0).ToJulianDate();
                            stop  = new GregorianDate(2012, 8, 4, 16, 2, 0).ToJulianDate();
                            using (var interval = intervals.OpenInterval(start, stop))
                            {
                                interval.WriteRgbaf(Color.Lime);
                            }
                        }
            }

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

            using (var packet = writer.OpenPacket(outputStream))
            {
                packet.WriteId("examplePolygon");

                using (var polygon = packet.OpenPolygonProperty())
                {
                    using (var positions = polygon.OpenPositionsProperty())
                    {
                        var listOfPositions = new List <Cartographic> {
                            new Cartographic(0, 0, 0), new Cartographic(0, 10, 0), new Cartographic(10, 10, 0), new Cartographic(10, 0, 0),
                        };
                        positions.WriteCartographicDegrees(listOfPositions);
                    }

                    using (var holes = polygon.OpenHolesProperty())
                    {
                        var listOfHoles = new List <List <Cartographic> >
                        {
                            new List <Cartographic> {
                                new Cartographic(1, 1, 0), new Cartographic(1, 2, 0), new Cartographic(2, 2, 0),
                            },
                            new List <Cartographic> {
                                new Cartographic(4, 4, 0), new Cartographic(4, 5, 0), new Cartographic(5, 5, 0), new Cartographic(5, 4, 0),
                            },
                        };
                        holes.WriteCartographicDegrees(listOfHoles);
                    }

                    using (var material = polygon.OpenMaterialProperty())
                    {
                        using (var solidColor = material.OpenSolidColorProperty())
                        {
                            solidColor.WriteColorProperty(Color.Red);
                        }
                    }
                }
            }

            Console.WriteLine(StringWriter.ToString());
        }
 /// <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();
     }
 }
Exemple #33
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();
     }
 }
        /// <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();
        }
 /// <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();
 }
 /// <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();
 }
 /// <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 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();
 }
 /// <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();
 }
 /// <summary>
 /// Writes a <see cref="TimeInterval"/> as an ISO 8601 interval string.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="interval">The interval to write.</param>
 public static void WriteTimeInterval(CesiumOutputStream output, TimeInterval interval)
 {
     output.WriteValue(CesiumFormattingHelper.ToIso8601Interval(interval.Start, interval.Stop, output.PrettyFormatting ? Iso8601Format.Extended : Iso8601Format.Compact));
 }
 /// <summary>
 /// Writes a reference from an identifier and hierarchy of property names.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="identifier">The identifier of the referenced object.</param>
 /// <param name="propertyNames">The hierarchy of property names, where each name is a subproperty of the previous item.</param>
 public static void WriteReference(CesiumOutputStream output, string identifier, string[] propertyNames)
 {
     WriteReference(output, new Reference(identifier, propertyNames));
 }
 /// <summary>
 /// Writes a <see cref="JulianDate"/> as an ISO 8601 interval string.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="date">The date to write.</param>
 public static void WriteDate(CesiumOutputStream output, JulianDate date)
 {
     output.WriteValue(CesiumFormattingHelper.ToIso8601(date, output.PrettyFormatting ? Iso8601Format.Extended : Iso8601Format.Compact));
 }
 /// <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="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();
 }
 /// <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();
 }
 /// <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();
 }
 /// <summary>
 /// Writes a reference.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteReference(CesiumOutputStream output, string value)
 {
     output.WriteValue(value);
 }
 /// <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();
 }
 /// <summary>
 /// Writes a reference.
 /// </summary>
 /// <param name="output">The stream to which to write the value.</param>
 /// <param name="value">The value to write.</param>
 public static void WriteReference(CesiumOutputStream output, Reference value)
 {
     WriteReference(output, value.Value);
 }
 /// <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();
 }
 /// <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();
 }
 /// <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();
 }
 /// <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 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();
 }
 /// <summary>
 /// Gets an appropriate epoch from a list of dates and writes it to the <see cref="CesiumOutputStream"/>
 /// as the "epoch" property.  If the <paramref name="dates"/> collection is empty, the <paramref name="startIndex"/>
 /// is past the end of the collection, or the <paramref name="length"/> is zero, this method does not write
 /// the "epoch" property and returns <see cref="JulianDate.MinValue"/>.
 /// </summary>
 /// <param name="output">The stream to which to write the epoch.</param>
 /// <param name="dates">The collection of dates from which to determine the epoch.</param>
 /// <param name="startIndex">The first index in the collection to use.</param>
 /// <param name="length">The number of items from the collection to use.</param>
 /// <returns>A suitable epoch determined from the collection.</returns>
 private static JulianDate GetAndWriteEpoch(CesiumOutputStream output, IList<JulianDate> dates, int startIndex, int length)
 {
     if (startIndex < dates.Count)
     {
         JulianDate epoch = dates[startIndex];
         output.WritePropertyName("epoch");
         output.WriteValue(CesiumFormattingHelper.ToIso8601(epoch, output.PrettyFormatting ? Iso8601Format.Extended : Iso8601Format.Compact));
         return epoch;
     }
     else
     {
         return JulianDate.MinValue;
     }
 }
 /// <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="value">The value to write.</param>
 public static void WriteRgba(CesiumOutputStream output, Color value)
 {
     WriteRgba(output, value.R, value.G, value.B, value.A);
 }
 /// <summary>
 /// Starts a new <topic name="Cesium">Cesium</topic> packet on the given stream.
 /// </summary>
 /// <param name="output">The stream to which to write the packet.</param>
 /// <returns>The packet writer.</returns>
 public CesiumPacketWriter OpenPacket(CesiumOutputStream output)
 {
     CesiumPacketWriter packetWriter = m_packetWriter.Value;
     packetWriter.Open(output);
     return packetWriter;
 }
 /// <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="value">The value to write.</param>
 public static void WriteRgbaf(CesiumOutputStream output, Color value)
 {
     WriteRgbaf(output, value.R / 255.0, value.G / 255.0, value.B / 255.0, value.A / 255.0);
 }