Skip to content
Permalink
Browse files
Add CRS:84 just to WMS 1.3.0 Server capabilities document (#46149)
* Remove CRS:84 from WMS Capabilities document

* Add CRS:84 only for WMS version 1.3.0

* Fix WMS GetCapabilities 1.1.1 test

* Usage of const-qualified version
  • Loading branch information
jgrocha committed Nov 25, 2021
1 parent c1dd106 commit ab798c2e394e70f3742845ab17404c2194dd2697
Showing with 11 additions and 15 deletions.
  1. +11 −5 src/server/services/wms/qgswmsgetcapabilities.cpp
  2. +0 −10 tests/testdata/qgis_server/wms_getcapabilities_1_1_1.txt
@@ -1375,6 +1375,8 @@ namespace QgsWms
return;
}

const QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );

//insert the CRS elements after the title element to be in accordance with the WMS 1.3 specification
QDomElement titleElement = layerElement.firstChildElement( QStringLiteral( "Title" ) );
QDomElement abstractElement = layerElement.firstChildElement( QStringLiteral( "Abstract" ) );
@@ -1404,16 +1406,20 @@ namespace QgsWms
}
}

//Support for CRS:84 is mandatory (equals EPSG:4326 with reversed axis)
appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString( "CRS:84" ) );
// Support for CRS:84 is mandatory (equals EPSG:4326 with reversed axis)
// https://github.com/opengeospatial/ets-wms13/blob/47155399c09b200cb21382874fdb21d5fae4ab6e/src/site/markdown/index.md
if ( version == QLatin1String( "1.3.0" ) )
{
appendCrsElementToLayer( doc, layerElement, CRSPrecedingElement, QString( "CRS:84" ) );
}
}

void appendCrsElementToLayer( QDomDocument &doc, QDomElement &layerElement, const QDomElement &precedingElement,
const QString &crsText )
{
if ( crsText.isEmpty() )
return;
QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );
const QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );
QDomElement crsElement = doc.createElement( version == QLatin1String( "1.1.1" ) ? "SRS" : "CRS" );
QDomText crsTextNode = doc.createTextNode( crsText );
crsElement.appendChild( crsTextNode );
@@ -1542,7 +1548,7 @@ namespace QgsWms
return;
}

QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );
const QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );

QgsCoordinateReferenceSystem crs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsText );

@@ -1649,7 +1655,7 @@ namespace QgsWms
}


QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );
const QString version = doc.documentElement().attribute( QStringLiteral( "version" ) );

//create layer crs
QgsCoordinateReferenceSystem layerCrs = QgsCoordinateReferenceSystem::fromOgcWmsCrs( boundingBoxElem.attribute( version == QLatin1String( "1.1.1" ) ? "SRS" : "CRS" ) );
@@ -108,7 +108,6 @@ Content-Type: text/xml; charset=utf-8
<KeywordList>
<Keyword vocabulary="ISO">infoMapAccessService</Keyword>
</KeywordList>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901599" maxx="8.204165" miny="44.901236" minx="8.203154"/>
@@ -118,7 +117,6 @@ Content-Type: text/xml; charset=utf-8
<Name>layer_with_short_name</Name>
<Title>A Layer with a short name</Title>
<Abstract>A Layer with an abstract</Abstract>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203547" miny="44.901394" minx="8.203459"/>
@@ -144,7 +142,6 @@ Content-Type: text/xml; charset=utf-8
<Layer queryable="1">
<Name>landsat</Name>
<Title>landsat</Title>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="30.257289" maxx="18.045658" miny="30.151856" minx="17.924273"/>
@@ -163,7 +160,6 @@ Content-Type: text/xml; charset=utf-8
<Name>testlayer èé</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203547" miny="44.901394" minx="8.203459"/>
@@ -182,7 +178,6 @@ Content-Type: text/xml; charset=utf-8
<Name>fields_alias</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203547" miny="44.901394" minx="8.203459"/>
@@ -201,7 +196,6 @@ Content-Type: text/xml; charset=utf-8
<Name>exclude_attribute</Name>
<Title>A test vector layer</Title>
<Abstract>A test vector layer with unicode òà</Abstract>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203547" miny="44.901394" minx="8.203459"/>
@@ -220,7 +214,6 @@ Content-Type: text/xml; charset=utf-8
<Name>group_name</Name>
<Title>Group title</Title>
<Abstract>Group abstract</Abstract>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203548" miny="44.901394" minx="8.203459"/>
@@ -229,7 +222,6 @@ Content-Type: text/xml; charset=utf-8
<Layer queryable="1">
<Name>testlayer2</Name>
<Title>testlayer2</Title>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203547" miny="44.901394" minx="8.203459"/>
@@ -248,7 +240,6 @@ Content-Type: text/xml; charset=utf-8
<Layer queryable="0">
<Name>groupwithoutshortname</Name>
<Title>groupwithoutshortname</Title>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203548" miny="44.901394" minx="8.203459"/>
@@ -257,7 +248,6 @@ Content-Type: text/xml; charset=utf-8
<Layer queryable="0">
<Name>testlayer3</Name>
<Title>testlayer3</Title>
<SRS>CRS:84</SRS>
<SRS>EPSG:4326</SRS>
<SRS>EPSG:3857</SRS>
<LatLonBoundingBox maxy="44.901483" maxx="8.203547" miny="44.901394" minx="8.203459"/>

0 comments on commit ab798c2

Please sign in to comment.