Skip to content

Commit

Permalink
Cleaned up debugging output of CRS transform
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11404 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Aug 17, 2009
1 parent 9cd32f4 commit 61f4676
Showing 1 changed file with 18 additions and 26 deletions.
44 changes: 18 additions & 26 deletions src/core/qgscoordinatetransform.cpp
Expand Up @@ -32,7 +32,7 @@ extern "C"
}

// if defined shows all information about transform to stdout
#undef COORDINATE_TRANSFORM_VERBOSE
// #define COORDINATE_TRANSFORM_VERBOSE



Expand Down Expand Up @@ -106,7 +106,6 @@ void QgsCoordinateTransform::setSourceCrs( const QgsCoordinateReferenceSystem& t
}
void QgsCoordinateTransform::setDestCRS( const QgsCoordinateReferenceSystem& theCRS )
{
QgsDebugMsg( "entered." );
mDestCRS = theCRS;
initialise();
}
Expand All @@ -115,7 +114,6 @@ void QgsCoordinateTransform::setDestCRS( const QgsCoordinateReferenceSystem& the
void QgsCoordinateTransform::setDestCRSID( long theCRSID )
{
//!todo Add some logic here to determine if the srsid is a system or user one
QgsDebugMsg( "entered." );
mDestCRS.createFromSrsId( theCRSID );
initialise();
}
Expand Down Expand Up @@ -152,6 +150,11 @@ void QgsCoordinateTransform::initialise()
mDestinationProjection = pj_init_plus( mDestCRS.toProj4().toUtf8() );
mSourceProjection = pj_init_plus( mSourceCRS.toProj4().toUtf8() );

#ifdef COORDINATE_TRANSFORM_VERBOSE
QgsDebugMsg( "From proj : " + mSourceCRS.toProj4() );
QgsDebugMsg( "To proj : " + mDestCRS.toProj4() );
#endif

mInitialisedFlag = true;
if ( mDestinationProjection == NULL )
{
Expand Down Expand Up @@ -197,6 +200,7 @@ void QgsCoordinateTransform::initialise()
{
// Transform must take place
mShortCircuit = false;
QgsDebugMsg( "Source/Dest CRS UNequal, shortcircuit is NOt set." );
}

}
Expand Down Expand Up @@ -227,9 +231,6 @@ QgsPoint QgsCoordinateTransform::transform( const QgsPoint thePoint, TransformDi
throw cse;
}

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

Expand Down Expand Up @@ -273,7 +274,7 @@ QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle theRect, Tran
throw cse;
}

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

#ifdef QGISDEBUG
//double xorg = x;
//double yorg = y;
// QgsDebugMsg(QString("[[[[[[Number of points to transform: %1]]]]]]").arg(numPoints));
#ifdef COORDINATE_TRANSFORM_VERBOSE
double xorg = *x;
double yorg = *y;
QgsDebugMsg( QString( "[[[[[[ Number of points to transform: %1 ]]]]]]" ).arg( numPoints ) );
#endif

// use proj4 to do the transform
QString dir;
// if the source/destination projection is lat/long, convert the points to radians
Expand All @@ -451,24 +453,11 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
int projResult;
if ( direction == ReverseTransform )
{
#if 0
QgsDebugMsg( "!!!! ReverseTransform PROJ4 TRANSFORM !!!!" );
QgsDebugMsg( QString( " numPoint: %1" ).arg( numPoints ) );
QgsDebugMsg( QString( " x : %1" ).arg( x ) );
QgsDebugMsg( QString( " y : %1" ).arg( y ) );
#endif
projResult = pj_transform( mDestinationProjection, mSourceProjection, numPoints, 0, x, y, z );
dir = "inverse";
}
else
{
#if 0
QgsDebugMsg( "!!!! ForwardTransform PROJ4 TRANSFORM !!!!" );
QgsDebugMsg( QString( " numPoint: %1" ).arg( numPoints ) );
QgsDebugMsg( QString( " x : %1" ).arg( x ) );
QgsDebugMsg( QString( " y : %1" ).arg( y ) );
QgsDebugMsg( QString( " z : %1" ).arg( z ) );
#endif
assert( mSourceProjection != 0 );
assert( mDestinationProjection != 0 );
projResult = pj_transform( mSourceProjection, mDestinationProjection, numPoints, 0, x, y, z );
Expand Down Expand Up @@ -503,6 +492,7 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
QgsLogger::warning( "Throwing exception " + QString( __FILE__ ) + QString::number( __LINE__ ) );
throw QgsCsException( msg );
}

// if the result is lat/long, convert the results from radians back
// to degrees
if (( pj_is_latlong( mDestinationProjection ) && ( direction == ForwardTransform ) )
Expand All @@ -515,8 +505,10 @@ void QgsCoordinateTransform::transformCoords( const int& numPoints, double *x, d
z[i] *= RAD_TO_DEG;
}
}
#ifdef QGISDEBUG
// QgsDebugMsg(QString("[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]").arg(xorg).arg(yorg).arg(x).arg(y));
#ifdef COORDINATE_TRANSFORM_VERBOSE
QgsDebugMsg( QString( "[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]" )
.arg( xorg, 0, 'g', 15 ).arg( yorg, 0, 'g', 15 )
.arg( *x, 0, 'g', 15 ).arg( *y, 0, 'g', 15 ) );
#endif
}

Expand Down

0 comments on commit 61f4676

Please sign in to comment.