-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Uniform the decimal places number in Identify tool #7836
Uniform the decimal places number in Identify tool #7836
Conversation
Make uniform the number of decimal places of values displayed in "Derived" item tree of Identify Tool.
Any chance we could (re-?)add thousands separator to facilitate reading? |
Example on how to go at it: |
I'd update the formatDistance and formatArea functions, that'll benefit other parts (measurement tools) |
One thing we need to account for here is very small distances/perimeters, and ensure that they do not display as 0.000. instead we should switch to scientific notation whenever the value is > 0 but would display as 0.000 |
to reflect the changes in the number of decimal places of Length, Area and Perimeter values displayed by Identity tool
@nirvn, working on formatDistance and formatArea, please also consider that: QgsUnitTypes/QgsDistanceArea formatDistance and formatArea (and then the homonymous ones, of both QgsMeasureDialog and QgsMapToolIdentify, which are based on them) rely on qgsRound(), through QgsUnitTypes::scaledDistance and QgsUnitTypes::scaledArea, to round measurements to a specified number of decimal places. It seems to me that there is a flaw in qgsRound() which leads to inconsistent results of the Measure tool (and Identify tool also) in QGIS 3: see the difference underlined in red between segment length (rounded by QLocale().toString()) and total length (rounded by formatDistance through qgsRound()) values In fact, in qgsround() definition
scaleFactor is declared as Int and thus it can correctly store up to the 9th power of 10, consequently the rounding provides incorrect results from the 9th decimal place onwards. Since it is allowed to set up to 12 as number of decimal places in Setting->Options->Map Tools (and moreover in Project Properties->General there is no upper limit to the decimal places allowed to be set!), By the way, in QGIS 2.18 this inconsistency problem is not present, since both formatDistance and formatArea rely on QString().arg(), which works similarly to QLocale().toString(), to round measurements, instead of on qgsRound(). |
If |
@m-kuhn, taking better account of any side effects of |
I don't remember exactly why it was introduced, but possibly because of an issue with rounding around Qt 5.6 (to string conversion didn't trim to a reasonable length). Would relying on |
The qgsRound() bug was fixed with PR #7941 |
Looking good! The only remaining thing to test (and add a unit check for) is what happens when the value is small enough and would be shown as 0.000 (even when it's non-zero, .e.g. 0.0001 ). In this case we need to either increase the number of decimals for that value, or (better?) show as scientific notation. |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist. |
I've filed a bug report (#20107) about the issue. |
Description
Now, in QGIS 3 and also 2.18, the Length, Area and Perimeter values are displayed always with 3 decimal places, while the other values are displayed according to the settings in Project Properties | General | Coordinate Display | Precision.
This commit lets the Length, Area and Perimeter values be displayed as the others are.
Fixes #20107
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and contain sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit