Skip to content
Permalink
Browse files
[FEATURE] move option to ignore GetMap and GetFeatureInfo URI from WM…
…S GetCapabilities to connection

git-svn-id: http://svn.osgeo.org/qgis/trunk@15559 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 22, 2011
1 parent 5770cef commit f3beea7942d7621b874351dd710ccfe2ff5f5651
@@ -286,6 +286,8 @@ QDomDocument QgsManageConnectionsDialog::saveWMSConnections( const QStringList &
QDomElement el = doc.createElement( "wms" );
el.setAttribute( "name", connections[ i ] );
el.setAttribute( "url", settings.value( path + connections[ i ] + "/url", "" ).toString() );
el.setAttribute( "ignoreGetMapURI", settings.value( path + connections[i] + "/ignoreGetMapURI", false ).toBool() ? "true" : "false" );
el.setAttribute( "ignoreGetFeatureInfoURI", settings.value( path + connections[i] + "/ignoreGetFeatureInfoURI", false ).toBool() ? "true" : "false" );

path = "/Qgis/WMS/";
el.setAttribute( "username", settings.value( path + connections[ i ] + "/username", "" ).toString() );
@@ -423,6 +425,8 @@ void QgsManageConnectionsDialog::loadWMSConnections( const QDomDocument &doc, co
// no dups detected or overwrite is allowed
settings.beginGroup( "/Qgis/connections-wms" );
settings.setValue( QString( "/" + connectionName + "/url" ) , child.attribute( "url" ) );
settings.setValue( QString( "/" + connectionName + "/ignoreGetMapURI" ), child.attribute( "ignoreGetMapURI" ) == "true" );
settings.setValue( QString( "/" + connectionName + "/ignoreGetFeatureInfoURI" ), child.attribute( "ignoreGetFeatureInfoURI" ) == "true" );
settings.endGroup();

if ( !child.attribute( "username" ).isEmpty() )
@@ -41,6 +41,18 @@ QgsNewHttpConnection::QgsNewHttpConnection(
QString credentialsKey = "/Qgis/WMS/" + connName;
txtName->setText( connName );
txtUrl->setText( settings.value( key + "/url" ).toString() );

if ( mBaseKey == "/Qgis/connections-wms/" )
{
cbxIgnoreGetMapURI->setChecked( settings.value( key + "/ignoreGetMapURI", false ).toBool() );
cbxIgnoreGetFeatureInfoURI->setChecked( settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool() );
}
else
{
cbxIgnoreGetMapURI->setVisible( false );
cbxIgnoreGetFeatureInfoURI->setVisible( false );
}

txtUserName->setText( settings.value( credentialsKey + "/username" ).toString() );
txtPassword->setText( settings.value( credentialsKey + "/password" ).toString() );
}
@@ -96,6 +108,12 @@ void QgsNewHttpConnection::accept()
url.setEncodedQueryItems( params );

settings.setValue( key + "/url", url.toString() );
if ( mBaseKey == "/Qgis/connections-wms/" )
{
settings.setValue( key + "/ignoreGetMapURI", cbxIgnoreGetMapURI->isChecked() );
settings.setValue( key + "/ignoreGetFeatureInfoURI", cbxIgnoreGetFeatureInfoURI->isChecked() );
}

settings.setValue( credentialsKey + "/username", txtUserName->text() );
settings.setValue( credentialsKey + "/password", txtPassword->text() );

@@ -68,9 +68,6 @@ QgsWMSSourceSelect::QgsWMSSourceSelect( QWidget * parent, Qt::WFlags fl )
mAddButton->setEnabled( false );
populateConnectionList();

cbxIgnoreGetMap->setEnabled( false );
cbxIgnoreGetFeatureInfo->setEnabled( false );

QHBoxLayout *layout = new QHBoxLayout;
mImageFormatGroup = new QButtonGroup;

@@ -411,57 +408,6 @@ bool QgsWMSSourceSelect::populateLayerList( QgsWmsProvider *wmsProvider )
lstLayers->expandItem( lstLayers->topLevelItem( 0 ) );
}

if ( wmsProvider->baseUrl() != wmsProvider->getMapUrl() )
{
QApplication::setOverrideCursor( Qt::ArrowCursor );

if ( QMessageBox::information( this,
tr( "WMS Provider" ),
tr( "Advertised GetMap URL\n\n %2\n\nis different from GetCapabilities URL\n\n %1\n\n"
"This might be an server configuration error. Should the URL be used?" )
.arg( wmsProvider->baseUrl() )
.arg( wmsProvider->getMapUrl() ),
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
{
cbxIgnoreGetMap->setChecked( false );
}
else
{
cbxIgnoreGetMap->setChecked( true );
}
cbxIgnoreGetMap->setEnabled( true );

QApplication::restoreOverrideCursor();
}
else
{
cbxIgnoreGetMap->setEnabled( false );
cbxIgnoreGetMap->setChecked( false );
}

if ( wmsProvider->baseUrl() != wmsProvider->getFeatureInfoUrl() )
{
QApplication::setOverrideCursor( Qt::ArrowCursor );

if ( QMessageBox::information( this,
tr( "WMS Provider" ),
tr( "Advertised GetFeatureInfo URL\n\n %2\n\nis different from GetCapabilities URL\n\n %1\n\n"
"This might be an server configuration error. Should the URL be used?" )
.arg( wmsProvider->baseUrl() )
.arg( wmsProvider->getFeatureInfoUrl() ),
QMessageBox::Yes | QMessageBox::No ) == QMessageBox::Yes )
{
cbxIgnoreGetFeatureInfo->setChecked( false );
}
else
{
cbxIgnoreGetFeatureInfo->setChecked( true );
}
cbxIgnoreGetFeatureInfo->setEnabled( true );

QApplication::restoreOverrideCursor();
}

return true;
}

@@ -475,12 +421,9 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
QString credentialsKey = "/Qgis/WMS/" + cmbConnections->currentText();

QStringList connStringParts;
QString part;

connStringParts += settings.value( key + "/url" ).toString();

mConnName = cmbConnections->currentText();
mConnectionInfo = connStringParts.join( " " );
mConnectionInfo = settings.value( key + "/url" ).toString();

// Check for credentials and prepend to the connection info
QString username = settings.value( credentialsKey + "/username" ).toString();
@@ -495,6 +438,29 @@ void QgsWMSSourceSelect::on_btnConnect_clicked()
mConnectionInfo = "username=" + username + ",password=" + password + ",url=" + mConnectionInfo;
}

bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
if ( ignoreGetMap || ignoreGetFeatureInfo )
{
QString connArgs = "ignoreUrl=";
if ( ignoreGetMap )
{
connArgs += "GetMap";
if ( ignoreGetFeatureInfo )
connArgs += ";";
}
if ( ignoreGetFeatureInfo )
connArgs += "GetFeatureInfo";

if ( mConnectionInfo.startsWith( "username=" ) )
{
mConnectionInfo.prepend( connArgs + "," );
}
else
{
mConnectionInfo.prepend( connArgs + ",url=" );
}
}

QgsDebugMsg( QString( "Connection info: '%1'." ).arg( mConnectionInfo ) );

@@ -572,31 +538,6 @@ void QgsWMSSourceSelect::addClicked()
}
}

