forked from FarmMaps/FarmMapsApiClient
Compare commits
No commits in common. "357bcaea6059aa2d6e7a9fe88646120c7fd6dc12" and "262bd641a83750954567af5538a46ef9630d48aa" have entirely different histories.
357bcaea60
...
262bd641a8
@ -120,13 +120,13 @@ namespace FarmmapsNbs
|
|||||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.uptake.zip"));
|
Path.Combine(DownloadFolder, $"{input.OutputFileName}.uptake.zip"));
|
||||||
|
|
||||||
_logger.LogInformation("Calculating application map");
|
_logger.LogInformation("Calculating application map");
|
||||||
var applicationMapItem =
|
var applianceMapItem =
|
||||||
await _nitrogenService.CalculateApplicationMap(cropfieldItem, geotiffItem, plantingDate,
|
await _nitrogenService.CalculateApplicationMap(cropfieldItem, geotiffItem, plantingDate,
|
||||||
measurementDate,
|
measurementDate,
|
||||||
input.InputVariable, targetNData.TargetN);
|
input.InputVariable, targetNData.TargetN);
|
||||||
|
|
||||||
_logger.LogInformation("Downloading application map");
|
_logger.LogInformation("Downloading application map");
|
||||||
await _farmmapsApiService.DownloadItemAsync(applicationMapItem.Code,
|
await _farmmapsApiService.DownloadItemAsync(applianceMapItem.Code,
|
||||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.application.zip"));
|
Path.Combine(DownloadFolder, $"{input.OutputFileName}.application.zip"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ namespace FarmmapsNbs
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates the nitrogen application map based on given input data
|
/// Creates the nitrogen appliance map based on given input data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cropfieldItem">The cropfield to base the calculations on</param>
|
/// <param name="cropfieldItem">The cropfield to base the calculations on</param>
|
||||||
/// <param name="inputItem">The farmmaps item containing the geotiff data</param>
|
/// <param name="inputItem">The farmmaps item containing the geotiff data</param>
|
||||||
@ -137,16 +137,16 @@ namespace FarmmapsNbs
|
|||||||
public async Task<Item> CalculateApplicationMap(Item cropfieldItem, Item inputItem, DateTime plantingDate,
|
public async Task<Item> CalculateApplicationMap(Item cropfieldItem, Item inputItem, DateTime plantingDate,
|
||||||
DateTime measurementDate, string inputType, double targetN)
|
DateTime measurementDate, string inputType, double targetN)
|
||||||
{
|
{
|
||||||
var nbsApplicationMapRequest = new TaskRequest {TaskType = VRANBS_TASK};
|
var nbsApplianceMapRequest = new TaskRequest {TaskType = VRANBS_TASK};
|
||||||
nbsApplicationMapRequest.attributes["operation"] = "application";
|
nbsApplianceMapRequest.attributes["operation"] = "application";
|
||||||
nbsApplicationMapRequest.attributes["inputCode"] = inputItem.Code;
|
nbsApplianceMapRequest.attributes["inputCode"] = inputItem.Code;
|
||||||
nbsApplicationMapRequest.attributes["plantingDate"] = plantingDate.ToString();
|
nbsApplianceMapRequest.attributes["plantingDate"] = plantingDate.ToString();
|
||||||
nbsApplicationMapRequest.attributes["measurementDate"] = measurementDate.ToString();
|
nbsApplianceMapRequest.attributes["measurementDate"] = measurementDate.ToString();
|
||||||
nbsApplicationMapRequest.attributes["inputCode"] = inputItem.Code;
|
nbsApplianceMapRequest.attributes["inputCode"] = inputItem.Code;
|
||||||
nbsApplicationMapRequest.attributes["inputType"] = inputType.ToLower();
|
nbsApplianceMapRequest.attributes["inputType"] = inputType.ToLower();
|
||||||
nbsApplicationMapRequest.attributes["targetN"] = targetN.ToString(CultureInfo.InvariantCulture);
|
nbsApplianceMapRequest.attributes["targetN"] = targetN.ToString(CultureInfo.InvariantCulture);
|
||||||
|
|
||||||
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, nbsApplicationMapRequest);
|
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, nbsApplianceMapRequest);
|
||||||
|
|
||||||
await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) =>
|
await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) =>
|
||||||
{
|
{
|
||||||
@ -163,17 +163,17 @@ namespace FarmmapsNbs
|
|||||||
}
|
}
|
||||||
|
|
||||||
var itemName = $"VRANbs application";
|
var itemName = $"VRANbs application";
|
||||||
var applicationMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
|
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
|
||||||
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
|
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
|
||||||
i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) &&
|
i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) &&
|
||||||
i.Name.ToLower().Contains(itemName.ToLower()));
|
i.Name.ToLower().Contains(itemName.ToLower()));
|
||||||
if (applicationMapItem == null)
|
if (applianceMapItem == null)
|
||||||
{
|
{
|
||||||
_logger.LogError("Could not find the application map geotiff child item under cropfield");
|
_logger.LogError("Could not find the application map geotiff child item under cropfield");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return applicationMapItem;
|
return applianceMapItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user