Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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/qgis@5606 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Jul 17, 2006
1 parent fc5e7d5 commit 9b6c654
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/core/qgsrasterdataprovider.h
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
38 changes: 21 additions & 17 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}


Expand Down
4 changes: 2 additions & 2 deletions src/providers/wms/qgswmsprovider.h
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/raster/qgsrasterlayer.cpp
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/raster/qgsrasterlayer.h
Expand Up @@ -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();
Expand Down

0 comments on commit 9b6c654

Please sign in to comment.