Skip to content

Commit aa256b8

Browse files
committedOct 22, 2013
[FEATURE]
- make wms dpi mode configurable (fixes #8929) - enum for tile request attributes - allow setting of User-Agent (fixes #7361) - show error messages on WMS GetCapabilities
1 parent fa90fc9 commit aa256b8

File tree

10 files changed

+172
-55
lines changed

10 files changed

+172
-55
lines changed
 

‎src/app/qgsoptions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
247247

248248
//Network timeout
249249
mNetworkTimeoutSpinBox->setValue( settings.value( "/qgis/networkAndProxy/networkTimeout", "60000" ).toInt() );
250+
leUserAgent->setText( settings.value( "/qgis/networkAndProxy/userAgent", "Mozilla/5.0" ).toString() );

Comment on line R250

Komzpa commented on Sep 5, 2016

@Komzpa

hello,
fake User-Agent Mozilla/5.0 is now banned on tile.openstreetmap.org.
this should default to real non-faked user-agent string, i.e. QGIS/2.17.0 or similar, to get passed through and properly managed.

jef-n replied on Sep 5, 2016

@jef-n
MemberAuthor

This mimics Qt's default user-agent.

Komzpa replied on Sep 5, 2016

@Komzpa

@jef-n unfortunately, this renders QGIS/QuickMapServices unusable now - default "Mozilla/5.0" is banned, as it is used by too many different applications that don't bother to identify themselves so that osm.org sysadmins can contact them in case of problems.

Komzpa replied on Sep 5, 2016

@Komzpa

related QMS issue: nextgis/quickmapservices#103

jef-n replied on Sep 5, 2016

@jef-n
MemberAuthor

QGIS uses "User-Agent: Mozilla/5.0 QGIS/2.17.0" by default (the "Mozilla/5.0" part can be overridden in settings)

Komzpa replied on Sep 5, 2016

@Komzpa

@jef-n thanks! we'll continue investigation.

Komzpa replied on Sep 7, 2016

@Komzpa

throttling regex was updated on tile.osm.org: https://git.openstreetmap.org/chef.git/commitdiff/e3cf43a

Code has comments. Press enter to view.
250251

251252
// WMS/WMS-C tile expiry time
252253
mDefaultTileExpirySpinBox->setValue( settings.value( "/qgis/defaultTileExpiry", "24" ).toInt() );
253254

254-
// Feature funded by Regione Toscana - SITA
255255
// WMS/WMS-C default max retry in case of tile request errors
256256
mDefaultTileMaxRetrySpinBox->setValue( settings.value( "/qgis/defaultTileMaxRetry", "3" ).toInt() );
257257

@@ -903,11 +903,11 @@ void QgsOptions::saveOptions()
903903

904904
//Network timeout
905905
settings.setValue( "/qgis/networkAndProxy/networkTimeout", mNetworkTimeoutSpinBox->value() );
906+
settings.setValue( "/qgis/networkAndProxy/userAgent", leUserAgent->text() );
906907

907908
// WMS/WMS-C tile expiry time
908909
settings.setValue( "/qgis/defaultTileExpiry", mDefaultTileExpirySpinBox->value() );
909910

910-
// Feature funded by Regione Toscana - SITA
911911
// WMS/WMS-C default max retry in case of tile request errors
912912
settings.setValue( "/qgis/defaultTileMaxRetry", mDefaultTileMaxRetrySpinBox->value() );
913913

‎src/core/qgsnetworkaccessmanager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,14 @@ void QgsNetworkAccessManager::setFallbackProxyAndExcludes( const QNetworkProxy &
126126

127127
QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData )
128128
{
129+
QSettings s;
130+
131+
QNetworkRequest *pReq(( QNetworkRequest * ) &req ); // hack user agent
132+
pReq->setRawHeader( "User-Agent", s.value( "/qgis/networkAndProxy/userAgent", "Mozilla/5.0" ).toByteArray() );
133+
129134
emit requestAboutToBeCreated( op, req, outgoingData );
130135
QNetworkReply *reply = QNetworkAccessManager::createRequest( op, req, outgoingData );
136+
131137
connect( reply, SIGNAL( downloadProgress( qint64, qint64 ) ), this, SLOT( connectionProgress() ) );
132138
connect( reply, SIGNAL( uploadProgress( qint64, qint64 ) ), this, SLOT( connectionProgress() ) );
133139
connect( reply, SIGNAL( destroyed( QObject* ) ), this, SLOT( connectionDestroyed( QObject* ) ) );
@@ -136,7 +142,6 @@ QNetworkReply *QgsNetworkAccessManager::createRequest( QNetworkAccessManager::Op
136142
// abort request, when network timeout happens
137143
QTimer *timer = new QTimer( reply );
138144
connect( timer, SIGNAL( timeout() ), this, SLOT( abortRequest() ) );
139-
QSettings s;
140145
timer->setSingleShot( true );
141146
timer->start( s.value( "/qgis/networkAndProxy/networkTimeout", "20000" ).toInt() );
142147

‎src/gui/qgsmanageconnectionsdialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ QDomDocument QgsManageConnectionsDialog::saveOWSConnections( const QStringList &
347347
el.setAttribute( "invertAxisOrientation", settings.value( path + connections[i] + "/invertAxisOrientation", false ).toBool() ? "true" : "false" );
348348
el.setAttribute( "referer", settings.value( path + connections[ i ] + "/referer", "" ).toString() );
349349
el.setAttribute( "smoothPixmapTransform", settings.value( path + connections[i] + "/smoothPixmapTransform", false ).toBool() ? "true" : "false" );
350+
el.setAttribute( "dpiMode", settings.value( path + connections[i] + "/dpiMode", "7" ).toInt() );
350351
}
351352

352353
path = "/Qgis/" + service.toUpper() + "/";
@@ -582,6 +583,7 @@ void QgsManageConnectionsDialog::loadOWSConnections( const QDomDocument &doc, co
582583
settings.setValue( QString( "/" + connectionName + "/invertAxisOrientation" ), child.attribute( "invertAxisOrientation" ) == "true" );
583584
settings.setValue( QString( "/" + connectionName + "/referer" ), child.attribute( "referer" ) );
584585
settings.setValue( QString( "/" + connectionName + "/smoothPixmapTransform" ), child.attribute( "smoothPixmapTransform" ) == "true" );
586+
settings.setValue( QString( "/" + connectionName + "/dpiMode" ), child.attribute( "dpiMode", "7" ).toInt() );
585587
settings.endGroup();
586588

587589
if ( !child.attribute( "username" ).isEmpty() )

‎src/gui/qgsnewhttpconnection.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,33 @@ QgsNewHttpConnection::QgsNewHttpConnection(
5757
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
5858
cbxSmoothPixmapTransform->setChecked( settings.value( key + "/smoothPixmapTransform", false ).toBool() );
5959

60+
cmbDpiMode->clear();
61+
cmbDpiMode->addItem( tr( "all" ) );
62+
cmbDpiMode->addItem( tr( "off" ) );
63+
cmbDpiMode->addItem( tr( "QGIS" ) );
64+
cmbDpiMode->addItem( tr( "UMN" ) );
65+
cmbDpiMode->addItem( tr( "GeoServer" ) );
66+
int dpiIdx;
67+
switch ( settings.value( key + "/dpiMode", 7 ).toInt() )
68+
{
69+
case 0: // off
70+
dpiIdx = 1;
71+
break;
72+
case 1: // QGIS
73+
dpiIdx = 2;
74+
break;
75+
case 2: // UMN
76+
dpiIdx = 3;
77+
break;
78+
case 4: // GeoServer
79+
dpiIdx = 4;
80+
break;
81+
default: // other => all
82+
dpiIdx = 0;
83+
break;
84+
}
85+
cmbDpiMode->setCurrentIndex( dpiIdx );
86+
6087
txtReferer->setText( settings.value( key + "/referer" ).toString() );
6188

6289
txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
@@ -85,6 +112,9 @@ QgsNewHttpConnection::QgsNewHttpConnection(
85112
cbxIgnoreGetFeatureInfoURI->setVisible( false );
86113
mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
87114

115+
cmbDpiMode->setVisible( false );
116+
mGroupBox->layout()->removeWidget( cmbDpiMode );
117+
88118
txtReferer->setVisible( false );
89119
mGroupBox->layout()->removeWidget( txtReferer );
90120
lblReferer->setVisible( false );
@@ -170,6 +200,28 @@ void QgsNewHttpConnection::accept()
170200
settings.setValue( key + "/ignoreAxisOrientation", cbxIgnoreAxisOrientation->isChecked() );
171201
settings.setValue( key + "/invertAxisOrientation", cbxInvertAxisOrientation->isChecked() );
172202
settings.setValue( key + "/smoothPixmapTransform", cbxSmoothPixmapTransform->isChecked() );
203+
204+
int dpiMode;
205+
switch ( cmbDpiMode->currentIndex() )
206+
{
207+
case 0: // all => QGIS|UMN|GeoServer
208+
dpiMode = 7;
209+
break;
210+
case 1: // off
211+
dpiMode = 0;
212+
break;
213+
case 2: // QGIS
214+
dpiMode = 1;
215+
break;
216+
case 3: // UMN
217+
dpiMode = 2;
218+
break;
219+
case 4: // GeoServer
220+
dpiMode = 4;
221+
break;
222+
}
223+
224+
settings.setValue( key + "/dpiMode", dpiMode );
173225
}
174226
if ( mBaseKey == "/Qgis/connections-wms/" )
175227
{

‎src/mapserver/qgswmsserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ QImage* QgsWMSServer::createImage( int width, int height ) const
11781178

11791179
//apply DPI parameter if present. This is an extension of QGIS mapserver compared to WMS 1.3.
11801180
//Because of backwards compatibility, this parameter is optional
1181-
double OGC_PX_M = 0.00028; // OGC referance pixel size in meter, also used by qgis
1181+
double OGC_PX_M = 0.00028; // OGC reference pixel size in meter, also used by qgis
11821182
int dpm = 1 / OGC_PX_M;
11831183
if ( mParameterMap.contains( "DPI" ) )
11841184
{

‎src/providers/wms/qgswmsconnection.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) :
7878
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
7979
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();
8080
bool smoothPixmapTransform = settings.value( key + "/smoothPixmapTransform", false ).toBool();
81+
QString dpiMode = settings.value( key + "/dpiMode", "all" ).toString();
8182

8283
QString connArgs, delim;
8384

84-
8585
if ( ignoreGetMap )
8686
{
8787
connArgs += delim + "GetMap";
@@ -117,6 +117,13 @@ QgsWMSConnection::QgsWMSConnection( QString theConnName ) :
117117
mUri.setParam( "SmoothPixmapTransform", "1" );
118118
}
119119

120+
if ( !dpiMode.isEmpty() )
121+
{
122+
connArgs += delim + "dpiMode=" + dpiMode;
123+
delim = ";";
124+
mUri.setParam( "dpiMode", dpiMode );
125+
}
126+
120127
if ( !connArgs.isEmpty() )
121128
{
122129
connArgs.prepend( "ignoreUrl=" );

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
99
wms-c/wmts support : Jürgen E. Fischer < jef at norbit dot de >, norBIT GmbH
1010
11+
tile retry support : Luigi Pirelli < luipir at gmail dot com >
12+
(funded by Regione Toscana-SITA)
13+
1114
***************************************************************************/
1215

1316
/***************************************************************************
@@ -159,6 +162,8 @@ bool QgsWmsProvider::parseUri( QString uriString )
159162
mInvertAxisOrientation = uri.hasParam( "InvertAxisOrientation" ); // must be before parsing!
160163
mSmoothPixmapTransform = uri.hasParam( "SmoothPixmapTransform" );
161164

165+
mDpiMode = uri.hasParam( "dpiMode" ) ? ( QgsWmsDpiMode ) uri.param( "dpiMode" ).toInt() : dpiAll;
166+
162167
mUserName = uri.param( "username" );
163168
QgsDebugMsg( "set username to " + mUserName );
164169

@@ -645,15 +650,14 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
645650
setQueryItem( url, "STYLES", styles );
646651
setQueryItem( url, "FORMAT", mImageMimeType );
647652

648-
//DPI parameter is accepted by QGIS mapserver (and ignored by the other WMS servers)
649-
//map_resolution parameter works for UMN mapserver
650-
651-
//Different WMS servers have DPI parameters:
652653
if ( mDpi != -1 )
653654
{
654-
setQueryItem( url, "DPI", QString::number( mDpi ) ); //QGIS server
655-
setQueryItem( url, "MAP_RESOLUTION", QString::number( mDpi ) ); //UMN mapserver
656-
setQueryItem( url, "FORMAT_OPTIONS", QString( "dpi:%1" ).arg( mDpi ) ); //geoserver
655+
if ( mDpiMode & dpiQGIS )
656+
setQueryItem( url, "DPI", QString::number( mDpi ) );
657+
if ( mDpiMode & dpiUMN )
658+
setQueryItem( url, "MAP_RESOLUTION", QString::number( mDpi ) );
659+
if ( mDpiMode & dpiGeoServer )
660+
setQueryItem( url, "FORMAT_OPTIONS", QString( "dpi:%1" ).arg( mDpi ) );
657661
}
658662

659663
//MH: jpeg does not support transparency and some servers complain if jpg and transparent=true
@@ -830,9 +834,12 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
830834

831835
if ( mDpi != -1 )
832836
{
833-
setQueryItem( url, "DPI", QString::number( mDpi ) ); //QGIS server
834-
setQueryItem( url, "MAP_RESOLUTION", QString::number( mDpi ) ); //UMN mapserver
835-
setQueryItem( url, "FORMAT_OPTIONS", QString( "dpi:%1" ).arg( mDpi ) ); //geoserver
837+
if ( mDpiMode & dpiQGIS )
838+
setQueryItem( url, "DPI", QString::number( mDpi ) );
839+
if ( mDpiMode & dpiUMN )
840+
setQueryItem( url, "MAP_RESOLUTION", QString::number( mDpi ) );
841+
if ( mDpiMode & dpiGeoServer )
842+
setQueryItem( url, "FORMAT_OPTIONS", QString( "dpi:%1" ).arg( mDpi ) );
836843
}
837844

838845
if ( mImageMimeType == "image/x-jpegorpng" ||
@@ -860,12 +867,11 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
860867
QgsDebugMsg( QString( "tileRequest %1 %2/%3 (%4,%5): %6" ).arg( mTileReqNo ).arg( i++ ).arg( n ).arg( row ).arg( col ).arg( turl ) );
861868
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
862869
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
863-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ), mTileReqNo );
864-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ), i );
865-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ),
870+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ), mTileReqNo );
871+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileIndex ), i );
872+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRect ),
866873
QRectF( tm->topLeft.x() + col * twMap, tm->topLeft.y() - ( row + 1 ) * thMap, twMap, thMap ) );
867-
int retry = 0; // just for readability
868-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ), retry );
874+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRetry ), 0 );
869875

870876
QgsDebugMsg( QString( "gettile: %1" ).arg( turl ) );
871877
QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request );
@@ -915,12 +921,11 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
915921
QgsDebugMsg( QString( "tileRequest %1 %2/%3 (%4,%5): %6" ).arg( mTileReqNo ).arg( i++ ).arg( n ).arg( row ).arg( col ).arg( turl ) );
916922
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
917923
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
918-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ), mTileReqNo );
919-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ), i );
920-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ),
924+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ), mTileReqNo );
925+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileIndex ), i );
926+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRect ),
921927
QRectF( tm->topLeft.x() + col * twMap, tm->topLeft.y() - ( row + 1 ) * thMap, twMap, thMap ) );
922-
int retry = 0; // just for readability
923-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ), retry );
928+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRetry ), 0 );
924929

925930
QgsDebugMsg( QString( "gettile: %1" ).arg( turl ) );
926931
QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request );
@@ -957,12 +962,11 @@ QImage *QgsWmsProvider::draw( QgsRectangle const &viewExtent, int pixelWidth, i
957962
QgsDebugMsg( QString( "tileRequest %1 %2/%3 (%4,%5): %6" ).arg( mTileReqNo ).arg( i++ ).arg( n ).arg( row ).arg( col ).arg( turl ) );
958963
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
959964
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
960-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ), mTileReqNo );
961-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ), i );
962-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ),
965+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ), mTileReqNo );
966+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileIndex ), i );
967+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRect ),
963968
QRectF( tm->topLeft.x() + col * twMap, tm->topLeft.y() - ( row + 1 ) * thMap, twMap, thMap ) );
964-
int retry = 0; // just for readability
965-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ), retry );
969+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRetry ), 0 );
966970

967971
QgsDebugMsg( QString( "gettile: %1" ).arg( turl ) );
968972
QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request );
@@ -1039,7 +1043,6 @@ void QgsWmsProvider::readBlock( int bandNo, QgsRectangle const & viewExtent, in
10391043
//delete image;
10401044
}
10411045

1042-
// tile retry management developed with funding from Regione Toscana-SITA
10431046
void QgsWmsProvider::repeatTileRequest( QNetworkRequest const &oldRequest )
10441047
{
10451048
if ( mErrors == 100 )
@@ -1050,9 +1053,9 @@ void QgsWmsProvider::repeatTileRequest( QNetworkRequest const &oldRequest )
10501053
QNetworkRequest request( oldRequest );
10511054

10521055
QString url = request.url().toString();
1053-
int tileReqNo = request.attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ) ).toInt();
1054-
int tileNo = request.attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ) ).toInt();
1055-
int retry = request.attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ) ).toInt();
1056+
int tileReqNo = request.attribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ) ).toInt();
1057+
int tileNo = request.attribute( static_cast<QNetworkRequest::Attribute>( TileIndex ) ).toInt();
1058+
int retry = request.attribute( static_cast<QNetworkRequest::Attribute>( TileRetry ) ).toInt();
10561059
retry++;
10571060

10581061
QSettings s;
@@ -1074,7 +1077,7 @@ void QgsWmsProvider::repeatTileRequest( QNetworkRequest const &oldRequest )
10741077
.arg( tileReqNo ).arg( tileNo ).arg( retry ), tr( "WMS" ), QgsMessageLog::INFO );
10751078
}
10761079
QgsDebugMsg( QString( "repeat tileRequest %1 %2(retry %3) for url: %4" ).arg( tileReqNo ).arg( tileNo ).arg( retry ).arg( url ) );
1077-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ), retry );
1080+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRetry ), retry );
10781081

10791082
QNetworkReply *reply = QgsNetworkAccessManager::instance()->get( request );
10801083
mTileReplies << reply;
@@ -1124,10 +1127,10 @@ void QgsWmsProvider::tileReplyFinished()
11241127
QgsNetworkAccessManager::instance()->cache()->updateMetaData( cmd );
11251128
}
11261129

1127-
int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ) ).toInt();
1128-
int tileNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ) ).toInt();
1129-
QRectF r = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ) ).toRectF();
1130-
int retry = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ) ).toInt();
1130+
int tileReqNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ) ).toInt();
1131+
int tileNo = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileIndex ) ).toInt();
1132+
QRectF r = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileRect ) ).toRectF();
1133+
int retry = reply->request().attribute( static_cast<QNetworkRequest::Attribute>( TileRetry ) ).toInt();
11311134

11321135
#if QT_VERSION >= 0x40500
11331136
QgsDebugMsg( QString( "tile reply %1 (%2) tile:%3(retry %4) rect:%5,%6 %7,%8) fromcache:%9 error:%10 url:%11" )
@@ -1155,10 +1158,10 @@ void QgsWmsProvider::tileReplyFinished()
11551158
setAuthorization( request );
11561159
request.setAttribute( QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache );
11571160
request.setAttribute( QNetworkRequest::CacheSaveControlAttribute, true );
1158-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 0 ), tileReqNo );
1159-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 1 ), tileNo );
1160-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 2 ), r );
1161-
request.setAttribute( static_cast<QNetworkRequest::Attribute>( QNetworkRequest::User + 3 ), retry );
1161+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileReqNo ), tileReqNo );
1162+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileIndex ), tileNo );
1163+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRect ), r );
1164+
request.setAttribute( static_cast<QNetworkRequest::Attribute>( TileRetry ), 0 );
11621165

11631166
mTileReplies.removeOne( reply );
11641167
reply->deleteLater();
@@ -1496,7 +1499,7 @@ bool QgsWmsProvider::retrieveServerCapabilities( bool forceRefresh )
14961499

14971500
QgsDebugMsg( "exiting." );
14981501

1499-
return true;
1502+
return mError.isEmpty();
15001503
}
15011504

15021505
void QgsWmsProvider::capabilitiesReplyFinished()

‎src/providers/wms/qgswmsprovider.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,23 @@ struct QgsWmsSupportedFormat
434434
QString label;
435435
};
436436

437+
enum QgsWmsTileAttribute
438+
{
439+
TileReqNo = QNetworkRequest::User + 0,
440+
TileIndex = QNetworkRequest::User + 1,
441+
TileRect = QNetworkRequest::User + 2,
442+
TileRetry = QNetworkRequest::User + 3,
443+
};
444+
445+
enum QgsWmsDpiMode
446+
{
447+
dpiNone = 0,
448+
dpiQGIS = 1,
449+
dpiUMN = 2,
450+
dpiGeoServer = 4,
451+
dpiAll = dpiQGIS | dpiUMN | dpiUMN,
452+
};
453+
437454
/**
438455
439456
\brief Data provider for OGC WMS layers.
@@ -1096,6 +1113,7 @@ class QgsWmsProvider : public QgsRasterDataProvider
10961113
bool mIgnoreAxisOrientation;
10971114
bool mInvertAxisOrientation;
10981115
bool mSmoothPixmapTransform;
1116+
enum QgsWmsDpiMode mDpiMode;
10991117

11001118
//! supported formats for GetFeatureInfo in order of preference
11011119
QStringList mSupportedGetFeatureFormats;

‎src/ui/qgsnewhttpconnectionbase.ui

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>475</width>
10-
<height>415</height>
10+
<height>463</height>
1111
</rect>
1212
</property>
1313
<property name="windowTitle">
@@ -33,6 +33,16 @@
3333
<string>Connection details</string>
3434
</property>
3535
<layout class="QGridLayout">
36+
<item row="8" column="0">
37+
<widget class="QLabel" name="lblDpiMode">
38+
<property name="text">
39+
<string>DPI-Mode</string>
40+
</property>
41+
<property name="buddy">
42+
<cstring>cmbDpiMode</cstring>
43+
</property>
44+
</widget>
45+
</item>
3646
<item row="1" column="0">
3747
<widget class="QLabel" name="TextLabel1">
3848
<property name="text">
@@ -134,35 +144,35 @@
134144
</property>
135145
</widget>
136146
</item>
137-
<item row="9" column="0" colspan="2">
147+
<item row="13" column="0" colspan="2">
138148
<widget class="QCheckBox" name="cbxIgnoreGetFeatureInfoURI">
139149
<property name="text">
140150
<string>Ignore GetFeatureInfo URI reported in capabilities</string>
141151
</property>
142152
</widget>
143153
</item>
144-
<item row="8" column="0" colspan="2">
154+
<item row="12" column="0" colspan="2">
145155
<widget class="QCheckBox" name="cbxIgnoreGetMapURI">
146156
<property name="text">
147157
<string>Ignore GetMap URI reported in capabilities</string>
148158
</property>
149159
</widget>
150160
</item>
151-
<item row="10" column="0" colspan="2">
161+
<item row="14" column="0" colspan="2">
152162
<widget class="QCheckBox" name="cbxIgnoreAxisOrientation">
153163
<property name="text">
154164
<string>Ignore axis orientation (WMS 1.3/WMTS)</string>
155165
</property>
156166
</widget>
157167
</item>
158-
<item row="11" column="0" colspan="2">
168+
<item row="15" column="0" colspan="2">
159169
<widget class="QCheckBox" name="cbxInvertAxisOrientation">
160170
<property name="text">
161171
<string>Invert axis orientation</string>
162172
</property>
163173
</widget>
164174
</item>
165-
<item row="12" column="0" colspan="2">
175+
<item row="16" column="0" colspan="2">
166176
<widget class="QCheckBox" name="cbxSmoothPixmapTransform">
167177
<property name="text">
168178
<string>Smooth pixmap transform</string>
@@ -177,8 +187,14 @@
177187
<property name="text">
178188
<string>Referer</string>
179189
</property>
190+
<property name="buddy">
191+
<cstring>txtReferer</cstring>
192+
</property>
180193
</widget>
181194
</item>
195+
<item row="8" column="1">
196+
<widget class="QComboBox" name="cmbDpiMode"/>
197+
</item>
182198
</layout>
183199
</widget>
184200
</item>
@@ -197,8 +213,8 @@
197213
<slot>accept()</slot>
198214
<hints>
199215
<hint type="sourcelabel">
200-
<x>412</x>
201-
<y>244</y>
216+
<x>421</x>
217+
<y>453</y>
202218
</hint>
203219
<hint type="destinationlabel">
204220
<x>430</x>
@@ -213,8 +229,8 @@
213229
<slot>reject()</slot>
214230
<hints>
215231
<hint type="sourcelabel">
216-
<x>321</x>
217-
<y>244</y>
232+
<x>330</x>
233+
<y>453</y>
218234
</hint>
219235
<hint type="destinationlabel">
220236
<x>426</x>

‎src/ui/qgsoptionsbase.ui

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@
25002500
</property>
25012501
</widget>
25022502
</item>
2503-
<item row="5" column="3">
2503+
<item row="5" column="3">
25042504
<widget class="QRadioButton" name="radNautical">
25052505
<property name="text">
25062506
<string>Nautical Miles</string>
@@ -3814,6 +3814,20 @@
38143814
</item>
38153815
</layout>
38163816
</item>
3817+
<item>
3818+
<layout class="QHBoxLayout" name="horizontalLayout_34">
3819+
<item>
3820+
<widget class="QLabel" name="lblUserAgent">
3821+
<property name="text">
3822+
<string>User-Agent</string>
3823+
</property>
3824+
</widget>
3825+
</item>
3826+
<item>
3827+
<widget class="QLineEdit" name="leUserAgent"/>
3828+
</item>
3829+
</layout>
3830+
</item>
38173831
</layout>
38183832
</widget>
38193833
</item>

0 commit comments

Comments
 (0)
Please sign in to comment.