Exemplo n.º 1
0
        public void CartesianValueSubsetWritesMultipleCartesianProperty()
        {
            var startDate = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (var position = Packet.OpenPositionProperty())
                    using (var interval = position.OpenInterval())
                    {
                        var dates     = new List <JulianDate>();
                        var positions = new List <Cartesian>();

                        dates.Add(startDate);
                        positions.Add(new Cartesian(1.0, 2.0, 3.0));

                        dates.Add(startDate.AddSeconds(60.0));
                        positions.Add(new Cartesian(4.0, 5.0, 6.0));

                        dates.Add(startDate.AddSeconds(120.0));
                        positions.Add(new Cartesian(7.0, 8.0, 9.0));

                        interval.WriteCartesian(dates, positions, 1, 1);
                    }

            Assert.AreEqual("{\"position\":{\"epoch\":\"20120402T1201Z\",\"cartesian\":[0,4,5,6]}}", StringWriter.ToString());
        }
        public void VerticalOriginCanBeWrittenInsideInterval()
        {
            JulianDate startDate = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (VerticalOriginCesiumWriter writer = new VerticalOriginCesiumWriter("foo"))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(startDate, startDate.AddSeconds(100.0));
                    writer.WriteVerticalOrigin(CesiumVerticalOrigin.Center);
                }
            Assert.AreEqual("{\"foo\":{\"interval\":\"20120607T12Z/20120607T120140Z\",\"verticalOrigin\":\"CENTER\"}}", StringWriter.ToString());
        }
Exemplo n.º 3
0
        public void StringCanBeWrittenInsideInterval()
        {
            JulianDate startDate = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (StringCesiumWriter writer = new StringCesiumWriter("foo"))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(startDate, startDate.AddSeconds(100.0));
                    writer.WriteString("bar");
                }
            Assert.AreEqual("{\"foo\":{\"interval\":\"20120607T12Z/20120607T120140Z\",\"string\":\"bar\"}}", StringWriter.ToString());
        }
Exemplo n.º 4
0
        public void LabelStyleCanBeWrittenInsideInterval()
        {
            JulianDate startDate = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (LabelStyleCesiumWriter writer = new LabelStyleCesiumWriter("foo"))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(startDate, startDate.AddSeconds(100.0));
                    writer.WriteLabelStyle(CesiumLabelStyle.FillAndOutline);
                }
            Assert.AreEqual("{\"foo\":{\"interval\":\"20120607T12Z/20120607T120140Z\",\"labelStyle\":\"FILL_AND_OUTLINE\"}}", StringWriter.ToString());
        }
        public void DoubleCanBeWrittenInsideInterval()
        {
            var startDate = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (var writer = new DoubleCesiumWriter("foo"))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(startDate, startDate.AddSeconds(100.0));
                    writer.WriteNumber(1.23);
                }

            Assert.AreEqual("{\"foo\":{\"interval\":\"20120607T12Z/20120607T120140Z\",\"number\":1.23}}", StringWriter.ToString());
        }
Exemplo n.º 6
0
        public void BooleanCanBeWrittenInsideInterval()
        {
            var startDate = new GregorianDate(2012, 6, 7, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (var writer = new BooleanCesiumWriter("foo"))
                {
                    writer.Open(OutputStream);
                    writer.WriteInterval(startDate, startDate.AddSeconds(100.0));
                    writer.WriteBoolean(false);
                }

            Assert.AreEqual("{\"foo\":{\"interval\":\"20120607T12Z/20120607T120140Z\",\"boolean\":false}}", StringWriter.ToString());
        }
Exemplo n.º 7
0
        public void TestHolesIntervals()
        {
            var startDate = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();
            var stopDate  = new GregorianDate(2012, 4, 2, 13, 0, 0).ToJulianDate();

            using (Packet)
                using (var polygon = Packet.OpenPolygonProperty())
                    using (var holes = polygon.OpenHolesProperty())
                    {
                        using (var holesIntervals = holes.OpenMultipleIntervals())
                        {
                            using (var interval = holesIntervals.OpenInterval(startDate, startDate.AddSeconds(60 * 30)))
                            {
                                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),
                                    },
                                };
                                interval.WriteCartographicDegrees(listOfHoles);
                            }

                            using (var interval = holesIntervals.OpenInterval(startDate.AddSeconds(60 * 30), stopDate))
                            {
                                var listOfHoles = new List <List <Cartographic> >
                                {
                                    new List <Cartographic> {
                                        new Cartographic(11, 1, 0), new Cartographic(11, 2, 0), new Cartographic(12, 2, 0),
                                    },
                                    new List <Cartographic> {
                                        new Cartographic(14, 4, 0), new Cartographic(14, 5, 0), new Cartographic(15, 5, 0), new Cartographic(15, 4, 0),
                                    },
                                };
                                interval.WriteCartographicDegrees(listOfHoles);
                            }
                        }
                    }

            Assert.AreEqual("{\"polygon\":{\"holes\":[" +
                            "{\"interval\":\"20120402T12Z/20120402T1230Z\",\"cartographicDegrees\":[[1,1,0,1,2,0,2,2,0],[4,4,0,4,5,0,5,5,0,5,4,0]]}," +
                            "{\"interval\":\"20120402T1230Z/20120402T13Z\",\"cartographicDegrees\":[[11,1,0,11,2,0,12,2,0],[14,4,0,14,5,0,15,5,0,15,4,0]]}" +
                            "]}}", StringWriter.ToString());
        }
        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.º 9
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 },
            });
        }
Exemplo n.º 10
0
        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.º 11
0
        public void CartesianValueWritesMultipleCartesianProperty()
        {
            var epoch = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (var position = Packet.OpenPositionProperty())
                    using (var interval = position.OpenInterval())
                    {
                        var dates     = new List <JulianDate>();
                        var positions = new List <Cartesian>();

                        dates.Add(epoch);
                        positions.Add(new Cartesian(1.1, 2.2, 3.3));

                        dates.Add(epoch.AddSeconds(60.0));
                        positions.Add(new Cartesian(4.4, 5.5, 6.6));

                        interval.WriteCartesian(dates, positions);
                    }

            Assert.AreEqual("{\"position\":{\"epoch\":\"20120402T12Z\",\"cartesian\":[0,1.1,2.2,3.3,60,4.4,5.5,6.6]}}", StringWriter.ToString());
        }
Exemplo n.º 12
0
        public void TestScaleByDistancePropertySamples()
        {
            var epoch = new GregorianDate(2012, 4, 2, 12, 0, 0).ToJulianDate();

            using (Packet)
                using (var billboard = Packet.OpenBillboardProperty())
                    using (var interval = billboard.OpenInterval())
                        using (var scaleByDistance = interval.OpenScaleByDistanceProperty())
                        {
                            var dates  = new List <JulianDate>();
                            var values = new List <NearFarScalar>();

                            dates.Add(epoch);
                            values.Add(new NearFarScalar(100.0, 1.0, 200.0, 2.0));

                            dates.Add(epoch.AddSeconds(60.0));
                            values.Add(new NearFarScalar(200.0, 1.0, 300.0, 2.0));

                            scaleByDistance.WriteNearFarScalar(dates, values);
                        }

            Assert.AreEqual("{\"billboard\":{\"scaleByDistance\":{\"epoch\":\"20120402T12Z\",\"nearFarScalar\":[0,100,1,200,2,60,200,1,300,2]}}}", StringWriter.ToString());
        }
Exemplo n.º 13
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 },
                        },
                    }
                },
            });
        }