Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix DPI on getLegendGraphic concerning a RULE. It should not take the…
… context settings according to the mapSettings since it NEVER has a BBOX (since of RULE)
  • Loading branch information
signedav authored and nyalldawson committed Apr 1, 2023
1 parent f926eb4 commit fd55a84
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/server/services/wms/qgswmsrenderer.cpp
Expand Up @@ -209,6 +209,18 @@ namespace QgsWms
QgsLegendSettings settings = legendSettings();
QgsLayerTreeModelLegendNode::ItemContext ctx;
ctx.painter = painter.get();

// create context
QgsRenderContext context = QgsRenderContext::fromQPainter( painter.get() );
context.setScaleFactor( mContext.dotsPerMm() );
const double mmPerMapUnit = 1 / QgsServerProjectUtils::wmsDefaultMapUnitsPerMm( *mProject );
context.setMapToPixel( QgsMapToPixel( 1 / ( mmPerMapUnit * context.scaleFactor() ) ) );
QgsDistanceArea distanceArea = QgsDistanceArea();
distanceArea.setSourceCrs( QgsCoordinateReferenceSystem( mWmsParameters.crs() ), mProject->transformContext() );
distanceArea.setEllipsoid( geoNone() );
context.setDistanceArea( distanceArea );
ctx.context = &context;

nodeModel.drawSymbol( settings, &ctx, size.height() / dpmm );
painter->end();

Expand Down

0 comments on commit fd55a84

Please sign in to comment.