forked from FarmMaps/FarmMapsApiClient
zonering most basic flow
This commit is contained in:
@@ -5,6 +5,7 @@ using FarmmapsApi;
|
||||
using FarmmapsApi.Models;
|
||||
using FarmmapsApi.Services;
|
||||
using FarmmapsHaulmkilling.Models;
|
||||
using FarmmapsZonering.Models;
|
||||
using FarmmapsZonering.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
@@ -63,7 +64,7 @@ namespace FarmmapsZonering
|
||||
{
|
||||
_logger.LogInformation("Creating cropfield");
|
||||
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield VRA Zonering", 2020,
|
||||
@"{""type"":""Polygon"",""coordinates"":[[[4.617786844284247,52.22533706956424],[4.618642601314543,52.225938364585989],[4.6192153806397,52.22563988897754],[4.619192414656403,52.2256242822442],[4.620306732153958,52.225031745661528],[4.620542019225217,52.22519855319158],[4.621157509147853,52.22487436515405],[4.623387917230182,52.22367660757213],[4.624563444939009,52.22304740241544],[4.624562779355982,52.223046635247019],[4.624534908813479,52.22302596787506],[4.627873021330343,52.221240670658399],[4.627504935938338,52.220104419135129],[4.627324878706837,52.22020569669098],[4.627320696113512,52.22020660117888],[4.626707169518044,52.22053923770041],[4.624700376420229,52.221619047547488],[4.623471571183885,52.22227447969577],[4.623471511010673,52.22227500174403],[4.623468838689317,52.22228052566992],[4.617786844284247,52.22533706956424]]]}");
|
||||
@"{ ""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();
|
||||
}
|
||||
@@ -73,26 +74,30 @@ namespace FarmmapsZonering
|
||||
cropfieldItem = await _farmmapsApiService.GetItemAsync(_settings.CropfieldItemCode);
|
||||
}
|
||||
|
||||
ItemTaskStatus taskStatus;
|
||||
if (string.IsNullOrEmpty(_settings.SatelliteTaskCode))
|
||||
var inputFileName = "neo_ndvi-reglone-low-weed.tif";
|
||||
var dataPath = Path.Combine("Data", inputFileName);
|
||||
var geotiffItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE, dataPath,
|
||||
Path.GetFileNameWithoutExtension(inputFileName));
|
||||
|
||||
if (geotiffItem == null) {
|
||||
_logger.LogError("Could not find item for uploaded data");
|
||||
return;
|
||||
}
|
||||
|
||||
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, "[0] * 2", new Output()
|
||||
{
|
||||
_logger.LogInformation("Gathering satellite information for cropfield, this might take a while!");
|
||||
taskStatus = await _generalService.RunAndWaitForTask(cropfieldItem, SATELLITE_TASK, null, 20);
|
||||
|
||||
if (taskStatus.State == ItemTaskState.Error)
|
||||
{
|
||||
_logger.LogError($"Something went wrong when trying to process satellite data; {taskStatus.Message}");
|
||||
return;
|
||||
}
|
||||
|
||||
_settings.SatelliteTaskCode = taskStatus.Code;
|
||||
SaveSettings();
|
||||
|
||||
}
|
||||
else
|
||||
Name = "times_2_zonering",
|
||||
Unit = "n/kg",
|
||||
Quantity = "Nitrogen"
|
||||
}, new InputParameter()
|
||||
{
|
||||
taskStatus = await _farmmapsApiService.GetTaskStatusAsync(_settings.CropfieldItemCode, _settings.SatelliteTaskCode);
|
||||
}
|
||||
ItemCode = geotiffItem.Code,
|
||||
ItemLayer = geotiffItem.Data["layers"][0]["name"].ToString()
|
||||
});
|
||||
|
||||
_logger.LogInformation("Downloading output");
|
||||
await _farmmapsApiService.DownloadItemAsync(outputItem.Code,
|
||||
Path.Combine(DownloadFolder, $"times_2_zonering.zip"));
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
|
Reference in New Issue
Block a user