Skip to content

Commit 309ccfc

Browse files
author
homann
committed
Cleaned up debugging output of CRS transform
git-svn-id: http://svn.osgeo.org/qgis/trunk@11404 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 3f8d028 commit 309ccfc

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

src/core/qgscoordinatetransform.cpp

+18-26
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern "C"
3232
}
3333

3434
// if defined shows all information about transform to stdout
35-
#undef COORDINATE_TRANSFORM_VERBOSE
35+
// #define COORDINATE_TRANSFORM_VERBOSE
3636

3737

3838

@@ -106,7 +106,6 @@ void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& t
106106
}
107107
void QgsCoordinateTransform::setDestCRS( const QgsCoordinateReferenceSystem& theCRS )
108108
{
109-
QgsDebugMsg( "entered." );
110109
mDestCRS = theCRS;
111110
initialise();
112111
}
@@ -115,7 +114,6 @@ void QgsCoordinateTransform::setDestCRS( const QgsCoordinateReferenceSystem& the
115114
void QgsCoordinateTransform::setDestCRSID( long theCRSID )
116115
{
117116
//!todo Add some logic here to determine if the srsid is a system or user one
118-
QgsDebugMsg( "entered." );
119117
mDestCRS.createFromSrsId( theCRSID );
120118
initialise();
121119
}
@@ -152,6 +150,11 @@ void QgsCoordinateTransform::initialise()
152150
mDestinationProjection = pj_init_plus( mDestCRS.toProj4().toUtf8() );
153151
mSourceProjection = pj_init_plus( mSourceCRS.toProj4().toUtf8() );
154152

153+
#ifdef COORDINATE_TRANSFORM_VERBOSE
154+
QgsDebugMsg( "From proj : " + mSourceCRS.toProj4() );
155+
QgsDebugMsg( "To proj : " + mDestCRS.toProj4() );
156+
#endif
157+
155158
mInitialisedFlag = true;
156159
if ( mDestinationProjection == NULL )
157160
{
@@ -197,6 +200,7 @@ void QgsCoordinateTransform::initialise()
197200
{
198201
// Transform must take place
199202
mShortCircuit = false;
203+
QgsDebugMsg( "Source/Dest CRS UNequal, shortcircuit is NOt set." );
200204
}
201205

202206
}
@@ -227,9 +231,6 @@ QgsPoint QgsCoordinateTransform::transform( const QgsPoint thePoint, TransformDi
227231
throw cse;
228232
}
229233

230-
#ifdef QGISDEBUG
231-
// QgsDebugMsg(QString("Point projection...X : %1-->%2, Y: %3 -->%4").arg(thePoint.x()).arg(x).arg(thePoint.y()).arg(y));
232-
#endif
233234
return QgsPoint( x, y );
234235
}
235236

@@ -273,7 +274,7 @@ QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, Tran
273274
throw cse;
274275
}
275276

276-
#ifdef QGISDEBUG
277+
#ifdef COORDINATE_TRANSFORM_VERBOSE
277278
QgsDebugMsg( "Rect projection..." );
278279
QgsLogger::debug( "Xmin : ", theRect.xMinimum(), 1, __FILE__, __FUNCTION__, __LINE__ );
279280
QgsLogger::debug( "-->", x1, 1, __FILE__, __FUNCTION__, __LINE__ );
@@ -428,11 +429,12 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
428429
return;
429430
}
430431

431-
#ifdef QGISDEBUG
432-
//double xorg = x;
433-
//double yorg = y;
434-
// QgsDebugMsg(QString("[[[[[[Number of points to transform: %1]]]]]]").arg(numPoints));
432+
#ifdef COORDINATE_TRANSFORM_VERBOSE
433+
double xorg = *x;
434+
double yorg = *y;
435+
QgsDebugMsg( QString( "[[[[[[ Number of points to transform: %1 ]]]]]]" ).arg( numPoints ) );
435436
#endif
437+
436438
// use proj4 to do the transform
437439
QString dir;
438440
// if the source/destination projection is lat/long, convert the points to radians
@@ -451,24 +453,11 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
451453
int projResult;
452454
if ( direction == ReverseTransform )
453455
{
454-
#if 0
455-
QgsDebugMsg( "!!!! ReverseTransform PROJ4 TRANSFORM !!!!" );
456-
QgsDebugMsg( QString( " numPoint: %1" ).arg( numPoints ) );
457-
QgsDebugMsg( QString( " x : %1" ).arg( x ) );
458-
QgsDebugMsg( QString( " y : %1" ).arg( y ) );
459-
#endif
460456
projResult = pj_transform( mDestinationProjection, mSourceProjection, numPoints, 0, x, y, z );
461457
dir = "inverse";
462458
}
463459
else
464460
{
465-
#if 0
466-
QgsDebugMsg( "!!!! ForwardTransform PROJ4 TRANSFORM !!!!" );
467-
QgsDebugMsg( QString( " numPoint: %1" ).arg( numPoints ) );
468-
QgsDebugMsg( QString( " x : %1" ).arg( x ) );
469-
QgsDebugMsg( QString( " y : %1" ).arg( y ) );
470-
QgsDebugMsg( QString( " z : %1" ).arg( z ) );
471-
#endif
472461
assert( mSourceProjection != 0 );
473462
assert( mDestinationProjection != 0 );
474463
projResult = pj_transform( mSourceProjection, mDestinationProjection, numPoints, 0, x, y, z );
@@ -503,6 +492,7 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
503492
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
504493
throw QgsCsException( msg );
505494
}
495+
506496
// if the result is lat/long, convert the results from radians back
507497
// to degrees
508498
if (( pj_is_latlong( mDestinationProjection ) && ( direction == ForwardTransform ) )
@@ -515,8 +505,10 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
515505
z[i] *= RAD_TO_DEG;
516506
}
517507
}
518-
#ifdef QGISDEBUG
519-
// QgsDebugMsg(QString("[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]").arg(xorg).arg(yorg).arg(x).arg(y));
508+
#ifdef COORDINATE_TRANSFORM_VERBOSE
509+
QgsDebugMsg( QString( "[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]" )
510+
.arg( xorg, 0, 'g', 15 ).arg( yorg, 0, 'g', 15 )
511+
.arg( *x, 0, 'g', 15 ).arg( *y, 0, 'g', 15 ) );
520512
#endif
521513
}
522514

0 commit comments

Comments
 (0)