Added ability to query for herbicide agents.

This commit is contained in:
Mark van der Wal 2020-04-14 20:50:27 +02:00
parent 65debd6f5f
commit 56193b1b39
2 changed files with 17 additions and 19 deletions

View File

@ -30,25 +30,6 @@ namespace FarmmapsHerbicide
_farmmapsApiService = farmmapsApiService;
_generalService = generalService;
_herbicideService = herbicideService;
_liberatorTarweAgent = new HerbicideAgent()
{
Name = "Liberator",
SoilType = "Klei",
ExtraInputType = "OrganicMatter",
ActiveSubstanceContent = "diflu100+flufenacet400",
MinDosis = 0.33f,
MaxDosis = 0.6f,
A = 0.007f,
B = 0.25f,
C = 1.05f,
D = 97f,
E = 3f,
P = 1f,
Crop = "Tarwe",
Description = "Org. stof arme grond",
TankMix = string.Empty
};
}
public async Task RunAsync()
@ -59,6 +40,9 @@ namespace FarmmapsHerbicide
// !! this call is needed the first time an api is called with a fresh clientid and secret !!
await _farmmapsApiService.GetCurrentUserCodeAsync();
var roots = await _farmmapsApiService.GetCurrentUserRootsAsync();
var agents = await _herbicideService.GetHerbicideAgents();
_liberatorTarweAgent = agents.SingleOrDefault(a => a.Name.Equals("Liberator"));
await SingleLutumTiffFlow(roots);
await MultiVanDenBorneShapeFlow(roots);

View File

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FarmmapsApi.Models;
using FarmmapsApi.Services;
@ -24,6 +26,18 @@ namespace FarmmapsHerbicide
_generalService = generalService;
}
public async Task<List<HerbicideAgent>> GetHerbicideAgents()
{
var itemType = "vnd.farmmaps.package.vra.herbicide";
var vraHerbicideDataItems = await _farmmapsApiService.GetItemsAsync(string.Empty, itemType);
var item = vraHerbicideDataItems.FirstOrDefault();
if (item == null)
return null;
return item.Data.ContainsKey("agents") ? item.Data["agents"].ToObject<List<HerbicideAgent>>() : null;
}
public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, HerbicideAgent agent, params Item[] inputItem)
{
if (inputItem.Length == 0)