{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/digitraffic-fi/json-schema/digitraffic-fi-spatial-traffic-restriction-notification-schema.json",
  "title": "SpatialTrafficRestrictionNotification",
  "description": "Describes a restriction affecting the use of a railway infrastructure part",
  "x-generated": "2026-11-11",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/digitraffic-fi-rail-api-openapi.yml#/components/schemas/SpatialTrafficRestrictionNotification",
  "required": [
    "created",
    "id",
    "limitation",
    "location",
    "locations",
    "organization",
    "startDate",
    "state",
    "version"
  ],
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "Id"
    },
    "state": {
      "type": "string",
      "description": "State",
      "enum": [
        "FINISHED",
        "SENT",
        "DRAFT",
        "REMOVED"
      ]
    },
    "organization": {
      "type": "string",
      "description": "Which organization created this notification"
    },
    "created": {
      "type": "string",
      "description": "When this notification was created",
      "format": "date-time"
    },
    "modified": {
      "type": "string",
      "description": "When this notification last modified",
      "format": "date-time"
    },
    "limitation": {
      "type": "string",
      "description": "Limitation type",
      "enum": [
        "CLOSED_FROM_TRAFFIC",
        "CLOSED_FROM_ELECTRIC_ROLLING_STOCK",
        "TEMPORARY_SPEED_LIMIT",
        "AXLE_WEIGHT_MAX",
        "ATP_CONSTRUCTION_ZONE",
        "SWITCH_LOCKED",
        "FIREWORK_DANGER_ZONE",
        "OTHER"
      ]
    },
    "trackWorkNotificationId": {
      "type": "string",
      "description": "Track work notification identifier"
    },
    "axleWeightMax": {
      "type": "number",
      "description": "Max axle weight, required if limitation type is max axle weight",
      "format": "double"
    },
    "startDate": {
      "type": "string",
      "description": "Start datetime",
      "format": "date-time"
    },
    "endDate": {
      "type": "string",
      "description": "End datetime",
      "format": "date-time"
    },
    "finished": {
      "type": "string",
      "description": "Finished datetime, required if state is finished",
      "format": "date-time"
    },
    "location": {
      "type": "object",
      "description": "Approximate location"
    },
    "locations": {
      "uniqueItems": true,
      "type": "array",
      "description": "Locations",
      "items": {
        "$ref": "#/$defs/SpatialRumaLocation"
      }
    },
    "version": {
      "type": "integer",
      "description": "Version",
      "format": "int64"
    }
  },
  "$defs": {
    "ElementRange": {
      "title": "ElementRange",
      "required": [
        "elementId1",
        "elementId2",
        "trackIds"
      ],
      "type": "object",
      "properties": {
        "elementId1": {
          "type": "string",
          "description": "Identifier of element 1"
        },
        "elementId2": {
          "type": "string",
          "description": "Identifier of element 2"
        },
        "trackKilometerRange": {
          "type": "string",
          "description": "Track kilometer range, required if notification type is traffic restriction, e.g. (006) 754+0273 > 764+0771"
        },
        "trackIds": {
          "type": "array",
          "description": "Track identifiers",
          "items": {
            "type": "string",
            "description": "Track identifiers"
          }
        },
        "specifiers": {
          "type": "array",
          "description": "Specify a more detailed work area (track element)",
          "items": {
            "type": "string",
            "description": "Specify a more detailed work area (track element)"
          }
        }
      },
      "description": "Two consecutive elements in an identifier range"
    },
    "IdentifierRange": {
      "title": "IdentifierRange",
      "required": [
        "notificationId"
      ],
      "type": "object",
      "properties": {
        "notificationId": {
          "type": "string",
          "description": "Notification identifier"
        },
        "elementId": {
          "type": "string",
          "description": "Identifier of element, required if element pair or ranges are not present"
        },
        "elementPairId1": {
          "type": "string",
          "description": "Identifier of element 1 in element pair, required if element or ranges are not present"
        },
        "elementPairId2": {
          "type": "string",
          "description": "Identifier of element 2 in element pair, required if element or ranges are not present"
        },
        "speedLimit": {
          "$ref": "#/$defs/SpeedLimit"
        },
        "elementRanges": {
          "uniqueItems": true,
          "type": "array",
          "description": "Element ranges, required if element or element pair is not present",
          "items": {
            "$ref": "#/$defs/ElementRange"
          }
        }
      },
      "description": "Place of work: between two track elements or a single track element"
    },
    "SpatialRumaLocation": {
      "title": "SpatialRumaLocation",
      "required": [
        "locationType",
        "notificationId",
        "workPartIndex"
      ],
      "type": "object",
      "properties": {
        "notificationId": {
          "type": "string",
          "description": "Notification identifier"
        },
        "workPartIndex": {
          "type": "integer",
          "description": "Track work part index",
          "format": "int64"
        },
        "locationType": {
          "type": "string",
          "description": "Type",
          "enum": [
            "WORK",
            "FIREWORK",
            "SPEED_LIMIT"
          ]
        },
        "operatingPointId": {
          "type": "string",
          "description": "Identifier of operating point, required if section is not present"
        },
        "sectionBetweenOperatingPointsId": {
          "type": "string",
          "description": "Identifier of section between operating points, required if operating point is not present"
        },
        "location": {
          "type": "object",
          "description": "Location if no identifer ranges are present"
        },
        "identifierRanges": {
          "uniqueItems": true,
          "type": "array",
          "description": "Identifier ranges",
          "items": {
            "$ref": "#/$defs/IdentifierRange"
          }
        }
      },
      "description": "Location of work, either an operating point or a section between operating points"
    },
    "SpeedLimit": {
      "title": "SpeedLimit",
      "required": [
        "balises",
        "signs",
        "speed"
      ],
      "type": "object",
      "properties": {
        "speed": {
          "type": "integer",
          "description": "Speed limit value",
          "format": "int32"
        },
        "signs": {
          "type": "boolean",
          "description": "Speed limit signs used?"
        },
        "balises": {
          "type": "boolean",
          "description": "Balises used?"
        }
      },
      "description": "Speed limit set for a part of a track"
    }
  }
}