Skip to content
Permalink
Browse files

Merge pull request #38222 from Samweli/fix-wmst-refresh

Check for dimensions when comparing WMS layer properties
  • Loading branch information
nyalldawson committed Aug 17, 2020
2 parents 5d2495e + 838e61e commit 7d9666158152db92c08d523d08fa958c26e0fe4a
Showing with 169 additions and 0 deletions.
  1. +11 −0 src/providers/wms/qgswmscapabilities.h
  2. +158 −0 tests/src/providers/testqgswmscapabilities.cpp
@@ -204,6 +204,15 @@ struct QgsWmsDimensionProperty

return QgsDateTimeRange();
}

bool operator== ( const QgsWmsDimensionProperty &other ) const
{
return name == other.name && units == other.units &&
unitSymbol == other.unitSymbol && defaultValue == other.defaultValue &&
extent == other.extent && multipleValues == other.multipleValues &&
nearestValue == other.nearestValue && current == other.current;
}

};

//! Logo URL Property structure
@@ -347,6 +356,8 @@ struct QgsWmsLayerProperty
return false;
if ( !( abstract == layerProperty.abstract ) )
return false;
if ( !( dimensions == layerProperty.dimensions ) )
return false;

return true;
}
@@ -249,6 +249,164 @@ class TestQgsWmsCapabilities: public QObject
QCOMPARE( dimensionProperty.extent, extent );
}

void wmsLayerProperty_data()
{
QTest::addColumn<QString>( "firstLayer" );
QTest::addColumn<QString>( "secondLayer" );
QTest::addColumn<bool>( "result" );

QTest::newRow( "equal properties" ) << R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< true;

QTest::newRow( "different names" ) << R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test2</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< false;

QTest::newRow( "different titles" ) << R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test2</Title>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< false;

QTest::newRow( "different abstract" ) << R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test2</Title>
<Abstract>Test2</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< false;

QTest::newRow( "different dimension extent" ) << R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01
</Dimension>
</Layer>)"""
<< R"""(<Layer queryable="0" opaque="0" cascaded="0">
<Name>Test</Name>
<Title>Test</Title>
<Abstract>Test</Abstract>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90" />
<BoundingBox SRS="EPSG:4326"
minx="-180" miny="-90" maxx="180" maxy="90" />
<Dimension name="time" units="ISO8601">
2020-01-01/2020-12-31/P1M
</Dimension>
</Layer>)"""
<< false;
}

void wmsLayerProperty()
{
QFETCH( QString, firstLayer );
QFETCH( QString, secondLayer );
QFETCH( bool, result );

QDomDocument doc;
doc.setContent( firstLayer );

QDomDocument doc2;
doc2.setContent( secondLayer );

QgsWmsCapabilities cap;
QgsWmsLayerProperty firstLayerProp;
QgsWmsLayerProperty secondLayerProp;

cap.parseLayer( doc.documentElement(), firstLayerProp );
cap.parseLayer( doc2.documentElement(), secondLayerProp );

QCOMPARE( firstLayerProp.equal( secondLayerProp ), result );

}

};

QGSTEST_MAIN( TestQgsWmsCapabilities )

0 comments on commit 7d96661

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