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

r.horizon: fix bug in point mode computation #3288

Merged
merged 1 commit into from
Dec 11, 2023

Conversation

petrasovaa
Copy link
Contributor

In point mode, some variables were not set properly, leading to major errors. Whenever it entered https://github.com/OSGeo/grass/blob/main/raster/r.horizon/main.c#L940 condition, it resulted in an error due to global variables sinangle and cosangle equal to 0. Raster mode was fine, those variables are initialized to proper values.

The fix uses com_par function (which was previously unused) with minor modification of its input. It sets those variables (and some others) and can be used in both modes, so now the variables in both modes should be set consistently.

The test computes horizon for an artificial, circular area (circle with z value 0 and 1000 around), so the horizon angles should be close to identical. This test would have previously resulted in zero horizon height everywhere.

@petrasovaa petrasovaa added bug Something isn't working raster Related to raster data processing backport to 8.3 errata Include in errata (fixes wrongly computed results) labels Dec 4, 2023
@petrasovaa petrasovaa added this to the 8.4.0 milestone Dec 4, 2023
@petrasovaa petrasovaa self-assigned this Dec 4, 2023
Copy link
Contributor

@metzm metzm left a comment

Choose a reason for hiding this comment

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

The changes look good to me. Maybe this is a step forward to also get negative angles?

@petrasovaa
Copy link
Contributor Author

The changes look good to me. Maybe this is a step forward to also get negative angles?

I think this is likely unrelated.
But it reminded me the issue in this PR was originally analyzed in that bug report, so linking here for reference:
#2935 (comment)

@petrasovaa petrasovaa merged commit c8af2ea into OSGeo:main Dec 11, 2023
18 checks passed
@petrasovaa petrasovaa deleted the r.horizon-fix-single-point branch December 11, 2023 21:14
petrasovaa added a commit that referenced this pull request Dec 11, 2023
In point mode, some variables were not set properly, leading to major errors. Whenever it entered https://github.com/OSGeo/grass/blob/main/raster/r.horizon/main.c#L940 condition, it resulted in an error due to global variables sinangle and cosangle equal to 0. Raster mode was fine, those variables are initialized to proper values.

The fix uses com_par function (which was previously unused) with minor modification of its input. It sets those variables (and some others) and can be used in both modes, so now the variables in both modes should be set consistently.

The test computes horizon for an artificial, circular area (circle with z value 0 and 1000 around), so the horizon angles should be close to identical. This test would have previously resulted in zero horizon height everywhere.
HuidaeCho pushed a commit to HuidaeCho/grass that referenced this pull request Jan 9, 2024
In point mode, some variables were not set properly, leading to major errors. Whenever it entered https://github.com/OSGeo/grass/blob/main/raster/r.horizon/main.c#L940 condition, it resulted in an error due to global variables sinangle and cosangle equal to 0. Raster mode was fine, those variables are initialized to proper values.

The fix uses com_par function (which was previously unused) with minor modification of its input. It sets those variables (and some others) and can be used in both modes, so now the variables in both modes should be set consistently.

The test computes horizon for an artificial, circular area (circle with z value 0 and 1000 around), so the horizon angles should be close to identical. This test would have previously resulted in zero horizon height everywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working errata Include in errata (fixes wrongly computed results) raster Related to raster data processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants