Skip to content

Commit

Permalink
get FilterVersion, GMLVersion etc in a private function since it's us…
Browse files Browse the repository at this point in the history
…ed on multiple places
  • Loading branch information
signedav authored and nyalldawson committed Jul 20, 2022
1 parent 8041b6e commit 9457643
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/providers/wfs/qgswfsfeatureiterator.cpp
Expand Up @@ -369,7 +369,6 @@ QUrl QgsWFSFeatureDownloaderImpl::buildURL( qint64 startIndex, long long maxFeat

getFeatureUrl.setQuery( query );
QgsDebugMsgLevel( QStringLiteral( "WFS GetFeature URL: %1" ).arg( getFeatureUrl.toDisplayString( ) ), 2 );
qDebug() << "\n\n" << "WFS GetFeature URL: " << getFeatureUrl.toDisplayString() << "\n\n";
return getFeatureUrl;
}

Expand Down
65 changes: 28 additions & 37 deletions src/providers/wfs/qgswfsshareddata.cpp
Expand Up @@ -95,29 +95,15 @@ QString QgsWFSSharedData::srsName() const

QString QgsWFSSharedData::computedExpression( const QgsExpression &expression ) const
{
QgsOgcUtils::GMLVersion gmlVersion;
QgsOgcUtils::FilterVersion filterVersion;
bool honourAxisOrientation = false;
if ( mWFSVersion.startsWith( QLatin1String( "1.0" ) ) )
{
gmlVersion = QgsOgcUtils::GML_2_1_2;
filterVersion = QgsOgcUtils::FILTER_OGC_1_0;
}
else if ( mWFSVersion.startsWith( QLatin1String( "1.1" ) ) )
{
honourAxisOrientation = !mURI.ignoreAxisOrientation();
gmlVersion = QgsOgcUtils::GML_3_1_0;
filterVersion = QgsOgcUtils::FILTER_OGC_1_1;
}
else
{
honourAxisOrientation = !mURI.ignoreAxisOrientation();
gmlVersion = QgsOgcUtils::GML_3_2_1;
filterVersion = QgsOgcUtils::FILTER_FES_2_0;
}

if ( expression.isValid() )
{

QgsOgcUtils::GMLVersion gmlVersion;
QgsOgcUtils::FilterVersion filterVersion;
bool honourAxisOrientation = false;
getVersionValues( gmlVersion, filterVersion, honourAxisOrientation );

QDomDocument expressionDoc;
QDomElement expressionElem = QgsOgcUtils::expressionToOgcExpression( expression, expressionDoc, gmlVersion, filterVersion, mGeometryAttribute, srsName(), honourAxisOrientation, mURI.invertAxisOrientation(), nullptr, true );

Expand All @@ -139,23 +125,7 @@ bool QgsWFSSharedData::computeFilter( QString &errorMsg )
QgsOgcUtils::GMLVersion gmlVersion;
QgsOgcUtils::FilterVersion filterVersion;
bool honourAxisOrientation = false;
if ( mWFSVersion.startsWith( QLatin1String( "1.0" ) ) )
{
gmlVersion = QgsOgcUtils::GML_2_1_2;
filterVersion = QgsOgcUtils::FILTER_OGC_1_0;
}
else if ( mWFSVersion.startsWith( QLatin1String( "1.1" ) ) )
{
honourAxisOrientation = !mURI.ignoreAxisOrientation();
gmlVersion = QgsOgcUtils::GML_3_1_0;
filterVersion = QgsOgcUtils::FILTER_OGC_1_1;
}
else
{
honourAxisOrientation = !mURI.ignoreAxisOrientation();
gmlVersion = QgsOgcUtils::GML_3_2_1;
filterVersion = QgsOgcUtils::FILTER_FES_2_0;
}
getVersionValues( gmlVersion, filterVersion, honourAxisOrientation );

if ( !mURI.sql().isEmpty() )
{
Expand Down Expand Up @@ -294,6 +264,27 @@ long long QgsWFSSharedData::getFeatureCountFromServer() const
return request.getFeatureCount( mWFSVersion, mWFSFilter, mCaps );
}

void QgsWFSSharedData::getVersionValues( QgsOgcUtils::GMLVersion &gmlVersion, QgsOgcUtils::FilterVersion &filterVersion, bool &honourAxisOrientation ) const
{
if ( mWFSVersion.startsWith( QLatin1String( "1.0" ) ) )
{
gmlVersion = QgsOgcUtils::GML_2_1_2;
filterVersion = QgsOgcUtils::FILTER_OGC_1_0;
}
else if ( mWFSVersion.startsWith( QLatin1String( "1.1" ) ) )
{
honourAxisOrientation = !mURI.ignoreAxisOrientation();
gmlVersion = QgsOgcUtils::GML_3_1_0;
filterVersion = QgsOgcUtils::FILTER_OGC_1_1;
}
else
{
honourAxisOrientation = !mURI.ignoreAxisOrientation();
gmlVersion = QgsOgcUtils::GML_3_2_1;
filterVersion = QgsOgcUtils::FILTER_FES_2_0;
}
}

bool QgsWFSSharedData::detectPotentialServerAxisOrderIssueFromSingleFeatureExtent() const
{
Q_ASSERT( !mComputedExtent.isNull() );
Expand Down
3 changes: 3 additions & 0 deletions src/providers/wfs/qgswfsshareddata.h
Expand Up @@ -140,6 +140,9 @@ class QgsWFSSharedData : public QObject, public QgsBackgroundCachedSharedData
QgsRectangle getExtentFromSingleFeatureRequest() const override;

long long getFeatureCountFromServer() const override;

void getVersionValues( QgsOgcUtils::GMLVersion &gmlVersion, QgsOgcUtils::FilterVersion &filterVersion, bool &honourAxisOrientation ) const;

};

//! Utility class to issue a GetFeature resultType=hits request
Expand Down

0 comments on commit 9457643

Please sign in to comment.