{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://ncslive.no/watch/schema.json",
  "title": "NCS Live watch event",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "kind",
    "severity",
    "reason",
    "distanceMeters",
    "vessel",
    "asset",
    "mapUrl"
  ],
  "properties": {
    "kind": {
      "enum": [
        "trawling",
        "anchored",
        "loitering"
      ]
    },
    "severity": {
      "enum": [
        "critical",
        "warning",
        "info"
      ],
      "description": "critical < 250 m, warning < 600 m, info within the corridor"
    },
    "reason": {
      "type": "string"
    },
    "distanceMeters": {
      "type": "integer",
      "minimum": 0
    },
    "vessel": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "mmsi",
        "speedOverGroundKnots",
        "courseOverGroundDegrees",
        "position"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "mmsi": {
          "type": "integer"
        },
        "lengthMeters": {
          "type": [
            "number",
            "null"
          ]
        },
        "speedOverGroundKnots": {
          "type": "number"
        },
        "courseOverGroundDegrees": {
          "type": "number"
        },
        "navigationalStatus": {
          "type": [
            "integer",
            "null"
          ],
          "description": "ITU-R M.1371; 1 = at anchor, 7 = engaged in fishing"
        },
        "shipType": {
          "type": [
            "integer",
            "null"
          ]
        },
        "position": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "latitude",
            "longitude"
          ],
          "properties": {
            "latitude": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "longitude": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            }
          }
        },
        "observedAt": {
          "type": [
            "string",
            "null"
          ],
          "format": "date-time",
          "description": "The vessel's own AIS report time — the truth at sea"
        }
      }
    },
    "asset": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "name",
        "schematicRoute"
      ],
      "properties": {
        "type": {
          "enum": [
            "pipeline",
            "cable",
            "custom"
          ]
        },
        "name": {
          "type": "string"
        },
        "medium": {
          "type": [
            "string",
            "null"
          ]
        },
        "diameterInches": {
          "type": [
            "number",
            "null"
          ]
        },
        "maxDepthMeters": {
          "type": [
            "number",
            "null"
          ]
        },
        "schematicRoute": {
          "type": "boolean"
        },
        "nearestPoint": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "latitude",
            "longitude"
          ],
          "properties": {
            "latitude": {
              "type": "number",
              "minimum": -90,
              "maximum": 90
            },
            "longitude": {
              "type": "number",
              "minimum": -180,
              "maximum": 180
            }
          },
          "description": "The point on the asset the distance is measured to"
        }
      }
    },
    "mapUrl": {
      "type": "string",
      "format": "uri"
    }
  }
}