Skip to content
Permalink
Browse files

Remove special characters on wms dimension extent

  • Loading branch information
Samweli committed May 4, 2020
1 parent 8aa32f7 commit a001adbdabbc8f250dc377c65f966cacfbcd563a
Showing with 50 additions and 2 deletions.
  1. +2 −2 src/providers/wms/qgswmscapabilities.cpp
  2. +48 −0 tests/src/providers/testqgswmscapabilities.cpp
@@ -1075,7 +1075,7 @@ void QgsWmsCapabilities::parseDimension( const QDomElement &element, QgsWmsDimen
dimensionProperty.current = ( currentAttribute == QLatin1String( "1" ) || currentAttribute == QLatin1String( "true" ) );
}

dimensionProperty.extent = element.text();
dimensionProperty.extent = element.text().simplified();
}

void QgsWmsCapabilities::parseExtent( const QDomElement &element, QVector<QgsWmsDimensionProperty> &dimensionProperties )
@@ -1086,7 +1086,7 @@ void QgsWmsCapabilities::parseExtent( const QDomElement &element, QVector<QgsWms
{
if ( it->name == name )
{
it->extent = element.text();
it->extent = element.text().simplified();

it->defaultValue = element.attribute( QStringLiteral( "default" ) );

@@ -184,6 +184,54 @@ class TestQgsWmsCapabilities: public QObject
QCOMPARE( prop.dimensions.at( 0 ).units, QStringLiteral( "ISO8601" ) );
}

void wmsTemporalDimension_data()
{
QTest::addColumn<QString>( "dimension" );
QTest::addColumn<QString>( "extent" );

QTest::newRow( "single instant" ) << R"""(<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>)"""
<< "2020-01-01";

QTest::newRow( "interval" ) << R"""(<Dimension name="time" units="ISO8601">
2020-01-01/2020-12-31/P1M
</Dimension>)"""
<< "2020-01-01/2020-12-31/P1M";

QTest::newRow( "list" ) << R"""(<Dimension name="time" units="ISO8601">
2020-01-01,2020-06-31,2020-12-31
</Dimension>)"""
<< "2020-01-01,2020-06-31,2020-12-31";

QTest::newRow( "continuous" ) << R"""(<Dimension name="time" units="ISO8601">
2020-01-01/2020-06-31
</Dimension>)"""
<< "2020-01-01/2020-06-31";

QTest::newRow( "interval with internal newline characters" )
<< R"""(<Dimension name="time" units="ISO8601">
2020-01-01/2020-06-31/P1M,
2020-07-01/2020-12-31/P1D
</Dimension>)"""
<< "2020-01-01/2020-06-31/P1M, 2020-07-01/2020-12-31/P1D";
}

void wmsTemporalDimension()
{
QFETCH( QString, dimension );
QFETCH( QString, extent );

QDomDocument doc;
doc.setContent( dimension );
QgsWmsCapabilities cap;
QgsWmsDimensionProperty dimensionProperty;

cap.parseDimension( doc.documentElement(), dimensionProperty );

QCOMPARE( dimensionProperty.extent, extent );
}

};

QGSTEST_MAIN( TestQgsWmsCapabilities )

0 comments on commit a001adb

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