Skip to content

Commit

Permalink
Don't try to normalize proj coordinate operations constructed directly
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nyalldawson committed Dec 13, 2019
1 parent 8994a4b commit 82a84ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Expand Up @@ -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,
Expand Down
11 changes: 0 additions & 11 deletions src/core/qgscoordinatetransform_p.cpp
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgscoordinatetransformcontext.h
Expand Up @@ -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()
Expand Down

0 comments on commit 82a84ff

Please sign in to comment.