Added Taskmap sample code to potenAPI

This commit is contained in:
Riepma
2021-02-12 17:10:25 +01:00
parent a29b973268
commit c02b232837
6 changed files with 170 additions and 34 deletions

View File

@@ -58,6 +58,8 @@ namespace FarmmapsVRApoten
var variation = input.Variation;
var fieldName = input.FieldName;
bool useShadow = input.UseShadow;
bool convertToCountPerArea = input.ConvertToCountPerArea;
float rijBreedte_m = input.Rijbreedte_m;
var myDrive = roots.SingleOrDefault(r => r.Name == "My drive");
if (myDrive == null) {
@@ -94,7 +96,8 @@ namespace FarmmapsVRApoten
//Calculating AHN map
_logger.LogInformation("retreiving AHN map for field");
var AHNItem = await _generalService.RunAhnTask(cropfieldItem);
if (AHNItem == null) {
if (AHNItem == null)
{
_logger.LogError("Something went wrong while obtaining the AHN map");
return;
}
@@ -160,6 +163,8 @@ namespace FarmmapsVRApoten
Path.Combine(DownloadFolder, $"VRApoten_inputGeotiff_{input.OutputFileName}.zip"));
}
// create appliance map
_logger.LogInformation("Calculating application map");
@@ -180,13 +185,35 @@ namespace FarmmapsVRApoten
? "Download application map completed."
: "Something went wrong while downloading.");
_logger.LogInformation($"Converting geotiff to shape");
var taskmap = await _generalService.GeotiffToShape(applianceMapItem);
if (taskmap == null) {
// if convertToCountPerArea == True, than recalculate pootafstand in cm to # of poters/m2 from the geotiffItem with the use of the zoneringsTask
if (convertToCountPerArea)
{
applianceMapItem =
await _potenService.ConvertToCountPerAreaTroughZonering(cropfieldItem, applianceMapItem, input.Rijbreedte_m);
}
//GEOTIFF TO Taskmap
_logger.LogInformation($"Converting geotiff to taskmap");
var taskmap = await _generalService.CreateTaskmap(applianceMapItem, input.CellWidth, input.CellHeight, input.StartPoint.ToString(Formatting.None),
input.EndPoint.ToString(Formatting.None), input.Angle);
if (taskmap == null)
{
_logger.LogError("Something went wrong with geotiff to shape transformation");
return;
}
////GEOTIFF TO SHAPE
//_logger.LogInformation($"Converting geotiff to shape");
//var geotiffToShapeItem= await _generalService.GeotiffToShape(applianceMapItem);
//if (taskmap == null) {
// _logger.LogError("Something went wrong with geotiff to shape transformation");
// return;
//}
_logger.LogInformation("Downloading taskmap");
await _farmmapsApiService.DownloadItemAsync(taskmap.Code,
Path.Combine(DownloadFolder, $"VRApoten_taskmap_{input.OutputFileName}.zip"));