-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WMS: Better logic to pick the legend URL
QGIS had two problems: 1) It was using the specified legend URL only if its mime type was matching the layer's mime type. There is no reason for that. 2) When QGIS was using the default layer (empty string), it was not even trying to find out in what style to pick the legend URL.
- Loading branch information
Patrick Valsecchi
committed
May 29, 2016
1 parent
e79a327
commit 69bed21
Showing
4 changed files
with
126 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #include <QFile> | ||
| #include <QObject> | ||
| #include <QtTest/QtTest> | ||
| #include <qgswmsprovider.h> | ||
| #include <qgsapplication.h> | ||
|
|
||
| /** \ingroup UnitTests | ||
| * This is a unit test for the WMS provider. | ||
| */ | ||
| class TestQgsWmsProvider: public QObject | ||
| { | ||
| Q_OBJECT | ||
| private slots: | ||
|
|
||
| void initTestCase() | ||
| { | ||
| // init QGIS's paths - true means that all path will be inited from prefix | ||
| QgsApplication::init(); | ||
| QgsApplication::initQgis(); | ||
|
|
||
| QFile file( QString( TEST_DATA_DIR ) + "/provider/GetCapabilities.xml" ); | ||
| QVERIFY( file.open( QIODevice::ReadOnly | QIODevice::Text ) ); | ||
| const QByteArray content = file.readAll(); | ||
| QVERIFY( content.size() > 0 ); | ||
| const QgsWmsParserSettings config; | ||
|
|
||
| mCapabilities = new QgsWmsCapabilities(); | ||
| QVERIFY( mCapabilities->parseResponse( content, config ) ); | ||
| } | ||
|
|
||
| //runs after all tests | ||
| void cleanupTestCase() | ||
| { | ||
| delete mCapabilities; | ||
| QgsApplication::exitQgis(); | ||
| } | ||
|
|
||
| void legendGraphicsWithStyle() | ||
| { | ||
| QgsWmsProvider provider( "http://localhost:8380/mapserv?xxx&layers=agri_zones&styles=fb_style&format=image/jpg", mCapabilities ); | ||
| QCOMPARE( provider.getLegendGraphicUrl(), QString( "http://www.example.com/fb.png?" ) ); | ||
| } | ||
|
|
||
| void legendGraphicsWithSecondStyle() | ||
| { | ||
| QgsWmsProvider provider( "http://localhost:8380/mapserv?xxx&layers=agri_zones&styles=yt_style&format=image/jpg", mCapabilities ); | ||
| QCOMPARE( provider.getLegendGraphicUrl(), QString( "http://www.example.com/yt.png?" ) ); | ||
| } | ||
|
|
||
| void legendGraphicsWithoutStyleWithDefault() | ||
| { | ||
| QgsWmsProvider provider( "http://localhost:8380/mapserv?xxx&layers=buildings&styles=&format=image/jpg", mCapabilities ); | ||
| //only one style, can guess default => use it | ||
| QCOMPARE( provider.getLegendGraphicUrl(), QString( "http://www.example.com/buildings.png?" ) ); | ||
| } | ||
|
|
||
| void legendGraphicsWithoutStyleWithoutDefault() | ||
| { | ||
| QgsWmsProvider provider( "http://localhost:8380/mapserv?xxx&layers=agri_zones&styles=&format=image/jpg", mCapabilities ); | ||
| //two style, cannot guess default => use the WMS GetLegendGraphics | ||
| QCOMPARE( provider.getLegendGraphicUrl(), QString( "http://localhost:8380/mapserv?" ) ); | ||
| } | ||
|
|
||
| private: | ||
| QgsWmsCapabilities* mCapabilities; | ||
| }; | ||
|
|
||
| QTEST_MAIN( TestQgsWmsProvider ) | ||
| #include "testqgswmsprovider.moc" |
69bed21There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pvalsecc Hi Patrick, can you please have a look at this issue at the user mailing list (and my analysis of it):
https://lists.osgeo.org/pipermail/qgis-user/2016-September/037640.html
It looks like for a (raster) layer in that service, without an actual legendgraphic, this algorithm tries to pick the parent node style + legend. Which in this case is plain wrong.
Any idea how to fix this?
Regards,
Richard Duivenvoorde (richard@qgis.org)
69bed21There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rduivenvoorde,
IMHO, there is nothing to fix in QGIS, here. If a layer defines no style, it's wanted that it inherits the parent layer's style. Have a look at chapter 7.2.4.6.5 of the WMS implementation specification:
This PR is just a workaround for MapServer that is defining a style named
defaultfor both the parent and the child layers. This was making QGIS show 2defaultstyles for every child layers. Style inheritance was already there before. Now at has just a saner behavior in regard to non-standard compliant servers.I'll let you forward that to the user ML. I was not subscribed to it and therefore cannot reply directly to the thread.
Thanks.
69bed21There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pvalsecc I think you are right in your analysis, see also:
https://lists.osgeo.org/pipermail/qgis-user/2016-September/037674.html
Thanks for your response