Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 1bab141
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/mapserver/qgis_map_serv.cpp
Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion src/mapserver/qgssldconfigparser.cpp
Expand Up @@ -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?
}

Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgssldconfigparser.h
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/mapserver/qgswmsconfigparser.h
Expand Up @@ -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;

Expand Down
72 changes: 72 additions & 0 deletions src/mapserver/qgswmsprojectparser.cpp
Expand Up @@ -21,6 +21,7 @@
#include "qgslogger.h"
#include "qgsmaplayer.h"
#include "qgsmapserviceexception.h"
#include "qgspallabeling.h"
#include "qgsvectorlayer.h"

#include "qgscomposition.h"
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions src/mapserver/qgswmsprojectparser.h
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/mapserver/qgswmsserver.cpp
Expand Up @@ -999,6 +999,11 @@ QImage* QgsWMSServer::getMap()

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

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

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

0 comments on commit 1bab141

Please sign in to comment.