Skip to content
Permalink
Browse files

Fix for #436: prevent using CRS that's not supported by WMS server

git-svn-id: http://svn.osgeo.org/qgis/trunk@6209 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder
wonder committed Dec 8, 2006
1 parent a8e385e commit 8b77487c6000aa4e9ebe8ef061652265d3133634
Showing with 36 additions and 0 deletions.
  1. +36 −0 src/gui/qgsserversourceselect.cpp
@@ -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();
@@ -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);

0 comments on commit 8b77487

Please sign in to comment.
You can’t perform that action at this time.