6a Get Facilities
โถStep 6a: Get Facilities
Retrieve facility locations with polygon geometries for map rendering.
Filter by asset_task_id to scope to the current processing task.
โถWhat this step does
It reads the facility rows produced by the task through the standard
/locations/facilities endpoint, scoped by filter[assets.task_id]. Each
facility carries its geo polygon, name, country_code, and area,
plus links to its supply shed, plots, and per-facility metrics.
โถWhy it's needed
The entity read in Step 6 gives you the uploaded rows, but the map needs
actual geometry โ the facility boundaries to draw. This is where those
polygons come from. It also provides the join key: the id of each
facility here is what the deforestation and emissions metrics (6c/6d)
reference via their facility_id, so without this read there is nothing
to hang the metric colouring and tooltips on.
โถWhen you can skip it
Skip it for plot-only uploads โ if the task uploaded no facilities, this returns an empty set and the combined visualization renders just the plot polygons. It's only load-bearing when the workflow ingested facilities (the usual facility/supplier onboarding case).
โถRequest
GET /locations/facilities?filter[assets.task_id]=eq:{process-task-id}
Query parameters:
| Parameter | Description |
|---|---|
filter[assets.task_id] | Process task ID from Step 4 |
filter[country_code] | Filter by country (ISO 3166-1 alpha-2) |
filter[commodity] | Filter by commodity type |
page[number] | Page number |
page[size] | Items per page |
โถFrontend Usage
- Map polygons: Render
geoas facility boundaries on a Leaflet/Mapbox map - Color by risk: Join with deforestation metrics (6c) to color polygons by risk level
- Facility list: Show name, country, area in a sidebar
- Click handler: On facility click, show tooltip with metrics data
- Navigation: Use
links.shedto navigate to the latest supply shed,links.plotsto list plots - Metric fetch: Use
links.metrics_deforestationandlinks.metrics_emissionsto fetch metrics per facility