-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathXOrthoLaserMesure.cpp
278 lines (260 loc) · 8.82 KB
/
XOrthoLaserMesure.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#include "XOrthoLaserMesure.h"
#include "XOrthoLaserChantier.h"
#include "XOrthoLaserDalle.h"
#include "XBase.h"
#include "XArchiXMLException.h"
#include "XArchiXMLBaseTools.h"
#include "XArchiXMLTools.h"
// NO TRAJ #include "PostProcessedProjPosition.h"
// NO TRAJ #include "ProjPostProcessSolution.h"
#include <algorithm>
#include <sstream>
#include <iomanip>
//-----------------------------------------------------------------------------
//************* MESURE
//-----------------------------------------------------------------------------
XOrthoLaserMesure::XOrthoLaserMesure(XOrthoLaserPoint* Pt, XOrthoLaserDalle* img)
{
m_bValid = false;
m_pt = Pt;
m_img= img;
if(img != NULL)
m_strImage = img->Name();
}
//-----------------------------------------------------------------------------
XOrthoLaserMesure::~XOrthoLaserMesure(void)
{
}
//-----------------------------------------------------------------------------
XError* XOrthoLaserMesure::Error()
{
if(m_img == NULL)
return NULL;
return m_img->Error();
}
//-----------------------------------------------------------------------------
XOrthoLaserRxp* XOrthoLaserMesure::Rxp()
{
if(m_img != NULL)
return m_img->Rxp();
return NULL;
}
//-----------------------------------------------------------------------------
std::string XOrthoLaserMesure::strIdCouche()
{
if(m_img == NULL)
return m_strImage;
return Ortho()->strIdCouche();
}
//-----------------------------------------------------------------------------
// NO TRAJ ProjPostProcessSolution* XOrthoLaserMesure::Solution()
//{
// if(Rxp() != NULL)
// return Rxp()->Solution();
// return NULL;
//}
//-----------------------------------------------------------------------------
void XOrthoLaserMesure::Ortho(XOrthoLaserDalle* img)
{
m_img = img;
if(img != NULL)
m_strImage = img->Name();
}
//-----------------------------------------------------------------------------
void XOrthoLaserMesure::DeconnectOrtho()
{
if(m_img != NULL)
m_img->RemoveMesure(this);
}
//-----------------------------------------------------------------------------
XOrthoLaserPoint* XOrthoLaserMesure::Pt()
{
return m_pt;
}
//-----------------------------------------------------------------------------
void XOrthoLaserMesure::Pt(XOrthoLaserPoint* pt)
{
m_pt = pt;
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::SetMesure(double x, double y)
{
m_bValid = false;
X = x;
Y = y;
if(SetValuesFromOrtholas())
m_bValid = true;
return m_bValid;
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::SetValuesFromOrtholas()
{
if(m_img == NULL)
return XErrorAlert(Error(),__FUNCTION__,"image non connectee ",m_strImage.c_str() );; //??
if(!m_img->GetCoordTerrain(X,Y,&m_terrainLaser))
return XErrorError(Error(),__FUNCTION__,"erreur de GetCoordTerrain ", m_img->Name().c_str());
m_dTime= m_img->GetH(X,Y);
if(m_dTime == 0)
m_dTime= m_img->GetNearestH(X,Y);//on veut récupérer une heure pas trop loin
if(m_dTime == 0)
return XErrorError(Error(),__FUNCTION__,"Impossible de recuperer l'heure du point ", m_img->Name().c_str());
return true;
}
//-----------------------------------------------------------------------------
uint32 XOrthoLaserMesure::NumPoint()
{
if(m_pt == NULL)
return 0;
return m_pt->Num();
}
//-----------------------------------------------------------------------------
XPt3D XOrthoLaserMesure::Translation()
{
if(m_pt == NULL)
return m_terrainLaser;
return m_terrainLaser-*m_pt;
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::SetPointNumFromTime()
{
if(m_pt == NULL)
return false;
uint32 num = floor(m_dTime*1000);
m_pt->Num(num);
return true;
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::SetPointPosition()
{
if(m_pt == NULL)
return false;
if(m_img == NULL)
return false;
return m_img->GetCoordTerrain(X,Y,m_pt);
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::UpdateCoordFromPoint()
{
if(m_pt == NULL)
return false;
if(m_img == NULL)
return false;
//une mesure générée à partir des coordonnées du point est forcement invalide
m_bValid =false;
return m_img->GetMesure(*m_pt, this);
}
//-----------------------------------------------------------------------------
void XOrthoLaserMesure::DeconnectPoint()
{
if(m_pt != NULL)
m_pt->RemoveMesure(this);
}
//-----------------------------------------------------------------------------
//NO TRAJ bool XOrthoLaserMesure::ConnectSousEch()
//{
// if(m_pt == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_pt == NULL");
// if(m_img == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_img == NULL");
// XOrthoLaserRxp* rxp = m_img->Rxp();
// if(rxp == NULL)
// return XErrorError(Error(),__FUNCTION__,"rxp == NULL");
// ProjPostProcessSolution * sol = rxp->Solution();
// if(sol == NULL)
// return XErrorError(Error(),__FUNCTION__,"sol == NULL");
// XOrthoLaserChantier* chantier = m_img->Chantier();
// if(chantier == NULL)
// return XErrorError(Error(),__FUNCTION__,"chantier == NULL");
// float TimeInDalle = this->Time();
// float GpsTimeInDay = TimeInDalle + chantier->CorOrthoLaserTime2Gps(rxp->Date());
//
// int rg;
// PostProcessedProjPosition* PosSsEch = sol->SsEchPosition(GpsTimeInDay,&rg);
// if(PosSsEch == NULL)
// { Valid(false);
// return XErrorError(Error(),__FUNCTION__,"PosSsEch == NULL ",InfoTxt().c_str());
// }
//
// PosSsEch->contrainte = (m_pt)->CreateContrainte(this);
// return true;
//}
//-----------------------------------------------------------------------------
// NO TRAJ bool XOrthoLaserMesure::DeconnectSousEch()
//{
// if(!m_bValid)
// return true;
// if(m_pt == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_pt == NULL");
// if(m_img == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_img == NULL");
// if(m_img->Rxp() == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_img->Rxp() == NULL");
// if(m_img->Rxp()->Solution() == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_img->Rxp()->Solution() == NULL");
// if(m_img->Chantier() == NULL)
// return XErrorError(Error(),__FUNCTION__,"m_img->Chantier() == NULL");
// float TimeInDalle = this->Time();
// float GpsTimeInDay = TimeInDalle + m_img->Chantier()->CorOrthoLaserTime2Gps(m_img->Rxp()->Date());
//
// char message[1024];
// int rg;
// PostProcessedProjPosition* PosSsEch = m_img->Rxp()->Solution()->SsEchPosition(GpsTimeInDay,&rg);
// if(PosSsEch == NULL)
// {
// sprintf(message,"Contrainte non trouvee T=%.2lf !!! ",GpsTimeInDay);
// return XErrorError(Error(),__FUNCTION__,message,m_img->Rxp()->Solution()->MissionName().c_str());
// }
//
//
// if(PosSsEch->contrainte != NULL)
// delete PosSsEch->contrainte;
// PosSsEch->contrainte = NULL;
// sprintf(message,"Sup. contrainte %s ",m_img->Name());
// return XErrorInfo(Error(),__FUNCTION__,message,m_img->Rxp()->Solution()->MissionName().c_str());
//}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::EcritureVecteurViewer(std::ostream* out)//fichier vectoriel pour le Viewer
{
if(m_pt == NULL)
return out->good();
if(!m_bValid)
return out->good();
m_pt->EcritureVecteurViewer(out);//info sur le point
*out << X << " " << Y << std::endl;///coordonnées de la mesure
return out->good();
}
//-----------------------------------------------------------------------------
std::string XOrthoLaserMesure::InfoTxt()
{
std::ostringstream oss;
oss << "Mesure du point ";
if(m_pt == NULL)oss << "NULL"; else oss << m_pt->Num();
oss << " sur dalle " << m_strImage ;
if(m_img == NULL) oss << " connectee "; else oss << " NON connectee ";
oss << " time " << Time() ;
return oss.str();
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::WriteMesure(std::ostream* out)
{
if(!m_bValid)
return out->good();
if(m_pt == NULL)
return out->good();
*out << m_pt->Num() << '\t'<< X << '\t' << Y << std::endl;//coordonnées de la mesure
return out->good();
}
//-----------------------------------------------------------------------------
bool XOrthoLaserMesure::XmlWrite(std::ostream* out)
{
if(!m_bValid)
return out->good();
*out << "<OrthoLaserMesure>" << std::endl;
*out << "<dalle> " << m_strImage << " </dalle>" << std::endl;
*out << "<time> " << m_dTime << " </time>" << std::endl;
*out << "<X> " << X << " </X>" << std::endl;
*out << "<Y> " << Y << " </Y>" << std::endl;
m_terrainLaser.XmlWrite(out);
*out << "</OrthoLaserMesure>" << std::endl;
return out->good();
}