Skip to content
Permalink
Browse files

Add FeatureListURL in QGIS WMS Server GetCapabilities Request

When a layer is published as a WFS FeatureType, WMS GetCapabilities
Answer containing a FeatureListURL. The FeatureListURL contains an
OnlineResource element with the URL to the layer in GML.
  • Loading branch information
rldhont committed May 30, 2013
1 parent 8a932d2 commit 2fcd2da092eb5a51355edc8147e6c98244643154
Showing with 74 additions and 39 deletions.
  1. +74 −39 src/mapserver/qgsprojectparser.cpp
@@ -572,6 +572,52 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
layerElem.appendChild( keywordListElem );
}

//CRS
QStringList crsList = createCRSListForLayer( currentLayer );
appendCRSElementsToLayer( layerElem, doc, crsList );

//Ex_GeographicBoundingBox
appendLayerBoundingBoxes( layerElem, doc, currentLayer->extent(), currentLayer->crs() );

//only one default style in project file mode
QDomElement styleElem = doc.createElement( "Style" );
QDomElement styleNameElem = doc.createElement( "Name" );
QDomText styleNameText = doc.createTextNode( "default" );
styleNameElem.appendChild( styleNameText );
QDomElement styleTitleElem = doc.createElement( "Title" );
QDomText styleTitleText = doc.createTextNode( "default" );
styleTitleElem.appendChild( styleTitleText );
styleElem.appendChild( styleNameElem );
styleElem.appendChild( styleTitleElem );
layerElem.appendChild( styleElem );

//min/max scale denominatormScaleBasedVisibility
if ( currentLayer->hasScaleBasedVisibility() )
{
QString minScaleString = QString::number( currentLayer->minimumScale() );
QString maxScaleString = QString::number( currentLayer->maximumScale() );

if ( version == "1.1.1" )
{
QDomElement scaleHintElem = doc.createElement( "ScaleHint" );
scaleHintElem.setAttribute( "min", minScaleString );
scaleHintElem.setAttribute( "max", maxScaleString );
layerElem.appendChild( scaleHintElem );
}
else
{
QDomElement minScaleElem = doc.createElement( "MinScaleDenominator" );
QDomText minScaleText = doc.createTextNode( minScaleString );
minScaleElem.appendChild( minScaleText );
layerElem.appendChild( minScaleElem );
QDomElement maxScaleElem = doc.createElement( "MaxScaleDenominator" );
QDomText maxScaleText = doc.createTextNode( maxScaleString );
maxScaleElem.appendChild( maxScaleText );
layerElem.appendChild( maxScaleElem );
}
}

// layer attribution
QString attribution = currentLayer->attribution();
if ( !attribution.isEmpty() )
{
@@ -592,6 +638,7 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
layerElem.appendChild( attribElem );
}

// layer metadata URL
QString metadataUrl = currentLayer->metadataUrl();
if ( !metadataUrl.isEmpty() )
{
@@ -617,49 +664,37 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
layerElem.appendChild( metaUrlElem );
}

//CRS
QStringList crsList = createCRSListForLayer( currentLayer );
appendCRSElementsToLayer( layerElem, doc, crsList );

//Ex_GeographicBoundingBox
appendLayerBoundingBoxes( layerElem, doc, currentLayer->extent(), currentLayer->crs() );

//only one default style in project file mode
QDomElement styleElem = doc.createElement( "Style" );
QDomElement styleNameElem = doc.createElement( "Name" );
QDomText styleNameText = doc.createTextNode( "default" );
styleNameElem.appendChild( styleNameText );
QDomElement styleTitleElem = doc.createElement( "Title" );
QDomText styleTitleText = doc.createTextNode( "default" );
styleTitleElem.appendChild( styleTitleText );
styleElem.appendChild( styleNameElem );
styleElem.appendChild( styleTitleElem );
layerElem.appendChild( styleElem );

//min/max scale denominatormScaleBasedVisibility
if ( currentLayer->hasScaleBasedVisibility() )
// if the layer is published in WFS
// add a FeatureListURL element
// with an URL to the GML
QStringList wfsLayersId = wfsLayers();
if ( wfsLayersId.contains( currentLayer->id() ) )
{
QString minScaleString = QString::number( currentLayer->minimumScale() );
QString maxScaleString = QString::number( currentLayer->maximumScale() );
QDomElement featListUrlElem = doc.createElement( "FeatureListURL" );

if ( version == "1.1.1" )
{
QDomElement scaleHintElem = doc.createElement( "ScaleHint" );
scaleHintElem.setAttribute( "min", minScaleString );
scaleHintElem.setAttribute( "max", maxScaleString );
layerElem.appendChild( scaleHintElem );
}
else
QDomElement featListUrlFormatElem = doc.createElement( "Format" );
QDomText featListUrlFormatText = doc.createTextNode( "text/xml" );
featListUrlFormatElem.appendChild( featListUrlFormatText );
featListUrlElem.appendChild( featListUrlFormatElem );

QDomNodeList getCapNodeList = doc.elementsByTagName( "GetCapabilities" );
if ( getCapNodeList.count() > 0 )
{
QDomElement minScaleElem = doc.createElement( "MinScaleDenominator" );
QDomText minScaleText = doc.createTextNode( minScaleString );
minScaleElem.appendChild( minScaleText );
layerElem.appendChild( minScaleElem );
QDomElement maxScaleElem = doc.createElement( "MaxScaleDenominator" );
QDomText maxScaleText = doc.createTextNode( maxScaleString );
maxScaleElem.appendChild( maxScaleText );
layerElem.appendChild( maxScaleElem );
QDomElement getCapElem = getCapNodeList.at( 0 ).toElement();
QDomNodeList getCapORNodeList = getCapElem.elementsByTagName( "OnlineResource" );
if ( getCapORNodeList.count() > 0 )
{
QString getCapUrl = getCapORNodeList.at( 0 ).toElement().attribute( "xlink:href", "" );
QString featListUrl = getCapUrl + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + currentLayer->name() + "&OUPUTFORMAT=GML2";
QDomElement featListUrlORElem = doc.createElement( "OnlineResource" );
featListUrlORElem.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
featListUrlORElem.setAttribute( "xlink:type", "simple" );
featListUrlORElem.setAttribute( "xlink:href", featListUrl );
featListUrlElem.appendChild( featListUrlORElem );
}
}

layerElem.appendChild( featListUrlElem );
}

if ( fullProjectSettings )

0 comments on commit 2fcd2da

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