Skip to content

Commit

Permalink
Add FeatureListURL in QGIS WMS Server GetCapabilities Request
Browse files Browse the repository at this point in the history
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 2fcd2da
Showing 1 changed file with 74 additions and 39 deletions.
113 changes: 74 additions & 39 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
{
Expand All @@ -592,6 +638,7 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
layerElem.appendChild( attribElem );
}

// layer metadata URL
QString metadataUrl = currentLayer->metadataUrl();
if ( !metadataUrl.isEmpty() )
{
Expand All @@ -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 )
Expand Down

0 comments on commit 2fcd2da

Please sign in to comment.