BodiesCDPP3DView.cpp
6.95 KB
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
#include "BodiesCDPP3DView.h"
#include <vector>
//#include "../../CDPP3DViewSOAPClient/cdppBinder.nsmap"
#include "../../CDPP3DViewSOAPClient/cdpp3dviewcdppBinderProxy.h"
#include "../Common/Toolbox.h"
//#include "../DataRetriever/DataRetriever.h"
//#include "../File/FileLoaderManager.h"
#include "../TimeManager/TimeManager.h"
using namespace TREPS::Common;
using namespace TREPS::TimeManager;
namespace TREPS
{
namespace Bodies
{
BodiesCDPP3DViewClass::BodiesCDPP3DViewClass(RequestAbstractClass *trepsRequest):BodiesAbstractClass(trepsRequest),
client(NULL)
{
//init SOAP client for 3DView Web Service
this->client = new cdppBinderProxy(SOAP_IO_KEEPALIVE);
soap_ssl_init();
if (soap_ssl_client_context(this->client,
SOAP_SSL_NO_AUTHENTICATION,
NULL, // keyfile: required only when client must authenticate to server
NULL, // password to read the key file (not used with GNUTLS)
NULL, // cacert file to store trusted certificates
NULL, // capath to directory with trusted certificates
NULL // if randfile!=NULL: use a file with random data to seed randomness
)) {
this->errorMsg = "Error during the SOAP SSL init: ";
if (this->client->soap_fault_string() != NULL)
{
this->errorMsg += this->client->soap_fault_string();
}
LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
}
}
BodiesCDPP3DViewClass::~BodiesCDPP3DViewClass(void)
{
if (this->client != NULL)
{
delete this->client;
this->client = NULL;
}
}
bool BodiesCDPP3DViewClass::run()
{
this->errorMsg = "";
//for each vector
//for (t_VectorList::iterator it=this->request->getSrcVectors()->begin(); it != this->request->getSrcVectors()->end(); ++it)
//{
string generalStatus = "";
generalStatus += " - Running step : list bodies";
this->trepsRequest->setStatus(generalStatus.c_str());
t_Bodies bodies = this->callListBodiesRequest(request->getIsSc());
generalStatus = "Bodies found: ";
generalStatus += bodies.size();
generalStatus += " - Running step : filter bodies result";
//this->trepsRequest->setStatus(generalStatus.c_str());
LOG4CXX_INFO(this->app->getLog()->getPtr(),"listBodies result : " << bodies.size() << " bodies found");
t_Bodies filteredBodies;
//get time manager instance
TimeManagerClass *timeMgr = TimeManagerClass::getInstance();
for (unsigned int i=0;i<bodies.size();i++) {
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): in for : " << i);
ns4__Body* body = bodies.at(i);
ns4__TimeRange* coverage = body->coverage;
if(coverage==0) continue;
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): body " <<bodies.at(i)->name.c_str()<<"/"<<coverage);
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): body " <<bodies.at(i)->name.c_str()<<"/"<<coverage->startTime<<"/"<<coverage->stopTime);
time_t lBodyStart = coverage->startTime;
time_t lBodyStop = coverage->stopTime;
time_t lFileStart = timeMgr->to_TIMESTAMP(request->getStartTime());
time_t lFileStop = timeMgr->to_TIMESTAMP(request->getStopTime());
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): compare body start: " << ctime(&lBodyStart));
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): compare body stop: " << ctime(&lBodyStop));
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): compare filter start: " << ctime(&lFileStart));
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): compare filter stop: " << ctime(&lFileStop));
//check if body timerange covers file timerange
if((lBodyStart-lFileStart)<0 && (lBodyStop-lFileStop)>0) {
/*ns4__Body *lNewBody = soap_new_req_ns4__Body(body->soap, body->naifId, body->modelId, body->name,
soap_new_req_ns4__TimeRange(body->soap, lBodyStart, lBodyStop),
body->type, body->color, body->size,
body->prefFrame, body->prefCenter, body->prefStarSubset);
*/
filteredBodies.push_back(body);
}
}
LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): filtered bodies result : " << filteredBodies.size() << " bodies found");
//copy result xml file in op workspace
generalStatus = "Bodies filtered: ";
generalStatus += filteredBodies.size();
generalStatus += " - Running step : Save bodies result";
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): set Status");
//this->trepsRequest->setStatus(generalStatus.c_str());
//add result
//LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.run(): set result");
this->result->init(filteredBodies);
//}
return true;
}
t_Bodies BodiesCDPP3DViewClass::callListBodiesRequest(bool isSc)
{
bool res = false;
t_Bodies response;
string method = "listBodies";
//Init 3DView listBodies request
_ns3__listBodies listBodiesRequest;
_ns3__listBodiesResponse listBodiesResponse;
if(isSc) {
listBodiesRequest.pType = ns4__BodyType__SPACECRAFT;
LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.callListBodiesRequest(): type : sc");
res = (this->client->listBodies(&listBodiesRequest,&listBodiesResponse) == SOAP_OK);
} else {
listBodiesRequest.pType = ns4__BodyType__PLANET;
LOG4CXX_INFO(this->app->getLog()->getPtr(),"BodiesCDPP3DView.callListBodiesRequest(): type : planet");
//ns4__BodyType__PLANET, ///< xs:string value="PLANET"
//ns4__BodyType__SATELLITE, ///< xs:string value="SATELLITE"
//ns4__BodyType__COMET, ///< xs:string value="COMET"
//ns4__BodyType__ASTEROID, ///< xs:string value="ASTEROID"
res = (this->client->listBodies(&listBodiesRequest,&listBodiesResponse) == SOAP_OK);
t_Bodies planets = listBodiesResponse.return_;
/* listBodiesRequest.pType = ns4__BodyType__SATELLITE;
res = (this->client->listBodies(&listBodiesRequest,&listBodiesResponse) == SOAP_OK);
for(unsigned i=0;i<planets.size();i++) {
listBodiesResponse.return_.push_back(planets.at(i));
}
*/
}
//run listNewFrameOrb to perform transformation (rotation + translation)
//_ns3__listNewFrameOrbResponse listNewFrameOrbResponse;
//#ifndef WITH_GETORBURL
//this->deleteTimeList(listNewFrameOrbRequest.pDateTimeInput);
//this->deleteVectorTuple3d(listNewFrameOrbRequest.pDataInput);
//#endif
if (!res)
{
this->errorMsg = "Error during the call of ";
this->errorMsg += method;
this->errorMsg += " of 3DView Web Service";
if (this->client->soap_fault_string() != NULL)
{
this->errorMsg += " (";
this->errorMsg += this->client->soap_fault_string();
this->errorMsg += ")";
}
LOG4CXX_ERROR(this->app->getLog()->getPtr(),this->errorMsg);
} else {
response = listBodiesResponse.return_;
}
return response;
}
}
}