Updated Blight and Zonering

This commit is contained in:
2021-03-01 14:04:18 +01:00
parent a29b973268
commit 6debe82085
8 changed files with 80 additions and 31 deletions

View File

@@ -10,7 +10,7 @@ namespace FarmmapsZonering.Models
public string Formula { get; set; }
public string OutputFileName { get; set; }
public string CropFieldName { get; set; }
public string LayerName { get; set; }
public string CalculatedLayerName { get; set; }
public string CalculatedQuantity { get; set; }
public string CalculatedUnit { get; set; }
public bool CreateNewCropfield { get; set; }

View File

@@ -48,14 +48,19 @@ namespace FarmmapsZonering.Services
_logger.LogError($"Something went wrong with task execution: {itemTask.Message}");
return null;
}
var itemName = $"VRAZonering";
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
//i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) &&
// i.Name.ToLower().Contains(itemName.ToLower()));
i =>
i.Name.ToLower().Contains(itemName.ToLower()));
var uploadedFilesChildren = await _farmmapsApiService.GetItemChildrenAsync(cropfieldItem.Code);
//int last = uploadedFilesChildren.Count - 1;
//var applianceMapItem = uploadedFilesChildren[last];
var itemName = output.Name;
//var itemName = $"VRAZonering";
var applianceMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code,
GEOTIFF_PROCESSED_ITEMTYPE, itemName,
i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) &&
i.Name.ToLower().Contains(itemName.ToLower()));
if (applianceMapItem == null)
{
_logger.LogError("Could not find the VRAZonering geotiff child item under cropfield");

View File

@@ -73,7 +73,7 @@ namespace FarmmapsZonering
return;
}
bool useCreatedCropfield = true;
bool useCreatedCropfield = false;
bool GetWatBal = input.GetWatBal;
bool getVanDerSat = input.GetVanDerSat;
bool StoreVanDerSatStatistics = input.storeVanDerSatStatistics;
@@ -102,11 +102,6 @@ namespace FarmmapsZonering
_settings.CropfieldName = cropfieldItem.Name;
_settings.CropfieldItemCode = cropfieldItem.Code;
SaveSettings(settingsfile);
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 ] ] ] }");
_settings.CropfieldItemCode = cropfieldItem.Code;
SaveSettings(settingsfile);
}
else
{
@@ -163,7 +158,7 @@ namespace FarmmapsZonering
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, input.Formula, new Output()
{
Name = input.LayerName,
Name = input.CalculatedLayerName,
Quantity = input.CalculatedQuantity,
Unit = input.CalculatedUnit,
@@ -175,17 +170,18 @@ namespace FarmmapsZonering
},
new InputParameter()
{
ItemCode = inputOneItem.Code,
LayerName = inputOneItem.Data["layers"][0]["name"].ToString()
ItemCode = inputTwoItem.Code,
LayerName = inputTwoItem.Data["layers"][0]["name"].ToString()
});
_logger.LogInformation("Downloading output");
_logger.LogInformation("Downloading output");
_logger.LogInformation($"outputitem: {outputItem} with code {outputItem.Code} and date {outputItem.DataDate}");
//_logger.LogInformation($"Data: {outputItem.Data}");
await _farmmapsApiService.DownloadItemAsync(outputItem.Code,
Path.Combine(DownloadFolder, $"{input.OutputFileName}.zip"));
Path.Combine(DownloadFolder, $"{input.OutputFileName}.zoning.zip"));
}
// Functions to save previously created cropfields