public void TestFromImage() { var image = new Bitmap(EmbeddedData.Read("satellite.png")); var resource = CesiumResource.FromImage(image, CesiumImageFormat.Png); Assert.IsNotNull(resource); StringAssert.StartsWith("data:image/png;base64,", resource.Uri); }
public void TestFromImageFormats(CesiumImageFormat format) { var image = new Bitmap(EmbeddedData.Read("satellite.png")); var resource = CesiumResource.FromImage(image, format); Assert.IsNotNull(resource); StringAssert.StartsWith("data:", resource.Uri); StringAssert.Contains(";base64,", resource.Uri); }
public void TestFromStreamMimeType() { // arbitrary bytes byte[] contents = { 0, 1, 2, 3, 4 }; var stream = new MemoryStream(contents); var resource = CesiumResource.FromStream(stream, "application/octet-stream"); Assert.IsNotNull(resource); const string expected = "data:application/octet-stream;base64,AAECAwQ="; Assert.AreEqual(expected, resource.Uri); }
public void TestFromStream() { // arbitrary bytes byte[] contents = { 0, 1, 2, 3, 4 }; var stream = new MemoryStream(contents); var resource = CesiumResource.FromStream(stream, CesiumImageFormat.Png); Assert.IsNotNull(resource); const string expected = "data:image/png;base64,AAECAwQ="; Assert.AreEqual(expected, resource.Uri); }
public EntityPlatform(ExampleEntity entity, EarthCentralBody earth, string dataPath) { //id, string m_id = entity.EntityIdentifier.ToString(); //name, string string name = entity.Marking.ToString(); //Last Update, DateTime DateTime time = DateTime.Parse(entity.LastUpdateDateTime.ToString()); //Position, Cartesian string[] xyz = entity.Position.ToString().Split(','); Cartesian position = new Cartesian(Convert.ToDouble(xyz[0]), Convert.ToDouble(xyz[1]), Convert.ToDouble(xyz[2])); m_platform = new Platform(); m_platform.Name = name; m_platform.LocationPoint = new PointCartographic(earth, earth.Shape.CartesianToCartographic(position)); m_platform.OrientationAxes = new AxesVehicleVelocityLocalHorizontal(earth.FixedFrame, m_platform.LocationPoint); LabelGraphicsExtension labelExtension = new LabelGraphicsExtension(new LabelGraphics { Text = new ConstantCesiumProperty<string>(name), Scale = new ConstantCesiumProperty<double>(0.5), FillColor = new ConstantCesiumProperty<Color>(Color.White), PixelOffset = new ConstantCesiumProperty<Rectangular>(new Rectangular(35, -15)) }); m_platform.Extensions.Add(labelExtension); string symbol = entity.Symbology.ToString().Replace('*', '_') + ".png"; CesiumResource billboardResource = new CesiumResource(new Uri(dataPath + symbol), CesiumResourceBehavior.LinkTo); BillboardGraphicsExtension billboardExtension = new BillboardGraphicsExtension(new BillboardGraphics { Image = new ConstantCesiumProperty<CesiumResource>(billboardResource), Show = true, Scale = new ConstantCesiumProperty<double>(1) }); m_platform.Extensions.Add(billboardExtension); m_czmlDocument = new CzmlDocument(); m_czmlDocument.Name = "Realtime"; m_czmlDocument.RequestedInterval = new TimeInterval(new JulianDate(DateTime.Now), new JulianDate(DateTime.Now.AddDays(1.0))); m_czmlDocument.Clock = new Clock { Step = ClockStep.SystemClock }; m_czmlDocument.ObjectsToWrite.Add(m_platform); }