Skip to content

Commit 1bab141

Browse files
dakcartomhugent
authored andcommitted
Fix #10518, PAL engine settings no longer honored by qgis_mapserv
1 parent f04ea99 commit 1bab141

File tree

7 files changed

+86
-6
lines changed

7 files changed

+86
-6
lines changed

src/mapserver/qgis_map_serv.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ int main( int argc, char * argv[] )
389389
theRequestHandler->sendServiceException( QgsMapServiceException( "WMS configuration error", "There was an error reading the project file or the SLD configuration" ) );
390390
continue;
391391
}
392-
//adminConfigParser->loadLabelSettings( theMapRenderer->labelingEngine() );
393392
QgsWMSServer wmsServer( configFilePath, parameterMap, p, theRequestHandler.take(), theMapRenderer.data(), &capabilitiesCache );
394393
wmsServer.executeRequest();
395394
}

src/mapserver/qgssldconfigparser.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ void QgsSLDConfigParser::drawOverlays( QPainter *, int , int, int ) const
533533
//todo: fixme
534534
}
535535

536-
void QgsSLDConfigParser::loadLabelSettings( QgsLabelingEngineInterface * )
536+
void QgsSLDConfigParser::loadLabelSettings( QgsLabelingEngineInterface * lbl ) const
537537
{
538+
Q_UNUSED ( lbl );
538539
//needs to be here?
539540
}
540541

src/mapserver/qgssldconfigparser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class QgsSLDConfigParser: public QgsWMSConfigParser
7676
/**Draw text annotation items from the QGIS projectfile*/
7777
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;
7878

79-
//todo: fixme
80-
void loadLabelSettings( QgsLabelingEngineInterface* lbl );
79+
/**Load PAL engine settings from projectfile*/
80+
void loadLabelSettings( QgsLabelingEngineInterface* lbl ) const;
8181

8282
QString serviceUrl() const;
8383

src/mapserver/qgswmsconfigparser.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class QgsWMSConfigParser
7474
/**Draw text annotation items from the QGIS projectfile*/
7575
virtual void drawOverlays( QPainter* p, int dpi, int width, int height ) const = 0;
7676

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

8080
virtual QString serviceUrl() const = 0;
8181

src/mapserver/qgswmsprojectparser.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "qgslogger.h"
2222
#include "qgsmaplayer.h"
2323
#include "qgsmapserviceexception.h"
24+
#include "qgspallabeling.h"
2425
#include "qgsvectorlayer.h"
2526

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

1755+
void QgsWMSProjectParser::loadLabelSettings( QgsLabelingEngineInterface* lbl ) const
1756+
{
1757+
QgsPalLabeling* pal = dynamic_cast<QgsPalLabeling*>( lbl );
1758+
if ( pal )
1759+
{
1760+
QDomElement propertiesElem = mProjectParser.propertiesElem();
1761+
if ( propertiesElem.isNull() )
1762+
{
1763+
return;
1764+
}
1765+
1766+
QDomElement palElem = propertiesElem.firstChildElement( "PAL" );
1767+
if ( palElem.isNull() )
1768+
{
1769+
return;
1770+
}
1771+
1772+
//pal::Pal default positions for candidates;
1773+
int candPoint, candLine, candPoly;
1774+
pal->numCandidatePositions( candPoint, candLine, candPoly );
1775+
1776+
//mCandPoint
1777+
QDomElement candPointElem = palElem.firstChildElement( "CandidatesPoint" );
1778+
if ( !candPointElem.isNull() )
1779+
{
1780+
candPoint = candPointElem.text().toInt();
1781+
}
1782+
1783+
//mCandLine
1784+
QDomElement candLineElem = palElem.firstChildElement( "CandidatesLine" );
1785+
if ( !candLineElem.isNull() )
1786+
{
1787+
candLine = candLineElem.text().toInt();
1788+
}
1789+
1790+
//mCandPolygon
1791+
QDomElement candPolyElem = palElem.firstChildElement( "CandidatesPolygon" );
1792+
if ( !candPolyElem.isNull() )
1793+
{
1794+
candPoly = candPolyElem.text().toInt();
1795+
}
1796+
1797+
pal->setNumCandidatePositions( candPoint, candLine, candPoly );
1798+
1799+
//mShowingCandidates
1800+
QDomElement showCandElem = palElem.firstChildElement( "ShowingCandidates" );
1801+
if ( !showCandElem.isNull() )
1802+
{
1803+
pal->setShowingCandidates( showCandElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
1804+
}
1805+
1806+
//mShowingAllLabels
1807+
QDomElement showAllLabelsElem = palElem.firstChildElement( "ShowingAllLabels" );
1808+
if ( !showAllLabelsElem.isNull() )
1809+
{
1810+
pal->setShowingAllLabels( showAllLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
1811+
}
1812+
1813+
//mShowingPartialsLabels
1814+
QDomElement showPartialsLabelsElem = palElem.firstChildElement( "ShowingPartialsLabels" );
1815+
if ( !showPartialsLabelsElem.isNull() )
1816+
{
1817+
pal->setShowingPartialsLabels( showPartialsLabelsElem.text().compare( "true", Qt::CaseInsensitive ) == 0 );
1818+
}
1819+
1820+
//mDrawOutlineLabels
1821+
// TODO: This should probably always be true (already default) for WMS, regardless of any project setting.
1822+
// Not much sense to output text-as-text, when text-as-outlines gives better results.
1823+
}
1824+
}
1825+
17541826
int QgsWMSProjectParser::nLayers() const
17551827
{
17561828
return mProjectParser.numberOfLayers();

src/mapserver/qgswmsprojectparser.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ class QgsWMSProjectParser: public QgsWMSConfigParser
9898
/**Draw text annotation items from the QGIS projectfile*/
9999
void drawOverlays( QPainter* p, int dpi, int width, int height ) const;
100100

101+
/**Load PAL engine settings from projectfile*/
102+
void loadLabelSettings( QgsLabelingEngineInterface* lbl ) const;
103+
101104
int nLayers() const;
102105

103106
void serviceCapabilities( QDomElement& parentElement, QDomDocument& doc ) const;

src/mapserver/qgswmsserver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,11 @@ QImage* QgsWMSServer::getMap()
999999

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

1002+
if ( mConfigParser )
1003+
{
1004+
mConfigParser->loadLabelSettings( mMapRenderer->labelingEngine() );
1005+
}
1006+
10021007
mMapRenderer->render( &thePainter );
10031008
if ( mConfigParser )
10041009
{

0 commit comments

Comments
 (0)