Skip to content
Permalink
Browse files

added dimension property in the wms layer metadata

  • Loading branch information
Samweli committed Dec 24, 2019
1 parent c242856 commit f9ea39c9db410f5ab53e72435f90c4aa21ad0ce8
@@ -759,6 +759,32 @@ void QgsWmsCapabilities::parseLegendUrl( const QDomElement &element, QgsWmsLegen
}
}

void QgsWmsCapabilities::parseDimensions( 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" ) );

if ( !element.attribute( QStringLiteral( "unitSymbol" ) ).isNull() )
dimensionProperty.unitSymbol = element.attribute( QStringLiteral( "unitSymbol" ) );

if ( !element.attribute( QStringLiteral( "default" ) ).isNull() )
dimensionProperty.defaultValue = element.attribute( QStringLiteral( "default" ) );

if ( !element.attribute( QStringLiteral( "multipleValues" ) ).isNull() )
dimensionProperty.multipleValues = element.attribute( QStringLiteral( "multipleValues" ) ) == QLatin1String( "1" ) ? true : false ;

if ( !element.attribute( QStringLiteral( "nearestValue" ) ).isNull() )
dimensionProperty.nearestValue = element.attribute( QStringLiteral( "nearestValue" ) ) == QLatin1String( "1" ) ? true : false ;

if ( !element.attribute( QStringLiteral( "current" ) ).isNull() )
dimensionProperty.current = element.attribute( QStringLiteral( "current" ) ) == QLatin1String( "1" ) ? true : false ;

dimensionProperty.extent = element.text();
}


void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProperty &layerProperty,
QgsWmsLayerProperty *parentProperty )
{
@@ -932,7 +958,8 @@ void QgsWmsCapabilities::parseLayer( const QDomElement &element, QgsWmsLayerProp
}
else if ( tagName == QLatin1String( "Dimension" ) )
{
// TODO
layerProperty.dimensions << QgsWmsDimensionProperty();
parseDimensions( nodeElement, layerProperty.dimensions.last() );
}
else if ( tagName == QLatin1String( "Attribution" ) )
{
@@ -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

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

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

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

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

};

//! Logo URL Property structure
@@ -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;
@@ -691,6 +713,7 @@ class QgsWmsCapabilities

void parseCapability( const QDomElement &element, QgsWmsCapabilityProperty &capabilityProperty );
void parseRequest( const QDomElement &element, QgsWmsRequestProperty &requestProperty );
void parseDimensions( const QDomElement &element, QgsWmsDimensionProperty &dimensionProperty );
void parseLegendUrl( const QDomElement &element, QgsWmsLegendUrlProperty &legendUrlProperty );
void parseLayer( const QDomElement &element, QgsWmsLayerProperty &layerProperty, QgsWmsLayerProperty *parentProperty = nullptr );
void parseStyle( const QDomElement &element, QgsWmsStyleProperty &styleProperty );
@@ -1809,6 +1809,29 @@ 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>" );
}

// Layer Coordinate Reference Systems
for ( int j = 0; j < std::min( layer.crs.size(), 10 ); j++ )
{

0 comments on commit f9ea39c

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