diff --git a/src/core/qgsowsconnection.cpp b/src/core/qgsowsconnection.cpp index 2a145710aec..0d9ef447c8b 100644 --- a/src/core/qgsowsconnection.cpp +++ b/src/core/qgsowsconnection.cpp @@ -74,6 +74,7 @@ const QgsSettingsEntryBool *QgsOwsConnection::settingsInvertAxisOrientation = ne const QgsSettingsEntryString *QgsOwsConnection::settingsUsername = new QgsSettingsEntryString( QStringLiteral( "username" ), sTreeOwsConnections ) ; const QgsSettingsEntryString *QgsOwsConnection::settingsPassword = new QgsSettingsEntryString( QStringLiteral( "password" ), sTreeOwsConnections ) ; const QgsSettingsEntryString *QgsOwsConnection::settingsAuthCfg = new QgsSettingsEntryString( QStringLiteral( "authcfg" ), sTreeOwsConnections ) ; +const QgsSettingsEntryInteger *QgsOwsConnection::settingsFeatureCount = new QgsSettingsEntryInteger( QStringLiteral( "feature-count" ), sTreeOwsConnections, 10 ); QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connName ) : mConnName( connName ) @@ -212,6 +213,10 @@ QgsDataSourceUri &QgsOwsConnection::addWmsWcsConnectionSettings( QgsDataSourceUr { uri.setParam( QStringLiteral( "tilePixelRatio" ), QString::number( static_cast( settingsTilePixelRatio->value( {service.toLower(), connName} ) ) ) ); } + if ( settingsFeatureCount->exists( {service.toLower(), connName} ) ) + { + uri.setParam( QStringLiteral( "featureCount" ), QString::number( settingsFeatureCount->value( {service.toLower(), connName} ) ) ); + } return uri; } diff --git a/src/core/qgsowsconnection.h b/src/core/qgsowsconnection.h index 7ef9082f216..b570a37aff0 100644 --- a/src/core/qgsowsconnection.h +++ b/src/core/qgsowsconnection.h @@ -115,6 +115,7 @@ class CORE_EXPORT QgsOwsConnection : public QObject static const QgsSettingsEntryString *settingsUsername; static const QgsSettingsEntryString *settingsPassword; static const QgsSettingsEntryString *settingsAuthCfg; + static const QgsSettingsEntryInteger *settingsFeatureCount; #endif diff --git a/src/gui/qgsnewhttpconnection.cpp b/src/gui/qgsnewhttpconnection.cpp index 9f735bb2c3e..e602376b401 100644 --- a/src/gui/qgsnewhttpconnection.cpp +++ b/src/gui/qgsnewhttpconnection.cpp @@ -141,6 +141,11 @@ QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes typ cbxIgnoreGetFeatureInfoURI->setVisible( false ); mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI ); + sbFeatureCount->setVisible( false ); + mGroupBox->layout()->removeWidget( sbFeatureCount ); + lblFeatureCount->setVisible( false ); + mGroupBox->layout()->removeWidget( lblFeatureCount ); + cmbDpiMode->setVisible( false ); mGroupBox->layout()->removeWidget( cmbDpiMode ); lblDpiMode->setVisible( false ); @@ -320,6 +325,8 @@ void QgsNewHttpConnection::updateServiceSpecificSettings() Qgis::TilePixelRatio tilePixelRatio = QgsOwsConnection::settingsTilePixelRatio->value( detailsParameters ); cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData( static_cast( tilePixelRatio ) ) ); + sbFeatureCount->setValue( QgsOwsConnection::settingsFeatureCount->value( detailsParameters ) ); + const QString version = QgsOwsConnection::settingsVersion->value( detailsParameters ); int versionIdx = WFS_VERSION_MAX; // AUTO if ( version == QLatin1String( "1.0.0" ) ) @@ -426,6 +433,7 @@ void QgsNewHttpConnection::accept() if ( mTypes & ConnectionWms ) { QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->setValue( cbxIgnoreGetFeatureInfoURI->isChecked(), detailsParameters ); + QgsOwsConnection::settingsFeatureCount->setValue( sbFeatureCount->value(), detailsParameters ); } if ( mTypes & ConnectionWfs ) { diff --git a/src/providers/wms/qgswmsdataitems.cpp b/src/providers/wms/qgswmsdataitems.cpp index 880b0487efa..01e81da89d7 100644 --- a/src/providers/wms/qgswmsdataitems.cpp +++ b/src/providers/wms/qgswmsdataitems.cpp @@ -462,6 +462,14 @@ QString QgsWMSItemBase::createUri( bool withStyle ) crs = mLayerProperty.crs[0]; } mDataSourceUri.setParam( QStringLiteral( "crs" ), crs ); + + // Set default featureCount to 10, old connections might miss this + // setting. + if ( ! mDataSourceUri.hasParam( QStringLiteral( "featureCount" ) ) ) + { + mDataSourceUri.setParam( QStringLiteral( "featureCount" ), QStringLiteral( "10" ) ); + } + //uri = rasterLayerPath + "|layers=" + layers.join( "," ) + "|styles=" + styles.join( "," ) + "|format=" + format + "|crs=" + crs; return mDataSourceUri.encodedUri(); diff --git a/src/providers/wms/qgswmssourceselect.cpp b/src/providers/wms/qgswmssourceselect.cpp index 78a3fb97a9b..a1bd1572a57 100644 --- a/src/providers/wms/qgswmssourceselect.cpp +++ b/src/providers/wms/qgswmssourceselect.cpp @@ -469,6 +469,20 @@ void QgsWMSSourceSelect::btnConnect_clicked() QgsWMSConnection connection( cmbConnections->currentText() ); mUri = connection.uri(); + bool featureCountSet { }; + if ( connection.uri().hasParam( QStringLiteral( "featureCount" ) ) ) + { + connection.uri().param( QStringLiteral( "featureCount" ) ).toInt( &featureCountSet ); + if ( featureCountSet ) + mFeatureCount->setText( connection.uri().param( QStringLiteral( "featureCount" ) ) ); + } + + // Original default for old connections with no default feature count set + if ( ! featureCountSet ) + { + mFeatureCount->setText( QStringLiteral( "10" ) ); + } + QgsWmsSettings wmsSettings; if ( !wmsSettings.parseUri( mUri.encodedUri() ) ) { @@ -600,6 +614,9 @@ void QgsWMSSourceSelect::addButtonClicked() uri.setParam( QStringLiteral( "crs" ), crs ); QgsDebugMsgLevel( QStringLiteral( "crs=%2 " ).arg( crs ), 2 ); + // Remove in case the default value from the connection settings + // is being overridden here + uri.removeParam( QStringLiteral( "featureCount" ) ); if ( mFeatureCount->text().toInt() > 0 ) { uri.setParam( QStringLiteral( "featureCount" ), mFeatureCount->text() ); diff --git a/src/ui/qgsnewhttpconnectionbase.ui b/src/ui/qgsnewhttpconnectionbase.ui index 6860af8c25a..2150ab4931a 100644 --- a/src/ui/qgsnewhttpconnectionbase.ui +++ b/src/ui/qgsnewhttpconnectionbase.ui @@ -140,43 +140,43 @@ WMS/WMTS Options - - - - Ignore axis orientation (WMS 1.3/WMTS) - - - - - - - Ignore GetFeatureInfo URI reported in capabilities - - - - - - - Ignore GetMap/GetTile/GetLegendGraphic URI reported in capabilities - - - - + Smooth pixmap transform - + + + + Ignore axis orientation (WMS 1.3/WMTS) + + + + + + + + + + Maximum number of GetFeatureInfo results + + + + Invert axis orientation - - + + + + Ignore GetFeatureInfo URI reported in capabilities + + @@ -188,8 +188,15 @@ - - + + + + Ignore reported layer extents + + + + + @@ -201,10 +208,29 @@ - - + + - Ignore reported layer extents + Ignore GetMap/GetTile/GetLegendGraphic URI reported in capabilities + + + + + + + <html><head/><body><p>Specify a default value for FEATURE_COUNT when a new layer is created from this connection. </p><p>FEATURE_COUNT defines the maximum number of results returned by a GetFeatureInfo request, if not specified the server default value (usually 1) will be used.</p><p>Set to 0 to use server default: no FEATURE_COUNT parameter will be added to the request.</p><p><br/></p></body></html> + + + server default + + + 0 + + + 1000 + + + 10 @@ -362,6 +388,7 @@ cbxWfsUseGml2EncodingForTransactions cmbDpiMode cmbTilePixelRatio + sbFeatureCount cbxIgnoreGetMapURI cbxIgnoreGetFeatureInfoURI cbxWmsIgnoreReportedLayerExtents @@ -379,8 +406,8 @@ accept() - 421 - 453 + 428 + 813 430 @@ -395,8 +422,8 @@ reject() - 330 - 453 + 337 + 813 426 diff --git a/src/ui/qgswmssourceselectbase.ui b/src/ui/qgswmssourceselectbase.ui index 3e78789fa25..90a137a4ef1 100644 --- a/src/ui/qgswmssourceselectbase.ui +++ b/src/ui/qgswmssourceselectbase.ui @@ -211,6 +211,9 @@ + + + 10 diff --git a/tests/src/python/test_qgsowsconnection.py b/tests/src/python/test_qgsowsconnection.py index a75757d3b1e..730294173b8 100644 --- a/tests/src/python/test_qgsowsconnection.py +++ b/tests/src/python/test_qgsowsconnection.py @@ -38,6 +38,7 @@ class TestQgsOwsConnection(QgisTestCase): settings.setValue(key + 'dpi-mode', 4) settings.setValue(key + 'ignore-axis-orientation', True) settings.setValue(key + 'invert-axis-orientation', True) + settings.setValue(key + 'feature-count', 9) key = '/connections/ows/items/wfs/connections/items/test/' settings.setValue(key + 'url', 'ccc.ddd.com') @@ -58,6 +59,7 @@ class TestQgsOwsConnection(QgisTestCase): self.assertEqual(uri.param('dpiMode'), '4') self.assertEqual(uri.param('IgnoreAxisOrientation'), '1') self.assertEqual(uri.param('InvertAxisOrientation'), '1') + self.assertEqual(uri.param('featureCount'), '9') def testWmsSettings(self): uri = QgsDataSourceUri() @@ -70,6 +72,7 @@ class TestQgsOwsConnection(QgisTestCase): self.assertEqual(uri.param('dpiMode'), '4') self.assertEqual(uri.param('IgnoreAxisOrientation'), '1') self.assertEqual(uri.param('InvertAxisOrientation'), '1') + self.assertEqual(uri.param('featureCount'), '9') def testWfsConnection(self): c = QgsOwsConnection('WFS', 'test')