24 #include <QDomElement>
25 #include <QApplication>
37 , mInitialisedFlag( false )
38 , mSourceProjection( 0 )
39 , mDestinationProjection( 0 )
46 , mInitialisedFlag( false )
47 , mSourceProjection( 0 )
48 , mDestinationProjection( 0 )
58 , mInitialisedFlag( false )
61 , mSourceProjection( 0 )
62 , mDestinationProjection( 0 )
69 , mInitialisedFlag( false )
70 , mSourceProjection( 0 )
71 , mDestinationProjection( 0 )
87 , mInitialisedFlag( false )
88 , mSourceProjection( 0 )
89 , mDestinationProjection( 0 )
160 #ifdef COORDINATE_TRANSFORM_VERBOSE
168 mInitialisedFlag =
false;
170 if ( !mSourceProjection )
172 mInitialisedFlag =
false;
174 #ifdef COORDINATE_TRANSFORM_VERBOSE
175 if ( mInitialisedFlag )
177 QgsDebugMsg(
"------------------------------------------------------------" );
178 QgsDebugMsg(
"The OGR Coordinate transformation for this layer was set to" );
179 QgsLogger::debug<QgsCoordinateReferenceSystem>(
"Input",
mSourceCRS, __FILE__, __FUNCTION__, __LINE__ );
180 QgsLogger::debug<QgsCoordinateReferenceSystem>(
"Output",
mDestCRS, __FILE__, __FUNCTION__, __LINE__ );
181 QgsDebugMsg(
"------------------------------------------------------------" );
185 QgsDebugMsg(
"------------------------------------------------------------" );
186 QgsDebugMsg(
"The OGR Coordinate transformation FAILED TO INITIALISE!" );
187 QgsDebugMsg(
"------------------------------------------------------------" );
190 if ( !mInitialisedFlag )
192 QgsDebugMsg(
"Coordinate transformation failed to initialize!" );
227 double x = thePoint.
x();
228 double y = thePoint.
y();
284 #ifdef COORDINATE_TRANSFORM_VERBOSE
320 std::vector<double>& y, std::vector<double>& z,
326 Q_ASSERT( x.size() == y.size() );
362 static const int numP = 8;
370 double x[numP * numP];
371 double y[numP * numP];
372 double z[numP * numP];
378 double dx = rect.
width() / ( double )( numP - 1 );
379 double dy = rect.
height() / ( double )( numP - 1 );
383 for (
int i = 0; i < numP ; i++ )
389 for (
int j = 0; j < numP; j++ )
391 x[( i*numP ) + j] = pointX;
392 y[( i*numP ) + j] = pointY;
394 z[( i*numP ) + j] = 0.0;
416 for (
int i = 0; i < numP * numP; i++ )
418 if ( qIsFinite( x[i] ) && qIsFinite( y[i] ) )
422 QgsDebugMsg(
"Projected extent: " + QString(( bb_rect.
toString() ).toLocal8Bit().data() ) );
433 + tr(
"The coordinates can not be reprojected."
441 + tr(
"The coordinates can not be reprojected."
446 #ifdef COORDINATE_TRANSFORM_VERBOSE
449 QgsDebugMsg( QString(
"[[[[[[ Number of points to transform: %1 ]]]]]]" ).arg( numPoints ) );
459 for (
int i = 0; i < numPoints; ++i )
471 dir = tr(
"inverse transform" );
478 dir = tr(
"forward transform" );
481 if ( projResult != 0 )
486 for (
int i = 0; i < numPoints; ++i )
490 points += QString(
"(%1, %2)\n" ).arg( x[i] ).arg( y[i] );
494 points += QString(
"(%1, %2)\n" ).arg( x[i] * RAD_TO_DEG ).arg( y[i] * RAD_TO_DEG );
498 QString msg = tr(
"%1 of\n%2\nfailed with error: %3\n" )
501 .arg( QString::fromUtf8( pj_strerrno( projResult ) ) );
503 QgsDebugMsg(
"Projection failed emitting invalid transform signal: " + msg );
517 for (
int i = 0; i < numPoints; ++i )
524 #ifdef COORDINATE_TRANSFORM_VERBOSE
525 QgsDebugMsg( QString(
"[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]" )
526 .arg( xorg, 0,
'g', 15 ).arg( yorg, 0,
'g', 15 )
527 .arg( *x, 0,
'g', 15 ).arg( *y, 0,
'g', 15 ) );
534 QgsDebugMsg(
"Reading Coordinate Transform from xml ------------------------!" );
536 QDomNode mySrcNode = theNode.namedItem(
"sourcesrs" );
539 QDomNode myDestNode = theNode.namedItem(
"destinationsrs" );
549 QDomElement myNodeElement = theNode.toElement();
550 QDomElement myTransformElement = theDoc.createElement(
"coordinatetransform" );
552 QDomElement mySourceElement = theDoc.createElement(
"sourcesrs" );
554 myTransformElement.appendChild( mySourceElement );
556 QDomElement myDestElement = theDoc.createElement(
"destinationsrs" );
558 myTransformElement.appendChild( myDestElement );
560 myNodeElement.appendChild( myTransformElement );
569 proj = QApplication::applicationDirPath()
570 +
"/share/proj/" + QString( name );
572 return proj.toUtf8();