From a17a1c24098c05f3375b6e140696b579a2419e71 Mon Sep 17 00:00:00 2001 From: Marco Matthies <71844+marcom@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:47:07 +0200 Subject: [PATCH] Add cropcover function, fix cropheight return value in case it isn't a farm plot --- src/crop/farmplot.jl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/crop/farmplot.jl b/src/crop/farmplot.jl index 49a100d..018ec54 100644 --- a/src/crop/farmplot.jl +++ b/src/crop/farmplot.jl @@ -59,6 +59,17 @@ Return the height of the crop at this position, or nothing if there is no crop h (utility wrapper). """ function cropheight(pos::Tuple{Int64,Int64}, model::SimulationModel) - ismissing(model.landscape[pos...].fieldid) ? nothing : + ismissing(model.landscape[pos...].fieldid) ? 0.0cm : # TODO: 0.0cm correct here? cropheight(model.farmplots[model.landscape[pos...].fieldid]) end + +""" + cropcover(model, position) + +Return the crop cover of the crop at this position, or nothing if +there is no crop here (utility wrapper). +""" +function cropcover(pos::Tuple{Int64,Int64}, model::SimulationModel) + ismissing(model.landscape[pos...].fieldid) ? 0.0 : # TODO: 0.0 correct here? + cropcover(model.farmplots[model.landscape[pos...].fieldid]) +end -- GitLab