コード例 #1
0
ファイル: Series.cs プロジェクト: slojo404/czml-writer
 /// <summary>
 /// Initializes a new instance of the <see cref="Series"/> class.
 /// </summary>
 /// <param name="id">The ID of the <see cref="Series"/></param>
 /// <param name="coordinatesDegrees">An array of <see cref="Cartographic"/> positions 
 /// where the latitude and longitude are given in degrees.</param>
 /// <param name="heightScalar">A value used to scale the height of each coordinate.</param>
 /// <example>
 /// CzmlDocument document = new CzmlDocument();
 /// Cartographic[] positions = new Cartographic[] { new Cartographic(45.0, -90.0, 300), new Cartographic(50.0, -100.0, 400) };
 /// Series series = new Series("test", positions, document);
 /// </example>
 public Series(string id, Cartographic[] coordinatesDegrees, CzmlDocument document, double heightScalar = 1.0)
 {        
     m_id = id;
     m_document = document;
     m_coordinates = (Cartographic[])coordinatesDegrees.Clone();
     m_scalar = heightScalar;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Series"/> class.
 /// </summary>
 /// <param name="id">The ID of the <see cref="Series"/></param>
 /// <param name="coordinatesDegrees">An array of <see cref="Cartographic"/> positions
 /// where the latitude and longitude are given in degrees.</param>
 /// <param name="heightScalar">A value used to scale the height of each coordinate.</param>
 /// <example>
 /// CzmlDocument document = new CzmlDocument();
 /// Cartographic[] positions = new Cartographic[] { new Cartographic(45.0, -90.0, 300), new Cartographic(50.0, -100.0, 400) };
 /// Series series = new Series("test", positions, document);
 /// </example>
 public Series(string id, Cartographic[] coordinatesDegrees, CzmlDocument document, double heightScalar = 1.0)
 {
     m_id          = id;
     m_document    = document;
     m_coordinates = (Cartographic[])coordinatesDegrees.Clone();
     m_scalar      = heightScalar;
 }
コード例 #3
0
        /// <summary>
        /// Converts a WebGL Globe JSON document to CZML.
        /// </summary>
        /// <param name="inputReader">A reader for a WebGL Globe JSON document.</param>
        /// <param name="outputWriter">A writer that will receive the converted CZML document.</param>
        /// <param name="prettyFormatting">If true, produces larger, more readable.  False by default.</param>
        /// <param name="heightScalar">An optional value used to scale the height component of each coordinate.</param>
        public static void WebGLGlobeJsonToCesiumLanguage(TextReader inputReader,
                                                          TextWriter outputWriter,
                                                          bool prettyFormatting = false,
                                                          double heightScalar   = 1.0)
        {
            CzmlDocument document = new CzmlDocument(outputWriter);

            document.CesiumOutputStream.PrettyFormatting = prettyFormatting;

            document.CesiumOutputStream.WriteStartSequence();

            JsonSerializer serializer = new JsonSerializer();

            using (JsonReader jsonReader = new JsonTextReader(inputReader))
            {
                JArray jsonArray = (JArray)serializer.Deserialize(jsonReader);

                foreach (JToken item in jsonArray)
                {
                    int numCoordinateComponents = item[1].Values().Count();
                    if (numCoordinateComponents % 3 != 0)
                    {
                        throw new ArgumentException("Coordinates listed in jsonContents must have 3 components.", "inputReader");
                    }

                    Cartographic[] coords = new Cartographic[numCoordinateComponents / 3];
                    for (int i = 0, j = 0; i < numCoordinateComponents; i += 3, j++)
                    {
                        coords[j] = new Cartographic((double)item[1][i + 1], (double)item[1][i], (double)item[1][i + 2]);
                    }

                    Series series = new Series((string)item[0], coords, document, heightScalar);
                    series.Write();
                }
            }

            document.CesiumOutputStream.WriteEndSequence();
        }
コード例 #4
0
        /// <summary>
        /// Converts a WebGL Globe JSON document to CZML.
        /// </summary>
        /// <param name="inputReader">A reader for a WebGL Globe JSON document.</param>
        /// <param name="outputWriter">A writer that will receive the converted CZML document.</param>
        /// <param name="prettyFormatting">If true, produces larger, more readable.  False by default.</param>
        /// <param name="heightScalar">An optional value used to scale the height component of each coordinate.</param>
        public static void WebGLGlobeJsonToCesiumLanguage(TextReader inputReader,
                                                          TextWriter outputWriter,
                                                          bool prettyFormatting = false,
                                                          double heightScalar = 1.0)
        {
            CzmlDocument document = new CzmlDocument(outputWriter);

            document.CesiumOutputStream.PrettyFormatting = prettyFormatting;

            document.CesiumOutputStream.WriteStartSequence();

            JsonSerializer serializer = new JsonSerializer();
            using (JsonReader jsonReader = new JsonTextReader(inputReader))
            {
                JArray jsonArray = (JArray)serializer.Deserialize(jsonReader);

                foreach (JToken item in jsonArray)
                {
                    int numCoordinateComponents = item[1].Values().Count();
                    if (numCoordinateComponents % 3 != 0)
                    {
                        throw new ArgumentException("Coordinates listed in jsonContents must have 3 components.", "inputReader");
                    }

                    Cartographic[] coords = new Cartographic[numCoordinateComponents / 3];
                    for (int i = 0, j = 0; i < numCoordinateComponents; i += 3, j++)
                    {
                        coords[j] = new Cartographic((double)item[1][i + 1], (double)item[1][i], (double)item[1][i + 2]);
                    }

                    Series series = new Series((string)item[0], coords, document, heightScalar);
                    series.Write();
                }
            }

            document.CesiumOutputStream.WriteEndSequence();
        }
コード例 #5
0
 public void SetUp()
 {
     m_stringWriter = new StringWriter();
     m_document = new CzmlDocument(m_stringWriter);
 }