<<

NAME

ProductOpener::ForestFootprint - compute the forest footprint of a food product

SYNOPSIS

ProductOpener::Ecoscore is used to compute the forest footprint of a food product.

DESCRIPTION

The modules implements the forest footprint computation as defined by the French NGO Envol Vert.

The computation is based on the amount of soy needed to produce the ingredients, and the risk that that soy contributed to deforestation.

FUNCTIONS

load_forest_footprint_data ()

Loads data needed to compute the forest footprint.

compute_forest_footprint ( $product_ref )

compute_forest_footprint() computes the forest footprint of a food product, and stores the details of the computation.

Arguments

Product reference $product_ref

Return values

The forest footprint and computations details are stored in the product reference passed as input parameter.

Returned values:

- ecoscore_score : numeric Eco-Score value - ecoscore_grade : corresponding A to E grade - forest_footprint_data : forest footprint computation details

add_footprint ( $product_ref, $ingredient_ref, $footprints_ref, $ingredients_category_ref, $footprint_ref )

This function is called when we have an ingredient or a category for which we have a forest footprint. It determines the type of the footprint based on labels, origins etc. and adds a corresponding footprint to the list of footprints for the products (possibly several if the product has multiple ingredients with a footprint)

Synopsis

add_footprint($product_ref, $ingredient_ref, $footprints_ref, $ingredients_category_ref, { tag => ["ingredients", $ingredients_ref->{id}, $category_ingredient_id], percent_estimate => $ingredients_ref->{percent_estimate}, });

compute_footprints_of_ingredients ( $product_ref, $footprints_ref, $ingredients_ref )

Computes the forest footprints of the ingredients.

The function is recursive and may call itself for sub-ingredients.

Arguments

Product reference $product_ref

Used to determine the footprint type based on labels, categories, origins etc.

Footprints reference $footprints_ref

Data structure to which we will add the forest footprints for the ingredients specified in $ingredients_ref

Ingredients reference $ingredients_ref

Ingredients reference that may contains an ingredients structure for sub-ingredients.

Return values

The footprints are stored in $footprints_ref

compute_footprint_of_category ( $product_ref, $footprints_ref )

Computes the forest footprints associated with the category of the product, if the product does not have ingredients (e.g. "whole chickens" category for which we may not have ingredients listed)

Arguments

Product reference $product_ref

Used to determine the footprint type based on labels, categories, origins etc.

Footprints reference $footprints_ref

Data structure to which we will add the forest footprints for the ingredients specified in $ingredients_ref

Return values

The footprints are stored in $footprints_ref

<<