Skip to content

Commit

Permalink
r.horizon: fix bad output by Apple ARM machines (#3403)
Browse files Browse the repository at this point in the history
Back and forth conversion of 0.0 deg to rad to deg resulted in -0.0 leading to
erroneous print out.

Problem pinpointed by Nicklas, solution provided by Anna.

Co-authored-by: Anna Petrasova <[email protected]>
  • Loading branch information
2 people authored and landam committed Feb 9, 2024
1 parent 5c5f3c1 commit 9150097
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions raster/r.horizon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ int max(int arg1, int arg2)

/**********************************************************/

void com_par()
void com_par(void)
{
if (fabs(sinangle) < 0.0000001) {
sinangle = 0.;
Expand Down Expand Up @@ -790,6 +790,7 @@ void calculate_shadow(void)
yp = ymin + yy0;

angle = (single_direction * deg2rad) + pihalf;
printangle = single_direction;

maxlength = fixedMaxLength;
fprintf(fp, "azimuth,horizon_height\n");
Expand Down Expand Up @@ -843,11 +844,6 @@ void calculate_shadow(void)
if (degreeOutput) {
shadow_angle *= rad2deg;
}
printangle = angle * rad2deg - 90.;
if (printangle < 0.)
printangle += 360;
else if (printangle >= 360.)
printangle -= 360;

if (compassOutput) {
double tmpangle;
Expand All @@ -862,11 +858,17 @@ void calculate_shadow(void)
}

angle += dfr_rad;
printangle += step;

if (angle < 0.)
angle += twopi;
else if (angle > twopi)
angle -= twopi;

if (printangle < 0.)
printangle += 360;
else if (printangle > 360.)
printangle -= 360;
} /* end of for loop over angles */
}

Expand Down

0 comments on commit 9150097

Please sign in to comment.