1717/* $Id$ */
1818#include < cassert>
1919#include " qgscoordinatetransform.h"
20+ #include " qgslogger.h"
2021
2122// qt includes
2223#include < QDomNode>
@@ -88,9 +89,7 @@ void QgsCoordinateTransform::setSourceSRS(const QgsSpatialRefSys& theSRS)
8889}
8990void QgsCoordinateTransform::setDestSRS (const QgsSpatialRefSys& theSRS)
9091{
91- #ifdef QGISDEBUG
92- std::cout << " QgsCoordinateTransform::setDestSRS called" << std::endl;
93- #endif
92+ QgsDebugMsg (" QgsCoordinateTransform::setDestSRS called" );
9493 mDestSRS = theSRS;
9594 initialise ();
9695}
@@ -99,9 +98,7 @@ void QgsCoordinateTransform::setDestSRS(const QgsSpatialRefSys& theSRS)
9998void QgsCoordinateTransform::setDestSRSID (long theSRSID)
10099{
101100 // !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" );
105102 mDestSRS .createFromSrsId (theSRSID);
106103 initialise ();
107104}
@@ -162,25 +159,23 @@ void QgsCoordinateTransform::initialise()
162159 {
163160 mInitialisedFlag = false ;
164161 }
165-
162+ # ifdef QGISDEBUG
166163 if (mInitialisedFlag )
167164 {
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 (" ------------------------------------------------------------" );
175171 }
176172 else
177173 {
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 (" ------------------------------------------------------------" );
183177 }
178+ #endif
184179}
185180
186181//
@@ -205,7 +200,7 @@ QgsPoint QgsCoordinateTransform::transform(const QgsPoint thePoint,TransformDire
205200 catch (QgsCsException &cse)
206201 {
207202 // rethrow the exception
208- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
203+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
209204 throw cse;
210205 }
211206
@@ -225,7 +220,7 @@ QgsPoint QgsCoordinateTransform::transform(const double theX, const double theY=
225220 catch (QgsCsException &cse)
226221 {
227222 // rethrow the exception
228- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
223+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
229224 throw cse;
230225 }
231226}
@@ -239,9 +234,6 @@ QgsRect QgsCoordinateTransform::transform(const QgsRect theRect,TransformDirecti
239234 double x2 = theRect.xMax ();
240235 double y2 = theRect.yMax ();
241236
242- #ifdef QGISDEBUG
243- std::cout << this ;
244- #endif
245237 // Number of points to reproject------+
246238 // |
247239 // V
@@ -254,25 +246,20 @@ QgsRect QgsCoordinateTransform::transform(const QgsRect theRect,TransformDirecti
254246 catch (QgsCsException &cse)
255247 {
256248 // rethrow the exception
257- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
249+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
258250 throw cse;
259251 }
260252
261253#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__);
276263#endif
277264 return QgsRect (x1, y1, x2 , y2);
278265}
@@ -292,8 +279,8 @@ void QgsCoordinateTransform::transformInPlace(double& x, double& y, double& z,
292279 }
293280 catch (QgsCsException &cse)
294281 {
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__));
297284 throw cse;
298285 }
299286}
@@ -319,7 +306,7 @@ void QgsCoordinateTransform::transformInPlace(std::vector<double>& x,
319306 catch (QgsCsException &cse)
320307 {
321308 // rethrow the exception
322- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
309+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
323310 throw cse;
324311 }
325312}
@@ -346,9 +333,7 @@ QgsRect QgsCoordinateTransform::transformBoundingBox(const QgsRect rect, Transfo
346333 double x[numP * numP];
347334 double y[numP * numP];
348335 double z[numP * numP];
349- #ifdef QGISDEBUG
350- std::cout << " Entering transformBoundingBox..." << std::endl;
351- #endif
336+ QgsDebugMsg (" Entering transformBoundingBox..." );
352337 // Populate the vectors
353338
354339 double dx = rect.width () / (double )(numP - 1 );
@@ -384,7 +369,7 @@ QgsRect QgsCoordinateTransform::transformBoundingBox(const QgsRect rect, Transfo
384369 catch (QgsCsException &cse)
385370 {
386371 // rethrow the exception
387- std::cout << " Throwing exception " << __FILE__ << __LINE__ << std::endl;
372+ QgsLogger::warning ( " Throwing exception " + QString ( __FILE__) + QString ( __LINE__));
388373 throw cse;
389374 }
390375
@@ -395,8 +380,9 @@ QgsRect QgsCoordinateTransform::transformBoundingBox(const QgsRect rect, Transfo
395380 bb_rect.combineExtentWith (x[i], y[i]);
396381 }
397382#ifdef QGISDEBUG
398- std::cout << " Projected extent: " << ( bb_rect.stringRep ()).toLocal8Bit ().data () << std::endl ;
383+ QgsDebugMsg ( " Projected extent: " + QString (( bb_rect.stringRep ()).toLocal8Bit ().data ())) ;
399384#endif
385+
400386 return bb_rect;
401387}
402388
@@ -472,10 +458,10 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
472458
473459 pjErr << tr (" with error: " ) << pj_strerrno (projResult) << ' \n ' ;
474460#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 ())) ;
476462#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__));
479465 throw QgsCsException (msg);
480466 }
481467 // 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
497483
498484bool QgsCoordinateTransform::readXML ( QDomNode & theNode )
499485{
500- #ifdef QGISDEBUG
501- std::cout << " Reading Coordinate Transform from xml ------------------------!" << std::endl;
502- #endif
486+ QgsDebugMsg (" Reading Coordinate Transform from xml ------------------------!" );
503487 QDomNode mySrcNodeParent = theNode.namedItem (" sourcesrs" );
504488 QDomNode mySrcNode = mySrcNodeParent.namedItem (" spatialrefsys" );
505489 mSourceSRS .readXML (mySrcNode);
0 commit comments