buildNSupplyRequest
@nmi-agro/fdm-source / fdm-calculator/src / buildNSupplyRequest
Function: buildNSupplyRequest()
buildNSupplyRequest(
field,soilData,cultivations,method,timeframe):Record<string,unknown>
Defined in: fdm-calculator/src/mineralization/builders.ts:139
Builds the JSON request body for POST /bemestingsplan/nsupply.
Maps FDM field, soil, and cultivation data to the flat parameter structure expected by the NMI nsupply endpoint.
Soil parameter mapping:
| FDM parameter | API field | Unit |
|---|---|---|
a_som_loi | a_som_loi | % |
a_clay_mi | a_clay_mi | % |
a_silt_mi | a_silt_mi | % |
a_sand_mi | a_sand_mi | % |
a_c_of | a_c_of | g C/kg |
a_cn_fr | a_cn_fr | — |
a_n_rt | a_n_rt | mg N/kg |
a_n_pmn | a_n_pmn | mg N/kg |
b_soiltype_agr | b_soiltype_agr | — |
a_depth_lower | a_depth | m (default 0.3) |
The BRP crop code is extracted from b_lu_catalogue of the main crop in the
requested timeframe. We strip the "nl_" prefix and convert to an integer.
Parameters
field
Basic field geometry (centroid required for lat/lon).
b_area?
number | null
b_centroid?
[number, number] | null
[longitude, latitude] in WGS84
soilData
Record<string, number | string | null | undefined>
Flat map of soil parameter values from getCurrentSoilData.
cultivations
object[]
Cultivations on the field (used to derive BRP code).
method
Mineralization model to request.
timeframe
Timeframe
Calendar year timeframe; start and end set d_start/d_end.
Returns
Record<string, unknown>
A plain object suitable for JSON.stringify and sending to the API.
Example
const body = buildNSupplyRequest(
{ b_centroid: [5.585, 53.288] },
{ a_som_loi: 3.5, a_clay_mi: 10, a_silt_mi: 20, a_depth_lower: 0.3 },
[{ b_lu_catalogue: "nl_256", b_lu_start: new Date("2026-04-01") }],
"minip",
{ start: new Date("2026-01-01"), end: new Date("2026-12-31") },
)