Merge remote-tracking branch 'origin/develop'
All checks were successful
FarmMaps/CarbonLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma
2023-11-08 10:05:38 +01:00
4 changed files with 18 additions and 10 deletions

View File

@@ -139,11 +139,11 @@ namespace FarmMapsAPI.Carbon
Area = cropField.Area, Area = cropField.Area,
HistoricalCropData = mappedCropData, HistoricalCropData = mappedCropData,
SoilType = MapSoil(cropField.SoilType), SoilType = MapSoil(cropField.SoilType),
SoilProperty = new SoilProperty { Clay_Content = cropField.SoilProperty.Clay_Content, OM_Const = cropField.SoilProperty.OM_Const, Depth10 = cropField.SoilProperty.Depth10 }, SoilProperty = new SoilProperty { Clay_Content = cropField.SoilProperty.Clay_Content, OM_Const = cropField.SoilProperty.OM_Const, Depth10 = cropField.SoilProperty.Depth10, Depth = cropField.SoilProperty.Depth, OM_Type = cropField.SoilProperty.OM_Type },
GreenManures = greenManures GreenManures = greenManures
}); });
foreach (var crops in cropField.HistoricalCropData) foreach (var crops in cropField.HistoricalCropData)
{ {
foreach (var cropYear in crops.Crops) foreach (var cropYear in crops.Crops)
{ {
if (!string.IsNullOrEmpty(cropYear.MiterraCropName)) if (!string.IsNullOrEmpty(cropYear.MiterraCropName))
@@ -157,8 +157,9 @@ namespace FarmMapsAPI.Carbon
CropRes = cropYear.CropRes, CropRes = cropYear.CropRes,
OrganicManures = OrganicManures =
cropYear.OrganicManures.Where(y=>y.Quantity > 0 && !string.IsNullOrEmpty(y.Type)).Select(x => new OrganicManureType { Type = x.Type, Quantity = x.Quantity }).ToList(), cropYear.OrganicManures.Where(y=>y.Quantity > 0 && !string.IsNullOrEmpty(y.Type)).Select(x => new OrganicManureType { Type = x.Type, Quantity = x.Quantity }).ToList(),
CropYield = cropYear.CropYield } } CropYield = cropYear.CropYield,
}); Irrigation = crops.Irrigations} }
});
} }
else else
{ {
@@ -265,6 +266,7 @@ namespace FarmMapsAPI.Carbon
var initialSoilKey = historicalCropdata.Keys.FirstOrDefault(x => x.Item1 == item.Key && x.Item2 == year.First()); var initialSoilKey = historicalCropdata.Keys.FirstOrDefault(x => x.Item1 == item.Key && x.Item2 == year.First());
var initialSoil = historicalCropdata[initialSoilKey].FirstOrDefault(); var initialSoil = historicalCropdata[initialSoilKey].FirstOrDefault();
var soilPropertyDepth10 = item.Value.Depth10; var soilPropertyDepth10 = item.Value.Depth10;
//FSA todo: different corrections for depth10 (10, 25, 30 cm)
if (initialSoil == "Temp_gras" && soilPropertyDepth10) if (initialSoil == "Temp_gras" && soilPropertyDepth10)
{ {
oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont * 0.97); oM_corr_SoilType.Add((item.Key, soilOfItem), item.Value.OM_Cont * 0.97);
@@ -778,7 +780,7 @@ namespace FarmMapsAPI.Carbon
{ {
smdMaxValue = smdMax[climateItem.Key] / 1.8; smdMaxValue = smdMax[climateItem.Key] / 1.8;
} }
//fsa todo: add precipitation
var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration; var result = climateItem.Value[i].Precipitation - climateItem.Value[i].Evapotranspiration;
result = result < 0 ? result : 0; result = result < 0 ? result : 0;
result = result < smdMaxValue ? smdMaxValue : result; result = result < smdMaxValue ? smdMaxValue : result;

View File

@@ -8,12 +8,12 @@
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<Version>2.2.0</Version> <Version>4.0.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Base.Core.Common" Version="2.3.0" /> <PackageReference Include="Base.Core.Common" Version="4.0.0-prerelease.2064" />
<PackageReference Include="Base.Core.Common.Geometry" Version="2.3.0" /> <PackageReference Include="Base.Core.Common.Geometry" Version="4.0.0-prerelease.2073" />
<PackageReference Include="NetTopologySuite" Version="2.5.0" /> <PackageReference Include="NetTopologySuite" Version="2.5.0" />
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="3.0.0" /> <PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="3.0.0" />
</ItemGroup> </ItemGroup>

View File

@@ -30,14 +30,16 @@ namespace CarbonService.Models
public SoilProperty SoilProperty { get; set; } public SoilProperty SoilProperty { get; set; }
[Required] [Required]
public List<HistoricalCropData> HistoricalCropData { get; set; } public List<HistoricalCropData> HistoricalCropData { get; set; }
public List<GreenManure> GreenManures { get; set; } public List<GreenManure> GreenManures { get; set; }
} }
public class SoilProperty public class SoilProperty
{ {
public double? OM_Const { get; set; } public double? OM_Const { get; set; }
public string OM_Type { get; set; }
public double? Clay_Content { get; set; } public double? Clay_Content { get; set; }
public bool? Depth10 { get; set; } public bool? Depth10 { get; set; }
public int? Depth { get; set; }
} }
public class OrgManureApplied public class OrgManureApplied
@@ -49,6 +51,7 @@ namespace CarbonService.Models
public List<OrganicManureType> OrganicManures { get; set; } public List<OrganicManureType> OrganicManures { get; set; }
public double? CropYield { get { return (int?)yield; } set { yield = value; } } public double? CropYield { get { return (int?)yield; } set { yield = value; } }
public bool CropRes { get; set; } public bool CropRes { get; set; }
public string Irrigation { get; set; }
} }
public class OrganicManureType public class OrganicManureType

View File

@@ -44,6 +44,7 @@ namespace FarmMapsAPI.Carbon.Models
public List<CropData> Crops { get; set; } public List<CropData> Crops { get; set; }
public List<GreenManureTypeFarmMaps> GreenManures { get; set; } public List<GreenManureTypeFarmMaps> GreenManures { get; set; }
public bool Rotation { get; set; } public bool Rotation { get; set; }
public string Irrigations { get; set; }
public HistoricalCropDataFarmMaps DeepCopy() public HistoricalCropDataFarmMaps DeepCopy()
{ {
@@ -75,8 +76,10 @@ namespace FarmMapsAPI.Carbon.Models
public class SoilPropertyFarmMaps public class SoilPropertyFarmMaps
{ {
public double? OM_Const { get; set; } public double? OM_Const { get; set; }
public string OM_Type { get; set; }
public double? Clay_Content { get; set; } public double? Clay_Content { get; set; }
public bool Depth10 { get; set; } public bool Depth10 { get; set; }
public int? Depth { get; set; }
} }
public class GreenManureTypeFarmMaps public class GreenManureTypeFarmMaps