how to add angle to Track

Aug 3, 2011 at 3:25 AM

I want to add angle into track,and the SharpKml.Dom.GX.Track.AddAngle() demand an vector class.But vector only contain Latitude,Longtitude and Altitude.

Where can i put the angle data?

Aug 3, 2011 at 4:27 AM

thanks everyone.I think the Latitude,Longtitude and Altitude can also represent heading roll and tilt.

Coordinator
Aug 3, 2011 at 1:43 PM
Edited Aug 3, 2011 at 1:45 PM

You are correct; the heading is stored in the longitude, the pitch in the latitude and the roll in the altitude, though it's not very intuitive!

When I wrote the library I tried to match closely the existing C++ version from Google (libkml), which has accessors for the properties (declared in vec3.h).

I'l look into copying the Vector class to an AngleVector class with these properties renamed in a future version, but for now you could create a few extension methods to help you:

public static class VectorExtensions
{
    public static double GetHeading(this Vector instance)
    {
        if (instance == null)
        {
            throw new ArgumentNullException("instance");
        }
        return instance.Longitude;
    }

    public static double GetPitch(this Vector instance)
    {
        if (instance == null)
        {
            throw new ArgumentNullException("instance");
        }
        return instance.Latitude;
    }

    public static double GetRoll(this Vector instance)
    {
        if (instance == null)
        {
            throw new ArgumentNullException("instance");
        }
        return instance.Altitude.GetValueOrDefault();
    }

    public static void SetHeading(this Vector instance, double value)
    {
        if (instance == null)
        {
            throw new ArgumentNullException("instance");
        }
        instance.Longitude = value;
    }

    public static void SetPitch(this Vector instance, double value)
    {
        if (instance == null)
        {
            throw new ArgumentNullException("instance");
        }
        instance.Latitude = value;
    }

    public static void SetRoll(this Vector instance, double value)
    {
        if (instance == null)
        {
            throw new ArgumentNullException("instance");
        }
        instance.Altitude = value;
    }
}
Aug 4, 2011 at 6:46 AM

Thank you very much for you reply.I have used the methods to create kml file,and all are right.

My asp.net project display web gis map,and sharpkml give me a great help.

I will go on using and pay attention to it.

                                                                                                                             Thanks!

Coordinator
Aug 5, 2011 at 3:09 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.