added option to process tiff data to NBS and Planting applicaions
This commit is contained in:
parent
b56b38c308
commit
ecfc76105f
@ -79,31 +79,44 @@ namespace FarmmapsNbs
|
||||
var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code,
|
||||
$"VRA NBS cropfield {input.OutputFileName}", plantingDate.Year, input.GeometryJson.ToString(Formatting.None));
|
||||
|
||||
var isGeoJson = input.File.Contains("json");
|
||||
var dataPath = Path.Combine("Data", input.File);
|
||||
var shapeItem = isGeoJson ?
|
||||
await _generalService.UploadDataAsync(uploadedRoot, SHAPE_PROCESSED_ITEMTYPE, dataPath, Path.GetFileNameWithoutExtension(input.File)):
|
||||
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.File));
|
||||
var geotiffItem = (Item)null;
|
||||
|
||||
if (shapeItem == null)
|
||||
{
|
||||
_logger.LogError("Could not find item for uploaded data");
|
||||
return;
|
||||
if (input.File.Contains(".tif") || input.File.Contains(".geotiff")) {
|
||||
_logger.LogInformation("input = tiff data");
|
||||
var dataPath = Path.Combine("Data", input.File);
|
||||
geotiffItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE, dataPath,
|
||||
Path.GetFileNameWithoutExtension(input.File));
|
||||
|
||||
if (geotiffItem == null) {
|
||||
_logger.LogError("Could not find item for uploaded data");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
var isGeoJson = input.File.Contains("json");
|
||||
var dataPath = Path.Combine("Data", input.File);
|
||||
var shapeItem = isGeoJson ?
|
||||
await _generalService.UploadDataAsync(uploadedRoot, SHAPE_PROCESSED_ITEMTYPE, dataPath, Path.GetFileNameWithoutExtension(input.File)) :
|
||||
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.File));
|
||||
|
||||
if (shapeItem == null) {
|
||||
_logger.LogError("Could not find item for uploaded data");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Converting shape to geotiff");
|
||||
geotiffItem = await _generalService.ShapeToGeotiff(shapeItem);
|
||||
if (geotiffItem == null) {
|
||||
_logger.LogError("Something went wrong with shape to geotiff transformation");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Downloading geotiff file");
|
||||
await _farmmapsApiService.DownloadItemAsync(geotiffItem.Code,
|
||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.input_geotiff.zip"));
|
||||
}
|
||||
|
||||
_logger.LogInformation($"Converting shape to geotiff");
|
||||
var geotiffItem = await _generalService.ShapeToGeotiff(shapeItem);
|
||||
if (geotiffItem == null)
|
||||
{
|
||||
_logger.LogError("Something went wrong with shape to geotiff transformation");
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Downloading geotiff file");
|
||||
await _farmmapsApiService.DownloadItemAsync(geotiffItem.Code,
|
||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.input_geotiff.zip"));
|
||||
|
||||
|
||||
_logger.LogInformation($"Calculating targetN with targetYield: {input.TargetYield}");
|
||||
var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem);
|
||||
var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate,
|
||||
@ -116,6 +129,9 @@ namespace FarmmapsNbs
|
||||
}
|
||||
|
||||
_logger.LogInformation($"TargetN: {targetNData.TargetN}");
|
||||
////Option to manually adjust the Target N, for test purposes only!
|
||||
//targetNData.TargetN = 225;
|
||||
//_logger.LogInformation($"TargetN adjusted: {targetNData.TargetN}");
|
||||
|
||||
var targetNDataPath = Path.Combine(DownloadFolder, $"{input.OutputFileName}.targetn.json");
|
||||
await File.WriteAllTextAsync(targetNDataPath, JsonConvert.SerializeObject(targetNData, Formatting.Indented));
|
||||
|
@ -94,8 +94,8 @@ namespace FarmmapsNbs
|
||||
nbsUptakeMapRequest.attributes["inputType"] = inputType.ToLower();
|
||||
nbsUptakeMapRequest.attributes["inputLayerName"] = "IRMI"; //toevoeging FS. Kolom IRMI hernoemd als IMI. Deze wordt niet automatisch herkend. En moet dus gespecificeerd worden.
|
||||
|
||||
var layers = inputItem.Data["layers"]; //toevoeging FS, check welke data lagen worden omgezet
|
||||
_logger.LogInformation($"DataLayers: {layers}"); //toevoeging FS check welke data lagen worden omgezet
|
||||
//var layers = inputItem.Data["layers"]; //toevoeging FS, check welke data lagen worden omgezet
|
||||
//_logger.LogInformation($"DataLayers: {layers}"); //toevoeging FS check welke data lagen worden omgezet
|
||||
|
||||
|
||||
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, nbsUptakeMapRequest);
|
||||
|
@ -128,6 +128,19 @@ namespace FarmmapsVRApoten
|
||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.BOFEK.zip"));
|
||||
}
|
||||
|
||||
|
||||
else if (input.File.Contains(".tif") || input.File.Contains(".geotiff")) {
|
||||
_logger.LogInformation("input = tiff data");
|
||||
var dataPath = Path.Combine("Data", input.File);
|
||||
geotiffItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE, dataPath,
|
||||
Path.GetFileNameWithoutExtension(input.File));
|
||||
|
||||
if (geotiffItem == null) {
|
||||
_logger.LogError("Could not find item for uploaded data");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var isGeoJson = input.File.Contains("json");
|
||||
|
Loading…
Reference in New Issue
Block a user