Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add min/max scale denominator to capabilities output
  • Loading branch information
Marco Hugentobler committed Sep 6, 2012
1 parent bd2af12 commit 91a06b3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/mapserver/qgsconfigparser.h
Expand Up @@ -41,7 +41,7 @@ class QgsConfigParser

/**Adds layer and style specific capabilities elements to the parent node. This includes the individual layers and styles, their description, native CRS, bounding boxes, etc.
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings = false ) const = 0;
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const = 0;

virtual void featureTypeList( QDomElement& parentElement, QDomDocument& doc ) const = 0;

Expand Down
38 changes: 34 additions & 4 deletions src/mapserver/qgsprojectparser.cpp
Expand Up @@ -87,7 +87,7 @@ int QgsProjectParser::numberOfLayers() const
return mProjectLayerElements.size();
}

void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings ) const
void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings ) const
{
QStringList nonIdentifiableLayers = identifyDisabledLayers();

Expand Down Expand Up @@ -133,7 +133,7 @@ void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement,

QDomElement legendElem = mXMLDoc->documentElement().firstChildElement( "legend" );

addLayers( doc, layerParentElem, legendElem, layerMap, nonIdentifiableLayers, fullProjectSettings );
addLayers( doc, layerParentElem, legendElem, layerMap, nonIdentifiableLayers, version, fullProjectSettings );

parentElement.appendChild( layerParentElem );
combineExtentAndCrsOfGroupChildren( layerParentElem, doc );
Expand Down Expand Up @@ -217,6 +217,7 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
const QDomElement &legendElem,
const QMap<QString, QgsMapLayer *> &layerMap,
const QStringList &nonIdentifiableLayers,
QString version,
bool fullProjectSettings ) const
{
QDomNodeList legendChildren = legendElem.childNodes();
Expand Down Expand Up @@ -269,12 +270,12 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
pLayerMap.insert( layerId( elem ), p->createLayerFromElement( elem ) );
}

p->addLayers( doc, layerElem, embeddedGroupElem, pLayerMap, pIdDisabled, fullProjectSettings );
p->addLayers( doc, layerElem, embeddedGroupElem, pLayerMap, pIdDisabled, version, fullProjectSettings );
}
}
else //normal (not embedded) legend group
{
addLayers( doc, layerElem, currentChildElem, layerMap, nonIdentifiableLayers, fullProjectSettings );
addLayers( doc, layerElem, currentChildElem, layerMap, nonIdentifiableLayers, version, fullProjectSettings );
}

// combine bounding boxes of children (groups/layers)
Expand Down Expand Up @@ -351,6 +352,32 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
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.3.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 );
}
else if ( version == "1.1.1" )
{
QDomElement scaleHintElem = doc.createElement( "ScaleHint" );
scaleHintElem.setAttribute( "min", minScaleString );
scaleHintElem.setAttribute( "max", maxScaleString );
layerElem.appendChild( scaleHintElem );
}
}

if ( fullProjectSettings )
{
addLayerProjectSettings( layerElem, doc, currentLayer );
Expand All @@ -377,6 +404,9 @@ void QgsProjectParser::addLayerProjectSettings( QDomElement& layerElem, QDomDocu
{
QgsVectorLayer* vLayer = static_cast<QgsVectorLayer*>( currentLayer );

//min/max scales for layer


//attributes
QDomElement attributesElem = doc.createElement( "Attributes" );
const QgsFieldMap& layerFields = vLayer->pendingFields();
Expand Down
3 changes: 2 additions & 1 deletion src/mapserver/qgsprojectparser.h
Expand Up @@ -37,7 +37,7 @@ class QgsProjectParser: public QgsConfigParser

/**Adds layer and style specific capabilities elements to the parent node. This includes the individual layers and styles, their description, native CRS, bounding boxes, etc.
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings = false ) const;
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;

virtual void featureTypeList( QDomElement& parentElement, QDomDocument& doc ) const;

Expand Down Expand Up @@ -153,6 +153,7 @@ class QgsProjectParser: public QgsConfigParser
const QDomElement &legendElem,
const QMap<QString, QgsMapLayer *> &layerMap,
const QStringList &nonIdentifiableLayers,
QString version, //1.1.1 or 1.3.0
bool fullProjectSettings = false ) const;

static void addLayerProjectSettings( QDomElement& layerElem, QDomDocument& doc, QgsMapLayer* currentLayer );
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgssldparser.cpp
Expand Up @@ -140,7 +140,7 @@ int QgsSLDParser::numberOfLayers() const
return ( userLayerList.size() + namedLayerList.size() );
}

void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings ) const
void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings ) const
{
//iterate over all <UserLayer> nodes
if ( mXMLDoc )
Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgssldparser.h
Expand Up @@ -54,7 +54,7 @@ class QgsSLDParser: public QgsConfigParser
virtual ~QgsSLDParser();

/**Adds layer and style specific capabilities elements to the parent node. This includes the individual layers and styles, their description, native CRS, bounding boxes, etc.*/
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings = false ) const;
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;

void featureTypeList( QDomElement &, QDomDocument & ) const {};

Expand Down
2 changes: 1 addition & 1 deletion src/mapserver/qgswmsserver.cpp
Expand Up @@ -215,7 +215,7 @@ QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInf
QgsDebugMsg( "calling layersAndStylesCapabilities" );
if ( mConfigParser )
{
mConfigParser->layersAndStylesCapabilities( capabilityElement, doc, fullProjectInformation );
mConfigParser->layersAndStylesCapabilities( capabilityElement, doc, version, fullProjectInformation );
}
QgsDebugMsg( "layersAndStylesCapabilities returned" );

Expand Down

0 comments on commit 91a06b3

Please sign in to comment.