Skip to content

Commit a001adb

Browse files
authoredMay 4, 2020
Remove special characters on wms dimension extent
1 parent 8aa32f7 commit a001adb

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed
 

‎src/providers/wms/qgswmscapabilities.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ void QgsWmsCapabilities::parseDimension( const QDomElement &element, QgsWmsDimen
10751075
dimensionProperty.current = ( currentAttribute == QLatin1String( "1" ) || currentAttribute == QLatin1String( "true" ) );
10761076
}
10771077

1078-
dimensionProperty.extent = element.text();
1078+
dimensionProperty.extent = element.text().simplified();
10791079
}
10801080

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

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

‎tests/src/providers/testqgswmscapabilities.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,54 @@ class TestQgsWmsCapabilities: public QObject
184184
QCOMPARE( prop.dimensions.at( 0 ).units, QStringLiteral( "ISO8601" ) );
185185
}
186186

187+
void wmsTemporalDimension_data()
188+
{
189+
QTest::addColumn<QString>( "dimension" );
190+
QTest::addColumn<QString>( "extent" );
191+
192+
QTest::newRow( "single instant" ) << R"""(<Dimension name="time" units="ISO8601">
193+
2020-01-01
194+
</Dimension>)"""
195+
<< "2020-01-01";
196+
197+
QTest::newRow( "interval" ) << R"""(<Dimension name="time" units="ISO8601">
198+
2020-01-01/2020-12-31/P1M
199+
</Dimension>)"""
200+
<< "2020-01-01/2020-12-31/P1M";
201+
202+
QTest::newRow( "list" ) << R"""(<Dimension name="time" units="ISO8601">
203+
2020-01-01,2020-06-31,2020-12-31
204+
</Dimension>)"""
205+
<< "2020-01-01,2020-06-31,2020-12-31";
206+
207+
QTest::newRow( "continuous" ) << R"""(<Dimension name="time" units="ISO8601">
208+
2020-01-01/2020-06-31
209+
</Dimension>)"""
210+
<< "2020-01-01/2020-06-31";
211+
212+
QTest::newRow( "interval with internal newline characters" )
213+
<< R"""(<Dimension name="time" units="ISO8601">
214+
2020-01-01/2020-06-31/P1M,
215+
2020-07-01/2020-12-31/P1D
216+
</Dimension>)"""
217+
<< "2020-01-01/2020-06-31/P1M, 2020-07-01/2020-12-31/P1D";
218+
}
219+
220+
void wmsTemporalDimension()
221+
{
222+
QFETCH( QString, dimension );
223+
QFETCH( QString, extent );
224+
225+
QDomDocument doc;
226+
doc.setContent( dimension );
227+
QgsWmsCapabilities cap;
228+
QgsWmsDimensionProperty dimensionProperty;
229+
230+
cap.parseDimension( doc.documentElement(), dimensionProperty );
231+
232+
QCOMPARE( dimensionProperty.extent, extent );
233+
}
234+
187235
};
188236

189237
QGSTEST_MAIN( TestQgsWmsCapabilities )

0 commit comments

Comments
 (0)
Please sign in to comment.