source: pacpussensors/trunk/StdDbtPlayerComponents/DbtPlyGgaManager.cpp@ 100

Last change on this file since 100 was 82, checked in by yuchunle, 9 years ago

added GPS dbt replay (GGA, GST, VTG)

File size: 5.3 KB
Line 
1/*********************************************************************
2// created: 2007/04/12 - 16:30
3
4//
5// author: Elie Al Alam & Gerald Dherbomez
6//
7// version: $Id: DbtPlyGgaManager.cpp 1203 2012-08-02 11:58:15Z morasjul $
8//
9// purpose: Dbite Player GGA Manager implementation
10*********************************************************************/
11
12#include "DbtPlyGgaManager.h"
13
14#include <cmath>
15#include <qapplication.h>
16
17//#include "kernel/ComponentManager.h"
18
19namespace pacpus {
20
21//////////////////////////////////////////////////////////////////////////
22// Construction de la fabrique de composant DbtPlyGgaManager
23//////////////////////////////////////////////////////////////////////////
24static ComponentFactory<DbtPlyGgaManager> sFactory("DbtPlyGgaManager");
25
26// double dist1[2];
27// double dist2[2];
28
29double atanh(double z)
30{
31 return (0.5 * log((z+1)/(1-z)));
32}
33
34double abs_me(double x)
35{
36 if(x<0) x=-x;
37 return x;
38}
39
40
41
42
43//////////////////////////////////////////////////////////////////////////
44//transformation des longitudes tatitudes en Lambert93
45//////////////////////////////////////////////////////////////////////////
46void lonlattolam(double lon, double lat, double & lam93x, double & lam93y)
47{
48 double GRS_a = 6378137;
49 double GRS_f = 1/298.257222101;
50
51 double GRS_b = GRS_a*(1-GRS_f);
52 double GRS_bb= GRS_b*GRS_b;
53 double GRS_aa= 40680631590769.0;
54 double GRS_e = sqrt((GRS_aa - GRS_bb) / (GRS_aa));
55
56 double n = 0.725607765053267;
57 double C = 11754255.4261;
58 double XS = 700000;
59 double YS = 12655612.0499;
60
61 double latiso;
62 latiso = atanh(sin(lat)) - GRS_e*atanh(GRS_e*sin(lat));
63 double gamma;
64 gamma = (lon - 0.0523598775598299)*n;
65 double R;
66 R = C * exp(-n*latiso);
67
68 lam93x = R *sin(gamma)+XS;
69 lam93y = -R *cos(gamma)+YS;
70}
71
72
73
74
75
76//////////////////////////////////////////////////////////////////////////
77//Transformation des coordonnees de Lambert93 en Longitude lattitude
78//////////////////////////////////////////////////////////////////////////
79void lamtolonlat(double lamx, double lamy, double & lon, double & lat)
80{
81 double GRS_a = 6378137;
82 double GRS_f = 1/298.257222101;
83 double GRS_b = GRS_a*(1-GRS_f);
84 double GRS_bb= GRS_b*GRS_b;
85 double GRS_aa= 40680631590769.0;
86 double GRS_e = sqrt((GRS_aa - GRS_bb) / (GRS_aa));
87
88 //double n = 0.725607765053267;
89 //double C = 11754255.4261;
90 //double XS = 700000;
91 //double YS = 12655612.0499;
92
93
94 //lamx = lamx-700000;
95 //lamy = lamy-12655612.0499;
96
97 double gamma;
98 gamma = atan(-(lamx-700000)/(lamy-12655612.0499));
99
100
101 lon = gamma/0.725607765053267 + 0.0523598775598299;
102 double R;
103 R = sqrt((lamx-700000) * (lamx-700000) + (lamy-12655612.0499) * (lamy-12655612.0499));
104
105 double latiso;
106 latiso = log((11754255.4261)/R)/(0.725607765053267);
107
108 double phiNew, phiOld;
109 phiOld =1;
110 phiNew= asin (tanh ( latiso + GRS_e * atanh(GRS_e * sin(phiOld))));
111 //printf("\nphiNew: %.20lf",phiNew);
112 while (abs_me(phiOld-phiNew) > 1e-10)
113 {
114
115 if(abs_me(phiOld-phiNew) > 1e-10)
116 {
117
118 phiOld = phiNew;
119 phiNew = asin(tanh(latiso+GRS_e*atanh(GRS_e*sin(phiOld))));
120 }
121 else
122 phiOld = phiNew;
123 }
124
125 lat = phiNew;
126}
127
128
129
130
131
132//////////////////////////////////////////////////////////////////////////
133/// Constructor
134DbtPlyGgaManager::DbtPlyGgaManager(QString name)
135 : DbtPlyFileManager(name)
136{
137
138}
139
140//////////////////////////////////////////////////////////////////////////
141/// Destructor
142DbtPlyGgaManager::~DbtPlyGgaManager()
143{
144
145}
146
147//////////////////////////////////////////////////////////////////////////
148// displayData
149//////////////////////////////////////////////////////////////////////////
150void DbtPlyGgaManager::processData(road_time_t t, road_timerange_t /*tr*/ , void * buf)
151{
152 // no data available
153 if (buf == NULL) {
154 printf("NULL");
155 emit displayLat(0);
156 emit displayLon(0);
157 }
158
159 val = (trame_gga_dbl*)(buf);
160
161
162 emit displayLat(val->lat);
163 emit displayLon(val->lon);
164
165}
166
167ComponentBase::COMPONENT_CONFIGURATION DbtPlyGgaManager::configureComponent(XmlComponentConfig config)
168{
169 DbtPlyFileManager::configureComponent(config);
170
171 return ComponentBase::CONFIGURED_OK;
172}
173
174
175
176
177void DbtPlyGgaManager::startActivity()
178{
179 DbtPlyFileManager::startActivity();
180 // user interface
181}
182
183
184
185
186void DbtPlyGgaManager::stopActivity()
187{
188 DbtPlyFileManager::stopActivity();
189}
190
191
192void DbtPlyGgaManager::displayUI()
193{
194 // todo
195 // afficher lat lon
196 // voir dans DbtPlyUserInterface§.cpp
197 w = new QWidget();
198 w->setWindowTitle(name());
199 w->show();
200 w->setFixedSize (170,80);
201
202 prop = new QGroupBox ("GGA Properties",w);
203 prop->show();
204 prop->setFixedSize(170,78);
205
206 lat = new QLabel("Latitude ", prop);
207 lat->move( 5, 15);
208 lat->show();
209 lat->setFixedSize (80,20);
210 latVal = new QLCDNumber (prop);
211 latVal->move( 5, 35);
212 latVal->setFixedSize(50,20);
213 latVal->show();
214 connect(this, SIGNAL(displayLat(double)) , latVal , SLOT(display(double)));
215
216 lon = new QLabel("Longitude ", prop);
217 lon->move( 90, 15);
218 lon->show();
219 lon->setFixedSize (80,27);
220
221 lonVal = new QLCDNumber (prop);
222 lonVal->move( 90, 35);
223 lonVal->setFixedSize(50,20);
224 lonVal->show();
225 connect (this, SIGNAL(displayLon(double)) , lonVal , SLOT(display(double)));
226}
227
228} // namespace pacpus
Note: See TracBrowser for help on using the repository browser.