public void ListsVertexPositionsForBothEndPoints() { Series series = new Series("test", new[] { new Cartographic(1.0, 2.0, 3.0) }, m_document); series.Write(); string result = m_stringWriter.ToString(); Assert.That(result.Contains("\"vertexPositions\":{\"cartographicDegrees\":[1.0,2.0,0.0,1.0,2.0,3.0]}")); }
public void ListsVertexPositionsForBothEndPoints() { Series series = new Series("test", new[] { new Cartographic(1, 2, 3) }, m_document); series.Write(); string result = m_stringWriter.ToString(); StringAssert.Contains("\"vertexPositions\":{\"cartographicDegrees\":[1,2,0,1,2,3]}", result); }
public void GeneratesIndexedIds() { Series series = new Series("test", new[] { new Cartographic(1, 2, 3), new Cartographic(4, 5, 6) }, m_document); series.Write(); string result = m_stringWriter.ToString(); StringAssert.Contains("\"id\":\"test0\"", result); StringAssert.Contains("\"id\":\"test1\"", result); }
public void UsesCartographicDegrees() { Series series = new Series("test", new[] { new Cartographic(90, 45, 3) }, m_document); series.Write(); string result = m_stringWriter.ToString(); StringAssert.Contains("\"cartographicDegrees\":", result); StringAssert.Contains("[90,45,0,90,45,3]", result); }
public void GeneratesIndexedIds() { Series series = new Series("test", new[] { new Cartographic(1.0, 2.0, 3.0), new Cartographic(4.0, 5.0, 6.0) }, m_document); series.Write(); string result = m_stringWriter.ToString(); Assert.That(result.Contains("\"id\":\"test0\"")); Assert.That(result.Contains("\"id\":\"test1\"")); }
public void UsesCartographicDegrees() { Series series = new Series("test", new[] { new Cartographic(90.0, 45.0, 3.0) }, m_document); series.Write(); string result = m_stringWriter.ToString(); Assert.That(result.Contains("\"cartographicDegrees\":")); Assert.That(result.Contains("[90.0,45.0,0.0,90.0,45.0,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(); }