Skip to content
Permalink
Browse files

[afs] Add halo/buffer support to label creation

  • Loading branch information
nirvn committed Dec 10, 2018
1 parent ccb9a61 commit 24d4640bc714e2f90cf4375584720f5cf2bbe783
Showing with 26 additions and 2 deletions.
  1. +10 −0 src/providers/arcgisrest/qgsarcgisrestutils.cpp
  2. +16 −2 tests/src/providers/testqgsarcgisrestutils.cpp
@@ -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();
@@ -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,"
@@ -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

0 comments on commit 24d4640

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