{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Environmental Context",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "context_id",
    "case_id",
    "location",
    "observations",
    "generated_at"
  ],
  "properties": {
    "context_id": {
      "type": "string"
    },
    "case_id": {
      "type": "string"
    },
    "location": {
      "type": "object",
      "required": [
        "latitude",
        "longitude"
      ],
      "properties": {
        "latitude": {
          "type": "number",
          "minimum": -90,
          "maximum": 90
        },
        "longitude": {
          "type": "number",
          "minimum": -180,
          "maximum": 180
        },
        "precision_m": {
          "type": [
            "number",
            "null"
          ]
        },
        "district": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "observations": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "variable",
          "value",
          "unit",
          "source_id",
          "observed_at"
        ],
        "properties": {
          "variable": {
            "type": "string"
          },
          "value": {},
          "unit": {
            "type": "string"
          },
          "source_id": {
            "type": "string"
          },
          "observed_at": {
            "type": "string",
            "format": "date-time"
          },
          "quality": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "soil": {
      "type": [
        "object",
        "null"
      ]
    },
    "terrain": {
      "type": [
        "object",
        "null"
      ]
    },
    "field_history": {
      "type": [
        "object",
        "null"
      ]
    },
    "generated_at": {
      "type": "string",
      "format": "date-time"
    },
    "limitations": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}