Skip to content

Commit 8cd44fc

Browse files
committedApr 22, 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 8b7bfbf commit 8cd44fc

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
@@ -436,6 +436,8 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
436436

437437
if ( fillOutlineColor.isValid() )
438438
{
439+
// mapbox fill strokes are always 1 px wide
440+
fillSymbol->setStrokeWidth( 0 );
439441
fillSymbol->setStrokeColor( fillOutlineColor );
440442
}
441443
else

‎tests/src/python/test_qgsmapboxglconverter.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,24 @@ def testLabelWithStops(self):
11271127
self.assertTrue(labeling_style.labelSettings().isExpression)
11281128
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')
11291129

1130+
def testFillStroke(self):
1131+
context = QgsMapBoxGlStyleConversionContext()
1132+
style = {
1133+
"id": "Land/Not ice",
1134+
"type": "fill",
1135+
"source": "esri",
1136+
"source-layer": "Land",
1137+
"layout": {},
1138+
"paint": {
1139+
"fill-color": "rgb(71,179,18)",
1140+
}
1141+
}
1142+
has_renderer, renderer = QgsMapBoxGlStyleConverter.parseFillLayer(style, context)
1143+
self.assertTrue(has_renderer)
1144+
1145+
# mapbox fill strokes are always 1 px wide
1146+
self.assertEqual(renderer.symbol()[0].strokeWidth(), 0)
1147+
11301148
def testFillOpacityWithStops(self):
11311149
context = QgsMapBoxGlStyleConversionContext()
11321150
style = {

0 commit comments

Comments
 (0)
Please sign in to comment.