"Inputfile created for zonering"

This commit is contained in:
Riepma
2020-12-18 10:22:23 +01:00
parent 02708ba01d
commit 764df7ce91
6 changed files with 74 additions and 18 deletions

View File

@@ -84,17 +84,14 @@ namespace FarmmapsZonering
}
Item cropfieldItem;
if (string.IsNullOrEmpty(_settings.CropfieldItemCode))
if (string.IsNullOrEmpty(_settings.CropfieldItemCode) || input.CreateNewCropfield == true)
{
_logger.LogInformation("Creating cropfield");
//var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, input.CropFieldName, input.cropYear
//$"VRA Poten cropfield {input.OutputFileName}",
//input.GeometryJson.ToString(Formatting.None));
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield VRA Zonering", 2020,
@"{ ""type"": ""Polygon"", ""coordinates"": [ [ [ 5.670991253771027, 52.796788997702613 ], [ 5.671526456638633, 52.797291618546666 ], [ 5.671275936147413, 52.797422436717852 ], [ 5.671959173850738, 52.798269302728798 ], [ 5.670649634919365, 52.798778791408822 ], [ 5.671503682048522, 52.799591206957416 ], [ 5.675159003761311, 52.798193567415474 ], [ 5.673029579585948, 52.796024727480535 ], [ 5.670991253771027, 52.796788997702613 ] ] ] }");
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, input.CropFieldName, input.CropYear,
input.GeometryJson.ToString(Formatting.None));
_settings.CropfieldName = cropfieldItem.Name;
_settings.CropfieldItemCode = cropfieldItem.Code;
SaveSettings();
}
@@ -105,24 +102,25 @@ namespace FarmmapsZonering
}
var inputOneItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
Path.Combine("Data", "data_9001.tif"),"data_9001");
Path.Combine("Data", $"{input.InputItemOne}"),Path.GetFileNameWithoutExtension($"{input.InputItemOne}"));
if (inputOneItem == null) {
_logger.LogError("Could not find item for uploaded data");
return;
}
var inputTwoItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
Path.Combine("Data", "data_times_two_4326.tiff"), "data_times_two_4326");
var inputTwoItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
Path.Combine("Data", $"{input.InputItemTwo}"), Path.GetFileNameWithoutExtension($"{input.InputItemTwo}"));
if (inputTwoItem == null) {
_logger.LogError("Could not find item for uploaded data");
return;
}
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, "if [0] >= 1.28 then [1] else 0", new Output()
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, input.Formula, new Output()
{
Name = "Remove",
Unit = "m&m",
Quantity = "Nonsense"
Name = input.LayerName,
Quantity = input.CalculatedQuantity,
Unit = input.CalculatedUnit,
}, new InputParameter()
{
ItemCode = inputOneItem.Code,
@@ -134,9 +132,12 @@ namespace FarmmapsZonering
LayerName = inputTwoItem.Data["layers"][0]["name"].ToString()
});
_logger.LogInformation("Downloading output");
_logger.LogInformation("Downloading output");
await _farmmapsApiService.DownloadItemAsync(outputItem.Code,
Path.Combine(DownloadFolder, $"NonsenseRemove.zip"));
Path.Combine(DownloadFolder, $"{input.OutputFileName}.zip"));
}
private void LoadSettings()