can now specify geojson bounds for upload.

changed how to get agents for haulmkilling.
This commit is contained in:
2021-04-11 17:22:19 +02:00
parent a94fb260c8
commit beaf00a043
5 changed files with 24 additions and 39 deletions

View File

@@ -6,6 +6,7 @@ using FarmmapsApi.Models;
using FarmmapsApi.Services;
using FarmmapsHaulmkilling.Models;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using static FarmmapsApi.Extensions;
using static FarmmapsApiSamples.Constants;
@@ -31,14 +32,11 @@ namespace FarmmapsHaulmkilling
/// <returns>List of haulmkilling agents</returns>
public async Task<List<HaulmkillingAgent>> GetHaulmkillingAgents()
{
var itemType = "vnd.farmmaps.package.vra.haulmkilling";
var vraHerbicideDataItems = await _farmmapsApiService.GetItemsAsync(string.Empty, itemType);
var itemType = "vnd.farmmaps.itemtype.codelist.fm005";
var haulmkillingAgentItems = 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<HaulmkillingAgent>>() : null;
return haulmkillingAgentItems.Select(item => item.Data.ToObject<HaulmkillingAgent>())
.ToList();
}
/// <summary>
@@ -47,11 +45,11 @@ namespace FarmmapsHaulmkilling
/// <param name="cropfieldItem">The context cropfield item to use</param>
/// <param name="inputItem">The geotiff item to use</param>
/// <param name="inputType">WDVI or NDVI</param>
/// <param name="agentName">One of the available agents</param>
/// <param name="agentCode">code of one of the available agents</param>
/// <param name="selectedOption">One of the available options</param>
/// <returns>Haulmkilling application map item</returns>
public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string inputType,
string agentName, string selectedOption)
string selectedOption, HaulmkillingAgent agent)
{
var taskRequest = new TaskRequest()
{
@@ -59,7 +57,7 @@ namespace FarmmapsHaulmkilling
};
taskRequest.attributes["inputCode"] = inputItem.Code;
taskRequest.attributes["inputType"] = inputType;
taskRequest.attributes["agentName"] = agentName;
taskRequest.attributes["agentCode"] = agent.Code;
taskRequest.attributes["selectedOption"] = selectedOption;
taskRequest.attributes["minPercentile"] = "0.0";
@@ -79,7 +77,7 @@ namespace FarmmapsHaulmkilling
return null;
}
var itemName = $"VRAHaulmkilling {agentName}";
var itemName = $"VRAHaulmkilling {agent.Label}";
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
i => i.Updated >= itemTask.Finished &&