{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://integragov.imglabs.com.br/protocolo/prg-1.0.schema.json",
  "title": "Protocolo de Reporte Georreferenciado (PRG 1.0)",
  "description": "Pacote mensal de andamento de um projeto financiado com recurso público. As regras de negócio (PRG-01 a PRG-12) são aplicadas pelo validador do IntegraGov. PRG-13: o sha256 de cada foto deve ser inédito no órgão.",
  "type": "object",
  "required": [
    "protocolo",
    "projeto",
    "periodo",
    "avanco_fisico",
    "valor_executado",
    "evidencias"
  ],
  "properties": {
    "protocolo": {
      "const": "PRG-1.0"
    },
    "projeto": {
      "type": "string",
      "description": "Código do projeto no órgão concedente."
    },
    "periodo": {
      "type": "string",
      "pattern": "^\\d{4}-(0[1-9]|1[0-2])$"
    },
    "avanco_fisico": {
      "type": "number",
      "minimum": 0,
      "maximum": 100,
      "description": "Percentual físico acumulado."
    },
    "valor_executado": {
      "type": "number",
      "minimum": 0,
      "description": "Valor executado acumulado, em reais."
    },
    "marcos_concluidos": {
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": 1
      }
    },
    "declaracao": {
      "type": "string",
      "maxLength": 1000
    },
    "evidencias": {
      "type": "object",
      "required": [
        "type",
        "features"
      ],
      "properties": {
        "type": {
          "const": "FeatureCollection"
        },
        "features": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "type",
              "geometry",
              "properties"
            ],
            "properties": {
              "type": {
                "const": "Feature"
              },
              "geometry": {
                "type": "object",
                "required": [
                  "type",
                  "coordinates"
                ],
                "properties": {
                  "type": {
                    "const": "Point"
                  },
                  "coordinates": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 2,
                    "maxItems": 3
                  }
                }
              },
              "properties": {
                "type": "object",
                "required": [
                  "tipo",
                  "data",
                  "sha256"
                ],
                "properties": {
                  "tipo": {
                    "enum": [
                      "foto"
                    ]
                  },
                  "arquivo": {
                    "type": "string"
                  },
                  "data": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "sha256": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                  },
                  "descricao": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "precisao_m": {
                    "type": "number",
                    "minimum": 0,
                    "description": "Precisão horizontal do GPS no momento da foto, em metros."
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}