Skip to main content

Maps

This API provides endpoints to create, modify or download user maps.

Maps types

idtype
1zonings
2yield
3altimetry
4nutrients
5anomalies
6prescription

APIs

GET

GET /api/users/me/maps

This enpoint can be used in two different ways:

  1. List: Returns all user maps. Could filter by field adding to the query string the following parameter:
    • id_lote: integer, field id.
  2. 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

  1. Response:
{
"res": "Error",
"info": "Map not found"
}
  1. 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 Record
  • nombre: String, name of the map
  • id_lote: integer, field id
  • id_tipo: integer, map type (look the complete list below)
  • geojson: GeoJSON, feature of the map
  • metadata: Object, metadata of the map

Response:

{
"info": "Valid data",
"res": "OK",
"code": 0
}

Errors

  1. Response:
{
"res": "Error",
"info": "The map name is already used"
}
  1. 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

  1. Response:
{
"res": "Error",
"info": "Map not found"
}
  1. Response:
{
"res": "Error",
"info": "Denied access"
}

This error could happen when trying to overwrite a map created by another user

  1. 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

  1. Response:
{
"res": "Error",
"info": "Map not found"
}
  1. Response:
{
"res": "Error",
"info": "Denied access"
}
  1. Response:
{
"res": "Error",
"info": "User does not have enough permissions"
}

DOWNLOAD

POST api/users/me/maps/download

Downloads the selected map in shapefile format inside a zip file.

The body must contains the following parameters

  • id_mapa: integer, map id
  • nombre: String, file name

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"
}