Skip to content

Commit

Permalink
[mvt] fix scaled icon size (qgis#58640)
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and notguiltyspark committed Sep 24, 2024
1 parent 51738a2 commit 4148cba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,9 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
const QString sprite = retrieveSpriteAsBase64WithProperties( jsonLayout.value( QStringLiteral( "icon-image" ) ), context, spriteSize, spriteProperty, spriteSizeProperty );
if ( !sprite.isEmpty() )
{
if ( jsonLayout.contains( QStringLiteral( "icon-size" ) ) )
spriteSize = spriteSize * jsonLayout.value( QStringLiteral( "icon-image" ) ).toDouble();

QgsRasterMarkerSymbolLayer *markerLayer = new QgsRasterMarkerSymbolLayer( );
markerLayer->setPath( sprite );
markerLayer->setSize( spriteSize.width() );
Expand Down
22 changes: 22 additions & 0 deletions tests/src/python/test_qgsmapboxglconverter.py
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,28 @@ def testDataDefinedIconRotate(self):
prop = dd_props.property(QgsSymbolLayer.Property.PropertyAngle)
self.assertEqual(prop.asExpression(), '"ROTATION"')

def testScaledIcon(self):
""" Test icon-rotate property that depends on a data attribute """
context = QgsMapBoxGlStyleConversionContext()

image = QImage(QSize(1, 1), QImage.Format.Format_ARGB32)
context.setSprites(image, {"foo": {"x": 0, "y": 0, "width": 2, "height": 2, "pixelRatio": 1}})
style = {
"layout": {
"icon-image": "{foo}",
"text-size": 11,
"icon-size": 2
},
"type": "symbol",
"id": "poi_label",
"source-layer": "poi_label"
}
renderer, has_renderer, labeling, has_labeling = QgsMapBoxGlStyleConverter.parseSymbolLayer(style, context)
self.assertTrue(has_renderer)
self.assertFalse(has_labeling)
size = renderer.symbol().symbolLayers()[0].size()
self.assertEqual(size, 4)

def testCircleLayer(self):
context = QgsMapBoxGlStyleConversionContext()
style = {
Expand Down

0 comments on commit 4148cba

Please sign in to comment.