Skip to content
Permalink
Browse files

[Feature][QGIS Server] Add WMS INSPIRE Capabilities

In the project properties the user can:
* activate INSPIRE capabilities
* select language of the service, 24 EU official languages + 5 regionals
* choose the scenario for service metadata and specify them

The WMS 1.3.0 capabilities reflects the INSPIRE configuration.
  • Loading branch information
rldhont committed Jan 5, 2016
1 parent bb5f0ff commit e276f170c7ccaa37879da0f0aae5b61edc79f090
BIN +652 Bytes images/flags/cy.png
Binary file not shown.
BIN +599 Bytes images/flags/en_GB.png
Binary file not shown.
BIN +481 Bytes images/flags/ga.png
Binary file not shown.
BIN +649 Bytes images/flags/gd.png
Binary file not shown.
BIN +420 Bytes images/flags/mt.png
Binary file not shown.
@@ -4,12 +4,16 @@
<file>flags/af.png</file>
<file>flags/ar.png</file>
<file>flags/bg.png</file>
<file>flags/cy.png</file>
<file>flags/de.png</file>
<file>flags/en_GB.png</file>
<file>flags/en_US.png</file>
<file>flags/es.png</file>
<file>flags/fa.png</file>
<file>flags/fi.png</file>
<file>flags/fr.png</file>
<file>flags/ga.png</file>
<file>flags/gd.png</file>
<file>flags/he.png</file>
<file>flags/hu.png</file>
<file>flags/id.png</file>
@@ -21,6 +25,7 @@
<file>flags/lt.png</file>
<file>flags/lv.png</file>
<file>flags/mn.png</file>
<file>flags/mt.png</file>
<file>flags/nl.png</file>
<file>flags/pt_BR.png</file>
<file>flags/pt_PT.png</file>
@@ -294,7 +294,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
{
mWMSContactPositionCb->setCurrentIndex( contactPositionIndex );
}
else if ( contactPositionText != "" )
else if ( !contactPositionText.isEmpty() )
{
mWMSContactPositionCb->setEditText( contactPositionText );
}
@@ -308,7 +308,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
{
mWMSFeesCb->setCurrentIndex( feesIndex );
}
else if ( feesText != "" )
else if ( !feesText.isEmpty() )
{
mWMSFeesCb->setEditText( feesText );
}
@@ -329,11 +329,82 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
{
mWMSAccessConstraintsCb->setCurrentIndex( accessConstraintsIndex );
}
else if ( accessConstraintsText != "" )
else if ( !accessConstraintsText.isEmpty() )
{
mWMSAccessConstraintsCb->setEditText( accessConstraintsText );
}

mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "bg" ) ), QLocale( "bg" ).nativeLanguageName(), "bul" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "cs" ) ), QLocale( "cs" ).nativeLanguageName(), "cze" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "da" ) ), QLocale( "da" ).nativeLanguageName(), "dan" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "nl" ) ), QLocale( "nl" ).nativeLanguageName(), "dut" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "en_GB" ) ), QLocale( "en_GB" ).nativeLanguageName(), "eng" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "et" ) ), QLocale( "et" ).nativeLanguageName(), "est" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "fi" ) ), QLocale( "fi" ).nativeLanguageName(), "fin" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "fr" ) ), QLocale( "fr" ).nativeLanguageName(), "fre" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "de" ) ), QLocale( "de" ).nativeLanguageName(), "ger" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "ga" ) ), QLocale( "ga" ).nativeLanguageName(), "gle" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "el" ) ), QLocale( "el" ).nativeLanguageName(), "gre" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "hu" ) ), QLocale( "hu" ).nativeLanguageName(), "hun" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "it" ) ), QLocale( "it" ).nativeLanguageName(), "ita" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "lv" ) ), QLocale( "lv" ).nativeLanguageName(), "lav" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "lt" ) ), QLocale( "lt" ).nativeLanguageName(), "lit" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "mt" ) ), QLocale( "mt" ).nativeLanguageName(), "mlt" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "pl" ) ), QLocale( "pl" ).nativeLanguageName(), "pol" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "pt_PT" ) ), QLocale( "pt_PT" ).nativeLanguageName(), "por" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "ro" ) ), QLocale( "ro" ).nativeLanguageName(), "rum" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "sk" ) ), QLocale( "sk" ).nativeLanguageName(), "slo" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "sl" ) ), QLocale( "sl" ).nativeLanguageName(), "slv" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "es" ) ), QLocale( "es" ).nativeLanguageName(), "spa" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "sv" ) ), QLocale( "sv" ).nativeLanguageName(), "swe" );

mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "eu" ) ), QLocale( "eu" ).nativeLanguageName(), "eus" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "ca" ) ), QLocale( "ca" ).nativeLanguageName(), "cat" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "gl" ) ), QLocale( "gl" ).nativeLanguageName(), "gal" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "gd" ) ), QLocale( "gd" ).nativeLanguageName(), "gla" );
mWMSInspireLanguage->addItem( QIcon( QString( ":/images/flags/%1.png" ).arg( "cy" ) ), QLocale( "cy" ).nativeLanguageName(), "cym" );
mWMSInspireLanguage->setCurrentIndex(
mWMSInspireLanguage->findText(
QLocale::system().nativeLanguageName()
)
);

bool addWMSInspire = QgsProject::instance()->readBoolEntry( "WMSInspire", "/activated" );
if ( addWMSInspire )
{
mWMSInspire->setChecked( addWMSInspire );
QString inspireLanguage = QgsProject::instance()->readEntry( "WMSInspire", "/language", "" );
int inspireLanguageIndex = mWMSInspireLanguage->findData( inspireLanguage );
mWMSInspireLanguage->setCurrentIndex( inspireLanguageIndex );

QString inspireMetadataUrl = QgsProject::instance()->readEntry( "WMSInspire", "/metadataUrl", "" );
if ( !inspireMetadataUrl.isEmpty() )
{
mWMSInspireScenario1->setChecked( true );
mWMSInspireMetadataUrl->setText( inspireMetadataUrl );
mWMSInspireMetadataUrlType->setCurrentIndex(
mWMSInspireMetadataUrlType->findText(
QgsProject::instance()->readEntry( "WMSInspire", "/metadataUrlType", "" )
)
);
}
else
{
QString inspireTemporalReference = QgsProject::instance()->readEntry( "WMSInspire", "/temporalReference", "" );
if ( !inspireTemporalReference.isEmpty() )
{
mWMSInspireScenario2->setChecked( true );
mWMSInspireTemporalReference->setDate( QDate::fromString( inspireTemporalReference, "yyyy-MM-dd" ) );
}
QString inspireMetadataDate = QgsProject::instance()->readEntry( "WMSInspire", "/metadataDate", "" );
if ( !inspireMetadataDate.isEmpty() )
{
mWMSInspireScenario2->setChecked( true );
mWMSInspireMetadataDate->setDate( QDate::fromString( inspireMetadataDate, "yyyy-MM-dd" ) );
}
}
}

// WMS GetFeatureInfo precision
int WMSprecision = QgsProject::instance()->readNumEntry( "WMSPrecision", "/", -1 );
if ( WMSprecision != -1 )
@@ -790,7 +861,10 @@ void QgsProjectProperties::apply()

QgsProject::instance()->writeEntry( "WMSServiceCapabilities", "/", grpOWSServiceCapabilities->isChecked() );
QgsProject::instance()->writeEntry( "WMSServiceTitle", "/", mWMSTitle->text() );
QgsProject::instance()->writeEntry( "WMSRootName", "/", mWMSName->text() );

if ( !mWMSName->text().isEmpty() )
QgsProject::instance()->writeEntry( "WMSRootName", "/", mWMSName->text() );

