Skip to content

Commit

Permalink
Merge pull request #44072 from qgis/backport-43949-to-release-3_20
Browse files Browse the repository at this point in the history
[Backport release-3_20] Take tile_buffer parameter into consideration when rendering labels
  • Loading branch information
rldhont committed Jul 8, 2021
2 parents f76f3a1 + 2ca76a6 commit 0ba3aee
Show file tree
Hide file tree
Showing 6 changed files with 1,141 additions and 94 deletions.
5 changes: 4 additions & 1 deletion src/core/labeling/qgspallabeling.cpp
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/core/maprenderer/qgsmaprendererjob.cpp
Expand Up @@ -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() );
Expand Down
38 changes: 38 additions & 0 deletions tests/src/python/test_qgsserver_wms_getmap.py
Expand Up @@ -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
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0ba3aee

Please sign in to comment.