Skip to content

Commit

Permalink
Merge pull request #33539 from Samweli/wms-t_layer_metadata_support
Browse files Browse the repository at this point in the history
Show dimensions metadata on WMS layer metadata
  • Loading branch information
nyalldawson committed Dec 31, 2019
2 parents 1bf7e72 + ad9313d commit bc5275a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 6 deletions.
32 changes: 31 additions & 1 deletion src/providers/wms/qgswmscapabilities.cpp
Expand Up @@ -759,6 +759,35 @@ void QgsWmsCapabilities::parseLegendUrl( const QDomElement &element, QgsWmsLegen
}
}

void QgsWmsCapabilities::parseDimension( const QDomElement &element, QgsWmsDimensionProperty &dimensionProperty )
{

// TODO, check for the name value if it is time, implement WMS-T support
dimensionProperty.name = element.attribute( QStringLiteral( "name" ) );
dimensionProperty.units = element.attribute( QStringLiteral( "units" ) );
dimensionProperty.unitSymbol = element.attribute( QStringLiteral( "unitSymbol" ) );
dimensionProperty.defaultValue = element.attribute( QStringLiteral( "default" ) );

if ( !element.attribute( QStringLiteral( "multipleValues" ) ).isNull() )
{
QString multipleValuesAttribute = element.attribute( QStringLiteral( "multipleValues" ) );
dimensionProperty.multipleValues = ( multipleValuesAttribute == QLatin1String( "1" ) || multipleValuesAttribute == QLatin1String( "true" ) );
}

if ( !element.attribute( QStringLiteral( "nearestValue" ) ).isNull() )
{
QString nearestValueAttribute = element.attribute( QStringLiteral( "nearestValue" ) );
dimensionProperty.nearestValue = ( nearestValueAttribute == QLatin1String( "1" ) || nearestValueAttribute == QLatin1String( "true" ) );
}

if ( !element.attribute( QStringLiteral( "current" ) ).isNull() )
{
QString currentAttribute = element.attribute( QStringLiteral( "current" ) );
dimensionProperty.current = ( currentAttribute == QLatin1String( "1" ) || currentAttribute == QLatin1String( "true" ) );
}

dimensionProperty.extent = element.text();
}

void QgsWmsCapabilities::parseMetadataUrl( const QDomElement &element, QgsWmsMetadataUrlProperty &metadataUrlProperty )
{
Expand Down Expand Up @@ -960,7 +989,8 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp
}
else if ( tagName == QLatin1String( "Dimension" ) )
{
// TODO
layerProperty.dimensions << QgsWmsDimensionProperty();
parseDimension( nodeElement, layerProperty.dimensions.last() );
}
else if ( tagName == QLatin1String( "Attribution" ) )
{
Expand Down
33 changes: 28 additions & 5 deletions src/providers/wms/qgswmscapabilities.h
Expand Up @@ -154,17 +154,38 @@ struct QgsWmsBoundingBoxProperty
QgsRectangle box; // consumes minx, miny, maxx, maxy.
};

//! Dimension Property structure
// TODO: Fill to WMS specifications
/**
* \brief Dimension Property structure.
*
* Contains the optional dimension element,
* the element can be present in Service or Layer metadata
*/
struct QgsWmsDimensionProperty
{
//! Name of the dimensional axis eg. time
QString name;

//! Units of the dimensional axis, defined from UCUM. Can be null.
QString units;

//! Optional, unit symbol a 7-bit ASCII character string also defined from UCUM.
QString unitSymbol;

//! Optional, default value to be used in GetMap request
QString defaultValue; // plain "default" is a reserved word
bool multipleValues;
bool nearestValue;
bool current;

//! Text containing available value(s) for the dimension
QString extent;

//! Optional, determines whether multiple values of the dimension can be requested
bool multipleValues = false;

//! Optional, whether nearest value of the dimension will be returned, if requested.
bool nearestValue = false;

//! Optional, valid only for temporal exents, determines whether data are normally kept current.
bool current = false;

};

//! Logo URL Property structure
Expand Down Expand Up @@ -283,6 +304,7 @@ struct QgsWmsLayerProperty
QgsWmsAttributionProperty attribution;
QVector<QgsWmsAuthorityUrlProperty> authorityUrl;
QVector<QgsWmsIdentifierProperty> identifier;
QVector<QgsWmsDimensionProperty> dimensions;
QVector<QgsWmsMetadataUrlProperty> metadataUrl;
QVector<QgsWmsDataListUrlProperty> dataListUrl;
QVector<QgsWmsFeatureListUrlProperty> featureListUrl;
Expand Down Expand Up @@ -691,6 +713,7 @@ class QgsWmsCapabilities

void parseCapability( const QDomElement &element, QgsWmsCapabilityProperty &capabilityProperty );
void parseRequest( const QDomElement &element, QgsWmsRequestProperty &requestProperty );
void parseDimension( const QDomElement &element, QgsWmsDimensionProperty &dimensionProperty );
void parseLegendUrl( const QDomElement &element, QgsWmsLegendUrlProperty &legendUrlProperty );
void parseMetadataUrl( const QDomElement &element, QgsWmsMetadataUrlProperty &metadataUrlProperty );
void parseLayer( const QDomElement &element, QgsWmsLayerProperty &layerProperty, QgsWmsLayerProperty *parentProperty = nullptr );
Expand Down
22 changes: 22 additions & 0 deletions src/providers/wms/qgswmsprovider.cpp
Expand Up @@ -1809,6 +1809,28 @@ QString QgsWmsProvider::layerMetadata( QgsWmsLayerProperty &layer )
QString::number( layer.fixedHeight ) %
QStringLiteral( "</td></tr>" );

// Dimensions
if ( !layer.dimensions.isEmpty() )
{
metadata += QStringLiteral( "<tr><th>" ) %
tr( "Dimensions" ) %
QStringLiteral( "</th>"
"<td><table class=\"tabular-view\">"
"<tr><th>" ) %
tr( "Name" ) %
QStringLiteral( "</th><th>" ) %
tr( "Unit" ) %
QStringLiteral( "</th><th>" ) %
tr( "Extent" ) %
QStringLiteral( "</th></tr>" );

for ( const QgsWmsDimensionProperty &d : qgis::as_const( layer.dimensions ) )
{
metadata += QStringLiteral( "<tr><td>" ) % d.name % QStringLiteral( "</td><td>" ) % d.units % QStringLiteral( "</td><td>" ) % d.extent % QStringLiteral( "</td></tr>" );
}
metadata += QStringLiteral( "</table>"
"</td></tr>" );
}
// Metadata URLs
if ( !layer.metadataUrl.isEmpty() )
{
Expand Down

0 comments on commit bc5275a

Please sign in to comment.