# This file is part of datacube-ows, part of the Open Data Cube project.
# See https://opendatacube.org for more information.
#
# Copyright (c) 2017-2024 OWS Contributors
# SPDX-License-Identifier: Apache-2.0


level3_labels = {
    "n/a": "No data",
    111: "Cultivated Terrestrial Vegetation",
    112: "Natural Terrestrial Vegetation",
    123: "Cultivated Aquatic Vegetation",
    124: "Natural Aquatic Vegetation",
    215: "Artificial Surface",
    216: "Natural Bare Surface",
    220: "Water"
}

level4_labels = {
    "n/a": "No data",
    1: 'Cultivated Terrestrial Vegetated',
    3: 'Cultivated Terrestrial Vegetated: Herbaceous',
    4: 'Cultivated Terrestrial Vegetated: Closed (> 65 %)',
    5: 'Cultivated Terrestrial Vegetated: Open (40 to 65 %)',
    6: 'Cultivated Terrestrial Vegetated: Open (15 to 40 %)',
    7: 'Cultivated Terrestrial Vegetated: Sparse (4 to 15 %)',
    8: 'Cultivated Terrestrial Vegetated: Scattered (1 to 4 %)',
    14: 'Cultivated Terrestrial Vegetated: Herbaceous Closed (> 65 %)',
    15: 'Cultivated Terrestrial Vegetated: Herbaceous Open (40 to 65 %)',
    16: 'Cultivated Terrestrial Vegetated: Herbaceous Open (15 to 40 %)',
    17: 'Cultivated Terrestrial Vegetated: Herbaceous Sparse (4 to 15 %)',
    18: 'Cultivated Terrestrial Vegetated: Herbaceous Scattered (1 to 4 %)',
    19: 'Natural Terrestrial Vegetated',
    20: 'Natural Terrestrial Vegetated: Woody',
    21: 'Natural Terrestrial Vegetated: Herbaceous',
    22: 'Natural Terrestrial Vegetated: Closed (> 65 %)',
    23: 'Natural Terrestrial Vegetated: Open (40 to 65 %)',
    24: 'Natural Terrestrial Vegetated: Open (15 to 40 %)',
    25: 'Natural Terrestrial Vegetated: Sparse (4 to 15 %)',
    26: 'Natural Terrestrial Vegetated: Scattered (1 to 4 %)',
    27: 'Natural Terrestrial Vegetated: Woody Closed (> 65 %)',
    28: 'Natural Terrestrial Vegetated: Woody Open (40 to 65 %)',
    29: 'Natural Terrestrial Vegetated: Woody Open (15 to 40 %)',
    30: 'Natural Terrestrial Vegetated: Woody Sparse (4 to 15 %)',
    31: 'Natural Terrestrial Vegetated: Woody Scattered (1 to 4 %)',
    32: 'Natural Terrestrial Vegetated: Herbaceous Closed (> 65 %)',
    33: 'Natural Terrestrial Vegetated: Herbaceous Open (40 to 65 %)',
    34: 'Natural Terrestrial Vegetated: Herbaceous Open (15 to 40 %)',
    35: 'Natural Terrestrial Vegetated: Herbaceous Sparse (4 to 15 %)',
    36: 'Natural Terrestrial Vegetated: Herbaceous Scattered (1 to 4 %)',
    55: 'Natural Aquatic Vegetated',
    56: 'Natural Aquatic Vegetated: Woody',
    57: 'Natural Aquatic Vegetated: Herbaceous',
    58: 'Natural Aquatic Vegetated: Closed (> 65 %)',
    59: 'Natural Aquatic Vegetated: Open (40 to 65 %)',
    60: 'Natural Aquatic Vegetated: Open (15 to 40 %)',
    61: 'Natural Aquatic Vegetated: Sparse (4 to 15 %)',
    62: 'Natural Aquatic Vegetated: Scattered (1 to 4 %)',
    63: 'Natural Aquatic Vegetated: Woody Closed (> 65 %)',
    64: 'Natural Aquatic Vegetated: Woody Closed (> 65 %) Water > 3 months (semi-) permanent',
    65: 'Natural Aquatic Vegetated: Woody Closed (> 65 %) Water < 3 months (temporary or seasonal)',
    66: 'Natural Aquatic Vegetated: Woody Open (40 to 65 %)',
    67: 'Natural Aquatic Vegetated: Woody Open (40 to 65 %) Water > 3 months (semi-) permanent',
    68: 'Natural Aquatic Vegetated: Woody Open (40 to 65 %) Water < 3 months (temporary or seasonal)',
    69: 'Natural Aquatic Vegetated: Woody Open (15 to 40 %)',
    70: 'Natural Aquatic Vegetated: Woody Open (15 to 40 %) Water > 3 months (semi-) permanent',
    71: 'Natural Aquatic Vegetated: Woody Open (15 to 40 %) Water < 3 months (temporary or seasonal)',
    72: 'Natural Aquatic Vegetated: Woody Sparse (4 to 15 %)',
    73: 'Natural Aquatic Vegetated: Woody Sparse (4 to 15 %) Water > 3 months (semi-) permanent',
    74: 'Natural Aquatic Vegetated: Woody Sparse (4 to 15 %) Water < 3 months (temporary or seasonal)',
    75: 'Natural Aquatic Vegetated: Woody Scattered (1 to 4 %)',
    76: 'Natural Aquatic Vegetated: Woody Scattered (1 to 4 %) Water > 3 months (semi-) permanent',
    77: 'Natural Aquatic Vegetated: Woody Scattered (1 to 4 %) Water < 3 months (temporary or seasonal)',
    78: 'Natural Aquatic Vegetated: Herbaceous Closed (> 65 %)',
    79: 'Natural Aquatic Vegetated: Herbaceous Closed (> 65 %) Water > 3 months (semi-) permanent',
    80: 'Natural Aquatic Vegetated: Herbaceous Closed (> 65 %) Water < 3 months (temporary or seasonal)',
    81: 'Natural Aquatic Vegetated: Herbaceous Open (40 to 65 %)',
    82: 'Natural Aquatic Vegetated: Herbaceous Open (40 to 65 %) Water > 3 months (semi-) permanent',
    83: 'Natural Aquatic Vegetated: Herbaceous Open (40 to 65 %) Water < 3 months (temporary or seasonal)',
    84: 'Natural Aquatic Vegetated: Herbaceous Open (15 to 40 %)',
    85: 'Natural Aquatic Vegetated: Herbaceous Open (15 to 40 %) Water > 3 months (semi-) permanent',
    86: 'Natural Aquatic Vegetated: Herbaceous Open (15 to 40 %) Water < 3 months (temporary or seasonal)',
    87: 'Natural Aquatic Vegetated: Herbaceous Sparse (4 to 15 %)',
    88: 'Natural Aquatic Vegetated: Herbaceous Sparse (4 to 15 %) Water > 3 months (semi-) permanent',
    89: 'Natural Aquatic Vegetated: Herbaceous Sparse (4 to 15 %) Water < 3 months (temporary or seasonal)',
    90: 'Natural Aquatic Vegetated: Herbaceous Scattered (1 to 4 %)',
    91: 'Natural Aquatic Vegetated: Herbaceous Scattered (1 to 4 %) Water > 3 months (semi-) permanent',
    92: 'Natural Aquatic Vegetated: Herbaceous Scattered (1 to 4 %) Water < 3 months (temporary or seasonal)',
    93: 'Artificial Surface',
    94: 'Natural Surface',
    95: 'Natural Surface: Sparsely vegetated',
    96: 'Natural Surface: Very sparsely vegetated',
    97: 'Natural Surface: Bare areas, unvegetated',
    98: 'Water',
    99: 'Water',
    100: 'Water: Tidal area',
    101: 'Water: Perennial (> 9 months)',
    102: 'Water: Non-perennial (7 to 9 months)',
    103: 'Water: Non-perennial (4 to 6 months)',
    104: 'Water: Non-perennial (1 to 3 months)',
}

