Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for #436: prevent using CRS that's not supported by WMS server
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@6209 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Dec 8, 2006
1 parent 5559331 commit a385320
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/gui/qgsserversourceselect.cpp
Expand Up @@ -449,6 +449,10 @@ void QgsServerSourceSelect::on_btnAdd_clicked()
{
QMessageBox::information(this, tr("Select Layer"), tr("You must select at least one layer first."));
}
else if (mWmsProvider->supportedCrsForLayers(m_selectedLayers).size() == 0)
{
QMessageBox::information(this, tr("Coordinate Reference System"), tr("There are no available coordinate reference system for the set of layers you've selected."));
}
else
{
accept();
Expand Down Expand Up @@ -570,6 +574,38 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()
.arg( crsFilter.count() )
);

// check whether current CRS is supported
// if not, use one of the available CRS
bool isThere = false;
long defaultEpsg = 0;
for ( QSet<QString>::const_iterator i = crsFilter.begin(); i != crsFilter.end(); ++i)
{
QStringList parts = i->split(":");

if (parts.at(0) == "EPSG")
{
long epsg = atol(parts.at(1));
if (epsg == m_Epsg)
{
isThere = true;
break;
}

// save first CRS in case we current m_Epsg is not available
if (i == crsFilter.begin())
defaultEpsg = epsg;
// prefer value of DEFAULT_WMS_EPSG if available
if (epsg == DEFAULT_WMS_EPSG)
defaultEpsg = epsg;
}
}

// we have to change selected CRS to default one
if (!isThere && crsFilter.size() > 0)
{
m_Epsg = defaultEpsg;
labelCoordRefSys->setText( descriptionForEpsg(m_Epsg) );
}
}

btnChangeSpatialRefSys->setEnabled(TRUE);
Expand Down

0 comments on commit a385320

Please sign in to comment.