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:

ParameterDescription
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 geo as 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.shed to navigate to the latest supply shed, links.plots to list plots
  • Metric fetch: Use links.metrics_deforestation and links.metrics_emissions to fetch metrics per facility