public void SetUp()
 {
     m_startDate         = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
     m_isoStartString    = CesiumFormattingHelper.ToIso8601(m_startDate, Iso8601Format.Compact);
     m_stopDate          = new GregorianDate(2012, 4, 2, 12, 1, 0).ToJulianDate();
     m_isoIntervalString = CesiumFormattingHelper.ToIso8601Interval(m_startDate, m_stopDate, Iso8601Format.Compact);
 }
Exemplo n.º 2
0
        public void TestShowPropertyInterval()
        {
            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 (Packet)
                using (var billboard = Packet.OpenBillboardProperty())
                    using (var show = billboard.OpenShowProperty())
                        using (var showIntervals = show.OpenMultipleIntervals())
                        {
                            using (var interval = showIntervals.OpenInterval(startDate, startDate.AddSeconds(1)))
                            {
                                interval.WriteBoolean(true);
                            }

                            using (var interval = showIntervals.OpenInterval(startDate.AddSeconds(1), startDate.AddSeconds(2)))
                            {
                                interval.WriteBoolean(false);
                            }

                            using (var interval = showIntervals.OpenInterval(startDate.AddSeconds(2), stopDate))
                            {
                                interval.WriteBoolean(true);
                            }
                        }

            string interval1String = CesiumFormattingHelper.ToIso8601Interval(startDate, startDate.AddSeconds(1), Iso8601Format.Compact);
            string interval2String = CesiumFormattingHelper.ToIso8601Interval(startDate.AddSeconds(1), startDate.AddSeconds(2), Iso8601Format.Compact);
            string interval3String = CesiumFormattingHelper.ToIso8601Interval(startDate.AddSeconds(2), stopDate, Iso8601Format.Compact);

            Assert.AreEqual("{\"billboard\":{\"show\":[{\"interval\":\"" + interval1String + "\",\"boolean\":true}," +
                            "{\"interval\":\"" + interval2String + "\",\"boolean\":false}," +
                            "{\"interval\":\"" + interval3String + "\",\"boolean\":true}" +
                            "]}}", StringWriter.ToString());
        }
Exemplo n.º 3
0
        public void TestDeletePropertyWithStartAndStop()
        {
            var          start          = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            var          stop           = start.AddDays(1.0);
            const string expectedId     = "id";
            const bool   expectedDelete = true;

            using (Packet)
            {
                Packet.WriteId(expectedId);

                using (var orientation = Packet.OpenOrientationProperty())
                    using (var interval = orientation.OpenInterval(start, stop))
                    {
                        interval.WriteDelete(expectedDelete);
                    }
            }

            AssertExpectedJson(new Dictionary <string, object>
            {
                { PacketCesiumWriter.IdPropertyName, expectedId },
                {
                    PacketCesiumWriter.OrientationPropertyName, new Dictionary <string, object>
                    {
                        { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                        { OrientationCesiumWriter.DeletePropertyName, expectedDelete },
                    }
                },
            });
        }
        public void PassToIso8601Interval()
        {
            // Since ToIso8601Interval is just a simple wrapper around two calls to
            // CesiumFormattingHelper.ToIso8601, this test is just a smoke screen.
            const string expectedBasicInterval    = "19800801T000000Z/20720703T000000Z";
            const string expectedExtendedInterval = "1980-08-01T00:00:00Z/2072-07-03T00:00:00Z";
            const string expectedCompactInterval  = "19800801T00Z/20720703T00Z";

            JulianDate start = new GregorianDate(1980, 08, 01).ToJulianDate();
            JulianDate stop  = new GregorianDate(2072, 07, 03).ToJulianDate();

            string basicInterval = CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Basic);

            Assert.AreEqual(expectedBasicInterval, basicInterval);

            string extendedInterval = CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Extended);

            Assert.AreEqual(expectedExtendedInterval, extendedInterval);

            string compactInterval = CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact);

            Assert.AreEqual(expectedCompactInterval, compactInterval);

            TimeInterval interval = new TimeInterval(start, stop);

            basicInterval = CesiumFormattingHelper.ToIso8601Interval(interval, Iso8601Format.Basic);
            Assert.AreEqual(expectedBasicInterval, basicInterval);

            extendedInterval = CesiumFormattingHelper.ToIso8601Interval(interval, Iso8601Format.Extended);
            Assert.AreEqual(expectedExtendedInterval, extendedInterval);

            compactInterval = CesiumFormattingHelper.ToIso8601Interval(interval, Iso8601Format.Compact);
            Assert.AreEqual(expectedCompactInterval, compactInterval);
        }
Exemplo n.º 5
0
        public void TestDeletePropertyWithStartAndStop()
        {
            var          start                = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            var          stop                 = start.AddDays(1.0);
            const string expectedId           = "id";
            const string expectedPropertyName = "foo";
            const bool   expectedDelete       = true;

            using (Packet)
            {
                Packet.WriteId(expectedId);

                using (var writer = new BooleanCesiumWriter(expectedPropertyName))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(start, stop);
                    writer.WriteDelete(expectedDelete);
                }
            }

            AssertExpectedJson(new Dictionary <string, object>
            {
                { PacketCesiumWriter.IdPropertyName, expectedId },
                {
                    expectedPropertyName, new Dictionary <string, object>
                    {
                        { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                        { BooleanCesiumWriter.DeletePropertyName, expectedDelete },
                    }
                },
            });
        }
        public void VerticalOriginCanBeWrittenInsideInterval()
        {
            var          start = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();
            var          stop  = start.AddSeconds(100.0);
            const string expectedPropertyName        = "foo";
            const CesiumVerticalOrigin expectedValue = CesiumVerticalOrigin.Center;

            using (Packet)
                using (var writer = new VerticalOriginCesiumWriter(expectedPropertyName))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(start, stop);
                    writer.WriteVerticalOrigin(expectedValue);
                }
            AssertExpectedJson(expectedPropertyName, new Dictionary <string, object>
            {
                { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                { VerticalOriginCesiumWriter.VerticalOriginPropertyName, CesiumFormattingHelper.VerticalOriginToString(expectedValue) },
            });
        }
