{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://ordinis.nstart.cloud/schemas/cuod/ground_station/1.0.0",
  "title": "Ground Station",
  "description": "Наземная станция приёма и/или управления КА. Геометрия (точка) пишется в отдельную колонку geometry, не дублируется в data.lat/lon.",
  "type": "object",
  "required": ["code", "name"],
  "additionalProperties": false,
  "properties": {
    "code": {
      "type": "string",
      "description": "Уникальный код станции",
      "pattern": "^[A-Z][A-Z0-9_-]{1,31}$"
    },
    "name": {
      "type": "object",
      "x-localized": true,
      "patternProperties": {
        "^[a-z]{2}-[A-Z]{2}$": { "type": "string", "minLength": 1 }
      },
      "required": ["ru-RU"]
    },
    "location": {
      "type": "object",
      "x-localized": true,
      "description": "Текстовое описание местоположения (город, регион, страна)",
      "patternProperties": {
        "^[a-z]{2}-[A-Z]{2}$": { "type": "string" }
      }
    },
    "country": {
      "type": "string",
      "description": "ISO 3166-1 alpha-2",
      "pattern": "^[A-Z]{2}$"
    },
    "lat": {
      "type": "number",
      "description": "Широта (для удобства поиска без geometry; geometry — source of truth)",
      "minimum": -90,
      "maximum": 90
    },
    "lon": {
      "type": "number",
      "minimum": -180,
      "maximum": 180
    },
    "elevation_m": {
      "type": "number",
      "description": "Высота над уровнем моря, м"
    },
    "elevation_min_deg": {
      "type": "number",
      "description": "Минимальный угол места, градусы (горизонт станции)",
      "minimum": 0,
      "maximum": 90
    },
    "antennas": {
      "type": "array",
      "description": "Антенные системы станции",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": ["id", "diameter_m", "bands"],
        "properties": {
          "id": { "type": "string" },
          "diameter_m": { "type": "number", "minimum": 0 },
          "bands": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["L_BAND", "S_BAND", "C_BAND", "X_BAND", "KU_BAND", "KA_BAND", "UHF", "VHF"]
            },
            "minItems": 1,
            "uniqueItems": true
          },
          "polarizations": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["LHCP", "RHCP", "H", "V"]
            }
          },
          "tx_capable": { "type": "boolean", "default": false },
          "rx_capable": { "type": "boolean", "default": true },
          "g_t_db_per_k": {
            "type": "number",
            "description": "G/T (gain-to-noise-temperature ratio), дБ/К"
          },
          "eirp_dbw": { "type": "number" }
        }
      }
    },
    "operator": {
      "type": "object",
      "x-localized": true,
      "patternProperties": {
        "^[a-z]{2}-[A-Z]{2}$": { "type": "string" }
      }
    },
    "status": {
      "type": "string",
      "enum": ["PLANNED", "OPERATIONAL", "MAINTENANCE", "DECOMMISSIONED"]
    }
  }
}
