forked from FarmMaps/FarmMapsApiClient
also write totalNapplied to csv file with KPI outputs per cropfield
This commit is contained in:
@@ -288,6 +288,32 @@ namespace FarmmapsKPI
|
||||
kpioPrevious = kpio;
|
||||
}
|
||||
|
||||
//Total N applied
|
||||
double totalNapplied = 0.0;
|
||||
double operationNapplied;
|
||||
JObject opData;
|
||||
for (int i = 0; i < crpOperationItemCodes.Count; i++)
|
||||
{
|
||||
codeOperation = crpOperationItemCodes[i];
|
||||
crpOperationItem = await _farmmapsApiService.GetItemAsync(codeOperation);
|
||||
operationNapplied = crpOperationItem.Data.GetValue("n").ToObject<double>();
|
||||
totalNapplied = totalNapplied + operationNapplied;
|
||||
}
|
||||
//Also add totalNapplied to the csv
|
||||
dataList = new List<string> { };
|
||||
//Seems sometimes duplicate KPI items are returned. So check that here and only write if this kpio is different from previous
|
||||
dataList.Add(kpioPrevious.parentName);
|
||||
dataList.Add(kpioPrevious.data.area);
|
||||
dataList.Add(kpioPrevious.data.cropTypeCode);
|
||||
dataList.Add(kpioPrevious.data.cropTypeName);
|
||||
dataList.Add("");
|
||||
dataList.Add("totalNapplied");
|
||||
dataList.Add(totalNapplied.ToString());
|
||||
dataList.Add(kpioPrevious.unit);
|
||||
dataList.Add("");
|
||||
dataList.Add("");
|
||||
sw.WriteLine(string.Join(",", dataList));
|
||||
|
||||
//Clean up. Only newly created fields
|
||||
//Look up instruction in Swagger / api / v1 / items /{ code}
|
||||
if (useExistingCropfieldWithChildren == false && input.DeleteNewlyCreatedAfterCalc == true)
|
||||
|
||||
Reference in New Issue
Block a user