OSDN Git Service

Heightへの対応,緯度・経度が反転していた不具合の修正
[yubeshi/yubeshi.git] / Yubeshi / Ubx / NavPosLlh.cs
1 /*\r
2  *      Yubeshi GPS Parser\r
3  *\r
4  *      This software is distributed under a zlib-style license.\r
5  *      See license.txt for more information.\r
6  */\r
7 \r
8 using System;\r
9 using System.Collections.Generic;\r
10 using System.Text;\r
11 \r
12 namespace Yubeshi.Ubx\r
13 {\r
14     public class NavPosLlh : Packet\r
15     {\r
16         #region constructors\r
17 \r
18         public NavPosLlh(byte[] sentence, int length)\r
19             : base(sentence, length)\r
20         {\r
21         }\r
22 \r
23         #endregion\r
24 \r
25         #region properties\r
26 \r
27         public decimal TimeOfWeek\r
28         {\r
29             get\r
30             {\r
31                 return BitConverter.ToUInt32(Raw, 6 + 0) * 1e-3m;\r
32             }\r
33         }\r
34 \r
35         public GeodeticCoordinate Position\r
36         {\r
37             get\r
38             {\r
39                 Degree lon = BitConverter.ToInt32(Raw, 6 + 4) * 1e-7;\r
40                 Degree lat = BitConverter.ToInt32(Raw, 6 + 8) * 1e-7;\r
41                 Height h = new Height(\r
42                                     BitConverter.ToUInt32(Raw, 6 + 12) * 1e-3, \r
43                                     Height.Base.Ellipsoid);\r
44                 return new GeodeticCoordinate(lat, lon, h);\r
45             }\r
46         }\r
47 \r
48         public Height MslHeight\r
49         {\r
50             get\r
51             {\r
52                 Height h = new Height(\r
53                                     BitConverter.ToUInt32(Raw, 6 + 16) * 1e-3,\r
54                                     Height.Base.MeanSeaLevel);\r
55                 return h;\r
56             }\r
57         }\r
58 \r
59         public double HorizonalAccuracy\r
60         {\r
61             get\r
62             {\r
63                 return BitConverter.ToUInt32(Raw, 6 + 20) * 1e-3;\r
64             }\r
65         }\r
66 \r
67         public double VerticalAccuracy\r
68         {\r
69             get\r
70             {\r
71                 return BitConverter.ToUInt32(Raw, 6 + 24) * 1e-3;\r
72             }\r
73         }\r
74         #endregion\r
75 \r
76         #region public methods\r
77 \r
78         public static bool TryParse(byte[] sentence, out UnknownPacket packet)\r
79         {\r
80             return TryParse(sentence, out packet, \r
81                                             MessageID.NavPosLlh, 28, Build);\r
82         }\r
83 \r
84         #endregion\r
85 \r
86         #region private methods\r
87 \r
88         private static Packet Build(byte[] sentence, int length)\r
89         {\r
90             return new NavPosLlh(sentence, length);\r
91         }\r
92 \r
93         #endregion\r
94     }\r
95 }\r