Skip to content
Permalink
Browse files

[FEATURE] Add DataUrl to layer's metadata

Like keyword list, attribution and metadata url, this information is
used by QGIS Server in WMS GetCapabilities and GetContext Request.
The user can add an url where he can find information about the layer.
  • Loading branch information
rldhont committed Jun 11, 2013
1 parent 597c402 commit 3115c3094854f4dba53153b2156c3ebb60ac9881
@@ -732,6 +732,12 @@ void QgsRasterLayerProperties::sync()
mLayerTitleLineEdit->setText( mRasterLayer->title() );
mLayerAbstractTextEdit->setPlainText( mRasterLayer->abstract() );
mLayerKeywordListLineEdit->setText( mRasterLayer->keywordList() );
mLayerDataUrlLineEdit->setText( mRasterLayer->dataUrl() );
mLayerDataUrlFormatComboBox->setCurrentIndex(
mLayerDataUrlFormatComboBox->findText(
mRasterLayer->dataUrlFormat()
)
);
//layer attribution and metadataUrl
mLayerAttributionLineEdit->setText( mRasterLayer->attribution() );
mLayerAttributionUrlLineEdit->setText( mRasterLayer->attributionUrl() );
@@ -912,6 +918,8 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->setTitle( mLayerTitleLineEdit->text() );
mRasterLayer->setAbstract( mLayerAbstractTextEdit->toPlainText() );
mRasterLayer->setKeywordList( mLayerKeywordListLineEdit->text() );
mRasterLayer->setDataUrl( mLayerDataUrlLineEdit->text() );
mRasterLayer->setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
//layer attribution and metadataUrl
mRasterLayer->setAttribution( mLayerAttributionLineEdit->text() );
mRasterLayer->setAttributionUrl( mLayerAttributionUrlLineEdit->text() );
@@ -229,6 +229,12 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
mLayerTitleLineEdit->setText( layer->title() );
mLayerAbstractTextEdit->setPlainText( layer->abstract() );
mLayerKeywordListLineEdit->setText( layer->keywordList() );
mLayerDataUrlLineEdit->setText( layer->dataUrl() );
mLayerDataUrlFormatComboBox->setCurrentIndex(
mLayerDataUrlFormatComboBox->findText(
layer->dataUrlFormat()
)
);
//layer attribution and metadataUrl
mLayerAttributionLineEdit->setText( layer->attribution() );
mLayerAttributionUrlLineEdit->setText( layer->attributionUrl() );
@@ -484,6 +490,8 @@ void QgsVectorLayerProperties::apply()
layer->setTitle( mLayerTitleLineEdit->text() );
layer->setAbstract( mLayerAbstractTextEdit->toPlainText() );
layer->setKeywordList( mLayerKeywordListLineEdit->text() );
layer->setDataUrl( mLayerDataUrlLineEdit->text() );
layer->setDataUrlFormat( mLayerDataUrlFormatComboBox->currentText() );
//layer attribution and metadataUrl
layer->setAttribution( mLayerAttributionLineEdit->text() );
layer->setAttributionUrl( mLayerAttributionUrlLineEdit->text() );
@@ -371,6 +371,14 @@ bool QgsMapLayer::readLayerXML( const QDomElement& layerElement )
mKeywordList = kwdList.join( ", " );
}

//metadataUrl
QDomElement dataUrlElem = layerElement.firstChildElement( "dataUrl" );
if ( !dataUrlElem.isNull() )
{
mDataUrl = dataUrlElem.text();
mDataUrlFormat = dataUrlElem.attribute( "format", "" );
}

//attribution
QDomElement attribElem = layerElement.firstChildElement( "attribution" );
if ( !attribElem.isNull() )
@@ -502,6 +510,17 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
layerElement.appendChild( layerKeywordList );
}

