Skip to content
Permalink
Browse files

wms server: call getStyles from getStyle

  • Loading branch information
mhugent committed Jan 12, 2014
1 parent b6f9ddc commit f59f07774045fae3357a644761f132c8eb89191b
Showing with 3 additions and 37 deletions.
  1. +3 −37 src/mapserver/qgsprojectparser.cpp
@@ -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

0 comments on commit f59f077

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