update poten; schaduw moet nu als attribute worden meegegeven
This commit is contained in:
		| @@ -64,11 +64,12 @@ namespace FarmmapsApi.Services | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         public async Task<Item> ShapeToGeotiff(Item shapeItem) { |         public async Task<Item> ShapeToGeotiff(Item shapeItem) { | ||||||
|  |             var startUpload = DateTime.UtcNow.AddSeconds(-3); | ||||||
|             await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff"); |             await RunAndWaitForTask(shapeItem, "vnd.farmmaps.task.shapetogeotiff"); | ||||||
|  |  | ||||||
|             // the parent of the shape item is now the tiff item |             return await FindChildItemAsync(shapeItem.ParentCode, GEOTIFF_PROCESSED_ITEMTYPE, shapeItem.Name, | ||||||
|             shapeItem = await _farmmapsApiService.GetItemAsync(shapeItem.Code); |                 i => i.Created >= startUpload && | ||||||
|             return await _farmmapsApiService.GetItemAsync(shapeItem.ParentCode); |                      i.Name.ToLower().Contains(shapeItem.Name.ToLower())); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -104,12 +104,13 @@ namespace FarmmapsNbs | |||||||
|             await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) => |             await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) => | ||||||
|             { |             { | ||||||
|                 var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode); |                 var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode); | ||||||
|  |                 _logger.LogInformation($"Calculating uptake map; status: {itemTaskStatus.State}"); | ||||||
|                 if (itemTaskStatus.IsFinished) |                 if (itemTaskStatus.IsFinished) | ||||||
|                     tokenSource.Cancel(); |                     tokenSource.Cancel();            | ||||||
|             }); |             }); | ||||||
|              |              | ||||||
|             var itemTask = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode); |             var itemTask = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode); | ||||||
|             if(itemTask.State == ItemTaskState.Error) |             if (itemTask.State == ItemTaskState.Error) | ||||||
|             { |             { | ||||||
|                 _logger.LogError($"Something went wrong with task execution: {itemTask.Message}"); |                 _logger.LogError($"Something went wrong with task execution: {itemTask.Message}"); | ||||||
|                 return null; |                 return null; | ||||||
| @@ -159,7 +160,7 @@ namespace FarmmapsNbs | |||||||
|             await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) => |             await PollTask(TimeSpan.FromSeconds(5), async (tokenSource) => | ||||||
|             { |             { | ||||||
|                 var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode); |                 var itemTaskStatus = await _farmmapsApiService.GetTaskStatusAsync(cropfieldItem.Code, itemTaskCode); | ||||||
|  |                 _logger.LogInformation($"Calculating application map; status: {itemTaskStatus.State}"); | ||||||
|                 if (itemTaskStatus.IsFinished) |                 if (itemTaskStatus.IsFinished) | ||||||
|                     tokenSource.Cancel(); |                     tokenSource.Cancel(); | ||||||
|             }); |             }); | ||||||
| @@ -175,7 +176,7 @@ namespace FarmmapsNbs | |||||||
|  |  | ||||||
|             var itemName = $"VRANbs application"; |             var itemName = $"VRANbs application"; | ||||||
|             var applicationMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code, |             var applicationMapItem = await _generalService.FindChildItemAsync(cropfieldItem.Code, | ||||||
|                 GEOTIFF_PROCESSED_ITEMTYPE, itemName,  |                 GEOTIFF_PROCESSED_ITEMTYPE, itemName, | ||||||
|                 i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) && |                 i => i.Updated >= itemTask.Finished.GetValueOrDefault(DateTime.UtcNow) && | ||||||
|                      i.Name.ToLower().Contains(itemName.ToLower())); |                      i.Name.ToLower().Contains(itemName.ToLower())); | ||||||
|             if (applicationMapItem == null) |             if (applicationMapItem == null) | ||||||
|   | |||||||
							
								
								
									
										
											BIN
										
									
								
								FarmmapsPoten/Data/BBL-lutum.tif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								FarmmapsPoten/Data/BBL-lutum.tif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -157,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, countPerArea); |                 await _potenService.CalculateApplicationMapAsync(cropfieldItem, geotiffItem, meanDensity, variation, countPerArea, useShadow); | ||||||
