Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Apr 22, 2023
1 parent 4baab6d commit bb20f3d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Expand Up @@ -426,6 +426,8 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg

if ( fillOutlineColor.isValid() )
{
// mapbox fill strokes are always 1 px wide
fillSymbol->setStrokeWidth( 0 );
fillSymbol->setStrokeColor( fillOutlineColor );
}
else
Expand Down
18 changes: 18 additions & 0 deletions tests/src/python/test_qgsmapboxglconverter.py
Expand Up @@ -1061,6 +1061,24 @@ def testLabelWithStops(self):
self.assertTrue(labeling_style.labelSettings().isExpression)
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')

def testFillStroke(self):
context = QgsMapBoxGlStyleConversionContext()
style = {
"id": "Land/Not ice",
"type": "fill",
"source": "esri",
"source-layer": "Land",
"layout": {},
"paint": {
"fill-color": "rgb(71,179,18)",
}
}
has_renderer, renderer = QgsMapBoxGlStyleConverter.parseFillLayer(style, context)
self.assertTrue(has_renderer)

# mapbox fill strokes are always 1 px wide
self.assertEqual(renderer.symbol()[0].strokeWidth(), 0)

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

0 comments on commit bb20f3d

Please sign in to comment.