Exemple #1
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();
        }
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();
        }
Exemple #3
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 #4
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);
     }
 }
        /// <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>
 /// 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;
     }
 }