Skip to content
Permalink
Browse files
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
  • Loading branch information
morb_au committed Jul 17, 2006
1 parent 838b262 commit 2b799141a8ac832ff47a9a90e701f1dd7a1c72e5
@@ -138,15 +138,15 @@ class QgsRasterDataProvider : public QgsDataProvider
*
* \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.
*
* \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
@@ -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();
@@ -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;
}


@@ -528,15 +528,15 @@ class QgsWmsProvider : public QgsRasterDataProvider
*
* \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.
*
* \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
@@ -4827,15 +4827,15 @@ 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")
{
// Currently no meaning for anything other than OGC WMS layers
return QString();
}

return (dataProvider->identifyAsHtml(point));
return (dataProvider->identifyAsText(point));
}

void QgsRasterLayer::populateHistogram(int theBandNoInt, int theBinCountInt,bool theIgnoreOutOfRangeFlag,bool theHistogramEstimatedFlag)
@@ -285,12 +285,12 @@ class QgsRasterLayer : public QgsMapLayer
*
* \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();

0 comments on commit 2b79914

Please sign in to comment.