Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Convert interpolated fill pattern sprites
  • Loading branch information
nirvn authored and nyalldawson committed Sep 13, 2020
1 parent 73e73c0 commit b898ec2
Showing 1 changed file with 15 additions and 33 deletions.
48 changes: 15 additions & 33 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Expand Up @@ -325,46 +325,28 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
// String: {"fill-pattern": "dash-t"}
// Object: {"fill-pattern":{"stops":[[11,"wetland8"],[12,"wetland16"]]}}

switch ( fillPatternJson.type() )
QSize spriteSize;
QString spriteProperty, spriteSizeProperty;
const QString sprite = retrieveSpriteAsBase64( fillPatternJson, context, spriteSize, spriteProperty, spriteSizeProperty );
if ( !sprite.isEmpty() )
{
case QVariant::String:
{
QSize spriteSize;
QString spriteProperty, spriteSizeProperty;
const QString sprite = retrieveSpriteAsBase64( fillPatternJson, context, spriteSize, spriteProperty, spriteSizeProperty );
if ( !sprite.isEmpty() )
{
// when fill-pattern exists, set and insert QgsRasterFillSymbolLayer
QgsRasterFillSymbolLayer *rasterFill = new QgsRasterFillSymbolLayer();
rasterFill->setImageFilePath( sprite );
rasterFill->setCoordinateMode( QgsRasterFillSymbolLayer::Viewport );

if ( rasterOpacity >= 0 )
rasterFill->setOpacity( rasterOpacity );
rasterFill->setDataDefinedProperties( ddRasterProperties );
// when fill-pattern exists, set and insert QgsRasterFillSymbolLayer
QgsRasterFillSymbolLayer *rasterFill = new QgsRasterFillSymbolLayer();
rasterFill->setImageFilePath( sprite );
rasterFill->setCoordinateMode( QgsRasterFillSymbolLayer::Viewport );

symbol->appendSymbolLayer( rasterFill );
}
break;
if ( rasterOpacity >= 0 )
{
rasterFill->setOpacity( rasterOpacity );
}

case QVariant::Map:
if ( !spriteProperty.isEmpty() )
{
#if 0
// if Object, simpify into one sprite.
// TODO:
if isinstance( fill_pattern, dict )
{
pattern_stops = fill_pattern.get( "stops", [None] )
fill_pattern = pattern_stops[-1][-1]
}
#endif
FALLTHROUGH
ddRasterProperties.setProperty( QgsSymbolLayer::PropertyFile, QgsProperty::fromExpression( spriteProperty ) );
}

default:

break;
rasterFill->setDataDefinedProperties( ddRasterProperties );
symbol->appendSymbolLayer( rasterFill );
}
}

Expand Down

0 comments on commit b898ec2

Please sign in to comment.