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

[Backport queued_ltr_backports] WFS: emit hint when an axis order issue is likely (fixes #44054) #45047

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions src/providers/wfs/qgsbackgroundcachedshareddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,17 @@ void QgsBackgroundCachedSharedData::endOfDownload( bool success, int featureCoun
QgsDebugMsg( QStringLiteral( "Capability extent is probably wrong. Starting a new request with one feature limit to get at least one feature" ) );
mTryFetchingOneFeature = true;
mComputedExtent = getExtentFromSingleFeatureRequest();
if ( !mComputedExtent.isNull() )
if ( !mComputedExtent.isNull() &&
!detectPotentialServerAxisOrderIssueFromSingleFeatureExtent() )
{
// Grow the extent by ~ 50 km (completely arbitrary number if you wonder!)
// so that it is sufficiently zoomed out
if ( mSourceCrs.mapUnits() == QgsUnitTypes::DistanceMeters )
mComputedExtent.grow( 50. * 1000. );
else if ( mSourceCrs.mapUnits() == QgsUnitTypes::DistanceDegrees )
mComputedExtent.grow( 50. / 110 );
QgsMessageLog::logMessage( QObject::tr( "Layer extent reported by the server is not correct. "
"You may need to zoom on layer and then zoom out to see all features" ), mComponentTranslated );
pushError( QObject::tr( "Layer extent reported by the server is not correct. "
"You may need to zoom on layer and then zoom out to see all features" ) );
}
mMutex.unlock();
if ( !mComputedExtent.isNull() )
Expand Down
11 changes: 7 additions & 4 deletions src/providers/wfs/qgsbackgroundcachedshareddata.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class QgsBackgroundCachedSharedData
virtual QString layerName() const = 0;

//! Called when an error must be raised to the provider
virtual void pushError( const QString &errorMsg ) = 0;
virtual void pushError( const QString &errorMsg ) const = 0;

protected:

Expand All @@ -207,6 +207,9 @@ class QgsBackgroundCachedSharedData
//! Bounding box for the layer as returned by GetCapabilities
QgsRectangle mCapabilityExtent;

//! Extent computed from downloaded features
QgsRectangle mComputedExtent;

//! Flag is a /items request returns a numberMatched property
bool mHasNumberMatched = false;

Expand All @@ -218,6 +221,9 @@ class QgsBackgroundCachedSharedData
//! Should be called in the destructor of the implementation of this class !
void cleanup();

//! Returns true if it is likely that the server doesn't properly honor axis order.
virtual bool detectPotentialServerAxisOrderIssueFromSingleFeatureExtent() const { return false; }

private:

//! Cache directory manager
Expand Down Expand Up @@ -247,9 +253,6 @@ class QgsBackgroundCachedSharedData
*/
int mGenCounter = 0;

//! Extent computed from downloaded features
QgsRectangle mComputedExtent;

//! Spatial index of requested cached regions
QgsSpatialIndex mCachedRegions;

Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgsoapifprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ bool QgsOapifSharedData::computeServerFilter( QString &errorMsg )
return true;
}

void QgsOapifSharedData::pushError( const QString &errorMsg )
void QgsOapifSharedData::pushError( const QString &errorMsg ) const
{
QgsMessageLog::logMessage( errorMsg, tr( "OAPIF" ) );
emit raiseError( errorMsg );
Expand Down
4 changes: 2 additions & 2 deletions src/providers/wfs/qgsoapifprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class QgsOapifSharedData final: public QObject, public QgsBackgroundCachedShared
signals:

//! Raise error
void raiseError( const QString &errorMsg );
void raiseError( const QString &errorMsg ) const;

//! Extent has been updated
void extentUpdated();
Expand Down Expand Up @@ -186,7 +186,7 @@ class QgsOapifSharedData final: public QObject, public QgsBackgroundCachedShared
QString &untranslatedPart );

//! Log error to QgsMessageLog and raise it to the provider
void pushError( const QString &errorMsg ) override;
void pushError( const QString &errorMsg ) const override;

void emitExtentUpdated() override { emit extentUpdated(); }

Expand Down
17 changes: 16 additions & 1 deletion src/providers/wfs/qgswfsshareddata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ bool QgsWFSSharedData::computeFilter( QString &errorMsg )
return true;
}

void QgsWFSSharedData::pushError( const QString &errorMsg )
void QgsWFSSharedData::pushError( const QString &errorMsg ) const
{
QgsMessageLog::logMessage( errorMsg, tr( "WFS" ) );
emit raiseError( errorMsg );
Expand Down Expand Up @@ -237,6 +237,21 @@ int QgsWFSSharedData::getFeatureCountFromServer() const
return request.getFeatureCount( mWFSVersion, mWFSFilter, mCaps );
}

bool QgsWFSSharedData::detectPotentialServerAxisOrderIssueFromSingleFeatureExtent() const
{
Q_ASSERT( !mComputedExtent.isNull() );
if ( mWFSVersion.startsWith( QLatin1String( "1.1" ) ) &&
!mURI.ignoreAxisOrientation() &&
!mURI.invertAxisOrientation() &&
mSourceCrs.hasAxisInverted() &&
mCapabilityExtent.contains( mComputedExtent ) )
{
pushError( QObject::tr( "It is likely that there is an issue with coordinate axis order of geometries when interacting with the server. You may want to enable the Ignore axis orientation and/or Invert axis orientation settings of the WFS connection." ) );
return true;
}
return false;
}

// -------------------------


Expand Down
7 changes: 5 additions & 2 deletions src/providers/wfs/qgswfsshareddata.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class QgsWFSSharedData : public QObject, public QgsBackgroundCachedSharedData
signals:

//! Raise error
void raiseError( const QString &errorMsg );
void raiseError( const QString &errorMsg ) const;

//! Extent has been updated
void extentUpdated();
Expand Down Expand Up @@ -100,6 +100,9 @@ class QgsWFSSharedData : public QObject, public QgsBackgroundCachedSharedData
//! Create GML parser
QgsGmlStreamingParser *createParser() const;

//! Returns true if it is likely that the server doesn't properly honor axis order.
bool detectPotentialServerAxisOrderIssueFromSingleFeatureExtent() const override;

private:

//! WFS filter
Expand All @@ -109,7 +112,7 @@ class QgsWFSSharedData : public QObject, public QgsBackgroundCachedSharedData
QString mSortBy;

//! Log error to QgsMessageLog and raise it to the provider
void pushError( const QString &errorMsg ) override;
void pushError( const QString &errorMsg ) const override;

void emitExtentUpdated() override { emit extentUpdated(); }

Expand Down