Skip to content

Commit

Permalink
[FEATURE] move option to ignore GetMap and GetFeatureInfo URI from WM…
Browse files Browse the repository at this point in the history
…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 f3beea7
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 184 deletions.
4 changes: 4 additions & 0 deletions src/app/qgsmanageconnectionsdialog.cpp
Expand Up @@ -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() );
Expand Down Expand Up @@ -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() )
Expand Down
18 changes: 18 additions & 0 deletions src/app/qgsnewhttpconnection.cpp
Expand Up @@ -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() );
}
Expand Down Expand Up @@ -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() );

Expand Down
109 changes: 25 additions & 84 deletions src/app/qgswmssourceselect.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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();
Expand All @@ -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 ) );

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() )
Expand Down

0 comments on commit f3beea7

Please sign in to comment.