Maps
This API provides endpoints to create, modify or download user maps.
Maps types
id | type |
---|---|
1 | zonings |
2 | yield |
3 | altimetry |
4 | nutrients |
5 | anomalies |
6 | prescription |
APIs
GET
GET /api/users/me/maps
This enpoint can be used in two different ways:
- List: Returns all user maps. Could filter by field adding to the query string the following parameter:
id_lote
:integer
, field id.
- Map: Returns an specific map. Into the query string must be added the following parameter:
id
:integer
, map id
Response example
List
{
"data": [
{
"id_lote": 000000,
"id_tipo": 1,
"nombre": "test",
"id_usuario": 000000,
"fecha_ini": "2022-03-16 14:19:57.531485",
"id": 000000,
"metadata": {
"capas": {
"1": {
"color": [252, 141, 89, 255],
"nombre": "Field Zone 1"
},
"0": {
"color": [215, 48, 39, 255],
"nombre": "Field Zone 0"
},
"3": {
"color": [255, 255, 191, 255],
"nombre": "Field Zone 3"
},
"2": {
"color": [254, 224, 139, 255],
"nombre": "Field Zone 2"
},
"5": {
"color": [145, 207, 96, 255],
"nombre": "Field Zone 5"
},
"4": {
"color": [217, 239, 139, 255],
"nombre": "Field Zone 4"
},
"6": {
"color": [26, 152, 80, 255],
"nombre": "Field Zone 6"
}
}
}
},
{
"id_lote": 00000,
"id_tipo": 1,
"nombre": "test2",
"id_usuario": 000000,
"fecha_ini": "2022-03-17 15:58:40.060272",
"id": 000000,
"metadata": {
"capas": {
"1": {
"color": [252, 141, 89, 255],
"nombre": "Field Zone 1"
},
"0": {
"color": [215, 48, 39, 255],
"nombre": "Field Zone 0"
},
"3": {
"color": [217, 239, 139, 255],
"nombre": "Field Zone 3"
},
"2": {
"color": [254, 224, 139, 255],
"nombre": "Field Zone 2"
},
"5": {
"color": [26, 152, 80, 255],
"nombre": "Field Zone 5"
},
"4": {
"color": [145, 207, 96, 255],
"nombre": "Field Zone 4"
}
}
}
}
]
}
Map
{
"data": {
"nombre": "test2",
"geojson": {
"type": "FeatureCollection",
"features": [
{
"geometry": {
"type": "Polygon",
"coordinates": [...]
},
"type": "Feature",
"id": 17,
"properties": {
"nombre": "Field Zone 0",
"_featid": "76",
"id": 0
}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [...]
},
"type": "Feature",
"id": 19,
"properties": {
"nombre": "Field Zone 2",
"_featid": "59",
"id": 2
}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [...]
},
"type": "Feature",
"id": 20,
"properties": {
"nombre": "Field Zone 1",
"_featid": "66",
"id": 1
}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [...]
},
"type": "Feature",
"id": 23,
"properties": {
"nombre": "Field Zone 5",
"_featid": "23",
"id": 5
}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [...]
},
"type": "Feature",
"id": 26,
"properties": {
"nombre": "Field Zone 4",
"_featid": "24",
"id": 4
}
},
{
"geometry": {
"type": "Polygon",
"coordinates": [...]
},
"type": "Feature",
"id": 27,
"properties": {
"nombre": "Field Zone 3",
"_featid": "6",
"id": 3
}
}
]
},
"id_tipo": 1,
"id_lote": 00000,
"id_usuario": 0000,
"fecha_ini": "2022-03-17 15:58:40.060272",
"id": 00000,
"metadata": {
"capas": {
"1": {
"color": [
252,
141,
89,
255
],
"nombre": "Field Zone 1"
},
"0": {
"color": [
215,
48,
39,
255
],
"nombre": "Field Zone 0"
},
"3": {
"color": [
217,
239,
139,
255
],
"nombre": "Field Zone 3"
},
"2": {
"color": [
254,
224,
139,
255
],
"nombre": "Field Zone 2"
},
"5": {
"color": [
26,
152,
80,
255
],
"nombre": "Field Zone 5"
},
"4": {
"color": [
145,
207,
96,
255
],
"nombre": "Field Zone 4"
}
}
}
}
}
Errors
- Response:
{
"res": "Error",
"info": "Map not found"
}
- Response:
{
"res": "Error",
"info": "User does not have enough permissions"
}
POST
POST api/users/me/maps
Creates a new map. The request body contains:
create_application
:boolean
, used to create a new register at Farm Recordnombre
:String
, name of the mapid_lote
:integer
, field idid_tipo
:integer
, map type (look the complete list below)geojson
:GeoJSON
, feature of the mapmetadata
:Object
, metadata of the map
Response:
{
"info": "Valid data",
"res": "OK",
"code": 0
}
Errors
- Response:
{
"res": "Error",
"info": "The map name is already used"
}
- Response:
{
"res": "Error",
"info": "User does not have enough permissions"
}
PUT
PUT api/users/me/maps
Overwrite an existing map. The body contains the same as the POST request plus the following parameter:
id
:integer
, map id
Errors
- Response:
{
"res": "Error",
"info": "Map not found"
}
- Response:
{
"res": "Error",
"info": "Denied access"
}
This error could happen when trying to overwrite a map created by another user
- Response:
{
"res": "Error",
"info": "User does not have enough permissions"
}
PATCH
PATCH api/users/me/maps
Modifies an existing map. The body contains the same parameters as the PUT request.
The map id
must be specified
Errors
- Response:
{
"res": "Error",
"info": "Map not found"
}
- Response:
{
"res": "Error",
"info": "Denied access"
}
- Response:
{
"res": "Error",
"info": "User does not have enough permissions"
}
DOWNLOAD
POST api/users/me/maps/download
'Content-Type': 'multipart/form-data'
Returns a Blob
object of a Zip
file containing the map files in shapefile.
The body must contain the following:
id_mapa
:integer
, id of the map to downloadnombre
:String
, name of the file
Use example:
const form = new FormData();
form.append("id_mapa", id_mapa);
form.append("nombre", nombre);
const options = {
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
Authorization: `Bearer ${token}`
}
};
options.body = form;
fetch('https://api.auravant.com/api/users/me/maps/download', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
General errors:
{
"res": "Error",
"info": "Map not found"
}
{
"res": "Error",
"info": "Denied access"
}
{
"res": "Error",
"info": "The map name is already used"
}
{
"res": "Error",
"info": "Invalid field"
}
{
"res": "Error",
"info": "User does not have enough permissions"
}
{
"res": "Error",
"info": "User does not have enough permissions"
}
{
"res": "Error",
"info": "Invalid parameters"
}