[GRASS-git] [OSGeo/grass] c8af2e: r.horizon: fix bug in point mode computation (#3288)

Anna Petrasova noreply at github.com
Mon Dec 11 13:15:03 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/OSGeo/grass
  Commit: c8af2ea9b7bd03a228ef5e6cc09c39ea269ae314
      https://github.com/OSGeo/grass/commit/c8af2ea9b7bd03a228ef5e6cc09c39ea269ae314
  Author: Anna Petrasova <kratochanna at gmail.com>
  Date:   2023-12-11 (Mon, 11 Dec 2023)

  Changed paths:
    M raster/r.horizon/main.c
    M raster/r.horizon/testsuite/test_r_horizon.py

  Log Message:
  -----------
  r.horizon: fix bug in point mode computation (#3288)

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.




More information about the grass-commit mailing list