Skip to content
Permalink
Browse files

Fix #10518, PAL engine settings no longer honored by qgis_mapserv

  • Loading branch information
dakcarto authored and mhugent committed Jun 11, 2014
1 parent f04ea99 commit 1bab1414e24bfa6596e0396ac2cdb3a27eeeb6b7
@@ -389,7 +389,6 @@ int main( int argc, char * argv[] )
theRequestHandler->sendServiceException( QgsMapServiceException( "WMS configuration error", "There was an error reading the project file or the SLD configuration" ) );
continue;
}
//adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() );
QgsWMSServer wmsServer( configFilePath, parameterMap, p, theRequestHandler.take(), theMapRenderer.data(), &capabilitiesCache );
wmsServer.executeRequest();
}
@@ -533,8 +533,9 @@ void QgsSLDConfigParser::drawOverlays( QPainter *, int , int, int ) const
//todo: fixme
}

void QgsSLDConfigParser::loadLabelSettings( QgsLabelingEngineInterface * )
void QgsSLDConfigParser::loadLabelSettings( QgsLabelingEngineInterface * lbl ) const
{
Q_UNUSED ( lbl );
//needs to be here?
}

@@ -76,8 +76,8 @@ class QgsSLDConfigParser: public QgsWMSConfigParser
/**Draw text annotation items from the QGIS projectfile*/
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;

//todo: fixme
void loadLabelSettings( QgsLabelingEngineInterface* lbl );
/**Load PAL engine settings from projectfile*/
void loadLabelSettings( QgsLabelingEngineInterface* lbl ) const;

QString serviceUrl() const;

@@ -74,8 +74,8 @@ class QgsWMSConfigParser
/**Draw text annotation items from the QGIS projectfile*/
virtual void drawOverlays( QPainter* p, int dpi, int width, int height ) const = 0;

//todo: fixme
virtual void loadLabelSettings( QgsLabelingEngineInterface* lbl ) { Q_UNUSED( lbl ); } //= 0;
/**Load PAL engine settings from the QGIS projectfile*/
virtual void loadLabelSettings( QgsLabelingEngineInterface* lbl ) const = 0;

virtual QString serviceUrl() const = 0;

@@ -21,6 +21,7 @@
#include "qgslogger.h"
#include "qgsmaplayer.h"
#include "qgsmapserviceexception.h"
#include "qgspallabeling.h"
#include "qgsvectorlayer.h"

#include "qgscomposition.h"
@@ -1751,6 +1752,77 @@ void QgsWMSProjectParser::drawOverlays( QPainter* p, int dpi, int width, int hei
}
}

void QgsWMSProjectParser::loadLabelSettings( QgsLabelingEngineInterface* lbl ) const
{
QgsPalLabeling* pal = dynamic_cast<QgsPalLabeling*>( lbl );
if ( pal )
{
QDomElement propertiesElem = mProjectParser.propertiesElem();
if ( propertiesElem.isNull() )
{
return;
}

QDomElement palElem = propertiesElem.firstChildElement( "PAL" );
if ( palElem.isNull() )
{
return;
}

//pal::Pal default positions for candidates;
int candPoint, candLine, candPoly;
pal->numCandidatePositions( candPoint, candLine, candPoly );

//mCandPoint
QDomElement candPointElem = palElem.firstChildElement( "CandidatesPoint" );
if ( !candPointElem.isNull() )
{
candPoint = candPointElem.text().toInt();
}

//mCandLine
QDomElement candLineElem = palElem.firstChildElement( "CandidatesLine" );
if ( !candLineElem.isNull() )
{
candLine = candLineElem.text().toInt();
}

//mCandPolygon
QDomElement candPolyElem = palElem.firstChildElement( "CandidatesPolygon" );
if ( !candPolyElem.isNull() )
{
candPoly = candPolyElem.text().toInt();
}

pal->setNumCandidatePositions( candPoint, candLine, candPoly );

//mShowingCandidates
QDomElement showCandElem = palElem.firstChildElement( "ShowingCandidates" );
if ( !showCandElem.isNull() )
{
pal->setShowingCandidates( showCandElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

//mShowingAllLabels
QDomElement showAllLabelsElem = palElem.firstChildElement( "ShowingAllLabels" );
if ( !showAllLabelsElem.isNull() )
{
pal->setShowingAllLabels( showAllLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

//mShowingPartialsLabels
QDomElement showPartialsLabelsElem = palElem.firstChildElement( "ShowingPartialsLabels" );
if ( !showPartialsLabelsElem.isNull() )
{
pal->setShowingPartialsLabels( showPartialsLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
}

//mDrawOutlineLabels
// TODO: This should probably always be true (already default) for WMS, regardless of any project setting.
// Not much sense to output text-as-text, when text-as-outlines gives better results.
}
}

int QgsWMSProjectParser::nLayers() const
{
return mProjectParser.numberOfLayers();
@@ -98,6 +98,9 @@ class QgsWMSProjectParser: public QgsWMSConfigParser
/**Draw text annotation items from the QGIS projectfile*/
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;

/**Load PAL engine settings from projectfile*/
void loadLabelSettings( QgsLabelingEngineInterface* lbl ) const;

int nLayers() const;

void serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;
@@ -999,6 +999,11 @@ QImage* QgsWMSServer::getMap()

applyOpacities( layersList, bkVectorRenderers, bkRasterRenderers, labelTransparencies, labelBufferTransparencies );

if ( mConfigParser )
{
mConfigParser->loadLabelSettings( mMapRenderer->labelingEngine() );
}

mMapRenderer->render( &thePainter );
if ( mConfigParser )
{

0 comments on commit 1bab141

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