@@ -32,7 +32,7 @@ extern "C"
32
32
}
33
33
34
34
// if defined shows all information about transform to stdout
35
- # undef COORDINATE_TRANSFORM_VERBOSE
35
+ // #define COORDINATE_TRANSFORM_VERBOSE
36
36
37
37
38
38
@@ -106,7 +106,6 @@ void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& t
106
106
}
107
107
void QgsCoordinateTransform::setDestCRS ( const QgsCoordinateReferenceSystem& theCRS )
108
108
{
109
- QgsDebugMsg ( " entered." );
110
109
mDestCRS = theCRS;
111
110
initialise ();
112
111
}
@@ -115,7 +114,6 @@ void QgsCoordinateTransform::setDestCRS( const QgsCoordinateReferenceSystem& the
115
114
void QgsCoordinateTransform::setDestCRSID ( long theCRSID )
116
115
{
117
116
// !todo Add some logic here to determine if the srsid is a system or user one
118
- QgsDebugMsg ( " entered." );
119
117
mDestCRS .createFromSrsId ( theCRSID );
120
118
initialise ();
121
119
}
@@ -152,6 +150,11 @@ void QgsCoordinateTransform::initialise()
152
150
mDestinationProjection = pj_init_plus ( mDestCRS .toProj4 ().toUtf8 () );
153
151
mSourceProjection = pj_init_plus ( mSourceCRS .toProj4 ().toUtf8 () );
154
152
153
+ #ifdef COORDINATE_TRANSFORM_VERBOSE
154
+ QgsDebugMsg ( " From proj : " + mSourceCRS .toProj4 () );
155
+ QgsDebugMsg ( " To proj : " + mDestCRS .toProj4 () );
156
+ #endif
157
+
155
158
mInitialisedFlag = true ;
156
159
if ( mDestinationProjection == NULL )
157
160
{
@@ -197,6 +200,7 @@ void QgsCoordinateTransform::initialise()
197
200
{
198
201
// Transform must take place
199
202
mShortCircuit = false ;
203
+ QgsDebugMsg ( " Source/Dest CRS UNequal, shortcircuit is NOt set." );
200
204
}
201
205
202
206
}
@@ -227,9 +231,6 @@ QgsPoint QgsCoordinateTransform::transform( const QgsPoint thePoint, TransformDi
227
231
throw cse;
228
232
}
229
233
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
233
234
return QgsPoint ( x, y );
234
235
}
235
236
@@ -273,7 +274,7 @@ QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, Tran
273
274
throw cse;
274
275
}
275
276
276
- #ifdef QGISDEBUG
277
+ #ifdef COORDINATE_TRANSFORM_VERBOSE
277
278
QgsDebugMsg ( " Rect projection..." );
278
279
QgsLogger::debug ( " Xmin : " , theRect.xMinimum (), 1 , __FILE__, __FUNCTION__, __LINE__ );
279
280
QgsLogger::debug ( " -->" , x1, 1 , __FILE__, __FUNCTION__, __LINE__ );
@@ -428,11 +429,12 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
428
429
return ;
429
430
}
430
431
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 ) );
435
436
#endif
437
+
436
438
// use proj4 to do the transform
437
439
QString dir;
438
440
// 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
451
453
int projResult;
452
454
if ( direction == ReverseTransform )
453
455
{
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
460
456
projResult = pj_transform ( mDestinationProjection , mSourceProjection , numPoints, 0 , x, y, z );
461
457
dir = " inverse" ;
462
458
}
463
459
else
464
460
{
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
472
461
assert ( mSourceProjection != 0 );
473
462
assert ( mDestinationProjection != 0 );
474
463
projResult = pj_transform ( mSourceProjection , mDestinationProjection , numPoints, 0 , x, y, z );
@@ -503,6 +492,7 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
503
492
QgsLogger::warning ( " Throwing exception " + QString ( __FILE__ ) + QString::number ( __LINE__ ) );
504
493
throw QgsCsException ( msg );
505
494
}
495
+
506
496
// if the result is lat/long, convert the results from radians back
507
497
// to degrees
508
498
if (( pj_is_latlong ( mDestinationProjection ) && ( direction == ForwardTransform ) )
@@ -515,8 +505,10 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
515
505
z[i] *= RAD_TO_DEG;
516
506
}
517
507
}
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 ) );
520
512
#endif
521
513
}
522
514
0 commit comments