QgsProject::instance()->writeEntry( "WMSContactOrganization", "/", mWMSContactOrganization->text() );
QgsProject::instance()->writeEntry( "WMSContactPerson", "/", mWMSContactPerson->text() );
QgsProject::instance()->writeEntry( "WMSContactMail", "/", mWMSContactMail->text() );
@@ -802,7 +876,7 @@ void QgsProjectProperties::apply()
// WMS Contact Position
int contactPositionIndex = mWMSContactPositionCb->currentIndex();
QString contactPositionText = mWMSContactPositionCb->currentText();
if ( contactPositionText != "" && contactPositionText == mWMSContactPositionCb->itemText( contactPositionIndex ) )
if ( !contactPositionText.isEmpty() && contactPositionText == mWMSContactPositionCb->itemText( contactPositionIndex ) )
{
QgsProject::instance()->writeEntry( "WMSContactPosition", "/", mWMSContactPositionCb->itemData( contactPositionIndex ).toString() );
}
@@ -814,7 +888,7 @@ void QgsProjectProperties::apply()
// WMS Fees
int feesIndex = mWMSFeesCb->currentIndex();
QString feesText = mWMSFeesCb->currentText();
if ( feesText != "" && feesText == mWMSFeesCb->itemText( feesIndex ) )
if ( !feesText.isEmpty() && feesText == mWMSFeesCb->itemText( feesIndex ) )
{
QgsProject::instance()->writeEntry( "WMSFees", "/", mWMSFeesCb->itemData( feesIndex ).toString() );
}
@@ -826,7 +900,7 @@ void QgsProjectProperties::apply()
// WMS Access Constraints
int accessConstraintsIndex = mWMSAccessConstraintsCb->currentIndex();
QString accessConstraintsText = mWMSAccessConstraintsCb->currentText();
if ( accessConstraintsText != "" && accessConstraintsText == mWMSAccessConstraintsCb->itemText( accessConstraintsIndex ) )
if ( !accessConstraintsText.isEmpty() && accessConstraintsText == mWMSAccessConstraintsCb->itemText( accessConstraintsIndex ) )
{
QgsProject::instance()->writeEntry( "WMSAccessConstraints", "/", mWMSAccessConstraintsCb->itemData( accessConstraintsIndex ).toString() );
}
@@ -847,6 +921,27 @@ void QgsProjectProperties::apply()
QgsProject::instance()->removeEntry( "WMSKeywordList", "/" );
}

// WMS INSPIRE configuration
QgsProject::instance()->removeEntry( "WMSInspire", "/" );
if ( mWMSInspire->isChecked() )
{
QgsProject::instance()->writeEntry( "WMSInspire", "/activated", mWMSInspire->isChecked() );

int inspireLanguageIndex = mWMSInspireLanguage->currentIndex();
QgsProject::instance()->writeEntry( "WMSInspire", "/language", mWMSInspireLanguage->itemData( inspireLanguageIndex ).toString() );

if ( mWMSInspireScenario1->isChecked() )
{
QgsProject::instance()->writeEntry( "WMSInspire", "/metadataUrl", mWMSInspireMetadataUrl->text() );
QgsProject::instance()->writeEntry( "WMSInspire", "/metadataUrlType", mWMSInspireMetadataUrlType->currentText() );
}
else if ( mWMSInspireScenario2->isChecked() )
{
QgsProject::instance()->writeEntry( "WMSInspire", "/temporalReference", mWMSInspireTemporalReference->date().toString( "yyyy-MM-dd" ) );
QgsProject::instance()->writeEntry( "WMSInspire", "/metadataDate", mWMSInspireMetadataDate->date().toString( "yyyy-MM-dd" ) );
}
}

// WMS GetFeatureInfo geometry precision (decimal places)
QgsProject::instance()->writeEntry( "WMSPrecision", "/", mWMSPrecisionSpinBox->text() );

@@ -1326,6 +1421,20 @@ void QgsProjectProperties::on_pbnWFSLayersSelectAll_clicked()
}
}

void QgsProjectProperties::on_mWMSInspireScenario1_toggled( bool on )
{
mWMSInspireScenario2->blockSignals( true );
mWMSInspireScenario2->setChecked( !on );
mWMSInspireScenario2->blockSignals( false );
}

void QgsProjectProperties::on_mWMSInspireScenario2_toggled( bool on )
{
mWMSInspireScenario1->blockSignals( true );
mWMSInspireScenario1->setChecked( !on );
mWMSInspireScenario1->blockSignals( false );
}

