StartDate & EndDate of cropfield. Is relevant for N fixation by leguminose crops where currently N fixation depends on day between these two dates. If not provided a whole year is assumed which leads to high N fixation
This commit is contained in:
@@ -22,14 +22,20 @@ namespace FarmmapsApi.Services
|
||||
}
|
||||
|
||||
public async Task<Item> CreateCropfieldItemAsync(string parentItemCode, string name, int year,
|
||||
string fieldGeomJson, string data = "{}") {
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
string fieldGeomJson, string data = "{}", DateTime startDate = new DateTime(), DateTime endDate = new DateTime() )
|
||||
{
|
||||
//If user provides no startDate or endDate, then set startDate and endDate to full year provided through 'year'
|
||||
if (startDate == new DateTime() || endDate == new DateTime())
|
||||
{
|
||||
startDate = new DateTime(year, 1, 1);
|
||||
endDate = new DateTime(year, 12, 31);
|
||||
}
|
||||
var cropfieldItemRequest = new ItemRequest() {
|
||||
ParentCode = parentItemCode,
|
||||
ItemType = CROPFIELD_ITEMTYPE,
|
||||
Name = name,
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||
DataDate = startDate,
|
||||
DataEndDate = endDate,
|
||||
Data = JObject.Parse(data),
|
||||
Geometry = JObject.Parse(fieldGeomJson)
|
||||
};
|
||||
@@ -38,10 +44,14 @@ namespace FarmmapsApi.Services
|
||||
}
|
||||
|
||||
public async Task<Item> CreateOperationItemAsync(string cropRecordingItemCode, int year,
|
||||
string fieldGeomJson, string data = "{}")
|
||||
string fieldGeomJson, string data = "{}", DateTime startDate = new DateTime(), DateTime endDate = new DateTime())
|
||||
{
|
||||
// not sure if here we also need to specify DataDate, DataEndDate & Geometry. Do it just in case
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
//If user provides no startDate or endDate, then set startDate and endDate to full year provided through 'year'
|
||||
if (startDate == new DateTime() || endDate == new DateTime())
|
||||
{
|
||||
startDate = new DateTime(year, 1, 1);
|
||||
endDate = new DateTime(year, 12, 31);
|
||||
}
|
||||
JObject jdata = JObject.Parse(data);
|
||||
string name = string.Format($"CrpRec Operation, {jdata.GetValue("name")}");
|
||||
|
||||
@@ -50,8 +60,8 @@ namespace FarmmapsApi.Services
|
||||
ParentCode = cropRecordingItemCode,
|
||||
ItemType = CROPOP_ITEMTYPE,
|
||||
Name = name,
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||
DataDate = startDate,
|
||||
DataEndDate = endDate,
|
||||
Data = jdata,
|
||||
Geometry = JObject.Parse(fieldGeomJson)
|
||||
};
|
||||
@@ -59,18 +69,23 @@ namespace FarmmapsApi.Services
|
||||
return await _farmmapsApiService.CreateItemAsync(operationItemRequest);
|
||||
}
|
||||
public async Task<Item> CreateCropfieldCharacteristicItemAsync(string cropfieldItemCode, int year,
|
||||
string fieldGeomJson, string data = "{}")
|
||||
string fieldGeomJson, string data = "{}", DateTime startDate = new DateTime(), DateTime endDate = new DateTime())
|
||||
{
|
||||
//If user provides no startDate or endDate, then set startDate and endDate to full year provided through 'year'
|
||||
if (startDate == new DateTime() || endDate == new DateTime())
|
||||
{
|
||||
startDate = new DateTime(year, 1, 1);
|
||||
endDate = new DateTime(year, 12, 31);
|
||||
}
|
||||
// not sure if here we also need to specify DataDate, DataEndDate & Geometry. Do it just in case
|
||||
string name = "Cropfield characteristic";
|
||||
var currentYear = new DateTime(year, 1, 1);
|
||||
ItemRequest cropfieldCharactericsticItemRequest = new ItemRequest()
|
||||
{
|
||||
ParentCode = cropfieldItemCode,
|
||||
ItemType = CROPCHAR_ITEMTYPE,
|
||||
Name = name,
|
||||
DataDate = currentYear,
|
||||
DataEndDate = currentYear.AddYears(1).AddDays(-1),
|
||||
DataDate = startDate,
|
||||
DataEndDate = endDate,
|
||||
Data = JObject.Parse(data),
|
||||
Geometry = JObject.Parse(fieldGeomJson)
|
||||
};
|
||||
|
Reference in New Issue
Block a user