17
17
/* $Id$ */
18
18
#include < cassert>
19
19
#include " qgscoordinatetransform.h"
20
+ #include " qgslogger.h"
20
21
21
22
// qt includes
22
23
#include < QDomNode>
@@ -88,9 +89,7 @@ void QgsCoordinateTransform::setSourceSRS(const QgsSpatialRefSys& theSRS)
88
89
}
89
90
void QgsCoordinateTransform::setDestSRS (const QgsSpatialRefSys& theSRS)
90
91
{
91
- #ifdef QGISDEBUG
92
- std::cout << " QgsCoordinateTransform::setDestSRS called" << std::endl;
93
- #endif
92
+ QgsDebugMsg (" QgsCoordinateTransform::setDestSRS called" );
94
93
mDestSRS = theSRS;
95
94
initialise ();
96
95
}
@@ -99,9 +98,7 @@ void QgsCoordinateTransform::setDestSRS(const QgsSpatialRefSys& theSRS)
99
98
void QgsCoordinateTransform::setDestSRSID (long theSRSID)
100
99
{
101
100
// !todo Add some logic here to determine if the srsid is a system or user one
102
- #ifdef QGISDEBUG
103
- std::cout << " QgsCoordinateTransform::setDestSRSID slot called" << std::endl;
104
- #endif
101
+ QgsDebugMsg (" QgsCoordinateTransform::setDestSRSID slot called" );
105
102
mDestSRS .createFromSrsId (theSRSID);
106
103
initialise ();
107
104
}
@@ -162,25 +159,23 @@ void QgsCoordinateTransform::initialise()
162
159
{
163
160
mInitialisedFlag = false ;
164
161
}
165
-
162
+ # ifdef QGISDEBUG
166
163
if (mInitialisedFlag )
167
164
{
168
- #ifdef QGISDEBUG
169
- std::cout << " ------------------------------------------------------------\n "
170
- << " QgsCoordinateTransform::initialise()\n "
171
- << " The OGR Coordinate transformation for this layer was set to\n "
172
- << " INPUT: \n " << mSourceSRS << ' \n '
173
- << " OUTPUT: \n " << mDestSRS << ' \n '
174
- << " ------------------------------------------------------------\n " ;
165
+ QgsDebugMsg (" ------------------------------------------------------------" );
166
+ QgsDebugMsg (" QgsCoordinateTransform::initialise()" );
167
+ QgsDebugMsg (" The OGR Coordinate transformation for this layer was set to" );
168
+ QgsLogger::debug<QgsSpatialRefSys>(" Input" , mSourceSRS , __FILE__, __FUNCTION__, __LINE__);
169
+ QgsLogger::debug<QgsSpatialRefSys>(" Output" , mDestSRS , __FILE__, __FUNCTION__, __LINE__);
170
+ QgsDebugMsg (" ------------------------------------------------------------" );
175
171
}
176
172
else
177
173
{
178
- std::cout<< " ------------------------------------------------------------\n "
179
- << " QgsCoordinateTransform::initialise()\n "
180
- << " The OGR Coordinate transformation FAILED TO INITIALISE!\n "
181
- << " ------------------------------------------------------------\n " ;
182
- #endif
174
+ QgsDebugMsg (" ------------------------------------------------------------" );
175
+ QgsDebugMsg (" The OGR Coordinate transformation FAILED TO INITIALISE!" );
176
+ QgsDebugMsg (" ------------------------------------------------------------" );
183
177
}
178
+ #endif
184
179
}
185
180
186
181
//
@@ -205,7 +200,7 @@ QgsPoint QgsCoordinateTransform::transform(const QgsPoint thePoint,TransformDire
205
200
catch (QgsCsException &cse)
206
201
{
207
202
// rethrow the exception
208
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
203
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
209
204
throw cse;
210
205
}
211
206
@@ -225,7 +220,7 @@ QgsPoint QgsCoordinateTransform::transform(const double theX, const double theY=
225
220
catch (QgsCsException &cse)
226
221
{
227
222
// rethrow the exception
228
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
223
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
229
224
throw cse;
230
225
}
231
226
}
@@ -239,9 +234,6 @@ QgsRect QgsCoordinateTransform::transform(const QgsRect theRect,TransformDirecti
239
234
double x2 = theRect.xMax ();
240
235
double y2 = theRect.yMax ();
241
236
242
- #ifdef QGISDEBUG
243
- std::cout << this ;
244
- #endif
245
237
// Number of points to reproject------+
246
238
// |
247
239
// V
@@ -254,25 +246,20 @@ QgsRect QgsCoordinateTransform::transform(const QgsRect theRect,TransformDirecti
254
246
catch (QgsCsException &cse)
255
247
{
256
248
// rethrow the exception
257
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
249
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
258
250
throw cse;
259
251
}
260
252
261
253
#ifdef QGISDEBUG
262
- std::cout << " Rect projection..."
263
- << " Xmin : "
264
- << theRect.xMin ()
265
- << " -->" << x1
266
- << " , Ymin: "
267
- << theRect.yMin ()
268
- << " -->" << y1
269
- << " Xmax : "
270
- << theRect.xMax ()
271
- << " -->" << x2
272
- << " , Ymax: "
273
- << theRect.yMax ()
274
- << " -->" << y2
275
- << std::endl;
254
+ QgsDebugMsg (" Rect projection..." );
255
+ QgsLogger::debug (" Xmin : " , theRect.xMin (), 1 , __FILE__, __FUNCTION__, __LINE__);
256
+ QgsLogger::debug (" -->" , x1, 1 , __FILE__, __FUNCTION__, __LINE__);
257
+ QgsLogger::debug (" Ymin : " , theRect.yMin (), 1 , __FILE__, __FUNCTION__, __LINE__);
258
+ QgsLogger::debug (" -->" , y1, 1 , __FILE__, __FUNCTION__, __LINE__);
259
+ QgsLogger::debug (" Xmax : " , theRect.xMax (), 1 , __FILE__, __FUNCTION__, __LINE__);
260
+ QgsLogger::debug (" -->" , x2, 1 , __FILE__, __FUNCTION__, __LINE__);
261
+ QgsLogger::debug (" Ymax : " , theRect.yMax (), 1 , __FILE__, __FUNCTION__, __LINE__);
262
+ QgsLogger::debug (" -->" , y2, 1 , __FILE__, __FUNCTION__, __LINE__);
276
263
#endif
277
264
return QgsRect (x1, y1, x2 , y2);
278
265
}
@@ -292,8 +279,8 @@ void QgsCoordinateTransform::transformInPlace(double& x, double& y, double& z,
292
279
}
293
280
catch (QgsCsException &cse)
294
281
{
295
- // rethrow the exception
296
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
282
+ // rethrow the exception
283
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
297
284
throw cse;
298
285
}
299
286
}
@@ -319,7 +306,7 @@ void QgsCoordinateTransform::transformInPlace(std::vector<double>& x,
319
306
catch (QgsCsException &cse)
320
307
{
321
308
// rethrow the exception
322
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
309
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
323
310
throw cse;
324
311
}
325
312
}
@@ -346,9 +333,7 @@ QgsRect QgsCoordinateTransform::transformBoundingBox(const QgsRect rect, Transfo
346
333
double x[numP * numP];
347
334
double y[numP * numP];
348
335
double z[numP * numP];
349
- #ifdef QGISDEBUG
350
- std::cout << " Entering transformBoundingBox..." << std::endl;
351
- #endif
336
+ QgsDebugMsg (" Entering transformBoundingBox..." );
352
337
// Populate the vectors
353
338
354
339
double dx = rect.width () / (double )(numP - 1 );
@@ -384,7 +369,7 @@ QgsRect QgsCoordinateTransform::transformBoundingBox(const QgsRect rect, Transfo
384
369
catch (QgsCsException &cse)
385
370
{
386
371
// rethrow the exception
387
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
372
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
388
373
throw cse;
389
374
}
390
375
@@ -395,8 +380,9 @@ QgsRect QgsCoordinateTransform::transformBoundingBox(const QgsRect rect, Transfo
395
380
bb_rect.combineExtentWith (x[i], y[i]);
396
381
}
397
382
#ifdef QGISDEBUG
398
- std::cout << " Projected extent: " << ( bb_rect.stringRep ()).toLocal8Bit ().data () << std::endl ;
383
+ QgsDebugMsg ( " Projected extent: " + QString (( bb_rect.stringRep ()).toLocal8Bit ().data ())) ;
399
384
#endif
385
+
400
386
return bb_rect;
401
387
}
402
388
@@ -472,10 +458,10 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
472
458
473
459
pjErr << tr (" with error: " ) << pj_strerrno (projResult) << ' \n ' ;
474
460
#ifdef QGISDEBUG
475
- std::cout << " Projection failed emitting invalid transform signal: \n " << msg.toLocal8Bit ().data () << std::endl ;
461
+ QgsDebugMsg ( " Projection failed emitting invalid transform signal: " + QString ( msg.toLocal8Bit ().data ())) ;
476
462
#endif
477
- emit invalidTransformInput ();
478
- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
463
+ emit invalidTransformInput ();
464
+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
479
465
throw QgsCsException (msg);
480
466
}
481
467
// if the result is lat/long, convert the results from radians back
@@ -497,9 +483,7 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
497
483
498
484
bool QgsCoordinateTransform::readXML ( QDomNode & theNode )
499
485
{
500
- #ifdef QGISDEBUG
501
- std::cout << " Reading Coordinate Transform from xml ------------------------!" << std::endl;
502
- #endif
486
+ QgsDebugMsg (" Reading Coordinate Transform from xml ------------------------!" );
503
487
QDomNode mySrcNodeParent = theNode.namedItem (" sourcesrs" );
504
488
QDomNode mySrcNode = mySrcNodeParent.namedItem (" spatialrefsys" );
505
489
mSourceSRS .readXML (mySrcNode);
0 commit comments