Compare commits
11 Commits
ee854241a1
...
master
Author | SHA1 | Date | |
---|---|---|---|
56f4e66e68 | |||
27a44658e3 | |||
e0190575ae | |||
4630426de1 | |||
f8a0e2f5d9 | |||
49f9418bc5 | |||
9ce1c7748a | |||
c9f5fc00b9 | |||
3763bb735e | |||
c991c340aa | |||
a316a4a0b6 |
260
Blight-API.md
260
Blight-API.md
@@ -22,7 +22,7 @@ See [Authentication](Authentication.md)
|
||||
See [Create Croppingscheme](Create-Croppingscheme.md)
|
||||
|
||||
### Create crop field (if not exists)
|
||||
See [Create Cropfield](Create-Cropfield.md)
|
||||
See [Create Cropfield](Create-b-cropfield.md)
|
||||
|
||||
### <a name="create-advice"></a>Get blight advice
|
||||
|
||||
@@ -33,6 +33,8 @@ It is also possible to create a new advice at any time, see [Create blight advic
|
||||
A blight advice is a child record of a crop field.
|
||||
Use the crop field code to get the latest blight advice.
|
||||
|
||||
#### 1. get the blight item code
|
||||
|
||||
> Request
|
||||
```javascript
|
||||
GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.blight
|
||||
@@ -43,46 +45,54 @@ GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.blight
|
||||
{
|
||||
"parentCode": "string",
|
||||
"geometry": ...
|
||||
"url": ...
|
||||
"code": ...
|
||||
"size": ...
|
||||
"data": {
|
||||
"advices": [
|
||||
{
|
||||
"date": "2021-03-19T00:00:00",
|
||||
"weather": [
|
||||
{
|
||||
"hh": 0,
|
||||
"rain": 0.0,
|
||||
"humidity": 90.0,
|
||||
"irrigation": 0.0,
|
||||
"temperature": 2.0,
|
||||
"precipitation": 0.0
|
||||
},
|
||||
{
|
||||
"hh": 1,
|
||||
"rain": 0.0,
|
||||
"humidity": 91.0,
|
||||
"irrigation": 0.0,
|
||||
"temperature": 1.0,
|
||||
"precipitation": 0.0
|
||||
},...],
|
||||
"sprayTime": null,
|
||||
"sprayType": 3,
|
||||
"ooSporesRisk": false,
|
||||
"fungicideLeftPct": 0,
|
||||
"sprayEffectivity": null,
|
||||
"unprotectedGrowth": 0.0,
|
||||
"tuberInfectionRisk": false,
|
||||
"infectionRiskPerHour": [
|
||||
0,...]
|
||||
"itemtask": {
|
||||
"runs": {
|
||||
"last": "2023-02-22T03:02:01.8775194Z",
|
||||
"success": "2023-02-22T03:02:01.8775194Z"
|
||||
},
|
||||
"state": "ok",
|
||||
"messages": []
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
The data object contains the advices from emergence date and weather from planting date.
|
||||
The date property respresents the advice date, the weather array contains 24 objects, 1 for each hour.
|
||||
> Response 404 Not Found
|
||||
|
||||
|
||||
There is no advice available, try to create a new advice, see [Create blight advice](#create-advice).
|
||||
|
||||
Check the data field for itemtask/state. If state is "ok" there should be an advice.
|
||||
|
||||
|
||||
#### 2. get advice for the blight item
|
||||
Use the code found in the previous call (or use url) to get the advice.
|
||||
> Request
|
||||
```javascript
|
||||
GET /api/v1/items/{code}/data
|
||||
```
|
||||
> Response 200 OK
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
"sprayTime": null,
|
||||
"date": "2022-03-01T00:00:00",
|
||||
"weather": [
|
||||
{
|
||||
"temperature": 3.0,
|
||||
"precipitation": 0.0,
|
||||
"rain": 0.0,
|
||||
"irrigation": 0.0,
|
||||
"humidity": 71.0,
|
||||
"hh": 0,
|
||||
"leafwetnessmm": null
|
||||
},...
|
||||
}
|
||||
```
|
||||
> Response 404 Not Found
|
||||
|
||||
|
||||
### <a name="create-advice"></a>Create blight advice
|
||||
Task 'vnd.farmmaps.task.blight' must be executed to create an advice.
|
||||
@@ -144,7 +154,7 @@ GET api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.user.input
|
||||
}
|
||||
```
|
||||
|
||||
Get the first objecy of the array, change the data, and push the object back.
|
||||
Get the first object of the array, change the data, and push the object back.
|
||||
Use the code from the response above.
|
||||
|
||||
```javascript
|
||||
@@ -209,6 +219,186 @@ PUT /api/v1/items/{code}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
# Blight API
|
||||
[<< Home](README.md)
|
||||
|
||||
For the currently available public FarmMaps API you can take a look at swagger: https://farmmaps.eu/swagger
|
||||
|
||||
## API flow
|
||||
* Authenticate
|
||||
* Create cropping scheme (if not exists)
|
||||
* Create crop field (if not exists)
|
||||
* Get blight advice
|
||||
* Create blight advice
|
||||
* Add spray
|
||||
* Add irrigation
|
||||
* Get predefined fungicides
|
||||
|
||||
## Steps
|
||||
|
||||
### Authenticate
|
||||
See [Authentication](Authentication.md)
|
||||
|
||||
### Create cropping scheme (if not exists)
|
||||
See [Create Croppingscheme](Create-Croppingscheme.md)
|
||||
|
||||
### Create crop field (if not exists)
|
||||
See [Create Cropfield](Create-b-cropfield.md)
|
||||
|
||||
### <a name="create-advice"></a>Get blight advice
|
||||
|
||||
Blight is only available for potato fields.
|
||||
The advice is automatically created when new potato fields are added and is scheduled to be updated at configured times.
|
||||
It is also possible to create a new advice at any time, see [Create blight advice](#create-advice).
|
||||
|
||||
A blight advice is a child record of a crop field.
|
||||
Use the crop field code to get the latest blight advice.
|
||||
|
||||
#### 1. get the blight item code
|
||||
|
||||
> Request
|
||||
```javascript
|
||||
GET /api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.blight
|
||||
```
|
||||
> Response 200 OK
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
"parentCode": "string",
|
||||
"geometry": ...
|
||||
"url": ...
|
||||
"code": ...
|
||||
"size": ...
|
||||
"data": {
|
||||
"itemtask": {
|
||||
"runs": {
|
||||
"last": "2023-02-22T03:02:01.8775194Z",
|
||||
"success": "2023-02-22T03:02:01.8775194Z"
|
||||
},
|
||||
"state": "ok",
|
||||
"messages": []
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
> Response 404 Not Found
|
||||
|
||||
There is no advice available, try to create a new advice, see [Create blight advice](#create-advice).
|
||||
|
||||
Check the data field for itemtask/state. If state is "ok" there should be an advice.
|
||||
|
||||
|
||||
#### 2. get advice for the blight item
|
||||
Use the code found in the previous call (or use url) to get the advice.
|
||||
> Request
|
||||
```javascript
|
||||
GET /api/v1/items/{code}/data
|
||||
```
|
||||
> Response 200 OK
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
"sprayTime": null,
|
||||
"date": "2022-03-01T00:00:00",
|
||||
"weather": [
|
||||
{
|
||||
"temperature": 3.0,
|
||||
"precipitation": 0.0,
|
||||
"rain": 0.0,
|
||||
"irrigation": 0.0,
|
||||
"humidity": 71.0,
|
||||
"hh": 0,
|
||||
"leafwetnessmm": null
|
||||
},...
|
||||
}
|
||||
```
|
||||
> Response 404 Not Found
|
||||
|
||||
|
||||
### <a name="create-advice"></a>Create blight advice
|
||||
Task 'vnd.farmmaps.task.blight' must be executed to create an advice.
|
||||
This task is automatically created for potato fields and is scheduled to run at configered times to keep the advice updated. But it is possible to create this task at any time.
|
||||
|
||||
Add the crop field code to the URL and execute the following request.
|
||||
|
||||
> Request
|
||||
```javascript
|
||||
POST /api/v1/items/{code}/tasks
|
||||
{
|
||||
"TaskType": "vnd.farmmaps.task.blight",
|
||||
"Delay": null,
|
||||
"attributes": {}
|
||||
}
|
||||
```
|
||||
|
||||
> Response 200
|
||||
```javascript
|
||||
{
|
||||
"code": "{code}",
|
||||
"taskType": "vnd.farmmaps.task.blight",
|
||||
"attributes": {
|
||||
"messagePriority": "10"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
With the code in the response message and the code of the crop field, it is possible to check the task's state (error/ok/scheduled/processing). See [Check task status](Polling-task-status.md).
|
||||
|
||||
|
||||
### Late Blight Foliage Resistance settings
|
||||
It is possible to delay the first spray application based on the cultivar resistance level (8 and 9).
|
||||
These settings are stored on the user input item.
|
||||
|
||||
Get the blight advice code from [Get blight advice](#create-advice)
|
||||
Use this code in the following request.
|
||||
|
||||
> Request
|
||||
```javascript
|
||||
GET api/v1/items/{code}/children?it=vnd.farmmaps.itemtype.user.input
|
||||
```
|
||||
|
||||
> Response 200
|
||||
```javascript
|
||||
[
|
||||
{
|
||||
"code": "{code}",
|
||||
// ....
|
||||
"data": {
|
||||
"sprays": [],
|
||||
"phytoPressure": 0,
|
||||
"ignoreOoSpores": true,
|
||||
"ignoreTuberRisk": true,
|
||||
"haulmKillingDate": null,
|
||||
"suppressSprayAdvice": false,
|
||||
"infectionDate": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Set the suppressSprayAdvice to true and enter the infectionDate when an infection in the region has spotted.
|
||||
|
||||
```javascript
|
||||
PUT /api/v1/items/{code}
|
||||
{
|
||||
"parentCode": "....",
|
||||
// ....
|
||||
"data": {
|
||||
// ....
|
||||
"suppressSprayAdvice": true,
|
||||
"infectionDate": "2024-09-02T22:00:00Z"
|
||||
},
|
||||
// ....
|
||||
}
|
||||
```
|
||||
> Response 200
|
||||
```javascript
|
||||
{
|
||||
"parentCode": "....",
|
||||
// ....
|
||||
}
|
||||
```
|
||||
|
||||
### Add irrigation
|
||||
Irrigations are stored as child item of a crop recording item.
|
||||
First step is to get the crop recording item for the crop field.
|
||||
|
37
Create-Croppingscheme.md
Normal file
37
Create-Croppingscheme.md
Normal file
@@ -0,0 +1,37 @@
|
||||
## Create croppingscheme with the farmmaps API
|
||||
* Create a 'vnd.farmmaps.itemtype.croppingscheme' item as a child of the 'USER_IN' item.
|
||||
The data property can be used to add some information about the farm and the geometry can be used as location of the farm.
|
||||
|
||||
> Request
|
||||
```javascript
|
||||
POST /api/v1/items
|
||||
{
|
||||
"parentCode": "{USER_IN_item_code}",
|
||||
"itemType": "vnd.farmmaps.itemtype.croppingscheme",
|
||||
"name": "Name for the scheme",
|
||||
"data": {},
|
||||
"geometry": {"type":"Polygon","coordinates":[[[6.09942873984307,53.070025028087],[6.09992507404607,53.0705617890585],[6.10036959220086,53.0710679529031],[6.10065149010421,53.0714062774307],[6.10087493644271,53.0716712354474],[6.10091082982487,53.0716936039203],[6.10165087441291,53.0712041549161],[6.10204994718318,53.0709349338005],[6.10263143118855,53.0705789370018],[6.10311578125011,53.0702657538294],[6.10331686552072,53.0701314102389],[6.103326530575,53.070119463569],[6.10309137950343,53.0699829669055],[6.10184241586523,53.0692902201371],[6.10168497998891,53.0691984306747],[6.10092987659869,53.0694894453514],[6.09942873984307,53.070025028087]]]}
|
||||
}
|
||||
```
|
||||
> Response 201 Created
|
||||
```Javascript
|
||||
{
|
||||
"parentCode": "string",
|
||||
"geometry": {},
|
||||
"data": {},
|
||||
"tags": [
|
||||
"string"
|
||||
],
|
||||
"url": "string",
|
||||
"code": "string",
|
||||
"name": "string",
|
||||
"created": "2019-12-18T10:16:21.455Z",
|
||||
"updated": "2019-12-18T10:16:21.455Z",
|
||||
"dataDate": "2019-12-18T10:16:21.455Z",
|
||||
"itemType": "string",
|
||||
"sourceTask": "string",
|
||||
"size": 0,
|
||||
"state": 0,
|
||||
"thumbnail": true
|
||||
}
|
||||
```
|
216
Create-b-cropfield.md
Normal file
216
Create-b-cropfield.md
Normal file
@@ -0,0 +1,216 @@
|
||||
## Creating a cropfield
|
||||
This page explains what a cropfield is, and how to create one through the API.
|
||||
|
||||
Agricultural datasets generally refer to a specif crop, at a specific location at a specific time.
|
||||
Therefore, we need to create a "Cropfield" item, to define this location and a timeframe our data relates to.
|
||||
A cropfield provides a convienient way to group all data for a crop grown on a specific plot during a season.
|
||||
Farmmaps also uses the cropfield to collect and prepare context data such as weather, satelite imagery etc.
|
||||
|
||||
To create a cropfield we:
|
||||
* Get the parent folder to place the cropfield under
|
||||
* Create the cropfield
|
||||
|
||||
**Prerequisites**
|
||||
To create a cropfield we need:
|
||||
|
||||
* an acces token
|
||||
* coordinates of the cropfield (what points define the plot contour)
|
||||
* a startdate and an end date (what timeframe does this data aply to)
|
||||
|
||||
### Get parent element
|
||||
First, we'll get the parent code needed to place the cropfield in the hierarchy.
|
||||
Usually this is a cropping scheme.
|
||||
So when the code of the crop field is known, use this code as parent code to create the crop field and go to the next chapter.
|
||||
|
||||
## Get cropping scheme
|
||||
When the cropping scheme code is not known, we need to start from the top of the hierarchy, which is my_roots.
|
||||
|
||||
**Request**
|
||||
Replace `<acces token>` with your actual token.
|
||||
```http
|
||||
GET https://farmmaps.eu/api/v1/folders/my_roots HTTP/1.1
|
||||
Host: farmmaps.eu
|
||||
Accept: application/json
|
||||
Authorization: Bearer <access token>
|
||||
```
|
||||
|
||||
**Response**
|
||||
The response will be something similar to:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200 OK
|
||||
Date: Fri, 27 Aug 2021 19:00:55 GMT
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Connection: keep-alive
|
||||
Server: Kestrel
|
||||
Cache-Control: no-store,no-cache
|
||||
Pragma: no-cache
|
||||
Content-Length: 835
|
||||
|
||||
```
|
||||
|
||||
In the list returned, search for item which ends with USER_IN, which is shown above.
|
||||
This item will be the parent of the cropping scheme.
|
||||
|
||||
So make another call to check if a cropping scheme exist.
|
||||
|
||||
**Request**
|
||||
Replace `<acces token>` with your actual token.
|
||||
```http
|
||||
GET https://farmmaps.eu/api/v1/items/f25d8765a1cd407cb235961c73c268cf:USER_IN/children HTTP/1.1
|
||||
Host: farmmaps.eu
|
||||
Accept: application/json
|
||||
Authorization: Bearer <access token>
|
||||
```
|
||||
|
||||
**Response**
|
||||
The response will be something similar to:
|
||||
|
||||
```http
|
||||
HTTP/1.1 200 OK
|
||||
Date: Fri, 27 Aug 2021 19:17:36 GMT
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Connection: keep-alive
|
||||
Server: Kestrel
|
||||
Cache-Control: no-store,no-cache
|
||||
Pragma: no-cache
|
||||
Content-Length: 1519
|
||||
|
||||
```
|
||||
|
||||
When the list is empty, you need to create a new cropping scheme, which is described in another thread.
|
||||
|
||||
The `parentcode` we need for creating a crop field is **"f3ee8e3ac55b43bc89757bcaedc89992"**
|
||||
|
||||
### Create the cropfield
|
||||
Now we can create the cropfield. We do so by setting `"itemType": "vnd.farmmaps.itemtype.cropfield"` and adding data to the geometry parameter.
|
||||
Generally, a cropfield contour would be defined as a polygon, so we add `"type":"Polygon" and all the coordinates.
|
||||
We also need to specify a `dataDate` and a `dataEndDate` to indicate the the timeframe of the growing season.
|
||||
The `dataDate` needs to be before `dataEndDate` and cannot be on the same day.
|
||||
|
||||
**Request**
|
||||
|
||||
```http
|
||||
POST /api/v1/items HTTP/1.1
|
||||
Accept: application/json
|
||||
Authorization: Bearer <acces token>
|
||||
Content-Type: application/json
|
||||
Cache-Control: no-cache
|
||||
Host: farmmaps.awacc.nl
|
||||
Accept-Encoding: gzip, deflate, br
|
||||
Connection: keep-alive
|
||||
Content-Length: 916
|
||||
|
||||
{
|
||||
"parentCode": "f3ee8e3ac55b43bc89757bcaedc89992",
|
||||
"itemType": "vnd.farmmaps.itemtype.cropfield",
|
||||
"name": "cropfield test",
|
||||
"dataDate": "2021-01-01T00:00:0.0Z",
|
||||
"dataEndDate": "2021-12-31T00:00:00.0Z",
|
||||
"data": {},
|
||||
"geometry": {"type":"Polygon","coordinates":[[[6.09942873984307,53.070025028087],[6.09992507404607,53.0705617890585],[6.10036959220086,53.0710679529031],[6.10065149010421,53.0714062774307],[6.10087493644271,53.0716712354474],[6.10091082982487,53.0716936039203],[6.10165087441291,53.0712041549161],[6.10204994718318,53.0709349338005],[6.10263143118855,53.0705789370018],[6.10311578125011,53.0702657538294],[6.10331686552072,53.0701314102389],[6.103326530575,53.070119463569],[6.10309137950343,53.0699829669055],[6.10184241586523,53.0692902201371],[6.10168497998891,53.0691984306747],[6.10092987659869,53.0694894453514],[6.09942873984307,53.070025028087]]]}
|
||||
}
|
||||
```
|
||||
|
||||
**Response**
|
||||
```http
|
||||
HTTP/1.1 201 Created
|
||||
Server: nginx/1.14.0 (Ubuntu)
|
||||
Date: Fri, 27 Aug 2021 19:21:36 GMT
|
||||
Content-Type: application/json; charset=utf-8
|
||||
Transfer-Encoding: chunked
|
||||
Connection: keep-alive
|
||||
Cache-Control: no-store,no-cache
|
||||
Pragma: no-cache
|
||||
Content-Encoding: br
|
||||
Location: /api/v1/items/8ecbaa2d85d5484db7f16b281b7cd013
|
||||
Vary: Accept-Encoding
|
||||
|
||||
{
|
||||
"parentCode":"6601a06d812b40f9830c9fe4e63b1944",
|
||||
"geometry": {
|
||||
"type":"Polygon",
|
||||
"coordinates":[[
|
||||
[6.09942873984307,53.070025028087],
|
||||
[6.09992507404607,53.0705617890585],
|
||||
[6.10036959220086,53.0710679529031],
|
||||
[6.10065149010421,53.0714062774307],
|
||||
[6.10087493644271,53.0716712354474],
|
||||
[6.10091082982487,53.0716936039203],
|
||||
[6.10165087441291,53.0712041549161],
|
||||
[6.10204994718318,53.0709349338005],
|
||||
[6.10263143118855,53.0705789370018],
|
||||
[6.10311578125011,53.0702657538294],
|
||||
[6.10331686552072,53.0701314102389],
|
||||
[6.103326530575,53.070119463569],
|
||||
[6.10309137950343,53.0699829669055],
|
||||
[6.10184241586523,53.0692902201371],
|
||||
[6.10168497998891,53.0691984306747],
|
||||
[6.10092987659869,53.0694894453514],
|
||||
[6.09942873984307,53.070025028087]]
|
||||
]},
|
||||
"data":{},
|
||||
"tags":[],
|
||||
"isEditable":false,
|
||||
"url":"/api/v1/items/8ecbaa2d85d5484db7f16b281b7cd013",
|
||||
"code":"8ecbaa2d85d5484db7f16b281b7cd013",
|
||||
"name":"cropfield for VRA",
|
||||
"created":"2020-04-24T08:56:45.3727807Z",
|
||||
"updated":"2020-04-24T08:56:45.3727807Z",
|
||||
"dataDate":"2019-01-18T10:16:21.455Z",
|
||||
"itemType":"vnd.farmmaps.itemtype.cropfield",
|
||||
"size":0,
|
||||
"state":0,
|
||||
"thumbnail":false
|
||||
}
|
||||
```
|
||||
|
||||
**Troubleshooting**
|
||||
|Status code|Description|
|
||||
|---|---|
|
||||
|201|Cropfield created successfully|
|
||||
|401|Error: not authenticated|
|
||||
|403|Error: No write permissions in parent item|
|
||||
|404|Error: Parent item not found|
|
||||
|
||||
Now that the cropfield has been created, we can start the processing by running a task.
|
||||
This will collext all context data for the cropfield.
|
||||
We need the ItemCode of the cropfield to start the task so keep this at hand.
|
||||
|
||||
[6.10311578125011,53.0702657538294],
|
||||
[6.10331686552072,53.0701314102389],
|
||||
[6.103326530575,53.070119463569],
|
||||
[6.10309137950343,53.0699829669055],
|
||||
[6.10184241586523,53.0692902201371],
|
||||
[6.10168497998891,53.0691984306747],
|
||||
[6.10092987659869,53.0694894453514],
|
||||
[6.09942873984307,53.070025028087]]
|
||||
]},
|
||||
"data":{},
|
||||
"tags":[],
|
||||
"isEditable":false,
|
||||
"url":"/api/v1/items/8ecbaa2d85d5484db7f16b281b7cd013",
|
||||
"code":"8ecbaa2d85d5484db7f16b281b7cd013",
|
||||
"name":"cropfield for VRA",
|
||||
"created":"2020-04-24T08:56:45.3727807Z",
|
||||
"updated":"2020-04-24T08:56:45.3727807Z",
|
||||
"dataDate":"2019-01-18T10:16:21.455Z",
|
||||
"itemType":"vnd.farmmaps.itemtype.cropfield",
|
||||
"size":0,
|
||||
"state":0,
|
||||
"thumbnail":false
|
||||
}
|
||||
```
|
||||
|
||||
**Troubleshooting**
|
||||
|Status code|Description|
|
||||
|---|---|
|
||||
|201|Cropfield created successfully|
|
||||
|401|Error: not authenticated|
|
||||
|403|Error: No write permissions in parent item|
|
||||
|404|Error: Parent item not found|
|
||||
|
||||
Now that the cropfield has been created, we can start the processing by running a task.
|
||||
This will collext all context data for the cropfield.
|
||||
We need the ItemCode of the cropfield to start the task so keep this at hand.
|
||||
|
@@ -8,7 +8,7 @@ The response 'message' field can contain a string message based on the context.
|
||||
#### Get a list task of status for a given item
|
||||
> Request
|
||||
```javascript
|
||||
GET /api/v1/items/{code}/tasks
|
||||
GET /api/v1/items/{code}/tasks/
|
||||
```
|
||||
|
||||
> Response 200 OK
|
||||
|
Reference in New Issue
Block a user