Skip to content

Commit 9b6c654

Browse files
author
morb_au
committedJul 17, 2006
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

File tree

6 files changed

+32
-29
lines changed

6 files changed

+32
-29
lines changed
 

‎src/core/qgsrasterdataprovider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ class QgsRasterDataProvider : public QgsDataProvider
138138
*
139139
* \param point[in] The pixel coordinate (as it was displayed locally on screen)
140140
*
141-
* \retval An HTML document containing the return from the WMS server
141+
* \return A text document containing the return from the WMS server
142142
*
143143
* \note WMS Servers prefer to receive coordinates in image space, therefore
144144
* this function expects coordinates in that format.
145145
*
146146
* \note The arbitraryness of the returned document is enforced by WMS standards
147147
* up to at least v1.3.0
148148
*/
149-
virtual QString identifyAsHtml(const QgsPoint& point) = 0;
149+
virtual QString identifyAsText(const QgsPoint& point) = 0;
150150

151151
/**
152152
* \brief Returns the caption error text for the last error in this provider

‎src/gui/qgsmaptoolidentify.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(QgsRasterLayer* layer, const Qgs
157157
return;
158158
}
159159

160-
QString html = layer->identifyAsHtml(point);
160+
QString text = layer->identifyAsText(point);
161161

162-
if (html.isEmpty())
162+
if (text.isEmpty())
163163
{
164164
showError(layer);
165165
return;
@@ -171,8 +171,7 @@ void QgsMapToolIdentify::identifyRasterWmsLayer(QgsRasterLayer* layer, const Qgs
171171
}
172172

173173
mViewer->setCaption( layer->name() );
174-
mViewer->setMessageAsPlainText( html );
175-
// mViewer->setMessageAsHtml( html );
174+
mViewer->setMessageAsPlainText( text );
176175

177176
// mViewer->exec();
178177
mViewer->show();

‎src/providers/wms/qgswmsprovider.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,27 +2294,36 @@ QString QgsWmsProvider::getMetadata()
22942294
}
22952295

22962296

2297-
QString QgsWmsProvider::identifyAsHtml(const QgsPoint& point)
2297+
QString QgsWmsProvider::identifyAsText(const QgsPoint& point)
22982298
{
22992299
#ifdef QGISDEBUG
2300-
std::cout << "QgsWmsProvider::identifyAsHtml: entering." << std::endl;
2300+
std::cout << "QgsWmsProvider::identifyAsText: entering." << std::endl;
23012301
#endif
23022302

23032303
// Collect which layers to query on
23042304

2305-
QStringList visibleLayers = QStringList();
2305+
QStringList queryableLayers = QStringList();
23062306

2307-
for ( QStringList::Iterator it = activeSubLayers.begin();
2308-
it != activeSubLayers.end();
2309-
++it )
2307+
// Test for which layers are suitable for querying with
2308+
for ( QStringList::const_iterator it = activeSubLayers.begin();
2309+
it != activeSubLayers.end();
2310+
++it )
23102311
{
2312+
// Is sublayer visible?
23112313
if (TRUE == activeSubLayerVisibility.find( *it )->second)
23122314
{
2313-
visibleLayers += *it;
2315+
// Is sublayer queryable?
2316+
if (TRUE == mQueryableForLayer.find( *it )->second)
2317+
{
2318+
#ifdef QGISDEBUG
2319+
std::cout << "QgsWmsProvider::identifyAsText: '" << (*it).toLocal8Bit().data() << "' is queryable." << std::endl;
2320+
#endif
2321+
queryableLayers += *it;
2322+
}
23142323
}
23152324
}
23162325

2317-
QString layers = visibleLayers.join(",");
2326+
QString layers = queryableLayers.join(",");
23182327
Q3Url::encode( layers );
23192328

23202329
// Compose request to WMS server
@@ -2343,18 +2352,13 @@ QString QgsWmsProvider::identifyAsHtml(const QgsPoint& point)
23432352
requestUrl += QString( "Y=%1" )
23442353
.arg( point.y() );
23452354

2346-
QString html = retrieveUrl(requestUrl);
2347-
2348-
if (html.isEmpty())
2349-
{
2350-
return QString();
2351-
}
2355+
QString text = retrieveUrl(requestUrl);
23522356

23532357
#ifdef QGISDEBUG
2354-
std::cout << "QgsWmsProvider::identifyAsHtml: exiting with '"
2355-
<< html.toLocal8Bit().data() << "'." << std::endl;
2358+
std::cout << "QgsWmsProvider::identifyAsText: exiting with '"
2359+
<< text.toLocal8Bit().data() << "'." << std::endl;
23562360
#endif
2357-
return html;
2361+
return text;
23582362
}
23592363

23602364

‎src/providers/wms/qgswmsprovider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,15 +528,15 @@ class QgsWmsProvider : public QgsRasterDataProvider
528528
*
529529
* \param point[in] The pixel coordinate (as it was displayed locally on screen)
530530
*
531-
* \retval An HTML document containing the return from the WMS server
531+
* \return A text document containing the return from the WMS server
532532
*
533533
* \note WMS Servers prefer to receive coordinates in image space, therefore
534534
* this function expects coordinates in that format.
535535
*
536536
* \note The arbitraryness of the returned document is enforced by WMS standards
537537
* up to at least v1.3.0
538538
*/
539-
QString identifyAsHtml(const QgsPoint& point);
539+
QString identifyAsText(const QgsPoint& point);
540540

541541
/**
542542
* \brief Returns the caption error text for the last error in this provider

‎src/raster/qgsrasterlayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4827,15 +4827,15 @@ void QgsRasterLayer::identify(const QgsPoint& point, std::map<QString,QString>&
48274827
} // void QgsRasterLayer::identify
48284828

48294829

4830-
QString QgsRasterLayer::identifyAsHtml(const QgsPoint& point)
4830+
QString QgsRasterLayer::identifyAsText(const QgsPoint& point)
48314831
{
48324832
if (mProviderKey != "wms")
48334833
{
48344834
// Currently no meaning for anything other than OGC WMS layers
48354835
return QString();
48364836
}
48374837

4838-
return (dataProvider->identifyAsHtml(point));
4838+
return (dataProvider->identifyAsText(point));
48394839
}
48404840

48414841
void QgsRasterLayer::populateHistogram(int theBandNoInt, int theBinCountInt,bool theIgnoreOutOfRangeFlag,bool theHistogramEstimatedFlag)

‎src/raster/qgsrasterlayer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ class QgsRasterLayer : public QgsMapLayer
285285
*
286286
* \param point[in] an image pixel coordinate in the last requested extent of layer.
287287
*
288-
* \retval An HTML document containing the return from the WMS server
288+
* \return A text document containing the return from the WMS server
289289
*
290290
* \note The arbitraryness of the returned document is enforced by WMS standards
291291
* up to at least v1.3.0
292292
*/
293-
QString identifyAsHtml(const QgsPoint& point);
293+
QString identifyAsText(const QgsPoint& point);
294294

295295
/** \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*/
296296
QString getProjectionWKT();

0 commit comments

Comments
 (0)
Please sign in to comment.