diff --git a/db/views/20_freshwater_fish_habitat_accessibility_model.sql b/db/views/20_freshwater_fish_habitat_accessibility_model.sql index 942469f3..c20600c7 100644 --- a/db/views/20_freshwater_fish_habitat_accessibility_model.sql +++ b/db/views/20_freshwater_fish_habitat_accessibility_model.sql @@ -75,14 +75,16 @@ select s.localcode_ltree as localcode, s.feature_code, case - when a.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] and a.obsrvtn_upstr_salmon is true then 'OBSERVED' - when a.barriers_ch_cm_co_pk_sk_dnstr = array[]::text[] and a.obsrvtn_upstr_salmon is false then 'INFERRED' - when a.barriers_ch_cm_co_pk_sk_dnstr != array[]::text[] then 'NATURAL_BARRIER' + when cardinality(a.barriers_ch_cm_co_pk_sk_dnstr) = 0 and a.obsrvtn_upstr_salmon is true then 'OBSERVED' + when cardinality(a.barriers_ch_cm_co_pk_sk_dnstr) = 0 and a.obsrvtn_upstr_salmon is false then 'INFERRED' + when cardinality(a.barriers_ch_cm_co_pk_sk_dnstr) > 0 then 'NATURAL_BARRIER' + else NULL end as model_access_salmon, case - when a.barriers_st_dnstr = array[]::text[] and a.obsrvtn_upstr_st is true then 'OBSERVED' - when a.barriers_st_dnstr = array[]::text[] and a.obsrvtn_upstr_st is false then 'INFERRED' - when a.barriers_st_dnstr != array[]::text[] then 'NATURAL_BARRIER' + when cardinality(a.barriers_st_dnstr) = 0 and a.obsrvtn_upstr_st is true then 'OBSERVED' + when cardinality(a.barriers_st_dnstr) = 0 and a.obsrvtn_upstr_st is false then 'INFERRED' + when cardinality(a.barriers_st_dnstr) > 0 then 'NATURAL_BARRIER' + else NULL end as model_access_steelhead, array_to_string(a.barriers_ch_cm_co_pk_sk_dnstr, ';') as barriers_ch_cm_co_pk_sk_dnstr, array_to_string(a.barriers_st_dnstr, ';') as barriers_st_dnstr, diff --git a/docs/tables/freshwater_fish_habitat_accessibility_model/model_access.csv b/docs/tables/freshwater_fish_habitat_accessibility_model/model_access.csv index e7cfc8d7..604f13b2 100644 --- a/docs/tables/freshwater_fish_habitat_accessibility_model/model_access.csv +++ b/docs/tables/freshwater_fish_habitat_accessibility_model/model_access.csv @@ -13,9 +13,9 @@ column,description ``wscode``,A truncated version of the BC FWA fwa_watershed_code (trailing zeros removed and '-' replaced with '.' ``localcode``,A truncated version of the BC FWA local_watershed_code (trailing zeros removed and '-' replaced with '.' ``feature_code``,"A value based on the Canadian Council of Surveys and Mapping's (CCSM) system for classification of geographic features." -``model_access_salmon``,"Salmon access model result code. Values are 'OBSERVED'; 'INFERRED'; 'NATURAL_BARRIER'. NULL indicates species is not present in watershed group" -``model_access_steelhead``,"Steelhead access model result code. Values are 'OBSERVED'; 'INFERRED'; 'NATURAL_BARRIER'. NULL indicates species is not present in watershed group" -``barriers_ch_cm_co_pk_sk_dnstr``,"IDs of downstream natural barriers to salmon (see `barriers_salmon` table" +``model_access_salmon``,"Salmon access model result code. Values are 'OBSERVED'; 'INFERRED'; 'NATURAL_BARRIER'. NULL indicates species is not documented as present in watershed group" +``model_access_steelhead``,"Steelhead access model result code. Values are 'OBSERVED'; 'INFERRED'; 'NATURAL_BARRIER'. NULL indicates species is not documented as present in watershed group" +``barriers_ch_cm_co_pk_sk_dnstr``,"IDs of downstream natural barriers to salmon (see `barriers_salmon` table)" ``barriers_st_dnstr``,"IDs of downstream natural barriers to steelhead (see `barriers_steelhead` table)" ``barriers_anthropogenic_dnstr``,IDs of anthropogenic barriers downstream ``barriers_pscis_dnstr``,IDs of assessed PSCIS barriers downstream