void QgsProjectProperties::on_pbnWFSLayersUnselectAll_clicked()
{
for ( int i = 0; i < twWFSLayers->rowCount(); i++ )
@@ -1551,7 +1660,7 @@ void QgsProjectProperties::on_mTransparencySpinBox_valueChanged( int value )
void QgsProjectProperties::editSymbol( QComboBox* cbo )
{
QString symbolName = cbo->currentText();
if ( symbolName == "" )
if ( symbolName.isEmpty() )
{
QMessageBox::information( this, "", tr( "Select a valid symbol" ) );
return;
@@ -104,6 +104,8 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
void on_mRemoveWMSComposerButton_clicked();
void on_mAddLayerRestrictionButton_clicked();
void on_mRemoveLayerRestrictionButton_clicked();
void on_mWMSInspireScenario1_toggled( bool on );
void on_mWMSInspireScenario2_toggled( bool on );

/*!
* Slots to select/unselect all the WFS layers
@@ -75,7 +75,7 @@ QgsServerProjectParser::QgsServerProjectParser( QDomDocument* xmlDoc, const QStr
}
// Setting the QgsProject instance fileName
// to help converting relative pathes to absolute
if ( mProjectPath != "" )
if ( !mProjectPath.isEmpty() )
{
QgsProject::instance()->setFileName( mProjectPath );
}
@@ -563,7 +563,7 @@ void QgsServerProjectParser::serviceCapabilities( QDomElement& parentElement, QD
QDomElement feesElem = propertiesElement.firstChildElement( "WMSFees" );
QDomElement wmsFeesElem = doc.createElement( "Fees" );
QDomText wmsFeesText = doc.createTextNode( "conditions unknown" ); // default value if access conditions are unknown
if ( !feesElem.isNull() && feesElem.text() != "" )
if ( !feesElem.isNull() && !feesElem.text().isEmpty() )
{
wmsFeesText = doc.createTextNode( feesElem.text() );
}
@@ -574,7 +574,7 @@ void QgsServerProjectParser::serviceCapabilities( QDomElement& parentElement, QD
QDomElement accessConstraintsElem = propertiesElement.firstChildElement( "WMSAccessConstraints" );
QDomElement wmsAccessConstraintsElem = doc.createElement( "AccessConstraints" );
QDomText wmsAccessConstraintsText = doc.createTextNode( "None" ); // default value if access constraints are unknown
if ( !accessConstraintsElem.isNull() && accessConstraintsElem.text() != "" )
if ( !accessConstraintsElem.isNull() && !accessConstraintsElem.text().isEmpty() )
{
wmsAccessConstraintsText = doc.createTextNode( accessConstraintsElem.text() );
}
@@ -708,6 +708,15 @@ int QgsSLDConfigParser::WMSPrecision() const
return -1;
}

bool QgsSLDConfigParser::WMSInspireActivated() const
{
if ( mFallbackParser )
{
return mFallbackParser->WMSInspireActivated();
}
return false;
}

QgsComposition* QgsSLDConfigParser::createPrintComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, const QMap< QString, QString >& parameterMap ) const
{
if ( mFallbackParser )
@@ -734,6 +743,14 @@ void QgsSLDConfigParser::printCapabilities( QDomElement& parentElement, QDomDocu
}
}

void QgsSLDConfigParser::inspireCapabilities( QDomElement& parentElement, QDomDocument& doc ) const
{
if ( mFallbackParser )
{
mFallbackParser->inspireCapabilities( parentElement, doc );
}
}

void QgsSLDConfigParser::setScaleDenominator( double )
{
//soon...
@@ -104,6 +104,11 @@ class QgsSLDConfigParser : public QgsWMSConfigParser
double imageQuality() const override;
int WMSPrecision() const override;

// WMS inspire capabilities
bool WMSInspireActivated() const override;
/** Adds inspire capabilities to xml document. ParentElem usually is the <Capabilities> element*/
void inspireCapabilities( QDomElement& parentElement, QDomDocument& doc ) const override;

//printing

/** Creates a print composition, usually for a GetPrint request. Replaces map and label parameters*/
@@ -105,6 +105,11 @@ class SERVER_EXPORT QgsWMSConfigParser
// WMS GetFeatureInfo precision (decimal places)
virtual int WMSPrecision() const = 0;

// WMS inspire capabilities
virtual bool WMSInspireActivated() const = 0;
/** Adds inspire capabilities to xml document. ParentElem usually is the <Capabilities> element*/
virtual void inspireCapabilities( QDomElement& parentElement, QDomDocument& doc ) const = 0;

//printing

/** Creates a print composition, usually for a GetPrint request. Replaces map and label parameters*/

0 comments on commit e276f17

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