Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mvt] mapbox vector tiles conversion improvements #58154

Merged
merged 9 commits into from
Jul 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/core/vectortile/qgsmapboxglstyleconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
QgsPropertyCollection ddProperties;
QgsPropertyCollection ddRasterProperties;

bool colorIsDataDefined = false;

std::unique_ptr< QgsSymbol > symbol( std::make_unique< QgsFillSymbol >() );

// fill color
Expand All @@ -244,6 +246,7 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg

case QMetaType::Type::QVariantList:
case QMetaType::Type::QStringList:
colorIsDataDefined = true;
ddProperties.setProperty( QgsSymbolLayer::Property::FillColor, parseValueList( jsonFillColor.toList(), PropertyType::Color, context, 1, 255, &fillColor ) );
break;

Expand Down Expand Up @@ -453,7 +456,7 @@ bool QgsMapBoxGlStyleConverter::parseFillLayer( const QVariantMap &jsonLayer, Qg
fillSymbol->setStrokeStyle( Qt::NoPen );
}

if ( fillColor.isValid() )
if ( fillColor.isValid() || colorIsDataDefined )
{
fillSymbol->setFillColor( fillColor );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If fillColor isn't valid, then we'll be setting the fill symbol to an invalid QColor here... I don't think we want to do that!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you do? Move the check and do an else if?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what it's trying to do here? I think ideally it'd be set to eg the first colour in the list

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just trying to avoid to set "no brush" if it's data defined. So not setting it might be sufficient.

}
Expand Down Expand Up @@ -2679,7 +2682,12 @@ QgsProperty QgsMapBoxGlStyleConverter::parseMatchList( const QVariantList &json,

for ( int i = 2; i < json.length() - 1; i += 2 )
{
const QVariantList keys = json.value( i ).toList();
QVariantList keys;
QVariant variantKeys = json.value( i );
if ( variantKeys.canConvert< QVariantList >() )
keys = variantKeys.toList();
else
keys = {variantKeys};

QStringList matchString;
for ( const QVariant &key : keys )
Expand Down