From 76f6a14ecbec366a0607fa46699a22d7f7dbef14 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 9 Jul 2024 12:55:20 -0400 Subject: [PATCH 01/11] Implement parseEsriTextMarkerSymbolJson Implement parseEsriTextMarkerSymbolJson Add test for chr parameter Set chr parameter to text Implement borderLineSize width Add test for borderLineSize Add test for strokeColor Implement strokeColor Implement anchor points Add tests for anchor points Add test for angle Add test for offset Set sizeUnit Set offset Remove fontData map Add more specific tests Create parseEsriTextMarkerSymbolJson function Add tests Add necessary additional information to test json --- .../providers/arcgis/qgsarcgisrestutils.cpp | 81 ++++++++++++++++++- .../providers/arcgis/qgsarcgisrestutils.h | 1 + src/plugins/grass/scripts/t.rast.what.qgis.py | 2 +- tests/src/core/testqgsarcgisrestutils.cpp | 63 +++++++++++++++ tests/src/python/test_provider_ogr.py | 4 +- tests/src/python/test_provider_spatialite.py | 2 +- tests/src/python/test_provider_wfs.py | 4 +- 7 files changed, 149 insertions(+), 8 deletions(-) diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.cpp b/src/core/providers/arcgis/qgsarcgisrestutils.cpp index 1fcea44ce8d7..0612519911a4 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.cpp +++ b/src/core/providers/arcgis/qgsarcgisrestutils.cpp @@ -563,8 +563,7 @@ QgsSymbol *QgsArcGisRestUtils::convertSymbol( const QVariantMap &symbolData ) } else if ( type == QLatin1String( "esriTS" ) ) { - // text symbol - not supported - return nullptr; + return parseEsriTextMarkerSymbolJson( symbolData ).release(); } return nullptr; } @@ -748,6 +747,84 @@ std::unique_ptr QgsArcGisRestUtils::parseEsriPictureMarkerSymbo return symbol; } +std::unique_ptr QgsArcGisRestUtils::parseEsriTextMarkerSymbolJson( const QVariantMap &symbolData ) +{ + QgsSymbolLayerList layers; + + QString fontFamily; + fontFamily = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "family" ) ).toString(); + + QString chr; + chr = symbolData.value( QStringLiteral( "text" ) ).toString(); + + double pointSize; + pointSize = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "size" ) ).toDouble(); + + QColor color = convertColor( symbolData.value( QStringLiteral( "color" ) ) ); + + double angle; + angle = symbolData.value( QStringLiteral( "angle" ) ).toDouble(); + + std::unique_ptr< QgsFontMarkerSymbolLayer > markerLayer = std::make_unique< QgsFontMarkerSymbolLayer >( fontFamily, chr, pointSize, color, angle ); + + QColor strokeColor = convertColor( symbolData.value( QStringLiteral( "borderLineColor" ) ) ); + markerLayer->setStrokeColor( strokeColor ); + + double borderLineSize = symbolData.value( QStringLiteral( "borderLineSize" ) ).toDouble(); + markerLayer->setStrokeWidth( borderLineSize ); + + const QString fontStyle = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "style" ) ).toString(); + markerLayer->setFontStyle( fontStyle ); + + double xOffset = symbolData.value( QStringLiteral( "xoffset" ) ).toDouble(); + double yOffset = symbolData.value( QStringLiteral( "yoffset" ) ).toDouble(); + + markerLayer->setOffset( QPointF( xOffset, yOffset ) ); + markerLayer->setOffsetUnit( Qgis::RenderUnit::Points ); + + markerLayer->setSizeUnit( Qgis::RenderUnit::Points ); + + QgsMarkerSymbolLayer::HorizontalAnchorPoint hAlign; + QgsMarkerSymbolLayer::VerticalAnchorPoint vAlign; + + QString horizontalAnchorPoint = symbolData.value( QStringLiteral( "horizontalAlignment" ) ).toString(); + QString verticalAnchorPoint = symbolData.value( QStringLiteral( "verticalAlignment" ) ).toString(); + + if ( horizontalAnchorPoint == QString( "center" ) ) + { + hAlign = QgsMarkerSymbolLayer::HorizontalAnchorPoint::HCenter; + } + else if ( horizontalAnchorPoint == QString( "left" ) ) + { + hAlign = QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left; + } + else if ( horizontalAnchorPoint == QString( "right" ) ) + { + hAlign = QgsMarkerSymbolLayer::HorizontalAnchorPoint::Right; + } + + if ( verticalAnchorPoint == QString( "center" ) ) + { + vAlign = QgsMarkerSymbolLayer::VerticalAnchorPoint::VCenter; + } + else if ( verticalAnchorPoint == QString( "top" ) ) + { + vAlign = QgsMarkerSymbolLayer::VerticalAnchorPoint::Top; + } + else if ( verticalAnchorPoint == QString( "bottom" ) ) + { + vAlign = QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom; + } + + markerLayer->setHorizontalAnchorPoint( hAlign ); + markerLayer->setVerticalAnchorPoint( vAlign ); + + layers.append( markerLayer.release() ); + + std::unique_ptr< QgsMarkerSymbol > symbol = std::make_unique< QgsMarkerSymbol >( layers ); + return symbol; +} + QgsAbstractVectorLayerLabeling *QgsArcGisRestUtils::convertLabeling( const QVariantList &labelingData ) { if ( labelingData.empty() ) diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.h b/src/core/providers/arcgis/qgsarcgisrestutils.h index c5e9aa1c10aa..e016f64a9aed 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.h +++ b/src/core/providers/arcgis/qgsarcgisrestutils.h @@ -320,6 +320,7 @@ class CORE_EXPORT QgsArcGisRestUtils static std::unique_ptr< QgsFillSymbol > parseEsriPictureFillSymbolJson( const QVariantMap &symbolData ); static std::unique_ptr< QgsMarkerSymbol > parseEsriMarkerSymbolJson( const QVariantMap &symbolData ); static std::unique_ptr< QgsMarkerSymbol > parseEsriPictureMarkerSymbolJson( const QVariantMap &symbolData ); + static std::unique_ptr< QgsMarkerSymbol > parseEsriTextMarkerSymbolJson( const QVariantMap &symbolData ); static Qgis::MarkerShape parseEsriMarkerShape( const QString &style ); diff --git a/src/plugins/grass/scripts/t.rast.what.qgis.py b/src/plugins/grass/scripts/t.rast.what.qgis.py index 1b0beba20cc6..adfc1a85ed0e 100644 --- a/src/plugins/grass/scripts/t.rast.what.qgis.py +++ b/src/plugins/grass/scripts/t.rast.what.qgis.py @@ -93,7 +93,7 @@ #% description: Use stdin as input and ignore coordinates and point option #%end -## Temporary disabled the r.what flags due to test issues +# Temporary disabled the r.what flags due to test issues ##%flag ##% key: f ##% description: Show the category labels of the grid cell(s) diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index 7c7cc724d5bc..cb1a6d7a7b0e 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -253,6 +253,69 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() QCOMPARE( markerLayer->strokeWidth(), 5.0 ); QCOMPARE( markerLayer->strokeWidthUnit(), Qgis::RenderUnit::Points ); + // esriTS + const QVariantMap fontMap = jsonStringToMap( "{" + "\"type\": \"esriTS\"," + "\"text\": \"text\"," + "\"color\": [" + "78," + "78," + "78," + "255" + "]," + "\"backgroundColor\": [" + "0," + "0," + "0," + "0" + "]," + "\"borderLineSize\": 2," + "\"borderLineColor\": [" + "255," + "0," + "255," + "255" + "]," + "\"haloSize\": 2," + "\"haloColor\": [" + "0," + "255," + "0," + "255" + "]," + "\"verticalAlignment\": \"bottom\"," + "\"horizontalAlignment\": \"left\"," + "\"rightToLeft\": false," + "\"angle\": 0," + "\"xoffset\": 0," + "\"yoffset\": 0," + "\"kerning\": true," + "\"font\": {" + "\"family\": \"Arial\"," + "\"size\": 12," + "\"style\": \"normal\"," + "\"weight\": \"bold\"," + "\"decoration\": \"none\"" + "}" + "}" ); + + std::unique_ptr fontSymbol( QgsArcGisRestUtils::convertSymbol( fontMap ) ); + QgsMarkerSymbol *fontMarker = dynamic_cast< QgsMarkerSymbol * >( fontSymbol.get() ); + QVERIFY( fontMarker ); + QCOMPARE( fontMarker->symbolLayerCount(), 1 ); + QgsFontMarkerSymbolLayer *fontMarkerLayer = dynamic_cast< QgsFontMarkerSymbolLayer * >( fontMarker->symbolLayer( 0 ) ); + QVERIFY( fontMarkerLayer ); + QCOMPARE( fontMarkerLayer->fontStyle(), QString( "normal" ) ); + QCOMPARE( fontMarkerLayer->fontFamily(), QString( "Arial" ) ); + QCOMPARE( fontMarkerLayer->offset(), QPointF( 0, 0 ) ); + QCOMPARE( fontMarkerLayer->angle(), 0 ); + QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); + QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); + QColor strokeColor = fontMarkerLayer->strokeColor(); + QCOMPARE( strokeColor.red(), 255 ); + QCOMPARE( fontMarkerLayer->strokeWidth(), 2 ); + QCOMPARE( fontMarkerLayer->character(), QString( "text" ) ); + // invalid json symbol = QgsArcGisRestUtils::parseEsriMarkerSymbolJson( QVariantMap() ); QVERIFY( !symbol ); diff --git a/tests/src/python/test_provider_ogr.py b/tests/src/python/test_provider_ogr.py index acfda8867aa7..5617c7e87621 100644 --- a/tests/src/python/test_provider_ogr.py +++ b/tests/src/python/test_provider_ogr.py @@ -3551,7 +3551,7 @@ def testExtentCsv(self): with open(datasource_2d, 'w') as f: f.write('id,WKT\n') for i in range(9): - f.write(f'{i},POINT ({2*i} {i-3})\n') + f.write(f'{i},POINT ({2 * i} {i - 3})\n') vl = QgsVectorLayer(f'{datasource_2d}|layerid=0', 'test', 'ogr') self.assertTrue(vl.isValid()) @@ -3568,7 +3568,7 @@ def testExtentCsv(self): with open(datasource_3d, 'w') as f: f.write('id,WKT\n') for i in range(13): - f.write(f'{i},POINT Z({2*i} {i-3} {i-5})\n') + f.write(f'{i},POINT Z({2 * i} {i - 3} {i - 5})\n') vl = QgsVectorLayer(f'{datasource_3d}|layerid=0', 'test', 'ogr') self.assertTrue(vl.isValid()) diff --git a/tests/src/python/test_provider_spatialite.py b/tests/src/python/test_provider_spatialite.py index d2bddafd43f4..4bf9f9cbd249 100644 --- a/tests/src/python/test_provider_spatialite.py +++ b/tests/src/python/test_provider_spatialite.py @@ -123,7 +123,7 @@ def setUpClass(cls): cur.execute(sql) for i in range(2, 12): sql = "INSERT INTO test_z2 (id, name, geometry) " - sql += f"VALUES ({i-1}, 'toto 2', GeomFromText('POINT Z ({i-4} {i+1} {i})', 4326))" + sql += f"VALUES ({i - 1}, 'toto 2', GeomFromText('POINT Z ({i - 4} {i + 1} {i})', 4326))" cur.execute(sql) # table with M value geometry diff --git a/tests/src/python/test_provider_wfs.py b/tests/src/python/test_provider_wfs.py index 6c581fcf804b..ddaf9bc46c16 100644 --- a/tests/src/python/test_provider_wfs.py +++ b/tests/src/python/test_provider_wfs.py @@ -3829,7 +3829,7 @@ def testGetFeatureWithServerExpression(self): """), - 'wb') as f: + 'wb') as f: f.write(b""" """), - 'wb') as f: + 'wb') as f: f.write(b""" Date: Tue, 16 Jul 2024 01:46:13 -0400 Subject: [PATCH 02/11] Refactor variable declarations and assignments to use `const` where appropriate Co-authored-by: Nyall Dawson --- src/core/providers/arcgis/qgsarcgisrestutils.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.cpp b/src/core/providers/arcgis/qgsarcgisrestutils.cpp index 0612519911a4..126349fe4b12 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.cpp +++ b/src/core/providers/arcgis/qgsarcgisrestutils.cpp @@ -751,19 +751,15 @@ std::unique_ptr QgsArcGisRestUtils::parseEsriTextMarkerSymbolJs { QgsSymbolLayerList layers; - QString fontFamily; - fontFamily = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "family" ) ).toString(); + const QString fontFamily = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "family" ) ).toString(); - QString chr; - chr = symbolData.value( QStringLiteral( "text" ) ).toString(); + const QString chr = symbolData.value( QStringLiteral( "text" ) ).toString(); - double pointSize; - pointSize = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "size" ) ).toDouble(); + const double pointSize = symbolData.value( QStringLiteral( "font" ) ).toMap().value( QStringLiteral( "size" ) ).toDouble(); - QColor color = convertColor( symbolData.value( QStringLiteral( "color" ) ) ); + const QColor color = convertColor( symbolData.value( QStringLiteral( "color" ) ) ); - double angle; - angle = symbolData.value( QStringLiteral( "angle" ) ).toDouble(); + const double angle = symbolData.value( QStringLiteral( "angle" ) ).toDouble(); std::unique_ptr< QgsFontMarkerSymbolLayer > markerLayer = std::make_unique< QgsFontMarkerSymbolLayer >( fontFamily, chr, pointSize, color, angle ); From 4a03f7617536193e5382a97edf28bb521e471ea0 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 02:09:59 -0400 Subject: [PATCH 03/11] Set stroke width unit to points --- src/core/providers/arcgis/qgsarcgisrestutils.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.cpp b/src/core/providers/arcgis/qgsarcgisrestutils.cpp index 126349fe4b12..3accd0c8349e 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.cpp +++ b/src/core/providers/arcgis/qgsarcgisrestutils.cpp @@ -779,6 +779,7 @@ std::unique_ptr QgsArcGisRestUtils::parseEsriTextMarkerSymbolJs markerLayer->setOffsetUnit( Qgis::RenderUnit::Points ); markerLayer->setSizeUnit( Qgis::RenderUnit::Points ); + markerLayer->setStrokeWidthUnit( Qgis::RenderUnit::Points ); QgsMarkerSymbolLayer::HorizontalAnchorPoint hAlign; QgsMarkerSymbolLayer::VerticalAnchorPoint vAlign; From bae2f476165855f89c00c3a615d0a83136466b7e Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 02:10:16 -0400 Subject: [PATCH 04/11] Revert formatting of additional files --- src/plugins/grass/scripts/t.rast.what.qgis.py | 2 +- tests/src/python/test_provider_ogr.py | 4 ++-- tests/src/python/test_provider_spatialite.py | 2 +- tests/src/python/test_provider_wfs.py | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/grass/scripts/t.rast.what.qgis.py b/src/plugins/grass/scripts/t.rast.what.qgis.py index adfc1a85ed0e..1b0beba20cc6 100644 --- a/src/plugins/grass/scripts/t.rast.what.qgis.py +++ b/src/plugins/grass/scripts/t.rast.what.qgis.py @@ -93,7 +93,7 @@ #% description: Use stdin as input and ignore coordinates and point option #%end -# Temporary disabled the r.what flags due to test issues +## Temporary disabled the r.what flags due to test issues ##%flag ##% key: f ##% description: Show the category labels of the grid cell(s) diff --git a/tests/src/python/test_provider_ogr.py b/tests/src/python/test_provider_ogr.py index 5617c7e87621..acfda8867aa7 100644 --- a/tests/src/python/test_provider_ogr.py +++ b/tests/src/python/test_provider_ogr.py @@ -3551,7 +3551,7 @@ def testExtentCsv(self): with open(datasource_2d, 'w') as f: f.write('id,WKT\n') for i in range(9): - f.write(f'{i},POINT ({2 * i} {i - 3})\n') + f.write(f'{i},POINT ({2*i} {i-3})\n') vl = QgsVectorLayer(f'{datasource_2d}|layerid=0', 'test', 'ogr') self.assertTrue(vl.isValid()) @@ -3568,7 +3568,7 @@ def testExtentCsv(self): with open(datasource_3d, 'w') as f: f.write('id,WKT\n') for i in range(13): - f.write(f'{i},POINT Z({2 * i} {i - 3} {i - 5})\n') + f.write(f'{i},POINT Z({2*i} {i-3} {i-5})\n') vl = QgsVectorLayer(f'{datasource_3d}|layerid=0', 'test', 'ogr') self.assertTrue(vl.isValid()) diff --git a/tests/src/python/test_provider_spatialite.py b/tests/src/python/test_provider_spatialite.py index 4bf9f9cbd249..d2bddafd43f4 100644 --- a/tests/src/python/test_provider_spatialite.py +++ b/tests/src/python/test_provider_spatialite.py @@ -123,7 +123,7 @@ def setUpClass(cls): cur.execute(sql) for i in range(2, 12): sql = "INSERT INTO test_z2 (id, name, geometry) " - sql += f"VALUES ({i - 1}, 'toto 2', GeomFromText('POINT Z ({i - 4} {i + 1} {i})', 4326))" + sql += f"VALUES ({i-1}, 'toto 2', GeomFromText('POINT Z ({i-4} {i+1} {i})', 4326))" cur.execute(sql) # table with M value geometry diff --git a/tests/src/python/test_provider_wfs.py b/tests/src/python/test_provider_wfs.py index ddaf9bc46c16..6c581fcf804b 100644 --- a/tests/src/python/test_provider_wfs.py +++ b/tests/src/python/test_provider_wfs.py @@ -3829,7 +3829,7 @@ def testGetFeatureWithServerExpression(self): """), - 'wb') as f: + 'wb') as f: f.write(b""" """), - 'wb') as f: + 'wb') as f: f.write(b""" Date: Tue, 16 Jul 2024 02:57:12 -0400 Subject: [PATCH 05/11] Check for hex instead of single rgb value Co-authored-by: Nyall Dawson --- tests/src/core/testqgsarcgisrestutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index cb1a6d7a7b0e..2c16cf59b3c0 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -312,7 +312,7 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); QColor strokeColor = fontMarkerLayer->strokeColor(); - QCOMPARE( strokeColor.red(), 255 ); + QCOMPARE( strokeColor.name(), QStringLiteral("#ff0000" ) ); QCOMPARE( fontMarkerLayer->strokeWidth(), 2 ); QCOMPARE( fontMarkerLayer->character(), QString( "text" ) ); From 8063fb75ff9511a80cbdb0aa63df5c859315a063 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 02:57:45 -0400 Subject: [PATCH 06/11] Set angle value in test json to 45 Co-authored-by: Nyall Dawson --- tests/src/core/testqgsarcgisrestutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index 2c16cf59b3c0..e120969b1567 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -286,7 +286,7 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() "\"verticalAlignment\": \"bottom\"," "\"horizontalAlignment\": \"left\"," "\"rightToLeft\": false," - "\"angle\": 0," + "\"angle\": 45," "\"xoffset\": 0," "\"yoffset\": 0," "\"kerning\": true," From 99e0a24dc8415e1fe936662d053beec01dd247c7 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 03:02:20 -0400 Subject: [PATCH 07/11] Add test for main color --- tests/src/core/testqgsarcgisrestutils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index e120969b1567..28ac4dc99ae0 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -311,6 +311,8 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() QCOMPARE( fontMarkerLayer->angle(), 0 ); QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); + QColor mainColor = fontMarkerLayer->color(); + QCOMPARE( mainColor.name(), QStringLiteral("#4e4e4e" ) ); QColor strokeColor = fontMarkerLayer->strokeColor(); QCOMPARE( strokeColor.name(), QStringLiteral("#ff0000" ) ); QCOMPARE( fontMarkerLayer->strokeWidth(), 2 ); From d296b0788400224e4fd70fd6f2a519a0b0d41071 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 03:05:38 -0400 Subject: [PATCH 08/11] Create angle converter --- src/core/providers/arcgis/qgsarcgisrestutils.cpp | 4 +++- tests/src/core/testqgsarcgisrestutils.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.cpp b/src/core/providers/arcgis/qgsarcgisrestutils.cpp index 3accd0c8349e..e25a0b32f721 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.cpp +++ b/src/core/providers/arcgis/qgsarcgisrestutils.cpp @@ -759,7 +759,9 @@ std::unique_ptr QgsArcGisRestUtils::parseEsriTextMarkerSymbolJs const QColor color = convertColor( symbolData.value( QStringLiteral( "color" ) ) ); - const double angle = symbolData.value( QStringLiteral( "angle" ) ).toDouble(); + const double esriAngle = symbolData.value( QStringLiteral( "angle" ) ).toDouble(); + + const double angle = 90.0 - esriAngle; std::unique_ptr< QgsFontMarkerSymbolLayer > markerLayer = std::make_unique< QgsFontMarkerSymbolLayer >( fontFamily, chr, pointSize, color, angle ); diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index 28ac4dc99ae0..2dc92fec2d6e 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -308,7 +308,7 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() QCOMPARE( fontMarkerLayer->fontStyle(), QString( "normal" ) ); QCOMPARE( fontMarkerLayer->fontFamily(), QString( "Arial" ) ); QCOMPARE( fontMarkerLayer->offset(), QPointF( 0, 0 ) ); - QCOMPARE( fontMarkerLayer->angle(), 0 ); + QCOMPARE( fontMarkerLayer->angle(), 45 ); QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); QColor mainColor = fontMarkerLayer->color(); From 0f3e00b53fefe92f30c6ffa91089350714f5d657 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 03:07:10 -0400 Subject: [PATCH 09/11] Correct testing color for strokeColor --- tests/src/core/testqgsarcgisrestutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index 2dc92fec2d6e..34174cd4b860 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -314,7 +314,7 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() QColor mainColor = fontMarkerLayer->color(); QCOMPARE( mainColor.name(), QStringLiteral("#4e4e4e" ) ); QColor strokeColor = fontMarkerLayer->strokeColor(); - QCOMPARE( strokeColor.name(), QStringLiteral("#ff0000" ) ); + QCOMPARE( strokeColor.name(), QStringLiteral("#ff00ff" ) ); QCOMPARE( fontMarkerLayer->strokeWidth(), 2 ); QCOMPARE( fontMarkerLayer->character(), QString( "text" ) ); From a92819d79ab41b7e766127c1ff1f327c15ab54f2 Mon Sep 17 00:00:00 2001 From: Till Frankenbach Date: Tue, 16 Jul 2024 03:17:27 -0400 Subject: [PATCH 10/11] Run astyle_all.sh --- tests/src/core/testqgsarcgisrestutils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/core/testqgsarcgisrestutils.cpp b/tests/src/core/testqgsarcgisrestutils.cpp index 34174cd4b860..aff166b9096c 100644 --- a/tests/src/core/testqgsarcgisrestutils.cpp +++ b/tests/src/core/testqgsarcgisrestutils.cpp @@ -312,9 +312,9 @@ void TestQgsArcGisRestUtils::testParseMarkerSymbol() QCOMPARE( fontMarkerLayer->horizontalAnchorPoint(), QgsMarkerSymbolLayer::HorizontalAnchorPoint::Left ); QCOMPARE( fontMarkerLayer->verticalAnchorPoint(), QgsMarkerSymbolLayer::VerticalAnchorPoint::Bottom ); QColor mainColor = fontMarkerLayer->color(); - QCOMPARE( mainColor.name(), QStringLiteral("#4e4e4e" ) ); + QCOMPARE( mainColor.name(), QStringLiteral( "#4e4e4e" ) ); QColor strokeColor = fontMarkerLayer->strokeColor(); - QCOMPARE( strokeColor.name(), QStringLiteral("#ff00ff" ) ); + QCOMPARE( strokeColor.name(), QStringLiteral( "#ff00ff" ) ); QCOMPARE( fontMarkerLayer->strokeWidth(), 2 ); QCOMPARE( fontMarkerLayer->character(), QString( "text" ) ); From cf2d1aa913d8e6dc8d93d6b3a32fa77f983b97f2 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 17 Jul 2024 13:38:37 +1000 Subject: [PATCH 11/11] Apply suggestions from code review --- src/core/providers/arcgis/qgsarcgisrestutils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/providers/arcgis/qgsarcgisrestutils.cpp b/src/core/providers/arcgis/qgsarcgisrestutils.cpp index e25a0b32f721..07b4976f7485 100644 --- a/src/core/providers/arcgis/qgsarcgisrestutils.cpp +++ b/src/core/providers/arcgis/qgsarcgisrestutils.cpp @@ -783,8 +783,8 @@ std::unique_ptr QgsArcGisRestUtils::parseEsriTextMarkerSymbolJs markerLayer->setSizeUnit( Qgis::RenderUnit::Points ); markerLayer->setStrokeWidthUnit( Qgis::RenderUnit::Points ); - QgsMarkerSymbolLayer::HorizontalAnchorPoint hAlign; - QgsMarkerSymbolLayer::VerticalAnchorPoint vAlign; + QgsMarkerSymbolLayer::HorizontalAnchorPoint hAlign = QgsMarkerSymbolLayer::HorizontalAnchorPoint::HCenter; + QgsMarkerSymbolLayer::VerticalAnchorPoint vAlign = QgsMarkerSymbolLayer::VerticalAnchorPoint::VCenter; QString horizontalAnchorPoint = symbolData.value( QStringLiteral( "horizontalAlignment" ) ).toString(); QString verticalAnchorPoint = symbolData.value( QStringLiteral( "verticalAlignment" ) ).toString();