Compare commits
3 Commits
4288365e96
...
a065a28e01
Author | SHA1 | Date | |
---|---|---|---|
a065a28e01 | |||
c1801a2327 | |||
67ff626e87 |
@ -62,8 +62,9 @@ namespace FarmMapsBlight
|
||||
if (string.IsNullOrEmpty(_settings.CropfieldItemCode))
|
||||
{
|
||||
_logger.LogInformation("Creating cropfield");
|
||||
string cropFieldData = "{\"area\":0,\"code\":\"0552ef068b0e4e6590c317a4c662faea\",\"name\":null,\"polygon\":null,\"soilCode\":\"60\",\"soilName\":null,\"fieldCode\":null,\"schemeUrl\":null,\"externalId\":null,\"schemeCode\":null,\"varietyCode\":\"11113\",\"varietyName\":\"Bintje\",\"cropTypeCode\":\"1010101\",\"cropTypeName\":\"Consumptieaardappelen\",\"productionTypeCode\":\"1\",\"productionPurposeCode\":null,\"productionPurposeName\":null,\"productionSequenceCode\":\"HFDTLT\"}";
|
||||
cropfieldItem = await _generalService.CreateCropfieldItemAsync(myDrive.Code, "Cropfield Blight", 2020,
|
||||
@"{""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]]]}");
|
||||
@"{""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]]]}", cropFieldData);
|
||||
_settings.CropfieldItemCode = cropfieldItem.Code;
|
||||
SaveSettings();
|
||||
}
|
||||
@ -83,7 +84,7 @@ namespace FarmMapsBlight
|
||||
}
|
||||
|
||||
// advice as json
|
||||
var data = blightItem.Data;
|
||||
Console.WriteLine(blightItem.Data);
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
|
@ -1,7 +1,10 @@
|
||||
using FarmmapsApi.Models;
|
||||
using FarmmapsApi.Services;
|
||||
using FarmMapsBlight.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using static FarmmapsApi.Extensions;
|
||||
using static FarmmapsApiSamples.Constants;
|
||||
@ -32,6 +35,14 @@ namespace FarmMapsBlight
|
||||
taskRequest.attributes["plantingDate"] = plantingDate.ToUniversalTime().ToString("o");
|
||||
taskRequest.attributes["emergeDate"] = emergeDate.ToUniversalTime().ToString("o");
|
||||
|
||||
List<Spray> sprays = new List<Spray>();
|
||||
sprays.Add(new Spray() { fungicideCode = "FLEX", SprayTime = new DateTime(2020, 9, 1), dose = 0.6, isVRA = false });
|
||||
taskRequest.attributes["sprays"] = JsonConvert.SerializeObject(sprays);
|
||||
|
||||
List<Irrigation> irrigations = new List<Irrigation>();
|
||||
irrigations.Add(new Irrigation() { startTime = new DateTime(2020, 7, 1, 2, 0, 0), endTime = new DateTime(2020, 7, 1, 14, 0, 0) });
|
||||
taskRequest.attributes["irrigations"] = JsonConvert.SerializeObject(irrigations);
|
||||
|
||||
var taskCode = await _farmmapsApiService.QueueTaskAsync(cropfieldItem.Code, taskRequest);
|
||||
await PollTask(TimeSpan.FromSeconds(3), async (tokenSource) =>
|
||||
{
|
||||
|
11
FarmMapsBlight/Models/Irrigation.cs
Normal file
11
FarmMapsBlight/Models/Irrigation.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace FarmMapsBlight.Models
|
||||
{
|
||||
public class Irrigation
|
||||
{
|
||||
public DateTime startTime { get; set; }
|
||||
public DateTime endTime { get; set; }
|
||||
public double mm { get; set; }
|
||||
}
|
||||
}
|
12
FarmMapsBlight/Models/Spray.cs
Normal file
12
FarmMapsBlight/Models/Spray.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace FarmMapsBlight.Models
|
||||
{
|
||||
public class Spray
|
||||
{
|
||||
public DateTime SprayTime { get; set; }
|
||||
public string fungicideCode { get; set; }
|
||||
public double dose { get; set; }
|
||||
public bool isVRA { get; set; }
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
{
|
||||
"Authority": "https://accounts.farmmaps.awtest.nl/",
|
||||
//"Endpoint": "http://farmmaps.awtest.nl",
|
||||
//"Endpoint": "http://localhost:8095",
|
||||
"Endpoint": "http://localhost:8083",
|
||||
"Endpoint": "https://farmmaps.awtest.nl/",
|
||||
"BasePath": "api/v1",
|
||||
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
|
||||
"RedirectUri": "http://example.nl/api",
|
||||
|
@ -24,7 +24,7 @@ namespace FarmmapsApi.Services
|
||||
}
|
||||
|
||||
public async Task<Item> CreateCropfieldItemAsync(string parentItemCode, string name, int year,
|
||||
string fieldGeomJson)
|
||||
string fieldGeomJson, string data = "{}")
|
||||
{
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
var cropfieldItemRequest = new ItemRequest()
|
||||
@ -34,7 +34,7 @@ namespace FarmmapsApi.Services
|
||||
Name = name,
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||
Data = JObject.Parse("{}"),
|
||||
Data = JObject.Parse(data),
|
||||
Geometry = JObject.Parse(fieldGeomJson)
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"Authority": "https://accounts.farmmaps.awtest.nl/",
|
||||
"Endpoint": "http://farmmaps.awtest.nl",
|
||||
"Endpoint": "http://farmmaps.awtest.nl/",
|
||||
"BasePath": "api/v1",
|
||||
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
|
||||
"RedirectUri": "http://example.nl/api",
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"Authority": "https://accounts.farmmaps.awtest.nl/",
|
||||
"Endpoint": "http://localhost:8095/",
|
||||
"BasePath": "api/v1",
|
||||
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
|
||||
"RedirectUri": "http://example.nl/api",
|
||||
"ClientId": "",
|
||||
"ClientSecret": "",
|
||||
"Scopes": ["api"]
|
||||
"Authority": "https://accounts.farmmaps.awtest.nl/",
|
||||
"Endpoint": "https://farmmaps.awtest.nl/",
|
||||
"BasePath": "api/v1",
|
||||
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
|
||||
"RedirectUri": "http://example.nl/api",
|
||||
"ClientId": "",
|
||||
"ClientSecret": "",
|
||||
"Scopes": [ "api" ]
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"Authority": "https://accounts.farmmaps.awtest.nl/",
|
||||
"Endpoint": "http://localhost:8095/",
|
||||
"BasePath": "api/v1",
|
||||
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
|
||||
"RedirectUri": "http://example.nl/api",
|
||||
"ClientId": "",
|
||||
"ClientSecret": "",
|
||||
"Scopes": ["api"]
|
||||
"Authority": "https://accounts.farmmaps.awtest.nl/",
|
||||
"Endpoint": "https://farmmaps.awtest.nl/",
|
||||
"BasePath": "api/v1",
|
||||
"DiscoveryEndpointUrl": "https://accounts.farmmaps.awtest.nl/.well-known/openid-configuration",
|
||||
"RedirectUri": "http://example.nl/api",
|
||||
"ClientId": "",
|
||||
"ClientSecret": "",
|
||||
"Scopes": [ "api" ]
|
||||
}
|
Loading…
Reference in New Issue
Block a user