// layer metadataUrl
QString aDataUrl = dataUrl();
if ( !aDataUrl.isEmpty() )
{
QDomElement layerDataUrl = document.createElement( "dataUrl" ) ;
QDomText layerDataUrlText = document.createTextNode( aDataUrl );
layerDataUrl.appendChild( layerDataUrlText );
layerDataUrl.setAttribute( "format", dataUrlFormat() );
layerElement.appendChild( layerDataUrl );
}

// layer attribution
QString aAttribution = attribution();
if ( !aAttribution.isEmpty() )
@@ -99,6 +99,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
void setKeywordList( const QString& keywords ) { mKeywordList = keywords; }
const QString& keywordList() const { return mKeywordList; }

/* Layer dataUrl information */
void setDataUrl( const QString& dataUrl ) { mDataUrl = dataUrl; }
const QString& dataUrl() const { return mDataUrl; }
void setDataUrlFormat( const QString& dataUrlFormat ) { mDataUrlFormat = dataUrlFormat; }
const QString& dataUrlFormat() const { return mDataUrlFormat; }

/* Layer attribution information */
void setAttribution( const QString& attrib ) { mAttribution = attrib; }
const QString& attribution() const { return mAttribution; }
@@ -494,6 +500,10 @@ class CORE_EXPORT QgsMapLayer : public QObject
QString mAbstract;
QString mKeywordList;

/**DataUrl of the layer*/
QString mDataUrl;
QString mDataUrlFormat;

/**Attribution of the layer*/
QString mAttribution;
QString mAttributionUrl;
@@ -770,6 +770,24 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
}
}

// layer attribution
QString dataUrl = currentLayer->dataUrl();
if ( !dataUrl.isEmpty() )
{
QDomElement dataUrlElem = doc.createElement( "DataURL" );
QDomElement dataUrlFormatElem = doc.createElement( "Format" );
QString dataUrlFormat = currentLayer->dataUrlFormat();
QDomText dataUrlFormatText = doc.createTextNode( dataUrlFormat );
dataUrlFormatElem.appendChild( dataUrlFormatText );
dataUrlElem.appendChild( dataUrlFormatElem );
QDomElement dataORElem = doc.createElement( "OnlineResource" );
dataORElem.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
dataORElem.setAttribute( "xlink:type", "simple" );
dataORElem.setAttribute( "xlink:href", dataUrl );
dataUrlElem.appendChild( dataORElem );
layerElem.appendChild( dataUrlElem );
}

// layer attribution
QString attribution = currentLayer->attribution();
if ( !attribution.isEmpty() )
@@ -808,6 +826,10 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
else if ( metadataUrlType == "TC211" )
{
metaUrlElem.setAttribute( "type", "ISO19115:2003" );
}
else
{
metaUrlElem.setAttribute( "type", metadataUrlType );
}
QString metadataUrlFormat = currentLayer->metadataUrlFormat();
if ( !metadataUrlFormat.isEmpty() )
@@ -1124,6 +1146,21 @@ void QgsProjectParser::addOWSLayers( QDomDocument &doc,
layerElem.appendChild( keywordsElem );
}

// layer data URL
QString dataUrl = currentLayer->dataUrl();
if ( !dataUrl.isEmpty() )
{
QDomElement dataUrlElem = doc.createElement( "DataURL" );
QString dataUrlFormat = currentLayer->dataUrlFormat();
dataUrlElem.setAttribute( "format", dataUrlFormat );
QDomElement dataORElem = doc.createElement( "OnlineResource" );
dataORElem.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
dataORElem.setAttribute( "xlink:type", "simple" );
dataORElem.setAttribute( "xlink:href", dataUrl );
dataUrlElem.appendChild( dataORElem );
layerElem.appendChild( dataUrlElem );
}

// layer metadata URL
QString metadataUrl = currentLayer->metadataUrl();
if ( !metadataUrl.isEmpty() )

0 comments on commit 3115c30

Please sign in to comment.
You can’t perform that action at this time.