Skip to content
Permalink
Browse files
WFS: emit hint when an axis order issue is likely (fixes #44054)
  • Loading branch information
rouault authored and github-actions committed Sep 14, 2021
1 parent dbba1ed commit eba7940181bb09b62688ead2a8a6d1403c697487
@@ -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() )
@@ -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:

@@ -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;

@@ -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
@@ -247,9 +253,6 @@ class QgsBackgroundCachedSharedData
*/
int mGenCounter = 0;

//! Extent computed from downloaded features
QgsRectangle mComputedExtent;

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

@@ -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 );
@@ -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();
@@ -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(); }

@@ -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 );
@@ -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;
}

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


@@ -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();
@@ -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
@@ -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(); }

0 comments on commit eba7940

Please sign in to comment.