Skip to content

Commit e953141

Browse files
authoredFeb 4, 2019
Merge pull request #9005 from alexbruy/wcs-fix
fix CRS handling in the DescribeCoverage response (refs #21045) [wcs]
2 parents d3daa86 + 92f6eda commit e953141

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed
 

‎src/providers/wcs/qgswcscapabilities.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,24 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsW
794794
QDomElement supportedCRSsElement = firstChild( coverageOfferingElement, QStringLiteral( "supportedCRSs" ) );
795795

796796
// requestResponseCRSs and requestCRSs + responseCRSs are alternatives
797-
coverage->supportedCrs = domElementsTexts( coverageOfferingElement, QStringLiteral( "supportedCRSs.requestResponseCRSs" ) );
797+
// we try to parse one or the other
798+
QStringList crsList;
799+
crsList = domElementsTexts( coverageOfferingElement, QStringLiteral( "supportedCRSs.requestResponseCRSs" ) );
800+
if ( crsList.isEmpty() )
801+
{
802+
crsList = domElementsTexts( coverageOfferingElement, QStringLiteral( "supportedCRSs.requestCRSs" ) );
803+
crsList << domElementsTexts( coverageOfferingElement, QStringLiteral( "supportedCRSs.responseCRSs" ) );
804+
}
805+
806+
// exclude invalid CRSs from the lists
807+
for ( const QString &crsid : qgis::as_const( crsList ) )
808+
{
809+
if ( QgsCoordinateReferenceSystem::fromOgcWmsCrs( crsid ).isValid() )
810+
{
811+
coverage->supportedCrs << crsid;
812+
}
813+
}
814+
798815
// TODO: requestCRSs, responseCRSs - must be then implemented also in provider
799816
//QgsDebugMsg( "supportedCrs = " + coverage->supportedCrs.join( "," ) );
800817

@@ -817,7 +834,11 @@ bool QgsWcsCapabilities::parseDescribeCoverageDom10( QByteArray const &xml, QgsW
817834
// If supportedCRSs.nativeCRSs is not defined we try to get it from RectifiedGrid
818835
if ( coverage->nativeCrs.isEmpty() )
819836
{
820-
coverage->nativeCrs = gridElement.attribute( QStringLiteral( "srsName" ) );
837+
QString crs = gridElement.attribute( QStringLiteral( "srsName" ) );
838+
if ( QgsCoordinateReferenceSystem::fromOgcWmsCrs( crs ).isValid() )
839+
{
840+
coverage->nativeCrs = crs;
841+
}
821842
}
822843

823844
if ( !gridElement.isNull() )

‎src/providers/wcs/qgswcssourceselect.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ QStringList QgsWCSSourceSelect::selectedLayersFormats()
226226

227227
QStringList QgsWCSSourceSelect::selectedLayersCrses()
228228
{
229-
230229
QString identifier = selectedIdentifier();
231230
if ( identifier.isEmpty() ) { return QStringList(); }
232231

0 commit comments

Comments
 (0)
Please sign in to comment.