From 6d840396d4521a1645859bbb7bb5b4a1124960e4 Mon Sep 17 00:00:00 2001
From: Daniel Vedder <daniel.vedder@idiv.de>
Date: Sat, 26 Nov 2022 17:35:57 +0100
Subject: [PATCH] Wrote landcover() to interpret the Mundialis map

---
 README.md            |  6 +++---
 src/nature/nature.jl | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md
index 64d80b4..bb2507f 100644
--- a/README.md
+++ b/README.md
@@ -17,7 +17,7 @@ framework. It is currently in the very early stages of development.
 ### Installation
 
 Install the latest version of the [Julia](https://julialang.org/downloads/) programming 
-language. The recommended editors are [VSCode](https://www.julia-vscode.org/) or
+language (1.9+). The recommended editors are [VSCode](https://www.julia-vscode.org/) or
 [Emacs](https://www.emacswiki.org/emacs/JuliaProgrammingLanguage) (see `docs/editors.md`).
 To install package dependencies, open a Julia REPL in this folder and run 
 `using Pkg; Pkg.activate("."); Pkg.instantiate()`.
@@ -38,8 +38,8 @@ configuration file is specified, Persephone will run with its default settings.)
 The full list of commandline arguments is:
 
 ```
-usage: run.jl [-c CONFIGFILE] [-s SEED] [-m MAPFILE] [-o OUTDIR]
-              [-l LOGLEVEL] [-r RUNTIME] [--version] [-h]
+usage: run.jl [-c CONFIGFILE] [-s SEED] [-o OUTDIR] [-l LOGLEVEL] 
+              [--version] [-h]
 
 optional arguments:
   -c, --configfile CONFIGFILE
diff --git a/src/nature/nature.jl b/src/nature/nature.jl
index 87776e2..a4251cb 100644
--- a/src/nature/nature.jl
+++ b/src/nature/nature.jl
@@ -3,8 +3,13 @@
 ### This file is responsible for managing the animal modules.
 ###
 
+## An enum used to assign a sex to each animal
 @enum Sex hermaphrodite male female
 
+## The land cover classes encoded in the Mundialis Sentinel data.
+## Do not change the order of this enum, or landcover() will break!
+@enum LandCover nodata forest grass water builtup soil agriculture
+
 """
     Species
 
@@ -31,7 +36,8 @@ by the `species` struct passed by them during initialisation.
     energy::Int32
 end
 
-# This dict stores the definitions for all species that can be simulated
+# This dict stores the definitions for all species that can be simulated.
+# (The definitions are created in separate files and registered here.)
 let specieslist = Dict{String, Species}()
     """
         registerspecies(species)
@@ -79,3 +85,14 @@ function initnature!(model::AgentBasedModel)
     end
 end
 
+"""
+    landcover(model, position)
+
+Return the land cover class at this position.
+"""
+function landcover(model::AgentBasedModel, pos::Tuple{Int64,Int64})
+    #XXX It's probably worth converting the entire GeoArray to a LandCover array
+    lc = model.landcover[pos...][1]
+    (ismissing(lc)) && (return(nodata))
+    return LandCover(Int(lc/10))
+end
-- 
GitLab