Skip to content
Permalink
Browse files

Initial GetStyles implementation, still segfaults

  • Loading branch information
elpaso committed Jan 6, 2014
1 parent 0ae2b1a commit 25cdea12c3f3d61337a8d256099c7a44926890cd
@@ -692,7 +692,7 @@ int main( int argc, char * argv[] )
delete theServer;
continue;
}
else if ( request.compare( "GetStyles", Qt::CaseInsensitive ) == 0 || request.compare( "GetStyle", Qt::CaseInsensitive ) == 0 ) // GetStyle for compatibility with earlier QGIS versions
else if ( request.compare( "GetStyle", Qt::CaseInsensitive ) == 0 ) // GetStyle for compatibility with earlier QGIS versions
{
try
{
@@ -708,6 +708,27 @@ int main( int argc, char * argv[] )
delete theServer;
continue;
}
else if ( request.compare( "GetStyles", Qt::CaseInsensitive ) == 0 )
{
// GetStyles is only defined for WMS1.1.1/SLD1.0
if ( version != "1.1.1") {
theRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "GetStyles is only available in WMS version 1.1.1" ) );
} else {
try
{
QDomDocument doc = theServer->getStyles();
theRequestHandler->sendGetStyleResponse( doc );
}
catch ( QgsMapServiceException& ex )
{
theRequestHandler->sendServiceException( ex );
}
}

delete theRequestHandler;
delete theServer;
continue;
}
else if ( request.compare( "GetLegendGraphic", Qt::CaseInsensitive ) == 0 ||
request.compare( "GetLegendGraphics", Qt::CaseInsensitive ) == 0 )
// GetLegendGraphics for compatibility with earlier QGIS versions
@@ -78,6 +78,8 @@ class QgsConfigParser

/**Returns the xml fragment of a style*/
virtual QDomDocument getStyle( const QString& styleName, const QString& layerName ) const = 0;
/**Returns the xml fragment of layer styles*/
virtual QDomDocument getStyles( QStringList& layerList ) const = 0;

/**Returns the names of the published wfs layers (not the ids as in wfsLayers() )*/
virtual QStringList wfsLayerNames() const { return QStringList(); }
@@ -1924,6 +1924,14 @@ QDomDocument QgsProjectParser::getStyle( const QString& styleName, const QString
return myDocument;
}

QDomDocument QgsProjectParser::getStyles( QStringList& layerList ) const
{
QDomDocument myDocument = QDomDocument();
return myDocument;
}



QgsMapRenderer::OutputUnits QgsProjectParser::outputUnits() const
{
return QgsMapRenderer::Millimeters;
@@ -71,6 +71,9 @@ class QgsProjectParser: public QgsConfigParser

/**Returns the xml fragment of a style*/
virtual QDomDocument getStyle( const QString& styleName, const QString& layerName ) const;
/**Returns the xml fragment of layers styles*/
virtual QDomDocument getStyles( QStringList& layerList ) const;


/**Returns if output are MM or PIXEL*/
virtual QgsMapRenderer::OutputUnits outputUnits() const;
@@ -1412,6 +1412,36 @@ QDomDocument QgsSLDParser::getStyle( const QString& styleName, const QString& la
return styleDoc;
}

// TODO: support multiple layers
QDomDocument QgsSLDParser::getStyles( QStringList& layerList ) const
{
if ( layerList.size() < 1)
{
throw QgsMapServiceException( "LayerNotDefined", "Layer list is empty." );
}

// TODO: loop
QString layerName = layerList.at(0);

QDomElement userLayerElement = findUserLayerElement( layerName );

if ( userLayerElement.isNull() )
{
throw QgsMapServiceException( "LayerNotDefined", "Operation request is for a Layer not offered by the server." );
}

QDomElement userStyleElement = findUserStyleElement( userLayerElement, "" );

if ( userStyleElement.isNull() )
{
throw QgsMapServiceException( "StyleNotDefined", "Operation request references a Style not offered by the server." );
}

QDomDocument styleDoc;
styleDoc.appendChild( styleDoc.importNode( userStyleElement, true ) );
return styleDoc;
}

QString QgsSLDParser::layerNameFromUri( const QString& uri ) const
{
//file based?
@@ -77,6 +77,8 @@ class QgsSLDParser: public QgsConfigParser

/**Returns the xml fragment of a style*/
QDomDocument getStyle( const QString& styleName, const QString& layerName ) const;
/**Returns the xml fragment of layers styles*/
QDomDocument getStyles( QStringList& layerList ) const;

virtual void setParameterMap( const QMap<QString, QString>& parameterMap ) { mParameterMap = parameterMap; }

Binary file not shown.
@@ -601,6 +601,26 @@ QDomDocument QgsWMSServer::getStyle()
return mConfigParser->getStyle( styleName, layerName );
}

// GetStyles is only defined for WMS1.1.1/SLD1.0
QDomDocument QgsWMSServer::getStyles()
{

QDomDocument doc;

if ( !mParameterMap.contains( "LAYERS" ) )
{
throw QgsMapServiceException( "LayerNotSpecified", "Layers is mandatory for GetStyles operation" );
}

QStringList layersList = mParameterMap[ "LAYERS" ].split( ",", QString::SkipEmptyParts );
if ( layersList.size() < 1 )
{
throw QgsMapServiceException( "LayerNotSpecified", "Layers is mandatory for GetStyles operation" );
}

return mConfigParser->getStyles( layersList );
}

QByteArray* QgsWMSServer::getPrint( const QString& formatString )
{
QStringList layersList, stylesList, layerIdList;
@@ -72,6 +72,8 @@ class QgsWMSServer
QImage* getMap();
/**Returns an SLD file with the style of the requested layer. Exception is raised in case of troubles :-)*/
QDomDocument getStyle();
/**Returns an SLD file with the styles of the requested layers. Exception is raised in case of troubles :-)*/
QDomDocument getStyles();

/**Returns printed page as binary
@param formatString out: format of the print output (e.g. pdf, svg, png, ...)

0 comments on commit 25cdea1

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