Paddocks

Update Paddock Boundary

Save (or clear) a paddock's outline.

A dedicated endpoint rather than attributes on updatePaddock, because it is the single place two rules are enforced:

  • A typed area is never overwritten by a drawn one. area_source: "drawn" recomputes area_ha from the ring; area_source: "typed" saves the ring and leaves area_ha exactly as it is. A request that names no source keeps the paddock's own, so omitting the field can never clobber a typed number; a paddock that has never had one gets drawn.

  • Geometry is repaired before it is measured. Rings are validated (at least 4 positions, closed, finite, latitude within ±90 and longitude within ±180), repaired with ST_MakeValid, wound counter-clockwise and stored as a MultiPolygon — so a self-crossing ring cannot report a plausible-but-wrong hectare figure. The geometry read back may therefore be reordered or split into parts.

  • A paddock ring must be near its property. A ring whose centroid lies more than 25 km from the property's map point (centroid_lat / centroid_lon on the farm) is refused with a 422 that names the distance — with no imagery under the editor, that is the ring drawn over the wrong ground. A property with no map point yet is not guarded.

Area is computed by PostGIS as ST_Area(geography) in hectares. A paddock carries no map point of its own — it inherits its property's, and the point its name is drawn at is the ring's mean.

Provenance. boundary_source (traced | grid | gps | imported) is the client's claim about how the ring was captured and travels with it; boundary_captured_by is stamped server-side from the acting user and is never accepted from the request. Both are cleared with the ring.

The diary. When the save changes area_ha — a first ring measured under drawn, a redraw that measures differently, or a cleared ring that takes a measured area with it — one completed observation is filed on the paddock in the same transaction ("Boundary redrawn — area 70 ha, was 84 ha"; "Boundary drawn — area 70 ha"; "Boundary removed — was 84 ha"), through the same path a rename or a typed area change uses. A ring that measures the same, or one saved over a typed area, writes nothing. Requires organization edit rights.

put/paddocks/{id}/boundary

Request

  • Base URL: https://api.purplegrain.com/api/v1
  • URL: https://api.purplegrain.com/api/v1/paddocks/{id}/boundary
  • Auth: HTTP bearer

Path parameters

idstring required

Id of the record

Query parameters

includestring
Example:farm.organization

Comma-separated snake_case relationship paths to embed (JSON:API included array, or inlined for application/json). Never embedded by default; unknown paths ignored; dot notation selects children; max 10 paths. Allowed paths: farm, farm.organization.

Request body

Response

The paddock with its saved boundary.

Example response

{
  "data": {
    "type": "paddock"
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.