24 #include <QDomElement>
25 #include <QApplication>
39 , mInitialisedFlag( false )
40 , mSourceProjection( 0 )
41 , mDestinationProjection( 0 )
48 , mInitialisedFlag( false )
49 , mSourceProjection( 0 )
50 , mDestinationProjection( 0 )
60 , mInitialisedFlag( false )
63 , mSourceProjection( 0 )
64 , mDestinationProjection( 0 )
71 , mInitialisedFlag( false )
72 , mSourceProjection( 0 )
73 , mDestinationProjection( 0 )
89 , mInitialisedFlag( false )
90 , mSourceProjection( 0 )
91 , mDestinationProjection( 0 )
163 #ifdef COORDINATE_TRANSFORM_VERBOSE
171 mInitialisedFlag =
false;
175 mInitialisedFlag =
false;
177 #ifdef COORDINATE_TRANSFORM_VERBOSE
178 if ( mInitialisedFlag )
180 QgsDebugMsg(
"------------------------------------------------------------" );
181 QgsDebugMsg(
"The OGR Coordinate transformation for this layer was set to" );
182 QgsLogger::debug<QgsCoordinateReferenceSystem>(
"Input",
mSourceCRS, __FILE__, __FUNCTION__, __LINE__ );
183 QgsLogger::debug<QgsCoordinateReferenceSystem>(
"Output",
mDestCRS, __FILE__, __FUNCTION__, __LINE__ );
184 QgsDebugMsg(
"------------------------------------------------------------" );
188 QgsDebugMsg(
"------------------------------------------------------------" );
189 QgsDebugMsg(
"The OGR Coordinate transformation FAILED TO INITIALISE!" );
190 QgsDebugMsg(
"------------------------------------------------------------" );
193 if ( !mInitialisedFlag )
195 QgsDebugMsg(
"Coordinate transformation failed to initialize!" );
231 double x = thePoint.
x();
232 double y = thePoint.
y();
289 #ifdef COORDINATE_TRANSFORM_VERBOSE
293 QgsLogger::debug(
"Ymin : ", theRect.
yMinimum(), 1, __FILE__, __FUNCTION__, __LINE__ );
294 QgsLogger::debug(
"-->", y1, 1, __FILE__, __FUNCTION__, __LINE__ );
295 QgsLogger::debug(
"Xmax : ", theRect.
xMaximum(), 1, __FILE__, __FUNCTION__, __LINE__ );
296 QgsLogger::debug(
"-->", x2, 1, __FILE__, __FUNCTION__, __LINE__ );
297 QgsLogger::debug(
"Ymax : ", theRect.
yMaximum(), 1, __FILE__, __FUNCTION__, __LINE__ );
298 QgsLogger::debug(
"-->", y2, 1, __FILE__, __FUNCTION__, __LINE__ );
332 int nVertices = poly.size();
334 QVector<double> x( nVertices );
335 QVector<double> y( nVertices );
336 QVector<double> z( nVertices );
338 for (
int i = 0; i < nVertices; ++i )
340 const QPointF& pt = poly.at( i );
357 for (
int i = 0; i < nVertices; ++i )
359 QPointF& pt = poly[i];
366 QVector<double>& x, QVector<double>& y, QVector<double>& z,
372 Q_ASSERT( x.size() == y.size() );
393 TransformDirection direction )
const
420 QVector<float>& x, QVector<float>& y, QVector<float>& z,
421 TransformDirection direction )
const
426 Q_ASSERT( x.size() == y.size() );
436 int vectorSize = x.size();
437 QVector<double> xd( x.size() );
438 QVector<double> yd( y.size() );
439 QVector<double> zd( z.size() );
440 for (
int i = 0; i < vectorSize; ++i )
449 for (
int i = 0; i < vectorSize; ++i )
482 static const int numP = 8;
490 double x[numP * numP];
491 double y[numP * numP];
492 double z[numP * numP];
498 double dx = rect.
width() / ( double )( numP - 1 );
499 double dy = rect.
height() / ( double )( numP - 1 );
503 for (
int i = 0; i < numP ; i++ )
509 for (
int j = 0; j < numP; j++ )
511 x[( i*numP ) + j] = pointX;
512 y[( i*numP ) + j] = pointY;
514 z[( i*numP ) + j] = 0.0;
536 for (
int i = 0; i < numP * numP; i++ )
538 if ( qIsFinite( x[i] ) && qIsFinite( y[i] ) )
558 "The coordinates can not be reprojected. The CRS is: %1" )
565 "The coordinates can not be reprojected. The CRS is: %1" ).arg(
mDestCRS.
toProj4() ),
tr(
"CRS" ) );
569 #ifdef COORDINATE_TRANSFORM_VERBOSE
572 QgsDebugMsg( QString(
"[[[[[[ Number of points to transform: %1 ]]]]]]" ).arg( numPoints ) );
582 for (
int i = 0; i < numPoints; ++i )
594 dir =
tr(
"inverse transform" );
601 dir =
tr(
"forward transform" );
604 if ( projResult != 0 )
609 for (
int i = 0; i < numPoints; ++i )
613 points += QString(
"(%1, %2)\n" ).arg( x[i], 0,
'f' ).arg( y[i], 0,
'f' );
617 points += QString(
"(%1, %2)\n" ).arg( x[i] * RAD_TO_DEG, 0,
'f' ).arg( y[i] * RAD_TO_DEG, 0,
'f' );
621 QString msg =
tr(
"%1 of\n"
623 "PROJ.4: %3 +to %4\n"
628 .arg( QString::fromUtf8( pj_strerrno( projResult ) ) );
630 QgsDebugMsg(
"Projection failed emitting invalid transform signal: " + msg );
644 for (
int i = 0; i < numPoints; ++i )
651 #ifdef COORDINATE_TRANSFORM_VERBOSE
652 QgsDebugMsg( QString(
"[[[[[[ Projected %1, %2 to %3, %4 ]]]]]]" )
653 .arg( xorg, 0,
'g', 15 ).arg( yorg, 0,
'g', 15 )
654 .arg( *x, 0,
'g', 15 ).arg( *y, 0,
'g', 15 ) );
661 QgsDebugMsg(
"Reading Coordinate Transform from xml ------------------------!" );
663 QDomNode mySrcNode = theNode.namedItem(
"sourcesrs" );
666 QDomNode myDestNode = theNode.namedItem(
"destinationsrs" );
676 QDomElement myNodeElement = theNode.toElement();
677 QDomElement myTransformElement = theDoc.createElement(
"coordinatetransform" );
679 QDomElement mySourceElement = theDoc.createElement(
"sourcesrs" );
681 myTransformElement.appendChild( mySourceElement );
683 QDomElement myDestElement = theDoc.createElement(
"destinationsrs" );
685 myTransformElement.appendChild( myDestElement );
687 myNodeElement.appendChild( myTransformElement );
696 proj = QApplication::applicationDirPath()
697 +
"/share/proj/" + QString( name );
701 return proj.toUtf8();