removed 0.54 factor; fix farm totals; added miterra crop input
All checks were successful
FarmMaps.Develop/CarbonLib/pipeline/head This commit looks good

This commit is contained in:
2021-06-29 14:56:27 +02:00
parent 6554e059df
commit 110815f7ea
2 changed files with 40 additions and 26 deletions

View File

@@ -145,6 +145,21 @@ namespace FarmMapsAPI.Carbon
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))
{
mappedCropData.Add(new HistoricalCropData
{
Year = crops.Year,
Crops = new List<OrgManureApplied> {
new OrgManureApplied {
Crop = cropYear.MiterraCropName,
OrganicManures =
cropYear.OrganicManures.Select(x => new OrganicManureType { Type = x.Type, Quantity = x.Quantity }).ToList(),
CropYield = cropYear.CropYield } }
});
}
else
{ {
var cropMapping = mappingCropFarmmapsMiterraRothC.FirstOrDefault(x => x.CropCode == cropYear.CropCode); var cropMapping = mappingCropFarmmapsMiterraRothC.FirstOrDefault(x => x.CropCode == cropYear.CropCode);
if (cropMapping != null) if (cropMapping != null)
@@ -172,6 +187,7 @@ namespace FarmMapsAPI.Carbon
mappedCropData.Add(new HistoricalCropData { Year = crops.Year, Crops = new List<OrgManureApplied> { new OrgManureApplied { Crop = cropYear.CropCode, OrganicManures = null, CropYield = cropYear.CropYield } } }); mappedCropData.Add(new HistoricalCropData { Year = crops.Year, Crops = new List<OrgManureApplied> { new OrgManureApplied { Crop = cropYear.CropCode, OrganicManures = null, CropYield = cropYear.CropYield } } });
} }
} }
}
foreach (var cropYear in crops.GreenManures) foreach (var cropYear in crops.GreenManures)
{ {
@@ -1493,10 +1509,6 @@ namespace FarmMapsAPI.Carbon
sumCarbonGreenManure += item.Value.SingleOrDefault(x => x.Key == "CarbonGreenManure")?.Value ?? 0; sumCarbonGreenManure += item.Value.SingleOrDefault(x => x.Key == "CarbonGreenManure")?.Value ?? 0;
sumCarbonCompost += item.Value.SingleOrDefault(x => x.Key == "CarbonCompost")?.Value ?? 0; sumCarbonCompost += item.Value.SingleOrDefault(x => x.Key == "CarbonCompost")?.Value ?? 0;
} }
sumCarbonManure = sumCarbonManure / 0.54;
sumCarbonResidues = sumCarbonResidues / 0.54;
sumCarbonGreenManure = sumCarbonGreenManure / 0.54;
sumCarbonCompost = sumCarbonCompost / 0.54;
soc_Summary[(fieldLoop, yLoop)].Add(new ColumnValue("SOC_CarbonManure", sumCarbonManure)); soc_Summary[(fieldLoop, yLoop)].Add(new ColumnValue("SOC_CarbonManure", sumCarbonManure));
soc_Summary[(fieldLoop, yLoop)].Add(new ColumnValue("SOC_CarbonResidues", sumCarbonResidues)); soc_Summary[(fieldLoop, yLoop)].Add(new ColumnValue("SOC_CarbonResidues", sumCarbonResidues));
soc_Summary[(fieldLoop, yLoop)].Add(new ColumnValue("SOC_CarbonGreenManure", sumCarbonGreenManure)); soc_Summary[(fieldLoop, yLoop)].Add(new ColumnValue("SOC_CarbonGreenManure", sumCarbonGreenManure));
@@ -1518,7 +1530,7 @@ namespace FarmMapsAPI.Carbon
var crpField = cropFieldSummary.Single(x => x.Name == item.Key.Item1); var crpField = cropFieldSummary.Single(x => x.Name == item.Key.Item1);
var summary = crpField.Summary.Single(x => x.Year == item.Key.Item2); var summary = crpField.Summary.Single(x => x.Year == item.Key.Item2);
summary.Balance = sum / 0.54; summary.Balance = sum;
} }
foreach (var item in socIni) foreach (var item in socIni)
@@ -1639,13 +1651,14 @@ namespace FarmMapsAPI.Carbon
foreach (var item in soc_Summary.Where(x=>x.Key.Item2 == farm.Key.Item2)) foreach (var item in soc_Summary.Where(x=>x.Key.Item2 == farm.Key.Item2))
{ {
var cropfieldArea = item.Value.SingleOrDefault(x => x.Key == "Total_crop_area")?.Value ?? 0;
sumCarbonMan += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonManure")?.Value ?? 0; sumCarbonMan += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonManure")?.Value ?? 0;
sumCarbonRes += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonResidues")?.Value ?? 0; sumCarbonRes += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonResidues")?.Value ?? 0;
sumCarbonGreenMan += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonGreenManure")?.Value ?? 0; sumCarbonGreenMan += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonGreenManure")?.Value ?? 0;
sumCarbonCom += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonCompost")?.Value ?? 0; sumCarbonCom += item.Value.SingleOrDefault(x => x.Key == "SOC_CarbonCompost")?.Value ?? 0;
sumEmision += item.Value.SingleOrDefault(x => x.Key == "Emision")?.Value ?? 0; sumEmision += item.Value.SingleOrDefault(x => x.Key == "Emision")?.Value ?? 0;
sumBal += item.Value.SingleOrDefault(x => x.Key == "Balance")?.Value / 0.54 ?? 0; sumBal += item.Value.SingleOrDefault(x => x.Key == "Balance")?.Value * cropfieldArea ?? 0;
sumIni += item.Value.SingleOrDefault(x => x.Key == "Initial")?.Value ?? 0; sumIni += item.Value.SingleOrDefault(x => x.Key == "Initial")?.Value ?? 0;
sumInicc += item.Value.SingleOrDefault(x => x.Key == "IniCcontent")?.Value ?? 0; sumInicc += item.Value.SingleOrDefault(x => x.Key == "IniCcontent")?.Value ?? 0;
} }
@@ -1708,7 +1721,7 @@ namespace FarmMapsAPI.Carbon
var soilPropertiesField = new Dictionary<string, SoilPropertyType>(); var soilPropertiesField = new Dictionary<string, SoilPropertyType>();
foreach (var field in farmInput.CropFields) foreach (var field in farmInput.CropFields)
{ {
soilPropertiesField.Add(field.Name, new SoilPropertyType { OM_Cont = field.SoilProperty.OM_Const.Value, Clay_Content = field.SoilProperty.Clay_Content.Value, OM_Corr = field.SoilProperty.OM_Const.Value }); soilPropertiesField.Add(field.Name, new SoilPropertyType { OM_Cont = field.SoilProperty.OM_Const.Value, Clay_Content = field.SoilProperty.Clay_Content.Value, OM_Corr = field.SoilProperty.OM_Const.Value <= 20 ? field.SoilProperty.OM_Const.Value : 0 });
} }
return soilPropertiesField; return soilPropertiesField;

View File

@@ -55,6 +55,7 @@ namespace FarmMapsAPI.Carbon.Models
{ {
[Required] [Required]
public string CropCode { get; set; } public string CropCode { get; set; }
public string MiterraCropName { get; set; }
public List<OrganicManureFarmMaps> OrganicManures { get; set; } public List<OrganicManureFarmMaps> OrganicManures { get; set; }
public int? CropYield { get; set; } public int? CropYield { get; set; }
public bool CropRes { get; set; } public bool CropRes { get; set; }