if ( cbxIgnoreGetMap->isChecked() || cbxIgnoreGetFeatureInfo->isChecked() )
{
QString connArgs = "ignoreUrl=";

if ( cbxIgnoreGetMap->isChecked() )
{
connArgs += "GetMap";
if ( cbxIgnoreGetFeatureInfo->isChecked() )
connArgs += ";GetFeatureInfo";
}
else
{
connArgs += "GetFeatureInfo";
}

if ( connInfo.startsWith( "username=" ) || connInfo.startsWith( "tiled=" ) )
{
connInfo.prepend( connArgs + "," );
}
else
{
connInfo.prepend( connArgs + ",url=" );
}
}

QgisApp::instance()->addRasterLayer( connInfo,
leLayerName->text().isEmpty() ? layers.join( "/" ) : leLayerName->text(),
"wms", layers, styles, format, crs );
@@ -823,7 +764,7 @@ void QgsWMSSourceSelect::on_lstLayers_itemSelectionChanged()
}
}

gbCRS->setTitle( tr( "Coordinate Reference System (%n available)", "crs count", mCRSs.count() ) );
gbCRS->setTitle( tr( "Options (%n coordinate reference systems available)", "crs count", mCRSs.count() ) );
btnChangeSpatialRefSys->setDisabled( mCRSs.isEmpty() );

if ( !layers.isEmpty() && !mCRSs.isEmpty() )

0 comments on commit f3beea7

Please sign in to comment.