Skip to content
Permalink
Browse files

WMS server: report crs systems in the order given in the project

  • Loading branch information
marco
marco committed Aug 30, 2011
1 parent 1e7c8a7 commit 7deb0c977c552e4c0451fc9de897bafff7db45cd
@@ -256,20 +256,38 @@ void QgsConfigParser::appendCRSElementsToLayer( QDomElement& layerElement, QDomD
QDomElement titleElement = layerElement.firstChildElement( "Title" );

//In case the number of advertised CRS is constrained
QSet<QString> crsSet = supportedOutputCrsSet();

QStringList::const_iterator crsIt = crsList.constBegin();
for ( ; crsIt != crsList.constEnd(); ++crsIt )
QStringList constrainedCrsList = supportedOutputCrsList();
if ( constrainedCrsList.size() > 0 )
{
if ( !crsSet.isEmpty() && !crsSet.contains( *crsIt ) ) //consider epsg output constraint
for ( int i = constrainedCrsList.size() - 1; i >= 0; --i )
{
continue;
appendCRSElementToLayer( layerElement, titleElement, constrainedCrsList.at( i ), doc );
/*QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( constrainedCrsList.at( i ) );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );*/
}
QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( *crsIt );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );
}
else //no crs constraint
{
QStringList::const_iterator crsIt = crsList.constBegin();
for ( ; crsIt != crsList.constEnd(); ++crsIt )
{
appendCRSElementToLayer( layerElement, titleElement, *crsIt, doc );
/*QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsText = doc.createTextNode( *crsIt );
crsElement.appendChild( crsText );
layerElement.insertAfter( crsElement, titleElement );*/
}
}
}

void QgsConfigParser::appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& titleElement, const QString& crsText, QDomDocument& doc ) const
{
QDomElement crsElement = doc.createElement( "CRS" );
QDomText crsTextNode = doc.createTextNode( crsText );
crsElement.appendChild( crsTextNode );
layerElement.insertAfter( crsElement, titleElement );
}

QgsComposition* QgsConfigParser::createPrintComposition( const QString& composerTemplate, QgsMapRenderer* mapRenderer, const QMap< QString, QString >& parameterMap ) const
@@ -85,9 +85,9 @@ class QgsConfigParser
/**Returns an ID-list of layers which are not queryable*/
virtual QStringList identifyDisabledLayers() const { return QStringList(); }

/**Returns a set of supported epsg codes for the capabilities document. An empty set means
/**Returns a set of supported epsg codes for the capabilities document. An empty list means
that all possible CRS should be advertised (which could result in very long capabilities documents)*/
virtual QSet<QString> supportedOutputCrsSet() const { return QSet<QString>(); }
virtual QStringList supportedOutputCrsList() const { return QStringList(); }

/**True if the feature info response should contain the wkt geometry for vector features*/
virtual bool featureInfoWithWktGeometry() const { return false; }
@@ -153,6 +153,7 @@ class QgsConfigParser
@return true in case of success*/
bool crsSetForLayer( const QDomElement& layerElement, QSet<QString> &crsSet ) const;
void appendCRSElementsToLayer( QDomElement& layerElement, QDomDocument& doc, const QStringList &crsList ) const;
void appendCRSElementToLayer( QDomElement& layerElement, const QDomElement& titleElement, const QString& crsText, QDomDocument& doc ) const;

void setDefaultLegendSettings();
};
@@ -521,39 +521,39 @@ QStringList QgsProjectParser::identifyDisabledLayers() const
return disabledList;
}

QSet<QString> QgsProjectParser::supportedOutputCrsSet() const
QStringList QgsProjectParser::supportedOutputCrsList() const
{
QSet<QString> crsSet;
QStringList crsList;
if ( !mXMLDoc )
{
return crsSet;
return crsList;
}

QDomElement qgisElem = mXMLDoc->documentElement();
if ( qgisElem.isNull() )
{
return crsSet;
return crsList;
}
QDomElement propertiesElem = qgisElem.firstChildElement( "properties" );
if ( propertiesElem.isNull() )
{
return crsSet;
return crsList;
}
QDomElement wmsCrsElem = propertiesElem.firstChildElement( "WMSCrsList" );
if ( !wmsCrsElem.isNull() )
{
QDomNodeList valueList = wmsCrsElem.elementsByTagName( "value" );
for ( int i = 0; i < valueList.size(); ++i )
{
crsSet.insert( valueList.at( i ).toElement().text() );
crsList.append( valueList.at( i ).toElement().text() );
}
}
else
{
QDomElement wmsEpsgElem = propertiesElem.firstChildElement( "WMSEpsgList" );
if ( wmsEpsgElem.isNull() )
{
return crsSet;
return crsList;
}
QDomNodeList valueList = wmsEpsgElem.elementsByTagName( "value" );
bool conversionOk;
@@ -562,12 +562,12 @@ QSet<QString> QgsProjectParser::supportedOutputCrsSet() const
int epsgNr = valueList.at( i ).toElement().text().toInt( &conversionOk );
if ( conversionOk )
{
crsSet.insert( QString( "EPSG:%1" ).arg( epsgNr ) );
crsList.append( QString( "EPSG:%1" ).arg( epsgNr ) );
}
}
}

return crsSet;
return crsList;
}

bool QgsProjectParser::featureInfoWithWktGeometry() const
@@ -69,7 +69,7 @@ class QgsProjectParser: public QgsConfigParser
</WMSEpsgList>
</properties>
*/
virtual QSet<QString> supportedOutputCrsSet() const;
virtual QStringList supportedOutputCrsList() const;

/**True if the feature info response should contain the wkt geometry for vector features*/
virtual bool featureInfoWithWktGeometry() const;

0 comments on commit 7deb0c9

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