Skip to content
Permalink
Browse files

Don't try to normalize proj coordinate operations constructed directly

from the proj string via the transform context

This isn't possible -- only proj coordinate operations constructed
from a src/dest CRS pair can be normalized, not those constructed
from a proj string.

It was redundant in any case, since we always normalize the available
operations before giving users a choice of them.

So just add some big bold warnings to the dox in case anyone is
manually manipulating and adding custom operations, that these
also MUST be pre-normalized

Refs #33121, conversation in OSGeo/PROJ#1794

(cherry picked from commit 82a84ff)
  • Loading branch information
nyalldawson committed Dec 13, 2019
1 parent 49c2c2a commit 4ec223e96407898f294247b8cfea718de9092d4b
@@ -134,12 +134,20 @@ from the specified ``sourceCrs`` to the specified ``destinationCrs``.
string. If ``coordinateOperationProjString`` is empty, then the default Proj operation
will be used when transforming between the coordinate reference systems.

.. warning::

coordinateOperationProjString MUST be a proj string which has been normalized for
visualization, and must be constructed so that coordinates are always input and output
with x/y coordinate ordering. (Proj strings output by utilities such as projinfo will NOT
automatically normalize the axis order!).

Returns ``True`` if the new coordinate operation was added successfully.

.. seealso:: :py:func:`coordinateOperations`

.. seealso:: :py:func:`removeCoordinateOperation`


.. note::

Requires Proj 6.0 or later. Builds based on earlier Proj versions will ignore this setting,
@@ -355,17 +355,6 @@ ProjData QgsCoordinateTransformPrivate::threadLocalProjData()

transform.reset();
}
else
{
// transform may have either the source or destination CRS using swapped axis order. For QGIS, we ALWAYS need regular x/y axis order
transform.reset( proj_normalize_for_visualization( context, transform.get() ) );
if ( !transform )
{
const QString err = QObject::tr( "Cannot normalize transform between %1 and %2" ).arg( mSourceCRS.authid(),
mDestCRS.authid() );
QgsMessageLog::logMessage( err, QString(), Qgis::Critical );
}
}
}

QString nonAvailableError;
@@ -140,6 +140,11 @@ class CORE_EXPORT QgsCoordinateTransformContext
* string. If \a coordinateOperationProjString is empty, then the default Proj operation
* will be used when transforming between the coordinate reference systems.
*
* \warning coordinateOperationProjString MUST be a proj string which has been normalized for
* visualization, and must be constructed so that coordinates are always input and output
* with x/y coordinate ordering. (Proj strings output by utilities such as projinfo will NOT
* automatically normalize the axis order!).
*
* Returns TRUE if the new coordinate operation was added successfully.
*
* \see coordinateOperations()

0 comments on commit 4ec223e

Please sign in to comment.
You can’t perform that action at this time.