Skip to content

Correct geodetic scale denominator calculation#3828

Closed
fdiazcarsi wants to merge 1 commit intomapfish:masterfrom
fdiazcarsi:fix/correct-geodetic-scale-denominator-calculation
Closed

Correct geodetic scale denominator calculation#3828
fdiazcarsi wants to merge 1 commit intomapfish:masterfrom
fdiazcarsi:fix/correct-geodetic-scale-denominator-calculation

Conversation

@fdiazcarsi
Copy link
Copy Markdown
Contributor

This commit fixes a bug in the getGeodeticDenominator method within the Scale class.

Problem:
The calculation for minGeoX, which defines the starting X-coordinate of the horizontal line segment used for geodetic distance measurement, incorrectly used position.y instead of position.x. This resulted in the geodetic calculation being performed at an incorrect location on the map, leading to an inaccurate scale denominator.

Fix:
The minGeoX calculation has been corrected to use position.x - (geoWidth / 2.0), ensuring that the horizontal line segment is properly centered around the provided position's X-coordinate.

Impact:
This fix ensures that geodetic scale denominators are calculated accurately, improving the precision of map rendering and scale representation, especially for projections where geodetic corrections are critical.

@sbrunner
Copy link
Copy Markdown
Member

sbrunner commented Nov 4, 2025

Can you clear your pull request by doing an interactive rebase and removing all the extra commits?

@fdiazcarsi fdiazcarsi force-pushed the fix/correct-geodetic-scale-denominator-calculation branch from b2be240 to 4e511ee Compare November 6, 2025 07:48
@fdiazcarsi
Copy link
Copy Markdown
Contributor Author

Hi! As requested, I've cleaned up the PR history using an interactive rebase. It should now contain only the relevant commit on top of the latest master. Ready for review again. Thanks!

Copy link
Copy Markdown
Member

@sbrunner sbrunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sebr72 does it look good to you?

@fdiazcarsi
Copy link
Copy Markdown
Contributor Author

Yes, thank you.

@sbrunner sbrunner added backport 3.33 Add this label to backport the pull request to the '3.33' branch backport 3.28 Backport the pull request to the '3.28' branch backport 3.29 backport 3.30 Backport the pull request to the '3.30' branch backport 3.31 Backport the pull request to the '3.31' branch labels Nov 6, 2025
@sebr72
Copy link
Copy Markdown
Contributor

sebr72 commented Nov 6, 2025

@sbrunner
I agree with the intent of the PR. But what really puzzles me is the fact that none of the tests failed with such change.

@fdiazcarsi
Thanks for spotting and fixing this.
But since this PR is intended to be deployed to 6 versions, I believe that this kind of change must be tested.

@sebr72 sebr72 self-requested a review November 7, 2025 08:48
Copy link
Copy Markdown
Contributor

@sebr72 sebr72 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a general practice, we always add tests when making changes. But in this case in particular (as it appears to be a very old bug - and sometimes they are not), please create at least a Unit test if CI test is not required: Your decision

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an incorrect geodetic scale denominator computation in Scale#getGeodeticDenominator by correctly centering the geodetic measurement segment on the X coordinate of the provided map position.

Changes:

  • Correct minGeoX to use position.x (instead of position.y) when computing the geodetic measurement segment’s start X.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 201 to 205
double width = 1;
double geoWidthInches = getResolutionInInches() * width;
double geoWidth = DistanceUnit.IN.convertTo(geoWidthInches, this.unit);
double minGeoX = position.y - (geoWidth / 2.0);
double minGeoX = position.x - (geoWidth / 2.0);
double maxGeoX = minGeoX + geoWidth;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bug fix changes geodetic denominator behavior but there’s no regression test to prevent reintroducing the X/Y mix-up. Consider adding a unit test that calls getGeodeticDenominator() with a projection where distortion varies with easting (so swapping position.x and position.y would change the result), e.g., using CH1903 (EPSG:21781) with a coordinate where x != y and asserting the expected denominator.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

@sebr72
Copy link
Copy Markdown
Contributor

sebr72 commented Feb 12, 2026

@fdiazcarsi Without reply from you, and without sufficient test, we tried to get copilot to add some and it could not not). So we are closing this PR and creating #3979
Your feedback will be more than welcome

@sebr72 sebr72 closed this Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 3.28 Backport the pull request to the '3.28' branch backport 3.30 Backport the pull request to the '3.30' branch backport 3.31 Backport the pull request to the '3.31' branch backport 3.33 Add this label to backport the pull request to the '3.33' branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants