diff --git a/FarmmapsApi/Services/GeneralService.cs b/FarmmapsApi/Services/GeneralService.cs index 4e1f9b0..f61ba40 100644 --- a/FarmmapsApi/Services/GeneralService.cs +++ b/FarmmapsApi/Services/GeneralService.cs @@ -107,7 +107,7 @@ namespace FarmmapsApi.Services } // Create taskmap based on width, height and direction - public async Task CreateTaskmap(Item cropfieldItem, Item tiffItem, string cellWidth, string cellHeight, string startPoint, string endPoint = null, string angle = null) + public async Task 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 }; taskmapRequest.attributes["inputCode"] = tiffItem.Code; @@ -115,6 +115,7 @@ namespace FarmmapsApi.Services taskmapRequest.attributes["cellWidth"] = cellWidth; //metres taskmapRequest.attributes["cellHeight"] = cellHeight; //metres taskmapRequest.attributes["startPoint"] = startPoint; // Coordinates WGS84 + taskmapRequest.attributes["centered"] = centered; if (angle == null) taskmapRequest.attributes["endPoint"] = endPoint; // Coordinates WGS84 if (endPoint == null) taskmapRequest.attributes["angle"] = angle; // degrees between 0.0 and 360.0 diff --git a/FarmmapsApiSamples.sln b/FarmmapsApiSamples.sln index 65894a6..62501d5 100644 --- a/FarmmapsApiSamples.sln +++ b/FarmmapsApiSamples.sln @@ -19,9 +19,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsHaulmkilling", "Far EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FarmmapsPoten", "FarmmapsPoten\FarmmapsPoten.csproj", "{AAFAB03A-6F5C-4D91-991F-867B7898F981}" 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 -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 Global 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}.Release|Any CPU.ActiveCfg = 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 GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FarmmapsPoten/Models/PotenInput.cs b/FarmmapsPoten/Models/PotenInput.cs index 52bda2d..46a7e11 100644 --- a/FarmmapsPoten/Models/PotenInput.cs +++ b/FarmmapsPoten/Models/PotenInput.cs @@ -13,11 +13,13 @@ namespace FarmmapsPoten.Models public string MeanDensity { get; set; } public string Variation { get; set; } public bool UseShadow { get; set; } + public bool CountPerArea { get; set; } public JObject GeometryJson { get; set; } public bool GenerateTaskmap { get; set; } public string CellWidth { get; set; } public string CellHeight { get; set; } + public string Centered { get; set; } public JObject StartPoint { get; set; } public JObject EndPoint { get; set; } public string Angle { get; set; } diff --git a/FarmmapsPoten/PotenApplication.cs b/FarmmapsPoten/PotenApplication.cs index 637b9c3..2ebed6f 100644 --- a/FarmmapsPoten/PotenApplication.cs +++ b/FarmmapsPoten/PotenApplication.cs @@ -58,6 +58,7 @@ namespace FarmmapsVRApoten var variation = input.Variation; var fieldName = input.FieldName; bool useShadow = input.UseShadow; + bool countPerArea = input.CountPerArea; var myDrive = roots.SingleOrDefault(r => r.Name == "My drive"); if (myDrive == null) { @@ -156,7 +157,7 @@ namespace FarmmapsVRApoten // INPUT IS NEEDED as GEOTIFF var applianceMapItem = - await _potenService.CalculateApplicationMapAsync(cropfieldItem, geotiffItem, meanDensity, variation); + await _potenService.CalculateApplicationMapAsync(cropfieldItem, geotiffItem, meanDensity, variation, countPerArea); if (applianceMapItem == null) { return; @@ -174,8 +175,8 @@ namespace FarmmapsVRApoten //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), - input.EndPoint.ToString(Formatting.None), input.Angle); + var taskmap = await _generalService.CreateTaskmap(cropfieldItem, applianceMapItem, input.CellWidth, input.CellHeight, input.StartPoint.ToString(Formatting.None), + input.Centered, input.EndPoint.ToString(Formatting.None), input.Angle); if (taskmap == null) { _logger.LogError("Something went wrong with geotiff to taskmap transformation"); diff --git a/FarmmapsPoten/PotenInput.json b/FarmmapsPoten/PotenInput.json index 70691fd..3fd173c 100644 --- a/FarmmapsPoten/PotenInput.json +++ b/FarmmapsPoten/PotenInput.json @@ -7,6 +7,7 @@ "MeanDensity": "30", "Variation": "20", "UseShadow": false, + "CountPerArea": true, "geometryJson": { "type": "Polygon", "coordinates": [ @@ -23,13 +24,20 @@ "GenerateTaskmap": true, "CellWidth": "3", "CellHeight": "10", + "Centered": "true", "StartPoint": { "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": { "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 //"Angle": "317.0" // if no endpoint diff --git a/FarmmapsPoten/PotenService.cs b/FarmmapsPoten/PotenService.cs index 02acda9..e3d66e5 100644 --- a/FarmmapsPoten/PotenService.cs +++ b/FarmmapsPoten/PotenService.cs @@ -25,13 +25,14 @@ namespace FarmmapsVRApoten _generalService = generalService; } - public async Task CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string meanDensity, string variation) + public async Task CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string meanDensity, string variation, bool countPerArea) { var potenApplicationMapRequest = new TaskRequest() { TaskType = VRAPLANTING_TASK }; if (inputItem != null) {potenApplicationMapRequest.attributes["inputCode"] = inputItem.Code; } potenApplicationMapRequest.attributes["meanDensity"] = meanDensity; potenApplicationMapRequest.attributes["variation"] = variation; - + potenApplicationMapRequest.attributes["variation"] = variation; + potenApplicationMapRequest.attributes["countPerArea"] = countPerArea.ToString(); var taskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, potenApplicationMapRequest); _logger.LogInformation($"itemTaskCode: {taskCode}");