Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.10 backports #34607

Merged
merged 49 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
738e245
Fix QgsPoint ctor with invalid arguments
elpaso Feb 20, 2020
2a572de
Really hide actions menu from forms when empty
elpaso Feb 19, 2020
9d41136
SIP
elpaso Feb 19, 2020
655e6c3
Fix crash when adding child features from forms
elpaso Feb 19, 2020
04f3a6b
When the selected coordinate operation fails to project coordinates,
nyalldawson Feb 4, 2020
ba8bf7e
Show warnings on fallback transform
nyalldawson Feb 5, 2020
ba39f03
We can't always rely on proj_errno to indicate multi-point transform
nyalldawson Feb 13, 2020
05e7944
Add mechanism to disable user-visible warnings on use of fallback tra…
nyalldawson Feb 13, 2020
02d6961
Mark some transforms as approximate
nyalldawson Feb 14, 2020
c9613aa
Remove "used" operation from handler
nyalldawson Feb 14, 2020
177b73a
Don't try to get the operation details for the instantiated operation,
nyalldawson Feb 14, 2020
2a498e5
Don't include proj string in QgsCsException messages
nyalldawson Feb 14, 2020
bd8dabc
When using the fallback transform, we can't trust the results of proj…
nyalldawson Feb 14, 2020
e0a7a57
Only warn a single time per project for fallback transform usage
nyalldawson Feb 14, 2020
051e385
Much much faster QgsCoordinateReferenceSystem equality operator in ma…
nyalldawson Feb 14, 2020
f185ec2
ifdef out noisy debug code
nyalldawson Feb 14, 2020
c6b8720
Friendlier warning message when fallback transform is used
nyalldawson Feb 14, 2020
6e56208
Add API for disabling fallback handler and for determining after a tr…
nyalldawson Feb 14, 2020
b704595
[processing] Log use of ballpark transforms to processing log instead
nyalldawson Feb 14, 2020
a7d69f0
Ballpark warning should be warning level, not critical
nyalldawson Feb 14, 2020
ebafdb5
Crappy US spelling
nyalldawson Feb 14, 2020
755662d
Add API to QgsCoordinateTransformContext to prevent use of fallback
nyalldawson Feb 17, 2020
10480b1
Add API to QgsCoordinateTransform to control fallback availability
nyalldawson Feb 17, 2020
b6e207e
Fix allow fallback determination for reversed operations
nyalldawson Feb 17, 2020
43d9936
Fix interaction of QgsCoordinateTransform::setBallparkTransformsAreAp…
nyalldawson Feb 17, 2020
ff3fc2a
Less noisy transform failure errors
nyalldawson Feb 17, 2020
6aa1489
Fix doxygen warning
nyalldawson Feb 17, 2020
9a7ebe5
Fix build
nyalldawson Feb 17, 2020
7b549e3
Remove code paths for proj >= 6.0 < 6.3
nyalldawson Feb 17, 2020
006e7c0
Hard block compilation on proj 6.3.0
nyalldawson Feb 17, 2020
c881d36
Update test results for proj 7
nyalldawson Feb 19, 2020
12ffcd3
Update more test results for proj 7
nyalldawson Feb 20, 2020
62579ea
Update another test for proj 7
nyalldawson Feb 20, 2020
989c772
Update test for proj 6
nyalldawson Feb 20, 2020
7cc6f31
Disable a test which relies on proj 4 behavior
nyalldawson Feb 20, 2020
9f7ec8e
Fix FindProj.cmake (followup 38e57db0ed387e32)
jef-n Feb 21, 2020
9c14e0f
Don't try to use a fallback transform when we've already established
nyalldawson Feb 21, 2020
b38298e
Add helper method to read encoding from shapefile .cpg or LDID inform…
nyalldawson Feb 10, 2020
c4cfa46
Always disable GDAL side shapefile encoding handling
nyalldawson Feb 9, 2020
5941b94
Don't force set new layer encoding to the UI/encoding settings value
nyalldawson Feb 10, 2020
5650746
Expand tests
nyalldawson Feb 10, 2020
ee61400
Dox++
nyalldawson Feb 10, 2020
181e701
Default to automatically picking encoding when adding shapefiles
nyalldawson Feb 10, 2020
0941cb4
Default to "Automatic" encoding option when adding OGR vector files
nyalldawson Feb 10, 2020
d5590dd
QIoDevice::skip was added in Qt 5.10
nyalldawson Feb 10, 2020
d338bac
Split shapefile CPG/LDID based encoding detection to separate methods
nyalldawson Feb 10, 2020
b15394c
Use metadata method to retrieve Shapefile encoding on GDAL 3.1+ builds
nyalldawson Feb 12, 2020
b8c20dd
Correct autodetection of vsizip based shapefiles depends on GDAL 3.1
nyalldawson Feb 12, 2020
ef8a57d
Do not try to compute the center of a segment of null length (#34407)
Feb 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmake/FindProj.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ IF (PROJ_FOUND)
STRING(REGEX REPLACE "^.*PROJ_VERSION_MINOR +([0-9]+).*$" "\\1" PROJ_VERSION_MINOR "${proj_version}")
STRING(REGEX REPLACE "^.*PROJ_VERSION_PATCH +([0-9]+).*$" "\\1" PROJ_VERSION_PATCH "${proj_version}")
STRING(CONCAT PROJ_VERSION_STR "(" ${PROJ_VERSION_MAJOR} "." ${PROJ_VERSION_MINOR} "." ${PROJ_VERSION_PATCH} ")")
IF ((PROJ_VERSION_MAJOR EQUAL 6) AND (PROJ_VERSION_MINOR LESS 3))
MESSAGE (FATAL_ERROR "Cannot build QGIS using Proj ${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH} Use 6.3.0 or higher.")
ENDIF ((PROJ_VERSION_MAJOR EQUAL 6) AND (PROJ_VERSION_MINOR LESS 3))
IF ((PROJ_VERSION_MAJOR EQUAL 6) AND ((PROJ_VERSION_MINOR LESS 3) OR (PROJ_VERSION_MINOR EQUAL 3 AND PROJ_VERSION_PATCH LESS 1)))
MESSAGE (FATAL_ERROR "Cannot build QGIS using Proj ${PROJ_VERSION_MAJOR}.${PROJ_VERSION_MINOR}.${PROJ_VERSION_PATCH} Use 6.3.1 or higher.")
ENDIF ((PROJ_VERSION_MAJOR EQUAL 6) AND ((PROJ_VERSION_MINOR LESS 3) OR (PROJ_VERSION_MINOR EQUAL 3 AND PROJ_VERSION_PATCH LESS 1)))
ELSE(EXISTS ${PROJ_INCLUDE_DIR}/proj.h AND EXISTS ${PROJ_INCLUDE_DIR}/proj_experimental.h)
FILE(READ ${PROJ_INCLUDE_DIR}/proj_api.h proj_version)
STRING(REGEX REPLACE "^.*PJ_VERSION ([0-9]+).*$" "\\1" PJ_VERSION "${proj_version}")
Expand Down
9 changes: 7 additions & 2 deletions python/core/auto_generated/geometry/qgspoint.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ based on the following rules:
if ( sipCanConvertToType( a0, sipType_QgsPointXY, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
{
int state;
int sipIsErr = 0;
sipIsErr = 0;

QgsPointXY *p = reinterpret_cast<QgsPointXY *>( sipConvertToType( a0, sipType_QgsPointXY, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
if ( sipIsErr )
Expand All @@ -71,7 +71,7 @@ based on the following rules:
else if ( sipCanConvertToType( a0, sipType_QPointF, SIP_NOT_NONE ) && a1 == Py_None && a2 == Py_None && a3 == Py_None && a4 == Py_None )
{
int state;
int sipIsErr = 0;
sipIsErr = 0;

QPointF *p = reinterpret_cast<QPointF *>( sipConvertToType( a0, sipType_QPointF, 0, SIP_NOT_NONE, &state, &sipIsErr ) );
if ( sipIsErr )
Expand All @@ -97,6 +97,11 @@ based on the following rules:
QgsWkbTypes::Type wkbType = a4 == Py_None ? QgsWkbTypes::Unknown : static_cast<QgsWkbTypes::Type>( sipConvertToEnum( a4, sipType_QgsWkbTypes_Type ) );
sipCpp = new sipQgsPoint( QgsPoint( x, y, z, m, wkbType ) );
}
else // Invalid ctor arguments
{
PyErr_SetString( PyExc_TypeError, QStringLiteral( "Invalid type in constructor arguments." ).toUtf8().constData() );
sipIsErr = 1;
}
%End


Expand Down
113 changes: 113 additions & 0 deletions python/core/auto_generated/qgscoordinatetransform.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,119 @@ coordinates.
.. seealso:: :py:func:`coordinateOperation`

.. versionadded:: 3.8
%End

void setAllowFallbackTransforms( bool allowed );
%Docstring
Sets whether "ballpark" fallback transformations can be used in the case that the specified
coordinate operation fails (such as when coordinates from outside a required grid shift file
are transformed). See fallbackOperationOccurred() for further details.

.. note::

Requires Proj 6.0 or later. Builds based on earlier Proj versions will ignore this setting.

.. warning::

If setBallparkTransformsAreAppropriate() is set to ``True``, this setting will be ignored
and fallback transformations will always be permitted.


.. seealso:: :py:func:`allowFallbackTransforms`

.. seealso:: :py:func:`setBallparkTransformsAreAppropriate`

.. versionadded:: 3.12
%End

bool allowFallbackTransforms() const;
%Docstring
Returns whether "ballpark" fallback transformations will be used in the case that the specified
coordinate operation fails (such as when coordinates from outside a required grid shift file
are transformed). See fallbackOperationOccurred() for further details.

.. note::

Requires Proj 6.0 or later. Builds based on earlier Proj versions will ignore this setting.

.. seealso:: :py:func:`setAllowFallbackTransforms`

.. seealso:: :py:func:`setBallparkTransformsAreAppropriate`

.. versionadded:: 3.12
%End

void setBallparkTransformsAreAppropriate( bool appropriate );
%Docstring
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.

When a coordinate transform is only being used to generate ballpark results then the
``appropriate`` argument should be set to ``True``. This indicates that its perfectable
acceptable (and even expected!) for the transform to use fallback coordinate operations
in the case that the preferred or user-specified operation fails (such as when coordinates
from outside of a grid shift file's extent are transformed).

When ``appropriate`` is ``True``, then no warnings will be generated when the transform
falls back to a default operation, which may introduce inaccuracies when compared to
the default/specified coordinate operation.

This should be set when a transform expects that coordinates outside of the direct
area of use while be transformed, e.g. when transforming from a global extent to a
CRS with a localized area of use.

If ``appropriate`` is ``False`` (the default behavior), then transforms MAY STILL fallback to default operations
when the preferred or user-specified operation fails, however whenever this occurs
a user-visible warning will be generated.

If ``appropriate`` is ``True``, then this setting overrides allowFallbackTransforms()
and fallback transforms will always be allowed when required.

.. warning::

This setting applies to a single instance of a coordinate transform only,
and is not copied when a coordinate transform object is copied or assigned.

.. note::

Requires Proj 6.0 or later. Builds based on earlier Proj versions will ignore this setting.


.. versionadded:: 3.12
%End

void disableFallbackOperationHandler( bool disabled );
%Docstring
Sets whether the default fallback operation handler is disabled for this transform instance.

If the default handler is ``disabled`` then it is possible to determine whether a fallback
operation occurred by testing fallbackOperationOccurred() immediately after a transformation.

.. warning::

This setting applies to a single instance of a coordinate transform only,
and is not copied when a coordinate transform object is copied or assigned.

.. note::

Requires Proj 6.0 or later. Builds based on earlier Proj versions will never perform fallback operations.


.. seealso:: :py:func:`fallbackOperationOccurred`

.. versionadded:: 3.12
%End

bool fallbackOperationOccurred() const;
%Docstring
Returns ``True`` if a fallback operation occurred for the most recent transform.

.. note::

Requires Proj 6.0 or later. Builds based on earlier Proj versions will never perform fallback operations.

.. seealso:: :py:func:`disableFallbackOperationHandler`

.. versionadded:: 3.12
%End

int sourceDatumTransformId() const /Deprecated/;
Expand Down
21 changes: 20 additions & 1 deletion python/core/auto_generated/qgscoordinatetransformcontext.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Returns ``True`` if the new transform pair was added successfully.
Has no effect on builds based on Proj 6.0 or later, use addCoordinateOperation() instead.
%End

bool addCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &coordinateOperationProjString );
bool addCoordinateOperation( const QgsCoordinateReferenceSystem &sourceCrs, const QgsCoordinateReferenceSystem &destinationCrs, const QString &coordinateOperationProjString, bool allowFallback = true );
%Docstring
Adds a new ``coordinateOperationProjString`` to use when projecting coordinates
from the specified ``sourceCrs`` to the specified ``destinationCrs``.
Expand All @@ -134,6 +134,14 @@ 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.

If ``allowFallback`` is ``True`` (since QGIS 3.12), then "ballpark" fallback transformations
will be used in the case that the specified coordinate operation fails (such as when
coordinates from outside a required grid shift file are transformed). See
QgsCoordinateTransform.fallbackOperationOccurred() for further details. Note that if an
existing ``sourceCrs`` and ``destinationCrs`` pair are added with a different ``allowFallback``
value, that value will replace the existing one (i.e. each combination of ``sourceCrs`` and
``destinationCrs`` must be unique).

.. warning::

coordinateOperationProjString MUST be a proj string which has been normalized for
Expand Down Expand Up @@ -229,6 +237,17 @@ be used.


.. versionadded:: 3.8
%End

bool allowFallbackTransform( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const;
%Docstring
Returns ``True`` if approximate "ballpark" transforms may be used when transforming
between a ``source`` and ``destination`` CRS pair, in the case that the preferred
coordinate operation fails (such as when
coordinates from outside a required grid shift file are transformed). See
QgsCoordinateTransform.fallbackOperationOccurred() for further details.

.. versionadded:: 3.12
%End

bool mustReverseCoordinateOperation( const QgsCoordinateReferenceSystem &source, const QgsCoordinateReferenceSystem &destination ) const;
Expand Down
17 changes: 15 additions & 2 deletions python/core/auto_generated/qgsvectordataprovider.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,25 @@ Returns the above in friendly format.

virtual void setEncoding( const QString &e );
%Docstring
Set encoding used for accessing data from layer
Set encoding used for accessing data from layer.

An empty encoding string indicates that the provider should automatically
select the most appropriate encoding for the data source.

.. warning::

Support for setting the provider encoding depends on the underlying data
provider. Check capabilities() for the QgsVectorDataProvider.SelectEncoding
capability in order to determine if the provider supports this ability.

.. seealso:: :py:func:`encoding`
%End

QString encoding() const;
%Docstring
Gets encoding which is used for accessing data
Returns the encoding which is used for accessing data.

.. seealso:: :py:func:`setEncoding`
%End

int fieldNameIndex( const QString &fieldName ) const;
Expand Down
11 changes: 10 additions & 1 deletion python/core/auto_generated/qgsvectorlayer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,16 @@ Uses :py:class:`QgsExpression`

void setProviderEncoding( const QString &encoding );
%Docstring
Sets the textencoding of the data provider
Sets the text ``encoding`` of the data provider.

An empty ``encoding`` string indicates that the provider should automatically
select the most appropriate encoding.

.. warning::

Support for setting the provider encoding depends on the underlying data
provider. Check dataProvider().capabilities() for the QgsVectorDataProvider.SelectEncoding
capability in order to determine if the provider supports this ability.
%End

void setCoordinateSystem();
Expand Down
7 changes: 7 additions & 0 deletions python/gui/auto_generated/qgsactionmenu.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ Sets an expression context scope used to resolve underlying actions.
Returns an expression context scope used to resolve underlying actions.

.. versionadded:: 3.0
%End

QList<QgsAction> menuActions();
%Docstring
Returns menu actions

.. versionadded:: 3.12
%End

signals:
Expand Down
10 changes: 10 additions & 0 deletions src/analysis/processing/qgsalgorithmtransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ QgsFeatureList QgsTransformAlgorithm::processFeature( const QgsFeature &f, QgsPr
{
mCreatedTransform = true;
mTransform = QgsCoordinateTransform( sourceCrs(), mDestCrs, mTransformContext );

mTransform.disableFallbackOperationHandler( true );
}

if ( feature.hasGeometry() )
Expand All @@ -107,6 +109,14 @@ QgsFeatureList QgsTransformAlgorithm::processFeature( const QgsFeature &f, QgsPr
{
feature.clearGeometry();
}

if ( !mWarnedAboutFallbackTransform && mTransform.fallbackOperationOccurred() )
{
feedback->reportError( QObject::tr( "An alternative, ballpark-only transform was used when transforming coordinates for one or more features. "
"(Possibly an incorrect choice of operation was made for transformations between these reference systems - check "
"that the selected operation is valid for the full extent of the input layer.)" ) );
mWarnedAboutFallbackTransform = true; // only warn once to avoid flooding the log
}
}
catch ( QgsCsException & )
{
Expand Down
1 change: 1 addition & 0 deletions src/analysis/processing/qgsalgorithmtransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class QgsTransformAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QgsCoordinateReferenceSystem mDestCrs;
QgsCoordinateTransform mTransform;
QgsCoordinateTransformContext mTransformContext;
bool mWarnedAboutFallbackTransform = false;

};

Expand Down
7 changes: 4 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4976,7 +4976,8 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
if ( layer->isValid() )
{
userAskedToAddLayers = true;
layer->setProviderEncoding( enc );
if ( !enc.isEmpty() )
layer->setProviderEncoding( enc );

QStringList sublayers = layer->dataProvider()->subLayers();
QgsDebugMsg( QStringLiteral( "got valid layer with %1 sublayers" ).arg( sublayers.count() ) );
Expand Down Expand Up @@ -5206,7 +5207,7 @@ bool QgisApp::askUserForZipItemLayers( const QString &path )
}
else if ( layerItem->providerKey() == QLatin1String( "ogr" ) )
{
if ( addVectorLayers( QStringList( item->path() ), QStringLiteral( "System" ), QStringLiteral( "file" ) ) )
if ( addVectorLayers( QStringList( item->path() ), QString(), QStringLiteral( "file" ) ) )
ok = true;
}
}
Expand Down Expand Up @@ -6724,7 +6725,7 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
{
if ( allowInteractive )
{
ok = ok || addVectorLayersPrivate( QStringList( fileName ), QStringLiteral( "System" ), QStringLiteral( "file" ), false );
ok = ok || addVectorLayersPrivate( QStringList( fileName ), QString(), QStringLiteral( "file" ), false );
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/app/qgisappinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ QgsAttributeDialog *QgisAppInterface::getFeatureForm( QgsVectorLayer *l, QgsFeat
context.setDistanceArea( myDa );
context.setVectorLayerTools( qgis->vectorLayerTools() );
context.setMapCanvas( qgis->mapCanvas() );
context.setCadDockWidget( qgis->cadDockWidget() );
QgsAttributeDialog *dialog = new QgsAttributeDialog( l, &feature, false, qgis, true, context );
if ( !feature.isValid() )
{
Expand Down
Loading