forked from FarmMaps/FarmMapsApiClient
"Inputfile created for zonering"
This commit is contained in:
parent
02708ba01d
commit
764df7ce91
@ -15,6 +15,9 @@
|
|||||||
<None Update="appsettings.json">
|
<None Update="appsettings.json">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="ZoneringInput.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -3,5 +3,8 @@ namespace FarmmapsHaulmkilling.Models
|
|||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
public string CropfieldItemCode { get; set; }
|
public string CropfieldItemCode { get; set; }
|
||||||
|
public string CropfieldName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
20
FarmmapsZonering/Models/ZoneringInput.cs
Normal file
20
FarmmapsZonering/Models/ZoneringInput.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace FarmmapsZonering.Models
|
||||||
|
{
|
||||||
|
public class ZoneringInput
|
||||||
|
{
|
||||||
|
public string InputItemOne { get; set; }
|
||||||
|
public string InputItemTwo { get; set; }
|
||||||
|
public string Formula { get; set; }
|
||||||
|
public string OutputFileName { get; set; }
|
||||||
|
public string CropFieldName { get; set; }
|
||||||
|
public string LayerName { get; set; }
|
||||||
|
public string CalculatedQuantity { get; set; }
|
||||||
|
public string CalculatedUnit { get; set; }
|
||||||
|
public bool CreateNewCropfield { get; set; }
|
||||||
|
public int CropYear { get; set; }
|
||||||
|
public JObject GeometryJson { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -84,17 +84,14 @@ namespace FarmmapsZonering
|
|||||||
}
|
}
|
||||||
|
|
||||||
Item cropfieldItem;
|
Item cropfieldItem;
|
||||||
if (string.IsNullOrEmpty(_settings.CropfieldItemCode))
|
if (string.IsNullOrEmpty(_settings.CropfieldItemCode) || input.CreateNewCropfield == true)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Creating cropfield");
|
_logger.LogInformation("Creating cropfield");
|
||||||
|
|
||||||
//var cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, input.CropFieldName, input.cropYear
|
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, input.CropFieldName, input.CropYear,
|
||||||
//$"VRA Poten cropfield {input.OutputFileName}",
|
input.GeometryJson.ToString(Formatting.None));
|
||||||
//input.GeometryJson.ToString(Formatting.None));
|
|
||||||
|
|
||||||
|
_settings.CropfieldName = cropfieldItem.Name;
|
||||||
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;
|
_settings.CropfieldItemCode = cropfieldItem.Code;
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
@ -105,24 +102,25 @@ namespace FarmmapsZonering
|
|||||||
}
|
}
|
||||||
|
|
||||||
var inputOneItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
|
var inputOneItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
|
||||||
Path.Combine("Data", "data_9001.tif"),"data_9001");
|
Path.Combine("Data", $"{input.InputItemOne}"),Path.GetFileNameWithoutExtension($"{input.InputItemOne}"));
|
||||||
if (inputOneItem == null) {
|
if (inputOneItem == null) {
|
||||||
_logger.LogError("Could not find item for uploaded data");
|
_logger.LogError("Could not find item for uploaded data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputTwoItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
|
var inputTwoItem = await _generalService.UploadDataAsync(uploadedRoot, GEOTIFF_PROCESSED_ITEMTYPE,
|
||||||
Path.Combine("Data", "data_times_two_4326.tiff"), "data_times_two_4326");
|
Path.Combine("Data", $"{input.InputItemTwo}"), Path.GetFileNameWithoutExtension($"{input.InputItemTwo}"));
|
||||||
if (inputTwoItem == null) {
|
if (inputTwoItem == null) {
|
||||||
_logger.LogError("Could not find item for uploaded data");
|
_logger.LogError("Could not find item for uploaded data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, "if [0] >= 1.28 then [1] else 0", new Output()
|
var outputItem = await _zoneringService.CreateApplicationMapAsync(cropfieldItem, input.Formula, new Output()
|
||||||
{
|
{
|
||||||
Name = "Remove",
|
Name = input.LayerName,
|
||||||
Unit = "m&m",
|
Quantity = input.CalculatedQuantity,
|
||||||
Quantity = "Nonsense"
|
Unit = input.CalculatedUnit,
|
||||||
|
|
||||||
}, new InputParameter()
|
}, new InputParameter()
|
||||||
{
|
{
|
||||||
ItemCode = inputOneItem.Code,
|
ItemCode = inputOneItem.Code,
|
||||||
@ -135,8 +133,11 @@ namespace FarmmapsZonering
|
|||||||
});
|
});
|
||||||
|
|
||||||
_logger.LogInformation("Downloading output");
|
_logger.LogInformation("Downloading output");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await _farmmapsApiService.DownloadItemAsync(outputItem.Code,
|
await _farmmapsApiService.DownloadItemAsync(outputItem.Code,
|
||||||
Path.Combine(DownloadFolder, $"NonsenseRemove.zip"));
|
Path.Combine(DownloadFolder, $"{input.OutputFileName}.zip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSettings()
|
private void LoadSettings()
|
||||||
|
29
FarmmapsZonering/ZoneringInput.json
Normal file
29
FarmmapsZonering/ZoneringInput.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"InputItemOne": "20201106_Sentinel2_L2A_B04.tiff",
|
||||||
|
"InputItemTwo": "20201106_Sentinel2_L2A_B08.tiff",
|
||||||
|
"Formula": "([1]-[0])/([1]+[0])",
|
||||||
|
"CreatedLayerName": "Biomassa",
|
||||||
|
"CalculatedQuantity": "NDVI",
|
||||||
|
"CalculatedUnit": "ndviValue",
|
||||||
|
|
||||||
|
"OutputFileName": "FullField_NDVI",
|
||||||
|
"CropFieldName": "FullField",
|
||||||
|
"CreateNewCropfield": false,
|
||||||
|
"CropYear": 2020,
|
||||||
|
"geometryJson": {
|
||||||
|
"type": "Polygon",
|
||||||
|
"coordinates": [
|
||||||
|
|
||||||
|
[
|
||||||
|
[ 4.9593709, 52.8014339 ],
|
||||||
|
[ 4.9675488, 52.7943149 ],
|
||||||
|
[ 4.9735195, 52.7968665 ],
|
||||||
|
[ 4.9667833, 52.8030414 ],
|
||||||
|
[ 4.9593709, 52.8014339 ]
|
||||||
|
]
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user