Update zonering to find the right output files

Added taskmap creator to NBS
This commit is contained in:
Riepma
2021-02-15 17:06:09 +01:00
parent c02b232837
commit 101b683daa
9 changed files with 194 additions and 95 deletions

View File

@@ -107,26 +107,27 @@ namespace FarmmapsApi.Services
}
// Create taskmap based on width, height and direction
public async Task<Item> CreateTaskmap(Item tiffItem, string cellWidth, string cellHeight, string startPoint, string endPoint = null, string angle = null)
public async Task<Item> CreateTaskmap(Item cropfieldItem, Item tiffItem, string cellWidth, string cellHeight, string startPoint, string endPoint = null, string angle = null)
{
var taskmapRequest = new TaskRequest { TaskType = TASKMAP_TASK };
taskmapRequest.attributes["inputCode"] = tiffItem.Code;
taskmapRequest.attributes["operation"] = "shape"; // Currently onlye "shape" supported, if ISOXML is supported this should be an input
taskmapRequest.attributes["cellWidth"] = cellWidth; //metres
taskmapRequest.attributes["cellHeight"] = cellHeight; //metres
taskmapRequest.attributes["startPoint"] = startPoint; // Coordinates WGS84
if (angle == null) taskmapRequest.attributes["endPoint"] = endPoint; // Coordinates WGS84
if (endPoint == null) taskmapRequest.attributes["angle"] = angle; // degrees between 0.0 and 360.0
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(tiffItem.Code, taskmapRequest);
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, taskmapRequest);
await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) => {
var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(tiffItem.Code, itemTaskCode);
var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode);
_logger.LogInformation($"Waiting on conversion to Taskmap; status: {itemTaskStatus.State}");
if (itemTaskStatus.IsFinished)
tokenSource.Cancel();
});
var itemTask = await _farmmapsApiService.GetTaskStatusAsync(tiffItem.Code, itemTaskCode);
var itemTask = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode);
if (itemTask.State == ItemTaskState.Error)
{
_logger.LogError($"Something went wrong with task execution: {itemTask.Message}");