master #7
@ -79,31 +79,44 @@ namespace FarmmapsNbs
|
|||||||
var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code,
|
var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDriveRoot.Code,
|
||||||
$"VRA NBS cropfield {input.OutputFileName}", plantingDate.Year, input.GeometryJson.ToString(Formatting.None));
|
$"VRA NBS cropfield {input.OutputFileName}", plantingDate.Year, input.GeometryJson.ToString(Formatting.None));
|
||||||
|
|
||||||
var isGeoJson = input.File.Contains("json");
|
var geotiffItem = (Item)null;
|
||||||
var dataPath = Path.Combine("Data", input.File);
|
|
||||||
var shapeItem = isGeoJson ?
|
if (input.File.Contains(".tif") || input.File.Contains(".geotiff")) {
|
||||||
await _generalService.UploadDataAsync(uploadedRoot, SHAPE_PROCESSED_ITEMTYPE, dataPath, Path.GetFileNameWithoutExtension(input.File)):
|
_logger.LogInformation("input = tiff data");
|
||||||
await _generalService.UploadZipWithShapeAsync(uploadedRoot, dataPath, Path.GetFileNameWithoutExtension(input.File));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (shapeItem == null)
|
else {
|
||||||
{
|
var isGeoJson = input.File.Contains("json");
|
||||||
_logger.LogError("Could not find item for uploaded data");
|
var dataPath = Path.Combine("Data", input.File);
|
||||||
return;
|
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}");
|
_logger.LogInformation($"Calculating targetN with targetYield: {input.TargetYield}");
|
||||||
var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem);
|
var targetNItem = await _nitrogenService.CreateTargetNItem(cropfieldItem);
|
||||||
var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate,
|
var targetNData = await _nitrogenService.CalculateTargetN(cropfieldItem, targetNItem, plantingDate,
|
||||||
@ -116,6 +129,9 @@ namespace FarmmapsNbs
|
|||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation($"TargetN: {targetNData.TargetN}");
|
_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");
|
var targetNDataPath = Path.Combine(DownloadFolder, $"{input.OutputFileName}.targetn.json");
|
||||||
await File.WriteAllTextAsync(targetNDataPath, JsonConvert.SerializeObject(targetNData, Formatting.Indented));
|
await File.WriteAllTextAsync(targetNDataPath, JsonConvert.SerializeObject(targetNData, Formatting.Indented));
|
||||||
|
@ -94,8 +94,8 @@ namespace FarmmapsNbs
|
|||||||
nbsUptakeMapRequest.attributes["inputType"] = inputType.ToLower();
|
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.
|
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
|
//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
|
//_logger.LogInformation($"DataLayers: {layers}"); //toevoeging FS check welke data lagen worden omgezet
|
||||||
|
|
||||||
|
|
||||||
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, nbsUptakeMapRequest);
|
string itemTaskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, nbsUptakeMapRequest);
|
||||||
|
@ -128,6 +128,19 @@ namespace FarmmapsVRApoten
|
|||||||
Path.Combine(DownloadFolder, $"{input.OutputFileName}.BOFEK.zip"));
|
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
|
else
|
||||||
{
|
{
|
||||||
var isGeoJson = input.File.Contains("json");
|
var isGeoJson = input.File.Contains("json");
|
||||||
|
Loading…
Reference in New Issue
Block a user