lifeform_labels = {
    "n/a": "No data",
    1: "Woody",
    2: "Herbaceous",
}


cover_labels = {
    "n/a": "No data",
    10: "Closed (> 65 %)",
    12: "Open (40 to 65 %)",
    13: "Open (15 to 40 %)",
    15: "Sparse (4 to 15 %)",
    16: "Scattered (1 to 4 %)",
}

water_seasonality_labels = {
    "n/a": "No data",
    1: "Water > 3 months (semi-) permenant",
    2: "Water < 3 months (temporary or seasonal)",
}

water_persistence_labels = {
    "n/a": "No data",
    1: "Perennial (> 9 months)",
    7: "Non-perennial (7 to 9 months)",
    8: "Non-perennial (4 to 6 months)",
    9: "Non-perennial (1 to 3 months)",
}

bare_grad_labels = {
    "n/a": "No data",
    10: "Sparsely vegetated",
    12: "Very sparsely vegetated",
    15: "Bare areas, unvegetated",
}


def class_labels(data):
    return {
        "level3_label": level3_labels[data["level3"]],
        "level4_label": level4_labels[data["level4"]],
    }


def env_descriptor_labels(data):
    return {
        "lifeform_label": lifeform_labels[data["lifeform"]],
        "canopyco_label": cover_labels[data["canopy_cover"]],
        "watersea_label": water_seasonality_labels[data["water_seasonality"]],
        "waterper_label": water_persistence_labels[data["water_persistence"]],
        "baregrad_label": bare_grad_labels[data["bare_gradation"]],
    }
