Update zonering to find the right output files

Added taskmap creator to NBS
This commit is contained in:
Riepma
2021-02-15 17:06:09 +01:00
parent c02b232837
commit 101b683daa
9 changed files with 194 additions and 95 deletions

View File

@@ -0,0 +1,40 @@
[
{
"UseCreatedCropfield": false,
"storeStatistics": false,
"file": "20210127_WDVI_plus03.tif",
"inputVariable": "wdvi",
//"InputLayerName": "Band 1",
"outputFileName": "2021.02.15.Hapreet_Singh_0127-wdvi03_2",
"plantingDate": "2020-04-15",
"measurementDate": "2020-06-27",
"potatoPurposeType": "consumption",
"targetYield": 27,
"fieldName": "Mahindra-Hapreet-Singh",
"geometryJson": {
"type": "Polygon",
"coordinates": [
[
[ 75.929090780177305, 31.639314978348551 ],
[ 75.931353489378182, 31.639409065494881 ],
[ 75.931432810729120, 31.638956841735819 ],
[ 75.929072617175663, 31.638879365370279 ],
[ 75.929090780177305, 31.639314978348551 ]
]
]
},
"GenerateTaskmap": true,
"CellWidth": "3",
"CellHeight": "10",
"StartPoint": {
"type": "Point",
"coordinates": [ 75.931432810729120, 31.638956841735819 ]
},
"EndPoint": {
"type": "Point",
"coordinates": [ 75.929072617175663, 31.638879365370279 ]
} // if no angle
//"Angle": "317.0" // if no endpoint
}
]

View File

@@ -5,6 +5,7 @@ namespace FarmmapsNbs.Models
{
public class NitrogenInput
{
public bool UseCreatedCropfield { get; set; }
public string File { get; set; }
public string InputVariable { get; set; }
public string OutputFileName { get; set; }
@@ -16,6 +17,12 @@ namespace FarmmapsNbs.Models
public string InputLayerName { get; set; }
public string fieldName{ get; set; }
public bool storeSatelliteStatistics { get; set; }
public bool GenerateTaskmap { get; set; }
public string CellWidth { get; set; }
public string CellHeight { get; set; }
public JObject StartPoint { get; set; }
public JObject EndPoint { get; set; }
public string Angle { get; set; }
}

View File

@@ -37,7 +37,7 @@ namespace FarmmapsNbs
public async Task RunAsync()
{
var nitrogenInputJson = File.ReadAllText("NitrogenInput.json");
var nitrogenInputJson = File.ReadAllText("InputData-NBS.json"); //NitrogenInput.json
List<NitrogenInput> nitrogenInputs = JsonConvert.DeserializeObject<List<NitrogenInput>>(nitrogenInputJson);
if (!Directory.Exists(DownloadFolder))
@@ -64,7 +64,7 @@ namespace FarmmapsNbs
{
// !!specify if you are using an already created cropfield:
bool useCreatedCropfield = true;
bool useCreatedCropfield = input. UseCreatedCropfield;
var plantingDate = input.PlantingDate;
var FieldName = input.fieldName;
bool StoreStatistics = input.storeSatelliteStatistics;
@@ -274,13 +274,25 @@ namespace FarmmapsNbs
_logger.LogError("Could not find item for uploaded data");
return;
}
_logger.LogInformation($"Converting geotiff to shape");
var taskmap = await _generalService.GeotiffToShape(tiffItem);
if (taskmap == null) {
//_logger.LogInformation($"Converting geotiff to shape");
//var taskmap = await _generalService.GeotiffToShape(tiffItem);
//if (taskmap == null) {
// _logger.LogError("Something went wrong with geotiff to shape transformation");
// return;
//}
//ApplicationMap (GEOTIFF) To Taskmap
_logger.LogInformation($"Converting geotiff to taskmap");
var taskmap = await _generalService.CreateTaskmap(cropfieldItem, tiffItem, input.CellWidth, input.CellHeight, input.StartPoint.ToString(Formatting.None),
input.EndPoint.ToString(Formatting.None), input.Angle);
if (taskmap == null)
{
_logger.LogError("Something went wrong with geotiff to shape transformation");
return;
}
_logger.LogInformation("Downloading taskmap");
await _farmmapsApiService.DownloadItemAsync(taskmap.Code,
Path.Combine(DownloadFolder, $"{input.OutputFileName}.taskmap.zip"));