Skip to content
Snippets Groups Projects
Commit 5144fa4c authored by Marco Matthies's avatar Marco Matthies
Browse files

Add `soiltype` field to `FarmPlot`

- no majority counting of Pixels implemented yet, soil type is
  currently still determined by the first pixel of a FarmPlot
parent d33cf68d
No related branches found
No related tags found
No related merge requests found
...@@ -53,7 +53,8 @@ function initfields!(model::SimulationModel) ...@@ -53,7 +53,8 @@ function initfields!(model::SimulationModel)
push!(model.farmplots[objectid].pixels, (x,y)) push!(model.farmplots[objectid].pixels, (x,y))
else else
cropstate = makecropstate(model) cropstate = makecropstate(model)
fp = FarmPlot(length(model.farmplots) + 1, [(x, y)], -1, cropstate) soiltype = model.landscape[x,y].soiltype
fp = FarmPlot(length(model.farmplots) + 1, [(x, y)], -1, soiltype, cropstate)
push!(model.farmplots, fp) push!(model.farmplots, fp)
model.landscape[x,y].fieldid = fp.id model.landscape[x,y].fieldid = fp.id
convertid[rawid] = fp.id convertid[rawid] = fp.id
......
...@@ -12,6 +12,7 @@ mutable struct FarmPlot{T} <: ModelAgent ...@@ -12,6 +12,7 @@ mutable struct FarmPlot{T} <: ModelAgent
const id::Int64 const id::Int64
pixels::Vector{Tuple{Int64, Int64}} pixels::Vector{Tuple{Int64, Int64}}
farmer::Int64 farmer::Int64
soiltype::SoilType
cropstate::T cropstate::T
end end
......
...@@ -31,7 +31,7 @@ end ...@@ -31,7 +31,7 @@ end
mature = false mature = false
events = Ps.Management[] events = Ps.Management[]
force_growth = false force_growth = false
fp = FarmPlot(id, pixels, farmer, Ps.ALMaSS.CropState(croptype=ct, phase=Ps.ALMaSS.janfirst)) fp = FarmPlot(id, pixels, farmer, Ps.soiltype_nodata, Ps.ALMaSS.CropState(croptype=ct, phase=Ps.ALMaSS.janfirst))
@test fp isa FarmPlot @test fp isa FarmPlot
@test fp isa FarmPlot{Ps.ALMaSS.CropState} @test fp isa FarmPlot{Ps.ALMaSS.CropState}
@test croptype(fp) isa Ps.ALMaSS.CropType @test croptype(fp) isa Ps.ALMaSS.CropType
...@@ -46,7 +46,7 @@ end ...@@ -46,7 +46,7 @@ end
id = 0 id = 0
pixels = [(0, 0)] pixels = [(0, 0)]
farmer = 0 farmer = 0
fp = FarmPlot(id, pixels, farmer, Ps.SimpleCrop.CropState(ct, 0.0cm)) fp = FarmPlot(id, pixels, farmer, Ps.soiltype_nodata, Ps.SimpleCrop.CropState(ct, 0.0cm))
@test fp isa FarmPlot @test fp isa FarmPlot
@test fp isa FarmPlot{Ps.SimpleCrop.CropState} @test fp isa FarmPlot{Ps.SimpleCrop.CropState}
@test croptype(fp) isa Ps.SimpleCrop.CropType @test croptype(fp) isa Ps.SimpleCrop.CropType
......
...@@ -49,7 +49,7 @@ end) # end eval ...@@ -49,7 +49,7 @@ end) # end eval
model = inittestmodel() model = inittestmodel()
model.landscape[6,6] = Pixel(Ps.agriculture, Ps.soiltype_sand, 1, [], [], []) model.landscape[6,6] = Pixel(Ps.agriculture, Ps.soiltype_sand, 1, [], [], [])
fp = Ps.FarmPlot( fp = Ps.FarmPlot(
1, [(6,6)], 1, 1, [(6,6)], 1, Ps.soiltype_nodata,
Ps.ALMaSS.CropState( Ps.ALMaSS.CropState(
croptype = model.crops["winter wheat"], croptype = model.crops["winter wheat"],
phase = Ps.ALMaSS.janfirst, phase = Ps.ALMaSS.janfirst,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment