update poten app with centered and countPerArea

This commit is contained in:
Riepma 2021-03-01 16:31:31 +01:00
parent 3ad594d83f
commit 39a2024718
6 changed files with 29 additions and 10 deletions

View File

@ -107,7 +107,7 @@ namespace FarmmapsApi.Services
} }
// Create taskmap based on width, height and direction // Create taskmap based on width, height and direction
public async Task<Item> CreateTaskmap(Item cropfieldItem, Item tiffItem, string cellWidth, string cellHeight, string startPoint, string endPoint = null, string angle = null) public async Task<Item> CreateTaskmap(Item cropfieldItem, Item tiffItem, string cellWidth, string cellHeight, string startPoint, string centered = "false", string endPoint = null, string angle = null)
{ {
var taskmapRequest = new TaskRequest { TaskType = TASKMAP_TASK }; var taskmapRequest = new TaskRequest { TaskType = TASKMAP_TASK };
taskmapRequest.attributes["inputCode"] = tiffItem.Code; taskmapRequest.attributes["inputCode"] = tiffItem.Code;
@ -115,6 +115,7 @@ namespace FarmmapsApi.Services
taskmapRequest.attributes["cellWidth"] = cellWidth; //metres taskmapRequest.attributes["cellWidth"] = cellWidth; //metres
taskmapRequest.attributes["cellHeight"] = cellHeight; //metres taskmapRequest.attributes["cellHeight"] = cellHeight; //metres
taskmapRequest.attributes["startPoint"] = startPoint; // Coordinates WGS84 taskmapRequest.attributes["startPoint"] = startPoint; // Coordinates WGS84
taskmapRequest.attributes["centered"] = centered;
if (angle == null) taskmapRequest.attributes["endPoint"] = endPoint; // Coordinates WGS84 if (angle == null) taskmapRequest.attributes["endPoint"] = endPoint; // Coordinates WGS84
if (endPoint == null) taskmapRequest.attributes["angle"] = angle; // degrees between 0.0 and 360.0 if (endPoint == null) taskmapRequest.attributes["angle"] = angle; // degrees between 0.0 and 360.0

View File

@ -19,9 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsHaulmkilling", "Far
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsPoten", "FarmmapsPoten\FarmmapsPoten.csproj", "{AAFAB03A-6F5C-4D91-991F-867B7898F981}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsPoten", "FarmmapsPoten\FarmmapsPoten.csproj", "{AAFAB03A-6F5C-4D91-991F-867B7898F981}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmMapsBlight", "FarmMapsBlight\FarmMapsBlight.csproj", "{892E0932-5D11-4A37-979E-CEDB39C2E181}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmMapsBlight", "FarmMapsBlight\FarmMapsBlight.csproj", "{892E0932-5D11-4A37-979E-CEDB39C2E181}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmmapsZonering", "FarmmapsZonering\FarmmapsZonering.csproj", "{91A58C4A-4A80-4079-B43D-9B851206194F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsZonering", "FarmmapsZonering\FarmmapsZonering.csproj", "{91A58C4A-4A80-4079-B43D-9B851206194F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FarmmapsPoten_AVRapi", "FarmmapsPoten_AVRapi\FarmmapsPoten_AVRapi.csproj", "{E220AA18-D735-4B07-859B-C0DA11CD1E8B}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -57,6 +59,10 @@ Global
{91A58C4A-4A80-4079-B43D-9B851206194F}.Debug|Any CPU.Build.0 = Debug|Any CPU {91A58C4A-4A80-4079-B43D-9B851206194F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91A58C4A-4A80-4079-B43D-9B851206194F}.Release|Any CPU.ActiveCfg = Release|Any CPU {91A58C4A-4A80-4079-B43D-9B851206194F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91A58C4A-4A80-4079-B43D-9B851206194F}.Release|Any CPU.Build.0 = Release|Any CPU {91A58C4A-4A80-4079-B43D-9B851206194F}.Release|Any CPU.Build.0 = Release|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E220AA18-D735-4B07-859B-C0DA11CD1E8B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -13,11 +13,13 @@ namespace FarmmapsPoten.Models
public string MeanDensity { get; set; } public string MeanDensity { get; set; }
public string Variation { get; set; } public string Variation { get; set; }
public bool UseShadow { get; set; } public bool UseShadow { get; set; }
public bool CountPerArea { get; set; }
public JObject GeometryJson { get; set; } public JObject GeometryJson { get; set; }
public bool GenerateTaskmap { get; set; } public bool GenerateTaskmap { get; set; }
public string CellWidth { get; set; } public string CellWidth { get; set; }
public string CellHeight { get; set; } public string CellHeight { get; set; }
public string Centered { get; set; }
public JObject StartPoint { get; set; } public JObject StartPoint { get; set; }
public JObject EndPoint { get; set; } public JObject EndPoint { get; set; }
public string Angle { get; set; } public string Angle { get; set; }

View File

@ -58,6 +58,7 @@ namespace FarmmapsVRApoten
var variation = input.Variation; var variation = input.Variation;
var fieldName = input.FieldName; var fieldName = input.FieldName;
bool useShadow = input.UseShadow; bool useShadow = input.UseShadow;
bool countPerArea = input.CountPerArea;
var myDrive = roots.SingleOrDefault(r => r.Name == "My drive"); var myDrive = roots.SingleOrDefault(r => r.Name == "My drive");
if (myDrive == null) { if (myDrive == null) {
@ -156,7 +157,7 @@ namespace FarmmapsVRApoten
// INPUT IS NEEDED as GEOTIFF // INPUT IS NEEDED as GEOTIFF
var applianceMapItem = var applianceMapItem =
await _potenService.CalculateApplicationMapAsync(cropfieldItem, geotiffItem, meanDensity, variation); await _potenService.CalculateApplicationMapAsync(cropfieldItem, geotiffItem, meanDensity, variation, countPerArea);
if (applianceMapItem == null) { if (applianceMapItem == null) {
return; return;
@ -175,7 +176,7 @@ namespace FarmmapsVRApoten
//GEOTIFF TO Taskmap //GEOTIFF TO Taskmap
_logger.LogInformation($"Converting geotiff to taskmap"); _logger.LogInformation($"Converting geotiff to taskmap");
var taskmap = await _generalService.CreateTaskmap(cropfieldItem, applianceMapItem, input.CellWidth, input.CellHeight, input.StartPoint.ToString(Formatting.None), var taskmap = await _generalService.CreateTaskmap(cropfieldItem, applianceMapItem, input.CellWidth, input.CellHeight, input.StartPoint.ToString(Formatting.None),
input.EndPoint.ToString(Formatting.None), input.Angle); input.Centered, input.EndPoint.ToString(Formatting.None), input.Angle);
if (taskmap == null) if (taskmap == null)
{ {
_logger.LogError("Something went wrong with geotiff to taskmap transformation"); _logger.LogError("Something went wrong with geotiff to taskmap transformation");

View File

@ -7,6 +7,7 @@
"MeanDensity": "30", "MeanDensity": "30",
"Variation": "20", "Variation": "20",
"UseShadow": false, "UseShadow": false,
"CountPerArea": true,
"geometryJson": { "geometryJson": {
"type": "Polygon", "type": "Polygon",
"coordinates": [ "coordinates": [
@ -23,13 +24,20 @@
"GenerateTaskmap": true, "GenerateTaskmap": true,
"CellWidth": "3", "CellWidth": "3",
"CellHeight": "10", "CellHeight": "10",
"Centered": "true",
"StartPoint": { "StartPoint": {
"type": "Point", "type": "Point",
"coordinates": [ 5.66886041703652044, 52.52929999060298627 ] //"coordinates": [ 5.669032078413372, 52.527906465105254 ] // 1
//"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 2
//"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 3
"coordinates": [ 5.671853762296686, 52.528056589415456 ] // 4
}, },
"EndPoint": { "EndPoint": {
"type": "Point", "type": "Point",
"coordinates": [ 5.6716230923214912, 52.52946316399909676 ] "coordinates": [ 5.669032078413372, 52.527906465105254 ] // 1
//"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 2
//"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 3
//"coordinates": [ 5.671853762296686, 52.528056589415456 ] // 4
} // if no angle } // if no angle
//"Angle": "317.0" // if no endpoint //"Angle": "317.0" // if no endpoint

View File

@ -25,13 +25,14 @@ namespace FarmmapsVRApoten
_generalService = generalService; _generalService = generalService;
} }
public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string meanDensity, string variation) public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string meanDensity, string variation, bool countPerArea)
{ {
var potenApplicationMapRequest = new TaskRequest() { TaskType = VRAPLANTING_TASK }; var potenApplicationMapRequest = new TaskRequest() { TaskType = VRAPLANTING_TASK };
if (inputItem != null) {potenApplicationMapRequest.attributes["inputCode"] = inputItem.Code; } if (inputItem != null) {potenApplicationMapRequest.attributes["inputCode"] = inputItem.Code; }
potenApplicationMapRequest.attributes["meanDensity"] = meanDensity; potenApplicationMapRequest.attributes["meanDensity"] = meanDensity;
potenApplicationMapRequest.attributes["variation"] = variation; potenApplicationMapRequest.attributes["variation"] = variation;
potenApplicationMapRequest.attributes["variation"] = variation;
potenApplicationMapRequest.attributes["countPerArea"] = countPerArea.ToString();
var taskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, potenApplicationMapRequest); var taskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, potenApplicationMapRequest);
_logger.LogInformation($"itemTaskCode: {taskCode}"); _logger.LogInformation($"itemTaskCode: {taskCode}");