Skip to content
Permalink
Browse files

pulling metadata url from wms capabilities

  • Loading branch information
Samweli committed Dec 14, 2019
1 parent c126c7a commit 77497b949263c1c0891a83cef93c6b89e466cbf8
@@ -783,6 +783,34 @@ void QgsWmsCapabilities::parseLegendUrl( QDomElement const &e, QgsWmsLegendUrlPr
QgsDebugMsg( QStringLiteral( "exiting." ) );
}

void QgsWmsCapabilities::parseMetadataUrl( QDomElement const &e, QgsWmsMetadataUrlProperty &metadataUrlProperty )
{

QDomNode n1 = e.firstChild();
while ( !n1.isNull() )
{
QDomElement e1 = n1.toElement(); // try to convert the node to an element.
if ( !e1.isNull() )
{
QString tagName = e1.tagName();
if ( tagName.startsWith( QLatin1String( "wms:" ) ) )
tagName = tagName.mid( 4 );

if ( tagName == QLatin1String( "Format" ) )
{
metadataUrlProperty.format = e1.text();
}
else if ( tagName == QLatin1String( "OnlineResource" ) )
{
parseOnlineResource( e1, metadataUrlProperty.onlineResource );
}
}
n1 = n1.nextSibling();
}

QgsDebugMsg( QStringLiteral( "exiting." ) );
}

void QgsWmsCapabilities::parseLayer( QDomElement const &e, QgsWmsLayerProperty &layerProperty,
QgsWmsLayerProperty *parentProperty )
{
@@ -972,7 +1000,8 @@ void QgsWmsCapabilities::parseLayer( QDomElement const &e, QgsWmsLayerProperty &
}
else if ( tagName == QLatin1String( "MetadataURL" ) )
{
// TODO
layerProperty.metadataUrl << QgsWmsMetadataUrlProperty();
parseMetadataUrl( e1, layerProperty.metadataUrl.last() );
}
else if ( tagName == QLatin1String( "DataURL" ) )
{
@@ -692,6 +692,7 @@ class QgsWmsCapabilities
void parseCapability( QDomElement const &e, QgsWmsCapabilityProperty &capabilityProperty );
void parseRequest( QDomElement const &e, QgsWmsRequestProperty &requestProperty );
void parseLegendUrl( QDomElement const &e, QgsWmsLegendUrlProperty &legendUrlProperty );
void parseMetadataUrl( QDomElement const &e, QgsWmsMetadataUrlProperty &metadataUrlProperty );
void parseLayer( QDomElement const &e, QgsWmsLayerProperty &layerProperty, QgsWmsLayerProperty *parentProperty = nullptr );
void parseStyle( QDomElement const &e, QgsWmsStyleProperty &styleProperty );

@@ -1751,24 +1751,6 @@ QString QgsWmsProvider::layerMetadata( QgsWmsLayerProperty &layer )
QStringLiteral( "</td>"
"<td>" ) %
layer.title;

// Metadata URLs
if ( !layer.metadataUrl.isEmpty() )
{
metadata += QStringLiteral("</td></tr>" );
metadata += QStringLiteral( "<tr><th>" ) %
tr( "MetadataURLs" ) %
QStringLiteral( "</th>"
"<td><table class=\"tabular-view\">"
"<tr><th>Format</th><th>URL</th></tr>" );
for ( int k = 0; k < layer.metadataUrl.size(); k++ )
{
const QgsWmsMetadataUrlProperty &l = layer.metadataUrl[k];
metadata += QStringLiteral( "<tr><td>" ) % l.format % QStringLiteral( "</td><td>" ) % l.onlineResource.xlinkHref % QStringLiteral( "</td></tr>" );
}
metadata += QStringLiteral( "</table>" );
}

QStringLiteral( "</td></tr>"

// Layer Abstract
@@ -1827,6 +1809,23 @@ QString QgsWmsProvider::layerMetadata( QgsWmsLayerProperty &layer )
QString::number( layer.fixedHeight ) %
QStringLiteral( "</td></tr>" );

// Metadata URLs
if ( !layer.metadataUrl.isEmpty() )
{
metadata += QStringLiteral( "<tr><th>" ) %
tr( "MetadataURLs" ) %
QStringLiteral( "</th>"
"<td><table class=\"tabular-view\">"
"<tr><th>Format</th><th>URL</th></tr>" );
for ( int k = 0; k < layer.metadataUrl.size(); k++ )
{
const QgsWmsMetadataUrlProperty &l = layer.metadataUrl[k];
metadata += QStringLiteral( "<tr><td>" ) % l.format % QStringLiteral( "</td><td>" ) % l.onlineResource.xlinkHref % 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 77497b9

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