Click or drag to resize

Code Sample

The following is a complete code sample containing all of the pieces described in detail in the Visualization with Cesium topic. This demonstrates how to create a complex visualization containing multiple objects, and using analysis results to drive visualization.

C#
var earth = CentralBodiesFacet.GetFromContext().Earth;
var issTle =
    new TwoLineElementSet(@"1 25544U 98067A   10172.34241898  .00007451  00000-0  60420-4 0  3627
                            2 25544  51.6459 209.3399 0009135 352.3227 186.5240 15.71934500664129");

var issPoint = new Sgp4Propagator(issTle).CreatePoint();
var iss = new Platform
{
    Name = "ISS",
    LocationPoint = issPoint,
    OrientationAxes = new AxesVehicleVelocityLocalHorizontal(earth.FixedFrame, issPoint)
};

iss.Extensions.Add(new LabelGraphicsExtension(new LabelGraphics
{
    Text = iss.Name,
    FillColor = Color.White
}));

iss.Extensions.Add(new PathGraphicsExtension(new PathGraphics
{
    Material = new PolylineOutlineMaterialGraphics
    {
        Color = Color.White,
        OutlineWidth = 1.0,
        OutlineColor = Color.Black
    },
    Width = 2,
    LeadTime = 60 * 44, // 44 minutes
    TrailTime = 60 * 44
}));

iss.Extensions.Add(new IdentifierExtension("ISS"));

var facilityPoint = new PointCartographic(earth, new Cartographic(-1.3191780323141054, 0.69871349190638687, 0.0));
var facility = new Platform
{
    Name = "AGI HQ",
    LocationPoint = facilityPoint,
    OrientationAxes = new AxesEastNorthUp(earth, facilityPoint)
};

facility.Extensions.Add(new LabelGraphicsExtension(new LabelGraphics
{
    Text = facility.Name,
    FillColor = Color.White
}));

var link = new LinkInstantaneous(facility, iss);
var constraint = new CentralBodyObstructionConstraint(link, earth);

link.Extensions.Add(new LinkGraphicsExtension(new LinkGraphics
{
    Show = new AccessQueryCesiumProperty<bool>
    {
        Query = constraint,
        AccessExists = true,
        AccessUnknown = false,
        NoAccess = false
    },
    Material = new SolidColorMaterialGraphics(Color.Yellow),
    FollowSurface = false
}));

var sensor = new Platform
{
    LocationPoint = facility.LocationPoint,
    OrientationAxes = new AxesTargetingLink(link, LinkRole.Transmitter, new VectorFixed(iss.OrientationAxes, UnitCartesian.UnitZ))
};

sensor.Extensions.Add(new FieldOfViewExtension(new RectangularPyramid
{
    XHalfAngle = Trig.DegreesToRadians(8),
    YHalfAngle = Trig.DegreesToRadians(4.5),
    Radius = 500000
}));
sensor.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
{
    DomeSurfaceMaterial = new GridMaterialGraphics
    {
        Color = Color.White,
        CellAlpha = 0.0
    },
    LateralSurfaceMaterial = new SolidColorMaterialGraphics
    {
        Color = Color.FromArgb(128, Color.Green)
    }
}));

var interval = new TimeInterval(new JulianDate(new GregorianDate(2009, 1, 1)),
                                new JulianDate(new GregorianDate(2009, 1, 2)));
var czmlDocument = new CzmlDocument
{
    Name = "CompleteExample",
    Description = "A complete example",
    RequestedInterval = interval,
    Clock = new Clock
    {
        Interval = interval,
        CurrentTime = interval.Start
    }
};
czmlDocument.ObjectsToWrite.Add(iss);
czmlDocument.ObjectsToWrite.Add(facility);
czmlDocument.ObjectsToWrite.Add(link);
czmlDocument.ObjectsToWrite.Add(sensor);

using (var streamWriter = new StreamWriter("CompleteExample.czml"))
{
    czmlDocument.WriteDocument(streamWriter);
}