Skip to content

Commit ece2fb9

Browse files
committedApr 24, 2023
Fix stroke width conversion from mapbox styles
Mapbox fill strokes are always 1px in width, so we should translate these to hairline strokes in QGIS
1 parent 539d207 commit ece2fb9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 

‎src/core/vectortile/qgsmapboxglstyleconverter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
426426

427427
if ( fillOutlineColor.isValid() )
428428
{
429+
// mapbox fill strokes are always 1 px wide
430+
fillSymbol->setStrokeWidth( 0 );
429431
fillSymbol->setStrokeColor( fillOutlineColor );
430432
}
431433
else

‎tests/src/python/test_qgsmapboxglconverter.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,24 @@ def testLabelWithStops(self):
10611061
self.assertTrue(labeling_style.labelSettings().isExpression)
10621062
self.assertEqual(labeling_style.labelSettings().fieldName, 'CASE WHEN @vector_tile_zoom > 6 AND @vector_tile_zoom < 15 THEN concat(\'my \',"class",\' and \',"stuff") WHEN @vector_tile_zoom >= 15 THEN concat(\'my \',"class",\' and \',"stuff") ELSE \'\' END')
10631063

1064+
def testFillStroke(self):
1065+
context = QgsMapBoxGlStyleConversionContext()
1066+
style = {
1067+
"id": "Land/Not ice",
1068+
"type": "fill",
1069+
"source": "esri",
1070+
"source-layer": "Land",
1071+
"layout": {},
1072+
"paint": {
1073+
"fill-color": "rgb(71,179,18)",
1074+
}
1075+
}
1076+
has_renderer, renderer = QgsMapBoxGlStyleConverter.parseFillLayer(style, context)
1077+
self.assertTrue(has_renderer)
1078+
1079+
# mapbox fill strokes are always 1 px wide
1080+
self.assertEqual(renderer.symbol()[0].strokeWidth(), 0)
1081+
10641082
def testFillOpacityWithStops(self):
10651083
context = QgsMapBoxGlStyleConversionContext()
10661084
style = {

0 commit comments

Comments
 (0)
Please sign in to comment.