{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://landsat.usgs.gov/stac/landsat-extension/v1.1.1/schema.json",
    "title": "Landsat Extension",
    "description": "Landsat Extension to STAC Items and Collections",
    "allOf": [
        {
            "type": "object",
            "required": [
                "type",
                "properties",
                "assets"
            ],
            "properties": {
                "type": {
                    "const": "Feature"
                },
                "collection": {
                    "type": "string"
                },
                "properties": {
                    "allOf": [
                        {
                            "required": [
                                "landsat:scene_id",
                                "landsat:collection_category",
                                "landsat:collection_number",
                                "landsat:wrs_type",
                                "landsat:wrs_path",
                                "landsat:wrs_row",
                                "landsat:cloud_cover_land",
                                "landsat:correction"
                            ]
                        },
                        {
                            "$ref": "#/definitions/fields"
                        }
                    ]
                }
            }
        },
        {
            "$ref": "#/definitions/stac_extensions"
        }
    ],
    "definitions": {
        "stac_extensions": {
            "type": "object",
            "required": [
              "stac_extensions"
            ],
            "properties": {
                "stac_extensions": {
                    "type": "array",
                    "contains": {
                        "const": "https://landsat.usgs.gov/stac/landsat-extension/v1.1.1/schema.json"
                    }
                }
            }
        },
        "fields": {
            "landsat:scene_id": {
                "title": "Landsat Scene Identifier",
                "type": "string",
                "pattern": "^L[CEMOT][1-9][0-9]{3}[0-9]{3}[0-9]{7}[A-Z]{3}[0-9]{2}$"
            },
            "landsat:collection_category": {
                "title": "Collection Category",
                "type": "string",
                "enum": [
                    "A1",
                    "A2",
                    "T1",
                    "T2",
                    "RT"
                ]
            },
            "landsat:collection_number": {
                "title": "Collection Number",
                "type": "string",
                "enum": [
                    "01",
                    "02"
                ]
            },
            "landsat:wrs_type": {
                "title": "WRS Type",
                "type": "string",
                "enum": [
                    "1",
                    "2"
                ]
            },
            "landsat:wrs_path": {
                "title": "WRS Path",
                "type": "string",
                "pattern": "^(0{2}[1-9])$|^(0[1-9][0-9])$|^(1[0-9]{2})$|^(2[0-2][0-9]|23[0-3])$"
            },
            "landsat:wrs_row": {
                "title": "WRS Row",
                "type": "string",
                "pattern": "^(0{2}[1-9])$|^(0[1-9][0-9])$|^(1[0-9]{2})$|^(2[0-3][0-9]|24[0-8])$"
            },
            "landsat:cloud_cover_land": {
                "title": "Land Cloud Cover",
                "type": "number",
                "minimum": -1,
                "maximum": 100
            },
            "landsat:correction": {
                "title": "Product Correction Level",
                "type": "string",
                "enum": [
                    "L1TP",
                    "L1GT",
                    "L1GS",
                    "L2SR",
                    "L2SP"
                ]
            }
        }
    }
}
