Added lutum data, started herbicide service.
This commit is contained in:
parent
e01ac51095
commit
92a8d9573c
@ -12,14 +12,17 @@ namespace FarmmapsApiSamples
|
||||
private readonly FarmmapsApiService _farmmapsApiService;
|
||||
private readonly FarmmapsEventHub _farmmapsEventHub;
|
||||
private readonly NitrogenService _nitrogenService;
|
||||
private readonly HerbicideService _herbicideService;
|
||||
|
||||
public Application(ILogger<Application> logger, FarmmapsApiService farmmapsApiService,
|
||||
FarmmapsEventHub farmmapsEventHub, NitrogenService nitrogenService)
|
||||
FarmmapsEventHub farmmapsEventHub, NitrogenService nitrogenService,
|
||||
HerbicideService herbicideService)
|
||||
{
|
||||
_logger = logger;
|
||||
_farmmapsApiService = farmmapsApiService;
|
||||
_farmmapsEventHub = farmmapsEventHub;
|
||||
_nitrogenService = nitrogenService;
|
||||
_herbicideService = herbicideService;
|
||||
|
||||
_farmmapsEventHub.EventCallback += OnEvent;
|
||||
}
|
||||
@ -37,7 +40,8 @@ namespace FarmmapsApiSamples
|
||||
await _farmmapsApiService.GetCurrentUserCodeAsync();
|
||||
var roots = await _farmmapsApiService.GetCurrentUserRootsAsync();
|
||||
|
||||
await _nitrogenService.TestFlow(roots);
|
||||
// await _nitrogenService.TestFlow(roots);
|
||||
await _herbicideService.TestFlow(roots);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
BIN
FarmmapsApiSamples/Data/Lutum.tiff
Normal file
BIN
FarmmapsApiSamples/Data/Lutum.tiff
Normal file
Binary file not shown.
BIN
FarmmapsApiSamples/Data/Lutum.zip
Normal file
BIN
FarmmapsApiSamples/Data/Lutum.zip
Normal file
Binary file not shown.
62
FarmmapsApiSamples/HerbicideService.cs
Normal file
62
FarmmapsApiSamples/HerbicideService.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using FarmmapsApi.Models;
|
||||
using FarmmapsApi.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using static FarmmapsApiSamples.Constants;
|
||||
|
||||
namespace FarmmapsApiSamples
|
||||
{
|
||||
public class HerbicideService : ITestFlow
|
||||
{
|
||||
private readonly ILogger<HerbicideService> _logger;
|
||||
private readonly FarmmapsApiService _farmmapsApiService;
|
||||
|
||||
public HerbicideService(ILogger<HerbicideService> logger, FarmmapsApiService farmmapsApiService)
|
||||
{
|
||||
_logger = logger;
|
||||
_farmmapsApiService = farmmapsApiService;
|
||||
}
|
||||
|
||||
public async Task TestFlow(List<UserRoot> roots)
|
||||
{
|
||||
var myDrive = roots.SingleOrDefault(r => r.Name == "My drive");
|
||||
if (myDrive == null)
|
||||
{
|
||||
_logger.LogError("Could not find a needed root item");
|
||||
return;
|
||||
}
|
||||
var cropfieldItem = await GetOrCreateCropfieldItemAsync(myDrive.Code);
|
||||
|
||||
// find or create relevant data as geotiff format
|
||||
|
||||
// create or get herbicide agent
|
||||
|
||||
// call herbicide task
|
||||
|
||||
// download appliance map
|
||||
}
|
||||
|
||||
private async Task<Item> GetOrCreateCropfieldItemAsync(string parentItemCode)
|
||||
{
|
||||
var currentYear = new DateTime(DateTime.UtcNow.Year, 1, 1);
|
||||
var cropfieldItemRequest = new ItemRequest()
|
||||
{
|
||||
ParentCode = parentItemCode,
|
||||
ItemType = CROPFIELD_ITEMTYPE,
|
||||
Name = "Cropfield VRA Herbicide LUTUM",
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddMonths(3),
|
||||
Data = JObject.FromObject(new
|
||||
{startDate = currentYear, endDate = currentYear.AddMonths(3)}),
|
||||
Geometry = JObject.Parse(
|
||||
@"{""type"":""Polygon"",""coordinates"":[[[4.617786844284247,52.22533706956424],[4.618642601314543,52.225938364585989],[4.6192153806397,52.22563988897754],[4.619192414656403,52.2256242822442],[4.620306732153958,52.225031745661528],[4.620542019225217,52.22519855319158],[4.621157509147853,52.22487436515405],[4.623387917230182,52.22367660757213],[4.624563444939009,52.22304740241544],[4.624562779355982,52.223046635247019],[4.624534908813479,52.22302596787506],[4.627873021330343,52.221240670658399],[4.627504935938338,52.220104419135129],[4.627324878706837,52.22020569669098],[4.627320696113512,52.22020660117888],[4.626707169518044,52.22053923770041],[4.624700376420229,52.221619047547488],[4.623471571183885,52.22227447969577],[4.623471511010673,52.22227500174403],[4.623468838689317,52.22228052566992],[4.617786844284247,52.22533706956424]]]}")
|
||||
};
|
||||
|
||||
return await _farmmapsApiService.CreateItemAsync(cropfieldItemRequest);
|
||||
}
|
||||
}
|
||||
}
|
11
FarmmapsApiSamples/ITestFlow.cs
Normal file
11
FarmmapsApiSamples/ITestFlow.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using FarmmapsApi.Models;
|
||||
|
||||
namespace FarmmapsApiSamples
|
||||
{
|
||||
public interface ITestFlow
|
||||
{
|
||||
Task TestFlow(List<UserRoot> roots);
|
||||
}
|
||||
}
|
22
FarmmapsApiSamples/Models/HerbicideAgent.cs
Normal file
22
FarmmapsApiSamples/Models/HerbicideAgent.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace FarmmapsApiSamples.Models
|
||||
{
|
||||
public class HerbicideAgent
|
||||
{
|
||||
public string ProductType { get; set; }
|
||||
public string Middel { get; set; }
|
||||
public string Grondsoort { get; set; }
|
||||
public string ActieveStofGehalte{ get; set; }
|
||||
public string Gewas { get; set; }
|
||||
public string Opmerking { get; set; }
|
||||
public string TankMix { get; set; }
|
||||
public string ExtraProductType { get; set; }
|
||||
public float MinDosis { get; set; }
|
||||
public float MaxDosis { get; set; }
|
||||
public float A { get; set; }
|
||||
public float B { get; set; }
|
||||
public float C { get; set; }
|
||||
public float D { get; set; }
|
||||
public float E { get; set; }
|
||||
public float P { get; set; }
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ using static FarmmapsApiSamples.Constants;
|
||||
|
||||
namespace FarmmapsApiSamples
|
||||
{
|
||||
public class NitrogenService
|
||||
public class NitrogenService : ITestFlow
|
||||
{
|
||||
private readonly ILogger<NitrogenService> _logger;
|
||||
private readonly FarmmapsApiService _farmmapsApiService;
|
||||
|
@ -25,6 +25,7 @@ namespace FarmmapsApiSamples
|
||||
.AddFilter("System.Net.Http", LogLevel.Warning))
|
||||
.AddFarmmapsServices(configuration)
|
||||
.AddTransient<NitrogenService>()
|
||||
.AddTransient<HerbicideService>()
|
||||
.AddSingleton<IApp, Application>()
|
||||
.BuildServiceProvider();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user