Skip to content

Commit

Permalink
OAPIF: address @elpaso review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault authored and nyalldawson committed Oct 25, 2019
1 parent 2d3414a commit 4485ea3
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/providers/wfs/qgsbackgroundcachedfeatureiterator.h
Expand Up @@ -148,7 +148,7 @@ class QgsFeatureDownloaderImpl
QMutex mMutexCreateProgressDialog;
};

// Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derived from QObject
// Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derive from QObject
#define CONNECT_PROGRESS_DIALOG(actual_downloader_impl_class) do { \
connect( mProgressDialog, &QProgressDialog::canceled, this, &actual_downloader_impl_class::setStopFlag, Qt::DirectConnection ); \
connect( mProgressDialog, &QProgressDialog::canceled, this, &actual_downloader_impl_class::stop ); \
Expand All @@ -161,7 +161,7 @@ class QgsFeatureDownloaderImpl
} \
} while(0)

// Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derived from QObject
// Sorry for ugliness. Due to QgsFeatureDownloaderImpl that cannot derive from QObject
#define DEFINE_FEATURE_DOWLOADER_IMPL_SLOTS \
protected: \
void emitDoStop() override { emit doStop(); } \
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgsoapifapirequest.cpp
Expand Up @@ -153,7 +153,7 @@ void QgsOapifApiRequest::processReply()
{
mErrorCode = QgsBaseNetworkRequest::ApplicationLevelError;
mAppLevelError = ApplicationLevelError::JsonError;
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSon document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSON document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
emit gotResponse();
return;
}
Expand Down
16 changes: 8 additions & 8 deletions src/providers/wfs/qgsoapifcollection.cpp
Expand Up @@ -53,7 +53,7 @@ bool QgsOapifCollection::deserialize( const json &j )
const auto links = QgsOAPIFJson::parseLinks( j );
const auto selfUrl = QgsOAPIFJson::findLink( links,
QStringLiteral( "self" ),
QStringList() << QStringLiteral( "application/json" ) );
{ QStringLiteral( "application/json" ) } );
if ( !selfUrl.isEmpty() )
{
mLayerMetadata.setIdentifier( selfUrl );
Expand All @@ -65,7 +65,7 @@ bool QgsOapifCollection::deserialize( const json &j )

const auto parentUrl = QgsOAPIFJson::findLink( links,
QStringLiteral( "parent" ),
QStringList() << QStringLiteral( "application/json" ) );
{ QStringLiteral( "application/json" ) } );
if ( !parentUrl.isEmpty() )
{
mLayerMetadata.setParentIdentifier( parentUrl );
Expand Down Expand Up @@ -235,7 +235,7 @@ bool QgsOapifCollection::deserialize( const json &j )
mLayerMetadata.setExtent( metadataExtent );
}

// From STAC specification
// From STAC specification ( https://stacspec.org/ )
bool isProprietaryLicense = false;
if ( j.contains( "license" ) )
{
Expand All @@ -249,7 +249,7 @@ bool QgsOapifCollection::deserialize( const json &j )
}
else if ( license != QLatin1String( "various" ) )
{
mLayerMetadata.setLicenses( QStringList() << license );
mLayerMetadata.setLicenses( { license } );
}
}
}
Expand All @@ -271,7 +271,7 @@ bool QgsOapifCollection::deserialize( const json &j )
}
if ( licenses.isEmpty() && isProprietaryLicense )
{
licenses << "proprietary";
licenses << QStringLiteral( "proprietary" );
}
mLayerMetadata.setLicenses( licenses );
}
Expand Down Expand Up @@ -405,13 +405,13 @@ void QgsOapifCollectionsRequest::processReply()
// Paging informal extension used by api.planet.com/
mNextUrl = QgsOAPIFJson::findLink( links,
QStringLiteral( "next" ),
QStringList() << QStringLiteral( "application/json" ) );
{ QStringLiteral( "application/json" ) } );
}
catch ( const json::parse_error &ex )
{
mErrorCode = QgsBaseNetworkRequest::ApplicationLevelError;
mAppLevelError = ApplicationLevelError::JsonError;
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSon document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSON document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
emit gotResponse();
return;
}
Expand Down Expand Up @@ -488,7 +488,7 @@ void QgsOapifCollectionRequest::processReply()
{
mErrorCode = QgsBaseNetworkRequest::ApplicationLevelError;
mAppLevelError = ApplicationLevelError::JsonError;
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSon document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSON document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
emit gotResponse();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgsoapifcollection.h
Expand Up @@ -45,7 +45,7 @@ struct QgsOapifCollection
//! Layer metadata
QgsLayerMetadata mLayerMetadata;

//! Fills a collection from its JSon serialization
//! Fills a collection from its JSON serialization
bool deserialize( const json &j );
};