|  |  | ||||||
|             if (applianceMapItem == null) { |             if (applianceMapItem == null) { | ||||||
|                 return; |                 return; | ||||||
|   | |||||||
| @@ -1,46 +1,57 @@ | |||||||
| [ | [ | ||||||
|     { |   { | ||||||
|         "File": "PlantingSampleDataLutum.zip", |  | ||||||
|         "OutputFileName": "20210216_vraPoten_SampleData", |  | ||||||
|         "FieldName": "lutum", |  | ||||||
|         "PlantingYear": 2020, |  | ||||||
|         "MeanDensity": "30", |  | ||||||
|         "Variation": "20", |  | ||||||
|         "UseShadow": false, |  | ||||||
|         "CountPerArea": true, |  | ||||||
|         "geometryJson": { |  | ||||||
|             "type": "Polygon", |  | ||||||
|             "coordinates": [ |  | ||||||
|                 [ |  | ||||||
|                     [ 5.66886041703652044, 52.52929999060298627 ], |  | ||||||
|                     [ 5.6716230923214912, 52.52946316399909676 ], |  | ||||||
|                     [ 5.67185376229668581, 52.5280565894154563 ], |  | ||||||
|                     [ 5.66903207841337231, 52.52790646510525363 ], |  | ||||||
|                     [ 5.66886041703652044, 52.52929999060298627 ] |  | ||||||
|                 ] |  | ||||||
|             ] |  | ||||||
|         }, |  | ||||||
|  |  | ||||||
|         "GenerateTaskmap": true, |     "File": "BBL-lutum.tif", | ||||||
|         "CellWidth": "3", |     "OutputFileName": "BBL-poten_30_20_Shadow-True-v2_TifInput", | ||||||
|         "CellHeight": "10", |     "FieldName": "lutum", | ||||||
|         "Centered": "true", |     "PlantingYear": 2020, | ||||||
|         "StartPoint": { |     "MeanDensity": "30", | ||||||
|             "type": "Point", |     "Variation": "20", | ||||||
|             //"coordinates": [ 5.669032078413372, 52.527906465105254 ] // 1 |     "UseShadow": true, | ||||||
|             //"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 2 |     "CountPerArea": false, | ||||||
|             //"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 3 |     "geometryJson": { | ||||||
|             "coordinates": [ 5.671853762296686, 52.528056589415456 ] // 4 |       "type": "Polygon", | ||||||
|         }, |       "coordinates": [ | ||||||
|         "EndPoint": { |         [ | ||||||
|             "type": "Point", |           [ 4.61098862747705418, 52.22974843124053734 ], | ||||||
|             "coordinates": [ 5.669032078413372, 52.527906465105254 ] // 1 |           [ 4.61338362824790682, 52.22993593073885421 ], | ||||||
|             //"coordinates": [ 5.668860417036520, 52.529299990602986 ] // 2 |           [ 4.61949010053501397, 52.22667042162688489 ], | ||||||
|             //"coordinates": [ 5.671623092321491, 52.529463163999097 ] // 3 |           [ 4.61954106663577324, 52.22670579437124871 ], | ||||||
|             //"coordinates": [ 5.671853762296686, 52.528056589415456 ] // 4 |           [ 4.61953075937382085, 52.22671128094363269 ], | ||||||
|         } // if no angle |           [ 4.61954202811175296, 52.22670563321562298 ], | ||||||
|          |           [ 4.61901745087585081, 52.22634382962637289 ], | ||||||
|         //"Angle": "317.0" // if no endpoint |           [ 4.61812211075603685, 52.22571430401869463 ], | ||||||
|     } |           [ 4.61736058962494678, 52.22611942369080396 ], | ||||||
|  |           [ 4.61464150409827134, 52.2275669988328346 ], | ||||||
|  |           [ 4.61407137489250019, 52.22787370291415243 ], | ||||||
|  |           [ 4.61242270952427802, 52.2287649864655279 ], | ||||||
|  |           [ 4.61261020576063618, 52.22887063061121182 ], | ||||||
|  |           [ 4.61256645484349015, 52.22889713517798072 ], | ||||||
|  |           [ 4.61229657126373027, 52.22904994233584119 ], | ||||||
|  |           [ 4.61207777596369262, 52.2291602791168188 ], | ||||||
|  |           [ 4.61174554282434013, 52.22933965721241378 ], | ||||||
|  |           [ 4.61169310584479941, 52.22934596082312453 ], | ||||||
|  |           [ 4.61143525446537428, 52.22949107699816551 ], | ||||||
|  |           [ 4.61100843013417183, 52.22973689585098356 ], | ||||||
|  |           [ 4.61098862747705418, 52.22974843124053734 ] | ||||||
|  |         ] | ||||||
|  |       ] | ||||||
|  |     }, | ||||||
|  |  | ||||||
|  |     "GenerateTaskmap": true, | ||||||
|  |     "CellWidth": "3", | ||||||
|  |     "CellHeight": "10", | ||||||
|  |     "Centered": "false", | ||||||
|  |     "StartPoint": { | ||||||
|  |       "type": "Point", | ||||||
|  |       "coordinates": [ 4.61812211075603685, 52.22571430401869463 ] // BBL | ||||||
|  |     }, | ||||||
|  |     "EndPoint": { | ||||||
|  |       "type": "Point", | ||||||
|  |       "coordinates": [ 4.61242270952427802, 52.2287649864655279 ] // BBL | ||||||
|  |     } // if no angle | ||||||
|  |  | ||||||
|  |     //"Angle": "317.0" // if no endpoint | ||||||
|  |   } | ||||||
|  |  | ||||||
| ] | ] | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ namespace FarmmapsVRApoten | |||||||
|             _generalService = generalService; |             _generalService = generalService; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string meanDensity, string variation, bool countPerArea) |         public async Task<Item> CalculateApplicationMapAsync(Item cropfieldItem, Item inputItem, string meanDensity, string variation, bool countPerArea, bool useShadow) | ||||||
|         { |         { | ||||||
|             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; } | ||||||
| @@ -33,6 +33,7 @@ namespace FarmmapsVRApoten | |||||||
|             potenApplicationMapRequest.attributes["variation"] = variation; |             potenApplicationMapRequest.attributes["variation"] = variation; | ||||||
|             potenApplicationMapRequest.attributes["variation"] = variation; |             potenApplicationMapRequest.attributes["variation"] = variation; | ||||||
|             potenApplicationMapRequest.attributes["countPerArea"] = countPerArea.ToString(); |             potenApplicationMapRequest.attributes["countPerArea"] = countPerArea.ToString(); | ||||||
|  |             potenApplicationMapRequest.attributes["useShadow"] = 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}"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user