Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[afs] Add halo/buffer support to label creation
  • Loading branch information
nirvn committed Dec 10, 2018
1 parent ccb9a61 commit 24d4640
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/providers/arcgisrest/qgsarcgisrestutils.cpp
Expand Up @@ -862,6 +862,16 @@ QgsAbstractVectorLayerLabeling *QgsArcGisRestUtils::parseEsriLabeling( const QVa

QVariantMap symbol = labeling.value( QStringLiteral( "symbol" ) ).toMap();
format.setColor( parseEsriColorJson( symbol.value( QStringLiteral( "color" ) ) ) );
const double haloSize = symbol.value( QStringLiteral( "haloSize" ) ).toDouble();
if ( !qgsDoubleNear( haloSize, 0.0 ) )
{
QgsTextBufferSettings buffer;
buffer.setEnabled( true );
buffer.setSize( haloSize );
buffer.setSizeUnit( QgsUnitTypes::RenderPoints );
buffer.setColor( parseEsriColorJson( symbol.value( QStringLiteral( "haloColor" ) ) ) );
format.setBuffer( buffer );
}

const QString fontFamily = symbol.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "family" ) ).toString();
const QString fontStyle = symbol.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "style" ) ).toString();
Expand Down
18 changes: 16 additions & 2 deletions tests/src/providers/testqgsarcgisrestutils.cpp
Expand Up @@ -516,8 +516,13 @@ void TestQgsArcGisRestUtils::testParseLabeling()
"\"angle\": 0,"
"\"xoffset\": 0,"
"\"yoffset\": 0,"
"\"haloColor\": null,"
"\"haloSize\": null,"
"\"haloColor\": ["
"255,"
"255,"
"255,"
"255"
"],"
"\"haloSize\": 1,"
"\"font\": {"
"\"family\": \"Arial\","
"\"size\": 8,"
Expand Down Expand Up @@ -555,6 +560,15 @@ void TestQgsArcGisRestUtils::testParseLabeling()
QgsTextFormat textFormat = settings->format();
QCOMPARE( textFormat.color(), QColor( 255, 0, 0 ) );
QCOMPARE( textFormat.size(), 8.0 );
QCOMPARE( textFormat.buffer().enabled(), false );

settings = children.at( 1 )->settings();
QVERIFY( settings );
textFormat = settings->format();
QCOMPARE( textFormat.buffer().enabled(), true );
QCOMPARE( textFormat.buffer().color(), QColor( 255, 255, 255 ) );
QCOMPARE( textFormat.buffer().size(), 1.0 );
QCOMPARE( textFormat.buffer().sizeUnit(), QgsUnitTypes::RenderPoints );
}

QVariantMap TestQgsArcGisRestUtils::jsonStringToMap( const QString &string ) const
Expand Down

0 comments on commit 24d4640

Please sign in to comment.