Fix for trac ticket #4. (Tested on DEMIS site.)

With the Identify tool on a WMS layer, now send a query to the WMS server *only* on those layers that the WMS server had already declared queryable.  This avoids the server returning an error on un-queryable layers.

Also, QgsWmsProvider::identifyAsHtml() is renamed to QgsWmsProvider::identifyAsText() to better identify what it does.  Commentary, and other dependent variable and function names have also been updated to suit.



git-svn-id: http://svn.osgeo.org/qgis/trunk@5606 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
morb_au 2006-07-17 00:50:54 +00:00
parent 838b262737
commit 2b799141a8
6 changed files with 32 additions and 29 deletions

View File

@ -138,7 +138,7 @@ public:
*
* \param point[in] The pixel coordinate (as it was displayed locally on screen)
*
* \retval An HTML document containing the return from the WMS server
* \return A text document containing the return from the WMS server
*
* \note WMS Servers prefer to receive coordinates in image space, therefore
* this function expects coordinates in that format.
@ -146,7 +146,7 @@ public:
* \note The arbitraryness of the returned document is enforced by WMS standards
* up to at least v1.3.0
*/
virtual QString identifyAsHtml(const QgsPoint& point) = 0;
virtual QString identifyAsText(const QgsPoint& point) = 0;
/**
* \brief Returns the caption error text for the last error in this provider

View File

@ -157,9 +157,9 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(QgsRasterLayer* layer, const Qgs
return;
}
QString html = layer->identifyAsHtml(point);
QString text = layer->identifyAsText(point);
if (html.isEmpty())
if (text.isEmpty())
{
showError(layer);
return;
@ -171,8 +171,7 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(QgsRasterLayer* layer, const Qgs
}
mViewer->setCaption( layer->name() );
mViewer->setMessageAsPlainText( html );
// mViewer->setMessageAsHtml( html );
mViewer->setMessageAsPlainText( text );
// mViewer->exec();
mViewer->show();

View File

@ -2294,27 +2294,36 @@ QString QgsWmsProvider::getMetadata()
}
QString QgsWmsProvider::identifyAsHtml(const QgsPoint& point)
QString QgsWmsProvider::identifyAsText(const QgsPoint& point)
{
#ifdef QGISDEBUG
std::cout << "QgsWmsProvider::identifyAsHtml: entering." << std::endl;
std::cout << "QgsWmsProvider::identifyAsText: entering." << std::endl;
#endif
// Collect which layers to query on
QStringList visibleLayers = QStringList();
QStringList queryableLayers = QStringList();
for ( QStringList::Iterator it = activeSubLayers.begin();
it != activeSubLayers.end();
++it )
// Test for which layers are suitable for querying with
for ( QStringList::const_iterator it = activeSubLayers.begin();
it != activeSubLayers.end();
++it )
{
// Is sublayer visible?
if (TRUE == activeSubLayerVisibility.find( *it )->second)
{
visibleLayers += *it;
// Is sublayer queryable?
if (TRUE == mQueryableForLayer.find( *it )->second)
{
#ifdef QGISDEBUG
std::cout << "QgsWmsProvider::identifyAsText: '" << (*it).toLocal8Bit().data() << "' is queryable." << std::endl;
#endif
queryableLayers += *it;
}
}
}
QString layers = visibleLayers.join(",");
QString layers = queryableLayers.join(",");
Q3Url::encode( layers );
// Compose request to WMS server
@ -2343,18 +2352,13 @@ QString QgsWmsProvider::identifyAsHtml(const QgsPoint& point)
requestUrl += QString( "Y=%1" )
.arg( point.y() );
QString html = retrieveUrl(requestUrl);
if (html.isEmpty())
{
return QString();
}
QString text = retrieveUrl(requestUrl);
#ifdef QGISDEBUG
std::cout << "QgsWmsProvider::identifyAsHtml: exiting with '"
<< html.toLocal8Bit().data() << "'." << std::endl;
std::cout << "QgsWmsProvider::identifyAsText: exiting with '"
<< text.toLocal8Bit().data() << "'." << std::endl;
#endif
return html;
return text;
}

View File

@ -528,7 +528,7 @@ public:
*
* \param point[in] The pixel coordinate (as it was displayed locally on screen)
*
* \retval An HTML document containing the return from the WMS server
* \return A text document containing the return from the WMS server
*
* \note WMS Servers prefer to receive coordinates in image space, therefore
* this function expects coordinates in that format.
@ -536,7 +536,7 @@ public:
* \note The arbitraryness of the returned document is enforced by WMS standards
* up to at least v1.3.0
*/
QString identifyAsHtml(const QgsPoint& point);
QString identifyAsText(const QgsPoint& point);
/**
* \brief Returns the caption error text for the last error in this provider

View File

@ -4827,7 +4827,7 @@ void QgsRasterLayer::identify(const QgsPoint& point, std::map<QString,QString>&
} // void QgsRasterLayer::identify
QString QgsRasterLayer::identifyAsHtml(const QgsPoint& point)
QString QgsRasterLayer::identifyAsText(const QgsPoint& point)
{
if (mProviderKey != "wms")
{
@ -4835,7 +4835,7 @@ QString QgsRasterLayer::identifyAsHtml(const QgsPoint& point)
return QString();
}
return (dataProvider->identifyAsHtml(point));
return (dataProvider->identifyAsText(point));
}
void QgsRasterLayer::populateHistogram(int theBandNoInt, int theBinCountInt,bool theIgnoreOutOfRangeFlag,bool theHistogramEstimatedFlag)

View File

@ -285,12 +285,12 @@ public:
*
* \param point[in] an image pixel coordinate in the last requested extent of layer.
*
* \retval An HTML document containing the return from the WMS server
* \return A text document containing the return from the WMS server
*
* \note The arbitraryness of the returned document is enforced by WMS standards
* up to at least v1.3.0
*/
QString identifyAsHtml(const QgsPoint& point);
QString identifyAsText(const QgsPoint& point);
/** \brief Query gdal to find out the WKT projection string for this layer. This implements the virtual method of the same name defined in QgsMapLayer*/
QString getProjectionWKT();