Skip to content
Permalink
Browse files

Scale up buffer sizes when converting, in order to better match actua…

…l MapBox rendering
  • Loading branch information
nyalldawson committed Sep 14, 2020
1 parent 37471e5 commit 09ea6bebb4cb2ffe50aaa9374e552801c6d200e2
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/core/vectortile/qgsmapboxglstyleconverter.cpp
@@ -859,25 +859,29 @@ void QgsMapBoxGlStyleConverter::parseSymbolLayer( const QVariantMap &jsonLayer,
}

double bufferSize = 0.0;
// the pixel based text buffers appear larger when rendered on the web - so automatically scale
// them up when converting to a QGIS style
// (this number is based on trial-and-error comparisons only!)
constexpr double BUFFER_SIZE_SCALE = 2.0;
if ( jsonPaint.contains( QStringLiteral( "text-halo-width" ) ) )
{
const QVariant jsonHaloWidth = jsonPaint.value( QStringLiteral( "text-halo-width" ) );
switch ( jsonHaloWidth.type() )
{
case QVariant::Int:
case QVariant::Double:
bufferSize = jsonHaloWidth.toDouble() * context.pixelSizeConversionFactor();
bufferSize = jsonHaloWidth.toDouble() * context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE;
break;

case QVariant::Map:
bufferSize = 1;
ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseInterpolateByZoom( jsonHaloWidth.toMap(), context, context.pixelSizeConversionFactor(), &bufferSize ) );
ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseInterpolateByZoom( jsonHaloWidth.toMap(), context, context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE, &bufferSize ) );
break;

case QVariant::List:
case QVariant::StringList:
bufferSize = 1;
ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseValueList( jsonHaloWidth.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor(), 255, nullptr, &bufferSize ) );
ddLabelProperties.setProperty( QgsPalLayerSettings::BufferSize, parseValueList( jsonHaloWidth.toList(), PropertyType::Numeric, context, context.pixelSizeConversionFactor() * BUFFER_SIZE_SCALE, 255, nullptr, &bufferSize ) );
break;

default:

0 comments on commit 09ea6be

Please sign in to comment.
You can’t perform that action at this time.