Skip to content
Permalink
Browse files
Fixes #37945 : Take tile_buffer parameter into consideration when
rendering labels
  • Loading branch information
troopa81 committed Jun 30, 2021
1 parent 8cb816f commit cf01b4377d0d9021766f4a2ce902ceea4a5e9e86
@@ -456,7 +456,10 @@ bool QgsPalLayerSettings::prepare( QgsRenderContext &context, QSet<QString> &att
ptOne = xform->toMapCoordinates( 1, 0 );

// rect for clipping
extentGeom = QgsGeometry::fromRect( mapSettings.visibleExtent() );
QgsRectangle r1 = mapSettings.visibleExtent();
r1.grow( mapSettings.extentBuffer() );
extentGeom = QgsGeometry::fromRect( r1 );

if ( !qgsDoubleNear( mapSettings.rotation(), 0.0 ) )
{
//PAL features are prerotated, so extent also needs to be unrotated
@@ -688,7 +688,11 @@ LabelRenderJob QgsMapRendererJob::prepareLabelingJob( QPainter *painter, QgsLabe
job.context = QgsRenderContext::fromMapSettings( mSettings );
job.context.setPainter( painter );
job.context.setLabelingEngine( labelingEngine2 );

QgsRectangle r1 = mSettings.visibleExtent();
r1.grow( mSettings.extentBuffer() );
job.context.setExtent( mSettings.visibleExtent() );

job.context.setFeatureFilterProvider( mFeatureFilterProvider );
QgsCoordinateTransform ct;
ct.setDestinationCrs( mSettings.destinationCrs() );
@@ -1768,6 +1768,44 @@ def test_wms_getmap_tile_buffer(self):
r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Tiled_True")

# Check with labels and tiled=false
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(
os.path.join(self.testdata_path, 'wms_tile_buffer.qgs')),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetMap",
"BBOX": "310187,6163153,324347,6177313",
"CRS": "EPSG:3857",
"WIDTH": "512",
"HEIGHT": "512",
"LAYERS": "wms_tile_buffer_labels",
"FORMAT": "image/png",
"TILED": "false"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Tiled_Labels_False")

# Check with labels and tiled=true
qs = "?" + "&".join(["%s=%s" % i for i in list({
"MAP": urllib.parse.quote(
os.path.join(self.testdata_path, 'wms_tile_buffer.qgs')),
"SERVICE": "WMS",
"VERSION": "1.3.0",
"REQUEST": "GetMap",
"BBOX": "310187,6163153,324347,6177313",
"CRS": "EPSG:3857",
"WIDTH": "512",
"HEIGHT": "512",
"LAYERS": "wms_tile_buffer_labels",
"FORMAT": "image/png",
"TILED": "true"
}.items())])

r, h = self._result(self._execute_request(qs))
self._img_diff_error(r, h, "WMS_GetMap_Tiled_Labels_True")

@unittest.skipIf(os.getenv('QGIS_CONTINUOUS_INTEGRATION_RUN'), "This tests fails on GH workflow")
def test_mode8bit_with_transparency(self):
# 8 bits
Binary file not shown.
Binary file not shown.

0 comments on commit cf01b43

Please sign in to comment.