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

Add scale method option for layout scale bars #58904

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nyalldawson
Copy link
Collaborator

Instead of always calculating the scale along the bottom of the
map, expose a choice of methods to the user (along bottom,
middle, top, or average of the three measurements)

For new scalebars, default to the average method, which better
handles the scenario where the scale at the top or bottom of
the map cannot be calculated (eg when the top/bottom of the map
falls just outside valid areas for the map's crs)

This fixes one of the most common scenarios which cause scale
bar widths to blow out to massive sizes

Refs #55240

@nyalldawson nyalldawson added Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Sep 30, 2024
@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@qgis-bot
Copy link
Collaborator

@nyalldawson
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions bot added this to the 3.40.0 milestone Sep 30, 2024
Copy link

github-actions bot commented Sep 30, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 66f0e26)

Copy link

Tests failed for Qt 6

One or more tests failed using the build from commit 73f1f3f

layoutscalebar_singlebox (singleBox)

layoutscalebar_singlebox

Test failed at singleBox at tests/src/core/testqgslayoutscalebar.cpp:120

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_singlebox/expected_layoutscalebar_singlebox.png (found 186 pixels different)

layoutscalebar_singlebox_linesymbol (singleBoxLineSymbol)

layoutscalebar_singlebox_linesymbol

Test failed at singleBoxLineSymbol at tests/src/core/testqgslayoutscalebar.cpp:162

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_singlebox_linesymbol/expected_layoutscalebar_singlebox_linesymbol.png (found 290 pixels different)

layoutscalebar_singlebox_fillsymbol (singleBoxFillSymbol)

layoutscalebar_singlebox_fillsymbol

Test failed at singleBoxFillSymbol at tests/src/core/testqgslayoutscalebar.cpp:203

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_singlebox_fillsymbol/expected_layoutscalebar_singlebox_fillsymbol.png (found 256 pixels different)

layoutscalebar_singlebox_labelbelowsegment (singleBoxLabelBelowSegment)

layoutscalebar_singlebox_labelbelowsegment

Test failed at singleBoxLabelBelowSegment at tests/src/core/testqgslayoutscalebar.cpp:233

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_singlebox_labelbelowsegment/expected_layoutscalebar_singlebox_labelbelowsegment.png (found 287 pixels different)

layoutscalebar_singlebox_alpha (singleBoxAlpha)

layoutscalebar_singlebox_alpha

Test failed at singleBoxAlpha at tests/src/core/testqgslayoutscalebar.cpp:272

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_singlebox_alpha/expected_layoutscalebar_singlebox_alpha.png (found 134 pixels different)

layoutscalebar_doublebox (doubleBox)

layoutscalebar_doublebox

Test failed at doubleBox at tests/src/core/testqgslayoutscalebar.cpp:308

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_doublebox/expected_layoutscalebar_doublebox.png (found 146 pixels different)

layoutscalebar_doublebox_linesymbol (doubleBoxLineSymbol)

layoutscalebar_doublebox_linesymbol

Test failed at doubleBoxLineSymbol at tests/src/core/testqgslayoutscalebar.cpp:350

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_doublebox_linesymbol/expected_layoutscalebar_doublebox_linesymbol.png (found 307 pixels different)

layoutscalebar_doublebox_fillsymbol (doubleBoxFillSymbol)

layoutscalebar_doublebox_fillsymbol

Test failed at doubleBoxFillSymbol at tests/src/core/testqgslayoutscalebar.cpp:391

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_doublebox_fillsymbol/expected_layoutscalebar_doublebox_fillsymbol.png (found 266 pixels different)

layoutscalebar_doublebox_labelcenteredsegment (doubleBoxLabelCenteredSegment)

layoutscalebar_doublebox_labelcenteredsegment

Test failed at doubleBoxLabelCenteredSegment at tests/src/core/testqgslayoutscalebar.cpp:430

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_doublebox_labelcenteredsegment/expected_layoutscalebar_doublebox_labelcenteredsegment.png (found 564 pixels different)

layoutscalebar_tick (tick)

layoutscalebar_tick

Test failed at tick at tests/src/core/testqgslayoutscalebar.cpp:498

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_tick/expected_layoutscalebar_tick.png (found 147 pixels different)

layoutscalebar_tick_linesymbol (tickLineSymbol)

layoutscalebar_tick_linesymbol

Test failed at tickLineSymbol at tests/src/core/testqgslayoutscalebar.cpp:544

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_tick_linesymbol/expected_layoutscalebar_tick_linesymbol.png (found 277 pixels different)

layoutscalebar_datadefined (dataDefined)

layoutscalebar_datadefined

Test failed at dataDefined at tests/src/core/testqgslayoutscalebar.cpp:616

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_datadefined/expected_layoutscalebar_datadefined.png (found 221 pixels different)

layoutscalebar_textformat (textFormat)

layoutscalebar_textformat

Test failed at textFormat at tests/src/core/testqgslayoutscalebar.cpp:673

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_textformat/expected_layoutscalebar_textformat.png (found 276 pixels different)

layoutscalebar_numericformat (numericFormat)

layoutscalebar_numericformat

Test failed at numericFormat at tests/src/core/testqgslayoutscalebar.cpp:707

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_numericformat/expected_layoutscalebar_numericformat.png (found 222 pixels different)

layoutscalebar_stepped (steppedLine)

layoutscalebar_stepped

Test failed at steppedLine at tests/src/core/testqgslayoutscalebar.cpp:750

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_stepped/expected_layoutscalebar_stepped.png (found 335 pixels different)

layoutscalebar_hollow (hollow)

layoutscalebar_hollow

Test failed at hollow at tests/src/core/testqgslayoutscalebar.cpp:807

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_hollow/expected_layoutscalebar_hollow.png (found 314 pixels different)

layoutscalebar_tick_subdivisions (tickSubdivisions)

layoutscalebar_tick_subdivisions

Test failed at tickSubdivisions at tests/src/core/testqgslayoutscalebar.cpp:907

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_layoutscalebar_tick_subdivisions/expected_layoutscalebar_tick_subdivisions.png (found 289 pixels different)

scalebar_method (methodTop)

scalebar_method

Test failed at methodTop at tests/src/core/testqgslayoutscalebar.cpp:1076

Rendered image did not match tests/testdata/control_images/layout_scalebar/expected_scalebar_method/expected_scalebar_method.png (found 18426 pixels different)

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

Instead of always calculating the scale along the bottom of the
map, expose a choice of methods to the user (along bottom,
middle, top, or average of the three measurements)

For new scalebars, default to the average method, which better
handles the scenario where the scale at the top or bottom of
the map cannot be calculated (eg when the top/bottom of the map
falls just outside valid areas for the map's crs)

This fixes one of the most common scenarios which cause scale
bar widths to blow out to massive sizes

Refs qgis#55240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants