Merge branch 'server_legend_url'

This commit is contained in:
Marco Hugentobler 2014-04-22 05:04:52 +02:00
commit 324070f9c1
8 changed files with 300 additions and 67 deletions

View File

@ -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 );

View File

@ -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;

View File

@ -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() )

View File

@ -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;

View File

@ -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;
}

View File

@ -146,6 +146,8 @@ class QgsWMSProjectParser: public QgsWMSConfigParser
void createSvgAnnotationItems();
void cleanupSvgAnnotationItems();
void cleanupTextAnnotationItems();
QString getCapaServiceUrl( QDomDocument& doc ) const;
};
#endif // QGSWMSPROJECTPARSER_H

View File

@ -202,8 +202,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>686</height>
<width>713</width>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
@ -369,12 +369,12 @@
<string notr="true">rastergeneral</string>
</property>
<layout class="QGridLayout" name="_5">
<property name="margin">
<number>11</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<property name="margin">
<number>11</number>
</property>
<item row="0" column="4">
<widget class="QLabel" name="textLabel1_2_2_2">
<property name="toolTip">
@ -663,8 +663,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>686</height>
<width>713</width>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@ -1168,8 +1168,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>686</height>
<width>713</width>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
@ -1575,8 +1575,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>686</height>
<width>713</width>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
@ -1639,8 +1639,8 @@
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Cantarell';&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Cantarell'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
@ -1736,8 +1736,8 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>686</height>
<width>713</width>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_16">
@ -1786,18 +1786,12 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>700</width>
<height>686</height>
<width>713</width>
<height>705</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_12">
<item row="0" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaDescriptionGrpBx">
<property name="title">
<string>Description</string>
@ -1885,7 +1879,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaAttributionGrpBx">
<property name="title">
<string>Attribution</string>
@ -1917,7 +1911,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaMetaUrlGrpBx">
<property name="title">
<string>MetadataUrl</string>
@ -2008,7 +2002,65 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaLegendGrpBx">
<property name="title">
<string>LegendUrl</string>
</property>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="mLayerLegendUrlLabel">
<property name="text">
<string>Url</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mLayerLegendUrlLineEdit"/>
</item>
<item>
<widget class="QLabel" name="mLayerLegendUrlFormatLabel">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mLayerLegendUrlFormatComboBox">
<property name="minimumSize">
<size>
<width>137</width>
<height>0</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>image/png</string>
</property>
</item>
<item>
<property name="text">
<string>image/jpeg</string>
</property>
</item>
<item>
<property name="text">
<string>image/jpg</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaPropertiesGrpBx">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -2029,7 +2081,7 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
</item>
<item>
<item row="5" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -2116,6 +2168,11 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsScaleComboBox</class>
<extends>QComboBox</extends>
<header>qgsscalecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
@ -2132,11 +2189,6 @@ p, li { white-space: pre-wrap; }
<extends>QPushButton</extends>
<header>qgscolorbutton.h</header>
</customwidget>
<customwidget>
<class>QgsScaleComboBox</class>
<extends>QComboBox</extends>
<header>qgsscalecombobox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>

View File

@ -266,8 +266,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>427</width>
<height>525</height>
<width>383</width>
<height>504</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@ -467,12 +467,12 @@
<string notr="true">vectorgeneral</string>
</property>
<layout class="QGridLayout" name="_5">
<property name="margin">
<number>11</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<property name="margin">
<number>11</number>
</property>
<item row="0" column="4">
<widget class="QLabel" name="textLabel1_2_2_2">
<property name="toolTip">
@ -769,8 +769,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>121</width>
<height>38</height>
<width>101</width>
<height>35</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_28">
@ -875,8 +875,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>702</width>
<height>171</height>
<width>574</width>
<height>144</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
@ -1018,8 +1018,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>182</height>
<width>768</width>
<height>506</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_26">
@ -1179,8 +1179,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>755</width>
<height>487</height>
<width>768</width>
<height>506</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -1227,8 +1227,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>755</width>
<height>487</height>
<width>768</width>
<height>506</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_23">
@ -1325,8 +1325,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
<width>768</width>
<height>506</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_24">
@ -1367,15 +1367,12 @@
<rect>
<x>0</x>
<y>0</y>
<width>375</width>
<height>519</height>
<width>751</width>
<height>552</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaDescriptionGrpBx">
<property name="title">
<string>Description</string>
@ -1470,7 +1467,7 @@
</layout>
</widget>
</item>
<item>
<item row="1" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaAttributionGrpBx">
<property name="title">
<string>Attribution</string>
@ -1502,7 +1499,7 @@
</layout>
</widget>
</item>
<item>
<item row="2" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaMetaUrlGrpBx">
<property name="title">
<string>MetadataUrl</string>
@ -1593,7 +1590,65 @@
</layout>
</widget>
</item>
<item>
<item row="3" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaLegendGrpBx">
<property name="title">
<string>LegendUrl</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="mLayerLegendUrlLabel">
<property name="text">
<string>Url</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mLayerLegendUrlLineEdit"/>
</item>
<item>
<widget class="QLabel" name="mLayerLegendUrlFormatLabel">
<property name="text">
<string>Format</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="mLayerLegendUrlFormatComboBox">
<property name="minimumSize">
<size>
<width>137</width>
<height>0</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>image/png</string>
</property>
</item>
<item>
<property name="text">
<string>image/jpeg</string>
</property>
</item>
<item>
<property name="text">
<string>image/jpg</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QgsCollapsibleGroupBox" name="mMetaPropertiesGrpBx">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@ -1621,7 +1676,7 @@
</layout>
</widget>
</item>
<item>
<item row="5" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -1712,17 +1767,17 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsScaleComboBox</class>
<extends>QComboBox</extends>
<header>qgsscalecombobox.h</header>
</customwidget>
<customwidget>
<class>QgsCollapsibleGroupBox</class>
<extends>QGroupBox</extends>
<header>qgscollapsiblegroupbox.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QgsScaleComboBox</class>
<extends>QComboBox</extends>
<header>qgsscalecombobox.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>