Showing with 6 additions and 42 deletions.
  1. +4 −40 src/mapserver/qgsprojectparser.cpp
  2. +2 −2 src/mapserver/qgswmsserver.cpp
44 changes: 4 additions & 40 deletions src/mapserver/qgsprojectparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1898,43 +1898,9 @@ int QgsProjectParser::layersAndStyles( QStringList& layers, QStringList& styles

QDomDocument QgsProjectParser::getStyle( const QString& styleName, const QString& layerName ) const
{
QDomDocument myDocument = QDomDocument();

QDomNode header = myDocument.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" );
myDocument.appendChild( header );

// Create the root element
QDomElement root = myDocument.createElementNS( "http://www.opengis.net/sld", "StyledLayerDescriptor" );
root.setAttribute( "version", "1.1.0" );
root.setAttribute( "xsi:schemaLocation", "http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" );
root.setAttribute( "xmlns:ogc", "http://www.opengis.net/ogc" );
root.setAttribute( "xmlns:se", "http://www.opengis.net/se" );
root.setAttribute( "xmlns:xlink", "http://www.w3.org/1999/xlink" );
root.setAttribute( "xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance" );
myDocument.appendChild( root );

QList<QgsMapLayer*> layerList = mapLayerFromStyle( layerName, styleName );
if ( layerList.size() < 1 )
{
throw QgsMapServiceException( "Error", QString( "The layer for the TypeName '%1' is not found" ).arg( layerName ) );
}

QgsMapLayer* currentLayer = layerList.at( 0 );
QgsVectorLayer* layer = dynamic_cast<QgsVectorLayer*>( currentLayer );
if ( !layer )
{
throw QgsMapServiceException( "Error", QString( "Could not get style because:\n%1" ).arg( "Non-vector layers not supported yet" ) );
}
// Create the NamedLayer element
QDomElement namedLayerNode = myDocument.createElement( "NamedLayer" );
root.appendChild( namedLayerNode );

QString errorMsg;
if ( !layer->writeSld( namedLayerNode, myDocument, errorMsg ) )
{
throw QgsMapServiceException( "Error", QString( "Could not get style because:\n%1" ).arg( errorMsg ) );
}
return myDocument;
QStringList layerList;
layerList.append( layerName );
return getStyles( layerList );
}

QDomDocument QgsProjectParser::getStyles( QStringList& layerList ) const
Expand All @@ -1957,10 +1923,8 @@ QDomDocument QgsProjectParser::getStyles( QStringList& layerList ) const
for ( int i = 0; i < layerList.size(); i++ )
{
QString layerName;
QString typeName;
layerName = layerList.at( i );
typeName = layerName.replace( " ", "_" );
QList<QgsMapLayer*> currentLayerList = mapLayerFromTypeName( typeName );
QList<QgsMapLayer*> currentLayerList = mapLayerFromStyle( layerName, "", true );
if ( currentLayerList.size() < 1 )
{
throw QgsMapServiceException( "Error", QString( "The layer for the TypeName '%1' is not found" ).arg( layerName ) );
Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@ bool QgsWMSServer::testFilterStringSafety( const QString& filter ) const

void QgsWMSServer::groupStringList( QStringList& list, const QString& groupString )
{
//group contens within single quotes together
//group contents within single quotes together
bool groupActive = false;
int startGroup = -1;
int endGroup = -1;
Expand Down Expand Up @@ -2090,7 +2090,7 @@ void QgsWMSServer::groupStringList( QStringList& list, const QString& groupStrin
list[startGroup] = concatString;
for ( int j = startGroup + 1; j <= endGroup; ++j )
{
list.removeAt( j );
list.removeAt( startGroup + 1 );
--i;
}
}
Expand Down