Expand Down
4 changes: 2 additions & 2 deletions src/providers/wfs/qgsoapifitemsrequest.cpp
Expand Up @@ -151,7 +151,7 @@ void QgsOapifItemsRequest::processReply()
const auto links = QgsOAPIFJson::parseLinks( j );
mNextUrl = QgsOAPIFJson::findLink( links,
QStringLiteral( "next" ),
QStringList() << QStringLiteral( "application/geo+json" ) );
{ QStringLiteral( "application/geo+json" ) } );

if ( j.is_object() && j.contains( "numberMatched" ) )
{
Expand All @@ -166,7 +166,7 @@ void QgsOapifItemsRequest::processReply()
{
mErrorCode = QgsBaseNetworkRequest::ApplicationLevelError;
mAppLevelError = ApplicationLevelError::JsonError;
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSon document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSON document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
emit gotResponse();
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgsoapiflandingpagerequest.cpp
Expand Up @@ -129,7 +129,7 @@ void QgsOapifLandingPageRequest::processReply()
{
mErrorCode = QgsBaseNetworkRequest::ApplicationLevelError;
mAppLevelError = ApplicationLevelError::JsonError;
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSon document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
mErrorMessage = errorMessageWithReason( tr( "Cannot decode JSON document: %1" ).arg( QString::fromStdString( ex.what() ) ) );
emit gotResponse();
return;
}
Expand Down
14 changes: 7 additions & 7 deletions src/providers/wfs/qgsoapifprovider.cpp
Expand Up @@ -273,16 +273,16 @@ bool QgsOapifProvider::empty() const

};

bool QgsOapifProvider::setSubsetString( const QString &sql, bool updateFeatureCount )
bool QgsOapifProvider::setSubsetString( const QString &filter, bool updateFeatureCount )
{
QgsDebugMsgLevel( QStringLiteral( "sql = '%1'" ).arg( sql ), 4 );
QgsDebugMsgLevel( QStringLiteral( "filter = '%1'" ).arg( filter ), 4 );

if ( sql == mSubsetString )
if ( filter == mSubsetString )
return true;

if ( !sql.isEmpty() )
if ( !filter.isEmpty() )
{
QgsExpression filterExpression( sql );
QgsExpression filterExpression( filter );
if ( !filterExpression.isValid() )
{
QgsMessageLog::logMessage( filterExpression.parserErrorString(), tr( "OAPIF" ) );
Expand All @@ -294,11 +294,11 @@ bool QgsOapifProvider::setSubsetString( const QString &sql, bool updateFeatureCo
// (crashes might happen if not done at the beginning)
mShared->invalidateCache();

mSubsetString = sql;
mSubsetString = filter;
clearMinMaxCache();

// update URI
mShared->mURI.setFilter( sql );
mShared->mURI.setFilter( filter );
setDataSourceUri( mShared->mURI.uri() );
QString errorMsg;
if ( !mShared->computeServerFilter( errorMsg ) )
Expand Down
3 changes: 2 additions & 1 deletion src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -123,7 +123,8 @@ QgsWFSProvider::QgsWFSProvider( const QString &uri, const ProviderOptions &optio
{
auto downloader = qgis::make_unique<QgsFeatureDownloader>();
downloader->setImpl( qgis::make_unique<QgsWFSFeatureDownloaderImpl>( mShared.get(), downloader.get() ) );
connect( downloader.get(), static_cast<void ( QgsFeatureDownloader::* )( QVector<QgsFeatureUniqueIdPair> )>( &QgsFeatureDownloader::featureReceived ),
connect( downloader.get(),
qgis::overload < QVector<QgsFeatureUniqueIdPair> >::of( &QgsFeatureDownloader::featureReceived ),
this, &QgsWFSProvider::featureReceivedAnalyzeOneFeature );
downloader->run( false, /* serialize features */
1 /* maxfeatures */ );
Expand Down

0 comments on commit 4485ea3

Please sign in to comment.