Skip to content
Permalink
Browse files

Merge pull request #5566 from pblottiere/bugfix-ogc-getcapa-abstract

[server][bugfix] Fix OGC test recommendations
  • Loading branch information
pblottiere committed Nov 16, 2017
2 parents dfc0305 + 9283b26 commit 15c32c22c5f20da1aeef9e9812448af166774bd7
@@ -84,6 +84,7 @@ namespace QgsWms
const QgsLayerTreeGroup *layerTreeGroup,
bool projectSettings );

void addKeywordListElement( const QgsProject *project, QDomDocument &doc, QDomElement &parent );
}

void writeGetCapabilities( QgsServerInterface *serverIface, const QgsProject *project,
@@ -225,8 +226,6 @@ namespace QgsWms
QDomElement getServiceElement( QDomDocument &doc, const QgsProject *project, const QString &version,
const QgsServerRequest &request )
{
bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );

//Service element
QDomElement serviceElem = doc.createElement( QStringLiteral( "Service" ) );

@@ -254,34 +253,7 @@ namespace QgsWms
serviceElem.appendChild( abstractElem );
}

QDomElement keywordsElem = doc.createElement( QStringLiteral( "KeywordList" ) );
//add default keyword
QDomElement keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "ISO" ) );
QDomText keywordText = doc.createTextNode( QStringLiteral( "infoMapAccessService" ) );
keywordElem.appendChild( keywordText );
keywordsElem.appendChild( keywordElem );
serviceElem.appendChild( keywordsElem );
QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
if ( !keywords.isEmpty() )
{
for ( int i = 0; i < keywords.size(); ++i )
{
QString keyword = keywords.at( i );
if ( !keyword.isEmpty() )
{
keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordText = doc.createTextNode( keyword );
keywordElem.appendChild( keywordText );
if ( sia2045 )
{
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "SIA_Geo405" ) );
}
keywordsElem.appendChild( keywordElem );
}
}
serviceElem.appendChild( keywordsElem );
}
addKeywordListElement( project, doc, serviceElem );

QString onlineResource = QgsServerProjectUtils::owsServiceOnlineResource( *project );
if ( onlineResource.isEmpty() )
@@ -770,6 +742,18 @@ namespace QgsWms

QDomElement layerParentElem = doc.createElement( QStringLiteral( "Layer" ) );

// Root Layer title
QDomElement layerParentTitleElem = doc.createElement( QStringLiteral( "Title" ) );
QDomText layerParentTitleText = doc.createTextNode( project->title() );
layerParentTitleElem.appendChild( layerParentTitleText );
layerParentElem.appendChild( layerParentTitleElem );

// Root Layer abstract
QDomElement layerParentAbstElem = doc.createElement( QStringLiteral( "Abstract" ) );
QDomText layerParentAbstText = doc.createTextNode( project->title() );
layerParentAbstElem.appendChild( layerParentAbstText );
layerParentElem.appendChild( layerParentAbstElem );

// Root Layer name
QDomElement layerParentNameElem = doc.createElement( QStringLiteral( "Name" ) );
QString rootName = QgsServerProjectUtils::wmsRootName( *project );
@@ -785,11 +769,12 @@ namespace QgsWms
}
layerParentElem.appendChild( layerParentNameElem );

// Root Layer title
QDomElement layerParentTitleElem = doc.createElement( QStringLiteral( "Title" ) );
QDomText layerParentTitleText = doc.createTextNode( project->title() );
layerParentTitleElem.appendChild( layerParentTitleText );
layerParentElem.appendChild( layerParentTitleElem );
// Keyword list
addKeywordListElement( project, doc, layerParentElem );

// Metadata (empty but needed for OGC tests RECOMMENDATIONS)
QDomElement metaUrlElem = doc.createElement( QStringLiteral( "MetadataURL" ) );
layerParentElem.appendChild( metaUrlElem );

// Root Layer tree name
if ( projectSettings )
@@ -1734,6 +1719,35 @@ namespace QgsWms
}
}

void addKeywordListElement( const QgsProject *project, QDomDocument &doc, QDomElement &parent )
{
bool sia2045 = QgsServerProjectUtils::wmsInfoFormatSia2045( *project );

QDomElement keywordsElem = doc.createElement( QStringLiteral( "KeywordList" ) );
//add default keyword
QDomElement keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "ISO" ) );
QDomText keywordText = doc.createTextNode( QStringLiteral( "infoMapAccessService" ) );
keywordElem.appendChild( keywordText );
keywordsElem.appendChild( keywordElem );
parent.appendChild( keywordsElem );
QStringList keywords = QgsServerProjectUtils::owsServiceKeywords( *project );
for ( const QString &keyword : qgis::as_const( keywords ) )
{
if ( !keyword.isEmpty() )
{
keywordElem = doc.createElement( QStringLiteral( "Keyword" ) );
keywordText = doc.createTextNode( keyword );
keywordElem.appendChild( keywordText );
if ( sia2045 )
{
keywordElem.setAttribute( QStringLiteral( "vocabulary" ), QStringLiteral( "SIA_Geo405" ) );
}
keywordsElem.appendChild( keywordElem );
}
}
parent.appendChild( keywordsElem );
}
}


@@ -98,8 +98,8 @@ Content-Type: text/xml; charset=utf-8
<Format>XML</Format>
</Exception>
<Layer>
<Name>QGIS Test Project</Name>
<Title>QGIS Test Project</Title>
<Abstract>QGIS Test Project</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
@@ -111,6 +111,11 @@ Content-Type: text/xml; charset=utf-8
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60604e+06" maxx="913283" miny="5.60599e+06" CRS="EPSG:3857" minx="913171"/>
<BoundingBox maxy="8.20416" maxx="44.9016" miny="8.20315" CRS="EPSG:4326" minx="44.9012"/>
<Name>QGIS Test Project</Name>
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<MetadataURL/>
<Layer queryable="1">
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
@@ -120,8 +120,8 @@ Content-Type: text/xml; charset=utf-8
</inspire_common:ResponseLanguage>
</inspire_vs:ExtendedCapabilities>
<Layer>
<Name>QGIS Test Project</Name>
<Title>QGIS Test Project</Title>
<Abstract>QGIS Test Project</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
@@ -133,6 +133,11 @@ Content-Type: text/xml; charset=utf-8
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60604e+06" maxx="913283" miny="5.60599e+06" CRS="EPSG:3857" minx="913171"/>
<BoundingBox maxy="8.20416" maxx="44.9016" miny="8.20315" CRS="EPSG:4326" minx="44.9012"/>
<Name>QGIS Test Project</Name>
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<MetadataURL/>
<Layer queryable="1">
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
@@ -114,8 +114,8 @@ Content-Type: text/xml; charset=utf-8
<WFSLayer name="testlayer èé"/>
</WFSLayers>
<Layer>
<Name>QGIS Test Project</Name>
<Title>QGIS Test Project</Title>
<Abstract>QGIS Test Project</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
@@ -127,6 +127,11 @@ Content-Type: text/xml; charset=utf-8
</EX_GeographicBoundingBox>
<BoundingBox maxy="5.60604e+06" maxx="913283" miny="5.60599e+06" CRS="EPSG:3857" minx="913171"/>
<BoundingBox maxy="8.20416" maxx="44.9016" miny="8.20315" CRS="EPSG:4326" minx="44.9012"/>
<Name>QGIS Test Project</Name>
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<MetadataURL/>
<TreeName>QGIS Test Project</TreeName>
<Layer geometryType="Point" queryable="1" displayField="name" visible="1">
<Name>testlayer èé</Name>

0 comments on commit 15c32c2

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