Exemplo n.º 7
0
        public void DoubleCanBeWrittenInsideInterval()
        {
            var          start = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();
            var          stop  = start.AddSeconds(100.0);
            const string expectedPropertyName = "foo";
            const double expectedValue        = 1.23;

            using (Packet)
                using (var writer = new DoubleCesiumWriter(expectedPropertyName))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(start, stop);
                    writer.WriteNumber(expectedValue);
                }

            AssertExpectedJson(expectedPropertyName, new Dictionary <string, object>
            {
                { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                { DoubleCesiumWriter.NumberPropertyName, expectedValue },
            });
        }
        public void LabelStyleCanBeWrittenInsideInterval()
        {
            var                    start = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();
            var                    stop  = start.AddSeconds(100.0);
            const string           expectedPropertyName = "foo";
            const CesiumLabelStyle expectedValue        = CesiumLabelStyle.FillAndOutline;

            using (Packet)
                using (var writer = new LabelStyleCesiumWriter(expectedPropertyName))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(start, stop);
                    writer.WriteLabelStyle(expectedValue);
                }

            AssertExpectedJson(expectedPropertyName, new Dictionary <string, object>
            {
                { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) },
                { LabelStyleCesiumWriter.LabelStylePropertyName, CesiumFormattingHelper.LabelStyleToString(expectedValue) },
            });
        }
Exemplo n.º 9
0
        public void MultipleIntervalsAllowsWritingMultipleIntervals()
        {
            const string expectedPropertyName = "woot";

            JulianDate start = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            JulianDate stop  = new GregorianDate(2012, 4, 2, 13, 0, 0).ToJulianDate();

            using (Packet)
                using (var propertyWriter = CreatePropertyWriter(expectedPropertyName))
                {
                    propertyWriter.Open(OutputStream);
                    using (var intervalListWriter = propertyWriter.OpenMultipleIntervals())
                    {
                        using (TDerived intervalWriter = intervalListWriter.OpenInterval())
                        {
                            intervalWriter.WriteInterval(start, stop);
                        }

                        using (TDerived intervalWriter = intervalListWriter.OpenInterval())
                        {
                            intervalWriter.WriteInterval(new TimeInterval(start, stop));
                        }
                    }
                }

            AssertExpectedJson(new Dictionary <string, object>
            {
                {
                    expectedPropertyName, new List <object>
                    {
                        new Dictionary <string, object> {
                            { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) }
                        },
                        new Dictionary <string, object> {
                            { "interval", CesiumFormattingHelper.ToIso8601Interval(start, stop, Iso8601Format.Compact) }
                        },
                    }
                },
            });
        }
Exemplo n.º 10
0
        public void TestShowPropertyInterval()
        {
            var startDate = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            var stopDate  = new GregorianDate(2012, 4, 2, 12, 1, 0).ToJulianDate();

            var interval1Start = startDate;
            var interval1Stop  = startDate.AddSeconds(1);
            var interval2Start = interval1Stop;
            var interval2Stop  = startDate.AddSeconds(2);
            var interval3Start = interval2Stop;
            var interval3Stop  = stopDate;

            const bool interval1Value = true;
            const bool interval2Value = false;
            const bool interval3Value = true;

            using (Packet)
                using (var billboard = Packet.OpenBillboardProperty())
                    using (var show = billboard.OpenShowProperty())
                        using (var showIntervals = show.OpenMultipleIntervals())
                        {
                            using (var interval = showIntervals.OpenInterval(interval1Start, interval1Stop))
                            {
                                interval.WriteBoolean(interval1Value);
                            }

                            using (var interval = showIntervals.OpenInterval(interval2Start, interval2Stop))
                            {
                                interval.WriteBoolean(interval2Value);
                            }

                            using (var interval = showIntervals.OpenInterval(interval3Start, interval3Stop))
                            {
                                interval.WriteBoolean(interval3Value);
                            }
                        }

            AssertExpectedJson(PacketCesiumWriter.BillboardPropertyName, new Dictionary <string, object>
            {
                {
                    BillboardCesiumWriter.ShowPropertyName, new List <Dictionary <string, object> >
                    {
                        new Dictionary <string, object>
                        {
                            { "interval", CesiumFormattingHelper.ToIso8601Interval(interval1Start, interval1Stop, Iso8601Format.Compact) },
                            { BooleanCesiumWriter.BooleanPropertyName, interval1Value },
                        },
                        new Dictionary <string, object>
                        {
                            { "interval", CesiumFormattingHelper.ToIso8601Interval(interval2Start, interval2Stop, Iso8601Format.Compact) },
                            { BooleanCesiumWriter.BooleanPropertyName, interval2Value },
                        },
                        new Dictionary <string, object>
                        {
                            { "interval", CesiumFormattingHelper.ToIso8601Interval(interval3Start, interval3Stop, Iso8601Format.Compact) },
                            { BooleanCesiumWriter.BooleanPropertyName, interval3Value },
                        },
                    }
                },
            });
        }