Skip to content

Commit 91a06b3

Browse files
author
Marco Hugentobler
committedSep 6, 2012
Add min/max scale denominator to capabilities output
1 parent bd2af12 commit 91a06b3

File tree

6 files changed

+40
-9
lines changed

6 files changed

+40
-9
lines changed
 

‎src/mapserver/qgsconfigparser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class QgsConfigParser
4141

4242
/**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.
4343
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
44-
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings = false ) const = 0;
44+
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const = 0;
4545

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

‎src/mapserver/qgsprojectparser.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int QgsProjectParser::numberOfLayers() const
8787
return mProjectLayerElements.size();
8888
}
8989

90-
void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings ) const
90+
void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings ) const
9191
{
9292
QStringList nonIdentifiableLayers = identifyDisabledLayers();
9393

@@ -133,7 +133,7 @@ void QgsProjectParser::layersAndStylesCapabilities( QDomElement& parentElement,
133133

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

136-
addLayers( doc, layerParentElem, legendElem, layerMap, nonIdentifiableLayers, fullProjectSettings );
136+
addLayers( doc, layerParentElem, legendElem, layerMap, nonIdentifiableLayers, version, fullProjectSettings );
137137

138138
parentElement.appendChild( layerParentElem );
139139
combineExtentAndCrsOfGroupChildren( layerParentElem, doc );
@@ -217,6 +217,7 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
217217
const QDomElement &legendElem,
218218
const QMap<QString, QgsMapLayer *> &layerMap,
219219
const QStringList &nonIdentifiableLayers,
220+
QString version,
220221
bool fullProjectSettings ) const
221222
{
222223
QDomNodeList legendChildren = legendElem.childNodes();
@@ -269,12 +270,12 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
269270
pLayerMap.insert( layerId( elem ), p->createLayerFromElement( elem ) );
270271
}
271272

272-
p->addLayers( doc, layerElem, embeddedGroupElem, pLayerMap, pIdDisabled, fullProjectSettings );
273+
p->addLayers( doc, layerElem, embeddedGroupElem, pLayerMap, pIdDisabled, version, fullProjectSettings );
273274
}
274275
}
275276
else //normal (not embedded) legend group
276277
{
277-
addLayers( doc, layerElem, currentChildElem, layerMap, nonIdentifiableLayers, fullProjectSettings );
278+
addLayers( doc, layerElem, currentChildElem, layerMap, nonIdentifiableLayers, version, fullProjectSettings );
278279
}
279280

280281
// combine bounding boxes of children (groups/layers)
@@ -351,6 +352,32 @@ void QgsProjectParser::addLayers( QDomDocument &doc,
351352
styleElem.appendChild( styleTitleElem );
352353
layerElem.appendChild( styleElem );
353354

355+
//min/max scale denominatormScaleBasedVisibility
356+
if ( currentLayer->hasScaleBasedVisibility() )
357+
{
358+
QString minScaleString = QString::number( currentLayer->minimumScale() );
359+
QString maxScaleString = QString::number( currentLayer->maximumScale() );
360+
361+
if ( version == "1.3.0" )
362+
{
363+
QDomElement minScaleElem = doc.createElement( "MinScaleDenominator" );
364+
QDomText minScaleText = doc.createTextNode( minScaleString );
365+
minScaleElem.appendChild( minScaleText );
366+
layerElem.appendChild( minScaleElem );
367+
QDomElement maxScaleElem = doc.createElement( "MaxScaleDenominator" );
368+
QDomText maxScaleText = doc.createTextNode( maxScaleString );
369+
maxScaleElem.appendChild( maxScaleText );
370+
layerElem.appendChild( maxScaleElem );
371+
}
372+
else if ( version == "1.1.1" )
373+
{
374+
QDomElement scaleHintElem = doc.createElement( "ScaleHint" );
375+
scaleHintElem.setAttribute( "min", minScaleString );
376+
scaleHintElem.setAttribute( "max", maxScaleString );
377+
layerElem.appendChild( scaleHintElem );
378+
}
379+
}
380+
354381
if ( fullProjectSettings )
355382
{
356383
addLayerProjectSettings( layerElem, doc, currentLayer );
@@ -377,6 +404,9 @@ void QgsProjectParser::addLayerProjectSettings( QDomElement& layerElem, QDomDocu
377404
{
378405
QgsVectorLayer* vLayer = static_cast<QgsVectorLayer*>( currentLayer );
379406

407+
//min/max scales for layer
408+
409+
380410
//attributes
381411
QDomElement attributesElem = doc.createElement( "Attributes" );
382412
const QgsFieldMap& layerFields = vLayer->pendingFields();

‎src/mapserver/qgsprojectparser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class QgsProjectParser: public QgsConfigParser
3737

3838
/**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.
3939
@param fullProjectInformation If true: add extended project information (does not validate against WMS schema)*/
40-
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings = false ) const;
40+
virtual void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;
4141

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

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

158159
static void addLayerProjectSettings( QDomElement& layerElem, QDomDocument& doc, QgsMapLayer* currentLayer );

‎src/mapserver/qgssldparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ int QgsSLDParser::numberOfLayers() const
140140
return ( userLayerList.size() + namedLayerList.size() );
141141
}
142142

143-
void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings ) const
143+
void QgsSLDParser::layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings ) const
144144
{
145145
//iterate over all <UserLayer> nodes
146146
if ( mXMLDoc )

‎src/mapserver/qgssldparser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class QgsSLDParser: public QgsConfigParser
5454
virtual ~QgsSLDParser();
5555

5656
/**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.*/
57-
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, bool fullProjectSettings = false ) const;
57+
void layersAndStylesCapabilities( QDomElement& parentElement, QDomDocument& doc, const QString& version, bool fullProjectSettings = false ) const;
5858

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

‎src/mapserver/qgswmsserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ QDomDocument QgsWMSServer::getCapabilities( QString version, bool fullProjectInf
215215
QgsDebugMsg( "calling layersAndStylesCapabilities" );
216216
if ( mConfigParser )
217217
{
218-
mConfigParser->layersAndStylesCapabilities( capabilityElement, doc, fullProjectInformation );
218+
mConfigParser->layersAndStylesCapabilities( capabilityElement, doc, version, fullProjectInformation );
219219
}
220220
QgsDebugMsg( "layersAndStylesCapabilities returned" );
221221

0 commit comments

Comments
 (0)
Please sign in to comment.