diff --git a/src/app/qgsrasterlayerproperties.cpp b/src/app/qgsrasterlayerproperties.cpp
index e5f16c9a6af..daef408b312 100644
--- a/src/app/qgsrasterlayerproperties.cpp
+++ b/src/app/qgsrasterlayerproperties.cpp
@@ -737,6 +737,7 @@ void QgsRasterLayerProperties::sync()
mRasterLayer->dataUrlFormat()
)
);
+
//layer attribution and metadataUrl
mLayerAttributionLineEdit->setText( mRasterLayer->attribution() );
mLayerAttributionUrlLineEdit->setText( mRasterLayer->attributionUrl() );
@@ -752,6 +753,8 @@ void QgsRasterLayerProperties::sync()
)
);
+ mLayerLegendUrlLineEdit->setText( mRasterLayer->legendUrl() );
+ mLayerLegendUrlFormatComboBox->setCurrentIndex( mLayerLegendUrlFormatComboBox->findText( mRasterLayer->legendUrlFormat() ) );
} // QgsRasterLayerProperties::sync()
/*
@@ -925,6 +928,8 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->setMetadataUrl( mLayerMetadataUrlLineEdit->text() );
mRasterLayer->setMetadataUrlType( mLayerMetadataUrlTypeComboBox->currentText() );
mRasterLayer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );
+ mRasterLayer->setLegendUrl( mLayerLegendUrlLineEdit->text() );
+ mRasterLayer->setLegendUrlFormat( mLayerLegendUrlFormatComboBox->currentText() );
// update symbology
emit refreshLegend( mRasterLayer->id(), false );
diff --git a/src/app/qgsvectorlayerproperties.cpp b/src/app/qgsvectorlayerproperties.cpp
index 68811368e99..164549ee7cb 100644
--- a/src/app/qgsvectorlayerproperties.cpp
+++ b/src/app/qgsvectorlayerproperties.cpp
@@ -248,6 +248,12 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
layer->metadataUrlFormat()
)
);
+ mLayerLegendUrlLineEdit->setText( layer->legendUrl() );
+ mLayerLegendUrlFormatComboBox->setCurrentIndex(
+ mLayerLegendUrlFormatComboBox->findText(
+ layer->legendUrlFormat()
+ )
+ );
}
QSettings settings;
@@ -556,6 +562,8 @@ void QgsVectorLayerProperties::apply()
layer->setMetadataUrl( mLayerMetadataUrlLineEdit->text() );
layer->setMetadataUrlType( mLayerMetadataUrlTypeComboBox->currentText() );
layer->setMetadataUrlFormat( mLayerMetadataUrlFormatComboBox->currentText() );
+ layer->setLegendUrl( mLayerLegendUrlLineEdit->text() );
+ layer->setLegendUrlFormat( mLayerLegendUrlFormatComboBox->currentText() );
//layer simplify drawing configuration
QgsVectorSimplifyMethod::SimplifyHints simplifyHints = QgsVectorSimplifyMethod::NoSimplification;
diff --git a/src/core/qgsmaplayer.cpp b/src/core/qgsmaplayer.cpp
index 892328955ec..32451704aef 100644
--- a/src/core/qgsmaplayer.cpp
+++ b/src/core/qgsmaplayer.cpp
@@ -376,6 +376,14 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
mDataUrlFormat = dataUrlElem.attribute( "format", "" );
}
+ //legendUrl
+ QDomElement legendUrlElem = layerElement.firstChildElement( "legendUrl" );
+ if ( !legendUrlElem.isNull() )
+ {
+ mLegendUrl = legendUrlElem.text();
+ mLegendUrlFormat = legendUrlElem.attribute( "format", "" );
+ }
+
//attribution
QDomElement attribElem = layerElement.firstChildElement( "attribution" );
if ( !attribElem.isNull() )
@@ -518,6 +526,17 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
layerElement.appendChild( layerDataUrl );
}
+ // layer legendUrl
+ QString aLegendUrl = legendUrl();
+ if ( !aLegendUrl.isEmpty() )
+ {
+ QDomElement layerLegendUrl = document.createElement( "legendUrl" ) ;
+ QDomText layerLegendUrlText = document.createTextNode( aLegendUrl );
+ layerLegendUrl.appendChild( layerLegendUrlText );
+ layerLegendUrl.setAttribute( "format", legendUrlFormat() );
+ layerElement.appendChild( layerLegendUrl );
+ }
+
// layer attribution
QString aAttribution = attribution();
if ( !aAttribution.isEmpty() )
diff --git a/src/core/qgsmaplayer.h b/src/core/qgsmaplayer.h
index 9ed6af003f7..43a8169e3c6 100644
--- a/src/core/qgsmaplayer.h
+++ b/src/core/qgsmaplayer.h
@@ -369,6 +369,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
/** Return pointer to layer's undo stack */
QUndoStack *undoStack();
+ /* Layer legendUrl information */
+ void setLegendUrl( const QString& legendUrl ) { mLegendUrl = legendUrl; }
+ const QString& legendUrl() const { return mLegendUrl; }
+ void setLegendUrlFormat( const QString& legendUrlFormat ) { mLegendUrlFormat = legendUrlFormat; }
+ const QString& legendUrlFormat() const { return mLegendUrlFormat; }
+
/** @deprecated since 2.4 - returns NULL */
Q_DECL_DEPRECATED QImage *cacheImage() { return 0; }
/** @deprecated since 2.4 - caches listen to repaintRequested() signal to invalidate the cached image */
@@ -508,6 +514,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
QString mMetadataUrlType;
QString mMetadataUrlFormat;
+ /**WMS legend*/
+ QString mLegendUrl;
+ QString mLegendUrlFormat;
+
/** \brief Error */
QgsError mError;
diff --git a/src/mapserver/qgswmsprojectparser.cpp b/src/mapserver/qgswmsprojectparser.cpp
index d4dea2ebd69..1c02b46fa65 100644
--- a/src/mapserver/qgswmsprojectparser.cpp
+++ b/src/mapserver/qgswmsprojectparser.cpp
@@ -969,6 +969,70 @@ void QgsWMSProjectParser::addLayers( QDomDocument &doc,
styleTitleElem.appendChild( styleTitleText );
styleElem.appendChild( styleNameElem );
styleElem.appendChild( styleTitleElem );
+
+ // QString LegendURL for explicit layerbased GetLegendGraphic request
+ QDomElement getLayerLegendGraphicElem = doc.createElement( "LegendURL" );
+ QString hrefString = currentLayer->legendUrl();
+ bool customHrefString;
+ if ( !hrefString.isEmpty() )
+ {
+ customHrefString = true;
+ }
+ else
+ {
+ customHrefString = false;
+ hrefString = serviceUrl();
+ }
+ if ( hrefString.isEmpty() )
+ {
+ hrefString = getCapaServiceUrl( doc );
+ }
+ if ( !hrefString.isEmpty() )
+ {
+ QStringList getLayerLegendGraphicFormats;
+ if ( customHrefString == false )
+ {
+ getLayerLegendGraphicFormats << "image/png"; // << "jpeg" << "image/jpeg"
+
+ }
+ else
+ {
+ getLayerLegendGraphicFormats << currentLayer->legendUrlFormat();
+ }
+
+ for ( int i = 0; i < getLayerLegendGraphicFormats.size(); ++i )
+ {
+ QDomElement getLayerLegendGraphicFormatElem = doc.createElement( "Format" );
+ QString getLayerLegendGraphicFormat = getLayerLegendGraphicFormats[i];
+ QDomText getLayerLegendGraphicFormatText = doc.createTextNode( getLayerLegendGraphicFormat );
+ getLayerLegendGraphicFormatElem.appendChild( getLayerLegendGraphicFormatText );
+ getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicFormatElem );
+ }
+
+ // no parameters on custom hrefUrl, because should link directly to graphic
+ if ( customHrefString == false )
+ {
+ QUrl mapUrl( hrefString );
+ mapUrl.addQueryItem( "SERVICE", "WMS" );
+ mapUrl.addQueryItem( "VERSION", version );
+ mapUrl.addQueryItem( "REQUEST", "GetLegendGraphic" );
+ mapUrl.addQueryItem( "LAYER", currentLayer->name() );
+ mapUrl.addQueryItem( "FORMAT", "image/png" );
+ mapUrl.addQueryItem( "STYLE", styleNameText.data() );
+ if ( version == "1.3.0" )
+ {
+ mapUrl.addQueryItem( "SLD_VERSION", "1.1.0" );
+ }
+ hrefString = mapUrl.toString();
+ }
+
+ QDomElement getLayerLegendGraphicORElem = doc.createElement( "OnlineResource" );
+ getLayerLegendGraphicORElem.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
+ getLayerLegendGraphicORElem.setAttribute( "xlink:type", "simple" );
+ getLayerLegendGraphicORElem.setAttribute( "xlink:href", hrefString );
+ getLayerLegendGraphicElem.appendChild( getLayerLegendGraphicORElem );
+ styleElem.appendChild( getLayerLegendGraphicElem );
+ }
layerElem.appendChild( styleElem );
//min/max scale denominatormScaleBasedVisibility
@@ -1802,3 +1866,21 @@ void QgsWMSProjectParser::cleanupTextAnnotationItems()
}
mTextAnnotationItems.clear();
}
+
+QString QgsWMSProjectParser::getCapaServiceUrl( QDomDocument& doc ) const
+{
+ QString url;
+ QDomNodeList getCapNodeList = doc.elementsByTagName( "GetCapabilities" );
+ if ( getCapNodeList.count() > 0 )
+ {
+ QDomElement getCapElem = getCapNodeList.at( 0 ).toElement();
+ QDomNodeList getCapORNodeList = getCapElem.elementsByTagName( "OnlineResource" );
+ if ( getCapORNodeList.count() > 0 )
+ {
+ url = getCapORNodeList.at( 0 ).toElement().attribute( "xlink:href", "" );
+ }
+
+ }
+
+ return url;
+}
diff --git a/src/mapserver/qgswmsprojectparser.h b/src/mapserver/qgswmsprojectparser.h
index da2e4110d27..7060a22baed 100644
--- a/src/mapserver/qgswmsprojectparser.h
+++ b/src/mapserver/qgswmsprojectparser.h
@@ -146,6 +146,8 @@ class QgsWMSProjectParser: public QgsWMSConfigParser
void createSvgAnnotationItems();
void cleanupSvgAnnotationItems();
void cleanupTextAnnotationItems();
+
+ QString getCapaServiceUrl( QDomDocument& doc ) const;
};
#endif // QGSWMSPROJECTPARSER_H
diff --git a/src/ui/qgsrasterlayerpropertiesbase.ui b/src/ui/qgsrasterlayerpropertiesbase.ui
index 3fd72ea4c8e..c27f9ee642e 100644
--- a/src/ui/qgsrasterlayerpropertiesbase.ui
+++ b/src/ui/qgsrasterlayerpropertiesbase.ui
@@ -202,8 +202,8 @@
0
0
- 700
- 686
+ 713
+ 705
@@ -369,12 +369,12 @@
rastergeneral
-
- 11
-
6
+
+ 11
+
-
@@ -663,8 +663,8 @@
0
0
- 700
- 686
+ 713
+ 705
@@ -1168,8 +1168,8 @@
0
0
- 700
- 686
+ 713
+ 705
@@ -1575,8 +1575,8 @@
0
0
- 700
- 686
+ 713
+ 705
@@ -1639,8 +1639,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell';"><br /></span></p></body></html>
+</style></head><body style=" font-family:'Ubuntu'; font-size:9pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Cantarell'; font-size:11pt;"><br /></span></p></body></html>
@@ -1736,8 +1736,8 @@ p, li { white-space: pre-wrap; }
0
0
- 700
- 686
+ 713
+ 705
@@ -1786,18 +1786,12 @@ p, li { white-space: pre-wrap; }
0
0
- 700
- 686
+ 713
+ 705
-
-
- 0
-
-
- 0
-
- -
+
+
-
Description
@@ -1885,7 +1879,7 @@ p, li { white-space: pre-wrap; }
- -
+
-
Attribution
@@ -1917,7 +1911,7 @@ p, li { white-space: pre-wrap; }
- -
+
-
MetadataUrl
@@ -2008,7 +2002,65 @@ p, li { white-space: pre-wrap; }
- -
+
-
+
+
+ LegendUrl
+
+
+
-
+
+
-
+
+
+ Url
+
+
+
+ -
+
+
+ -
+
+
+ Format
+
+
+
+ -
+
+
+
+ 137
+ 0
+
+
+
+ 0
+
+
-
+
+ image/png
+
+
+ -
+
+ image/jpeg
+
+
+ -
+
+ image/jpg
+
+
+
+
+
+
+
+
+
+ -
@@ -2029,7 +2081,7 @@ p, li { white-space: pre-wrap; }
- -
+
-
Qt::Vertical
@@ -2116,6 +2168,11 @@ p, li { white-space: pre-wrap; }
+
+ QgsScaleComboBox
+ QComboBox
+
+
QgsCollapsibleGroupBox
QGroupBox
@@ -2132,11 +2189,6 @@ p, li { white-space: pre-wrap; }
QPushButton
-
- QgsScaleComboBox
- QComboBox
-
-
diff --git a/src/ui/qgsvectorlayerpropertiesbase.ui b/src/ui/qgsvectorlayerpropertiesbase.ui
index 8ff7d32579f..0871bd6496d 100644
--- a/src/ui/qgsvectorlayerpropertiesbase.ui
+++ b/src/ui/qgsvectorlayerpropertiesbase.ui
@@ -266,8 +266,8 @@
0
0
- 427
- 525
+ 383
+ 504
@@ -467,12 +467,12 @@
vectorgeneral
-
- 11
-
6
+
+ 11
+
-
@@ -769,8 +769,8 @@
0
0
- 121
- 38
+ 101
+ 35
@@ -875,8 +875,8 @@
0
0
- 702
- 171
+ 574
+ 144
@@ -1018,8 +1018,8 @@
0
0
- 476
- 182
+ 768
+ 506
@@ -1179,8 +1179,8 @@
0
0
- 755
- 487
+ 768
+ 506
@@ -1227,8 +1227,8 @@
0
0
- 755
- 487
+ 768
+ 506
@@ -1325,8 +1325,8 @@
0
0
- 100
- 30
+ 768
+ 506
@@ -1367,15 +1367,12 @@
0
0
- 375
- 519
+ 751
+ 552
-
-
- 0
-
-
-
+
+
-
Description
@@ -1470,7 +1467,7 @@
- -
+
-
Attribution
@@ -1502,7 +1499,7 @@
- -
+
-
MetadataUrl
@@ -1593,7 +1590,65 @@
- -
+
-
+
+
+ LegendUrl
+
+
+
-
+
+
-
+
+
+ Url
+
+
+
+ -
+
+
+ -
+
+
+ Format
+
+
+
+ -
+
+
+
+ 137
+ 0
+
+
+
+ 0
+
+
-
+
+ image/png
+
+
+ -
+
+ image/jpeg
+
+
+ -
+
+ image/jpg
+
+
+
+
+
+
+
+
+
+ -
@@ -1621,7 +1676,7 @@
- -
+
-
Qt::Vertical
@@ -1712,17 +1767,17 @@
+
+ QgsScaleComboBox
+ QComboBox
+
+
QgsCollapsibleGroupBox
QGroupBox
1
-
- QgsScaleComboBox
- QComboBox
-
-