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: always include distance output in JSON output #3768

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions raster/r.horizon/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ int main(int argc, char *argv[])
flag.horizonDistance = G_define_flag();
flag.horizonDistance->key = 'l';
flag.horizonDistance->description =
_("Include horizon distance in the output");
_("Include horizon distance in the plain output");
flag.horizonDistance->guisection = _("Point mode");

flag.degreeOutput = G_define_flag();
Expand Down Expand Up @@ -889,8 +889,7 @@ void calculate_point_mode(const Settings *settings, const Geometry *geometry,
case JSON:
json_array_append_number(azimuths, tmpangle);
json_array_append_number(horizons, shadow_angle);
if (settings->horizonDistance)
json_array_append_number(distances, horizon.length);
json_array_append_number(distances, horizon.length);
break;
}
}
Expand All @@ -905,8 +904,7 @@ void calculate_point_mode(const Settings *settings, const Geometry *geometry,
case JSON:
json_array_append_number(azimuths, printangle);
json_array_append_number(horizons, shadow_angle);
if (settings->horizonDistance)
json_array_append_number(distances, horizon.length);
json_array_append_number(distances, horizon.length);
break;
}
}
Expand All @@ -928,9 +926,7 @@ void calculate_point_mode(const Settings *settings, const Geometry *geometry,
if (format == JSON) {
json_object_set_value(json_origin, "azimuth", azimuths_value);
json_object_set_value(json_origin, "horizon_height", horizons_value);
if (settings->horizonDistance)
json_object_set_value(json_origin, "horizon_distance",
distances_value);
json_object_set_value(json_origin, "horizon_distance", distances_value);
}
}

Expand Down
3 changes: 3 additions & 0 deletions raster/r.horizon/testsuite/test_r_horizon.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_point_mode_multiple_direction_json(self):
reference["y"] = 216180.0
reference["azimuth"] = azimuths
reference["horizon_height"] = horizons
stdout[0].pop("horizon_distance", None)
petrasovaa marked this conversation as resolved.
Show resolved Hide resolved

self.assertListEqual([reference], stdout)

Expand Down Expand Up @@ -242,6 +243,8 @@ def test_point_mode_multiple_points_and_directions_json(self):
reference["y"] = 216180.0
reference["azimuth"] = azimuths
reference["horizon_height"] = horizons
stdout[0].pop("horizon_distance", None)
stdout[1].pop("horizon_distance", None)

self.assertListEqual([reference, reference], stdout)

Expand Down
Loading