/*
* Yubeshi GPS Parser
*
* This software is distributed under a zlib-style license.
* See license.txt for more information.
*/
using System;
using System.Collections.Generic;
using System.Text;
namespace Yubeshi.Nmea
{
///
/// Datum Reference
///
public class GpDtm : Packet
{
#region type definitions
public enum Code
{
Unknown = 0,
Wgs84 = 84,
Wgs72 = 72,
UserDefined = 999,
}
#endregion
#region fields
private static Dictionary codes;
private static readonly byte[] header;
private const int elementNum = 8;
#endregion
#region constructors
static GpDtm()
{
header = Encoding.ASCII.GetBytes("$GPDTM,");
codes = new Dictionary();
codes["W84"] = Code.Wgs84;
codes["W72"] = Code.Wgs72;
codes["999"] = Code.UserDefined;
}
public GpDtm()
{
}
public GpDtm(byte[] sentence)
: this(sentence, GetElements(sentence, elementNum))
{
}
private GpDtm(byte[] sentence, Elements elements)
: base(sentence, elements.PacketLength)
{
string[] v = elements.Values;
LocalDatumCode = codes[v[0]];
//Offset = new GeodeticCoordinate();
}
#endregion
#region properties
public Code LocalDatumCode
{
get;
private set;
}
public GeodeticCoordinate Offset
{
get;
private set;
}
public Code ReferenceDetumCode
{
get;
private set;
}
#endregion
#region public method
public static bool TryParse(byte[] sentence, out UnknownPacket packet)
{
return TryParse(sentence, out packet, header, elementNum, Build);
}
#endregion
#region private method
private static Packet Build(byte[] sentence, Elements elements)
{
return new GpDtm(sentence, elements);
}
#endregion
}
}