{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "http://imgarena.com/schemas/tennis.live.tracking.shots/2.0.0",
  "title": "IMGA tennis.live.tracking.shots Schema",
  "description": "Describes all the shots in a set timeframe",
  "type": "object",
  "required": [
    "created",
    "id",
    "type",
    "packetDetails",
    "matchDetails",
    "shots"
  ],
  "additionalProperties": false,
  "properties": {
    "created": {
      "title": "Packet Creation Datetime",
      "type": "string",
      "format": "date-time"
    },
    "id": {
      "title": "Packet ID",
      "type": "string",
      "format": "uuid"
    },
    "type": {
      "title": "Packet Type",
      "const": "live.tracking.shots"
    },
    "packetDetails": {
      "title": "Packet Details",
      "$ref": "#/$defs/packetDetail"
    },
    "matchDetails": {
      "title": "Match Details",
      "$ref": "#/$defs/matchDetail",
      "description": "The details of the match at the point this packet was sent"
    },
    "shots": {
      "title": "Shots Details",
      "description": "Details about the shots during this packet's timeframe",
      "type": "array",
      "items": {"$ref": "#/$defs/shotDetails"},
      "minItems": 1,
      "maxItems": 1
    }
  },
  "$defs": {
    "packetDetail": {
      "title": "Packet Details Schema",
      "type": "object",
      "required": [
        "set",
        "game",
        "point",
        "serve",
        "rally",
        "sequence",
        "start",
        "end"
      ],
      "additionalProperties": false,
      "properties": {
        "set": {
          "description": "The Set this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "game": {
          "description": "The Game this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "point": {
          "description": "The Point this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "serve": {
          "description": "The Serve this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "rally": {
          "description": "The Rally this packet is in",
          "type": "integer",
          "minimum": 1
        },
        "sequence": {
          "description": "The Sequence of this packet",
          "type": "integer",
          "minimum": 1
        },
        "slice": {
          "description": "The Slice of the Sequence of this packet",
          "type": "integer",
          "minimum": 1
        },
        "shot": {
          "description": "The total number of shots so far up to and including this packet",
          "type": "integer",
          "minimum": 1
        },
        "arc": {
          "description": "The total number of arcs so far up to and including this packet",
          "type": "integer",
          "minimum": 1
        },
        "start": {
          "description": "The UTC start timestamp of this packet",
          "type": "string",
          "format": "date-time"
        },
        "end": {
          "description": "The UTC end timestamp of this packet",
          "type": "string",
          "format": "date-time"
        },
        "update": {
          "description": "Is this packet an update to a previous packet",
          "type": "boolean"
        },
        "updatedPacketId": {
          "description": "The packet ID being updated",
          "type": "string",
          "format": "uuid"
        }
      },
      "examples": [
        {
          "set": 1,
          "game": 1,
          "point": 1,
          "serve": 1,
          "rally": 1,
          "sequence": 1,
          "start": "2022-08-14T06:10:13.7513333Z",
          "end": "2022-08-14T06:10:20.4825333Z"
        }
      ]
    },
    "matchDetail": {
      "title": "Match Details Schema",
      "type": "object",
      "required": [
        "competitionId",
        "year",
        "court",
        "matchId",
        "singles",
        "wheelchair",
        "electronicLineCalling",
        "televised",
        "format",
        "round",
        "players"
      ],
      "additionalProperties": false,
      "properties": {
        "year": {
          "description": "The year of the match",
          "type": "integer",
          "minimum": 2020,
          "maximum": 2100
        },
        "competitionId": {
          "description": "The competition id for the match",
          "type": "string"
        },
        "matchId": {
          "description": "The match id",
          "type": "string"
        },
        "court": {
          "description": "The court the match is being played in",
          "type": "string"
        },
        "singles": {
          "description": "Is the match a singles match",
          "type": "boolean"
        },
        "wheelchair": {
          "description": "Is the match wheelchair based",
          "type": "boolean"
        },
        "electronicLineCalling": {
          "description": "Is electronic line calling being used",
          "type": "boolean"
        },
        "televised": {
          "description": "Is the match televised",
          "type": "boolean"
        },
        "format": {
          "description": "The match format",
          "type": "string"
        },
        "round": {
          "description": "The match round string",
          "type": "string"
        },
        "players": {
          "description": "The players involved in the match",
          "type": "array",
          "items": {"$ref": "#/$defs/playerDetail"}
        }
      },
      "examples": [
        {
          "competitionId": "5817",
          "year": 2022,
          "court": "2",
          "matchId": "LS001",
          "singles": true,
          "wheelchair": false,
          "electronicLineCalling": false,
          "televised": false,
          "format": "BestOfThreeTiebreakSets",
          "round": "RoundOf2",
          "players": [
            {
              "team": 1,
              "player": 1,
              "id": "320922",
              "seed": "",
              "firstName": "Ksenia",
              "lastName": "Laskutova"
            },
            {
              "team": 2,
              "player": 1,
              "id": "00BQ9O",
              "seed": "",
              "firstName": "Marketa",
              "lastName": "Petruzelova"
            }
          ]
        }
      ]
    },
    "playerDetail": {
      "title": "Player Detail schema",
      "type": "object",
      "required": [
        "team",
        "player",
        "id",
        "firstName",
        "lastName"
      ],
      "additionalProperties": false,
      "properties": {
        "team": {
          "title": "The team the player is in",
          "description": "This is a numeric depiction of how many teams there are and which team the player resides in",
          "type": "integer",
          "minimum": 1
        },
        "player": {
          "title": "The id of the player in the team",
          "description": "This is a numeric depiction of how many players there are in a team.",
          "type": "integer",
          "minimum": 1
        },
        "id": {
          "title": "Competition Player ID",
          "type": "string"
        },
        "seed": {
          "title": "Player Seed",
          "type": "string"
        },
        "firstName": {
          "title": "Player's first name",
          "type": "string"
        },
        "lastName": {
          "title": "Player's last name",
          "type": "string"
        }
      },
      "examples": [
        {
          "team": 1,
          "player": 1,
          "id": "320922",
          "seed": "",
          "firstName": "Ksenia",
          "lastName": "Laskutova"
        },
        {
          "team": 2,
          "player": 1,
          "id": "00BQ9O",
          "seed": "",
          "firstName": "Marketa",
          "lastName": "Petruzelova"
        }
      ]
    },
    "shotDetails": {
      "title": "Shot Details schema",
      "type": "object",
      "required": [
        "eventId",
        "arcs"
      ],
      "additionalProperties": false,
      "properties": {
        "eventId": {
          "title": "Event ID",
          "description": "Id of the event which this ball arc described",
          "type": "string",
          "format": "uuid"
        },
        "arcs": {
          "title": "Ball Arc Details",
          "type": "array",
          "items": {"$ref": "#/$defs/arcDetails"},
          "minItems": 1
        }
      },
      "examples": [
        {
          "eventId": "37D0ED86-F2C6-4E14-82F6-358872D88042",
          "arcs": [
            {
              "type": "Toss",
              "startTime": 0,
              "endTime": 0.7066666666651145,
              "arcParameters": {
                "x": [
                  -11.807161859157418,
                  -0.42856374982784473,
                  0.18120277524667472,
                  0.18362183375757013,
                  1.1368683772161603E-12
                ],
                "y": [
                  -2.100554316537715,
                  0.11979214856364706,
                  -1.1537290631182486,
                  1.0342488257927016,
                  1.1368683772161603E-13
                ],
                "z": [
                  1.1486879336077713,
                  7.8831545534786756,
                  -4.528937816209918,
                  -0.4187572299720159,
                  -4.547473508864641E-13
                ]
              }
            }
          ]
        }
      ]
    },
    "arcDetails": {
      "title": "Ball Arc Details Schema",
      "type": "object",
      "required": [
        "type",
        "startTime",
        "endTime",
        "arcParameters"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "title": "The type of the arc",
          "enum": [
            "Toss",
            "Hit",
            "Net",
            "Clip",
            "Rebound",
            "Unknown"
          ],
          "description": "Toss - A ball toss.\nHit - An arc caused by contact with a racket.\nNet - An arc caused by contact with a racket that was hit into the net.\nClip - An arc caused by contact with the net, where the ball might continue over the net (or hit the net again).\nSkid - An arc whilst the ball was in contact with the court. Bounce - An arc created by contact with the ground. An out-of-bounce arc.\nRebound - An arc created by contact with the net, where the ball doesn't make forward progress over the net.\nUnknown - An arc where the origin is unknown. It may have been the result of an underarm toss, a high lob that has left the field of view of the tracking system, or some other reason.\n"
        },
        "startTime": {
          "description": "Start time relative to start of packet",
          "type": "number",
          "minimum": 0
        },
        "endTime": {
          "description": "End time relative to start of packet",
          "type": "number",
          "minimum": 0
        },
        "arcParameters": {
          "title": "Parameters of the arc",
          "$ref": "#/$defs/arcParameter",
          "description": "In detail, each arc describes the motion of the ball during its flight in Polynomial_X_Y_Z form. The number of terms is generally 3 to 4. This means a curve described by a quadratic motion or a curve described by a cubic motion. In context, this will be Position, Velocity, Acceleration, & Jerk."
        },
        "groundMark": {
          "description": "Details about the ground mark",
          "$ref": "#/$defs/groundMark"
        }
      },
      "examples": [
        {
          "type": "Toss",
          "startTime": 0,
          "endTime": 0.7066666666651145,
          "arcType": "Polynomial_X_Y_Z",
          "arcParameters": {
            "x": [
              -11.807161859157418,
              -0.42856374982784473,
              0.18120277524667472,
              0.18362183375757013,
              1.1368683772161603E-12
            ],
            "y": [
              -2.100554316537715,
              0.11979214856364706,
              -1.1537290631182486,
              1.0342488257927016,
              1.1368683772161603E-13
            ],
            "z": [
              1.1486879336077713,
              7.8831545534786756,
              -4.528937816209918,
              -0.4187572299720159,
              -4.547473508864641E-13
            ]
          }
        }
      ]
    },
    "arcParameter": {
      "title": "Ball Arc Parameter Schema",
      "type": "object",
      "description": "The parameters that define the mathematical representation or approximation of the arc. These are reported to the highest precision possible.",
      "required": [
        "x",
        "y",
        "z"
      ],
      "additionalProperties": false,
      "properties": {
        "x": {
          "description": "X Polynomial representation of the arc",
          "$ref": "#/$defs/polynomialArray"
        },
        "y": {
          "description": "Y Polynomial representation of the arc",
          "$ref": "#/$defs/polynomialArray"
        },
        "z": {
          "description": "Z Polynomial representation of the arc",
          "$ref": "#/$defs/polynomialArray"
        }
      },
      "examples": [
        {
          "x": [
            -11.807161859157418,
            -0.42856374982784473,
            0.18120277524667472,
            0.18362183375757013,
            1.1368683772161603E-12
          ],
          "y": [
            -2.100554316537715,
            0.11979214856364706,
            -1.1537290631182486,
            1.0342488257927016,
            1.1368683772161603E-13
          ],
          "z": [
            1.1486879336077713,
            7.8831545534786756,
            -4.528937816209918,
            -0.4187572299720159,
            -4.547473508864641E-13
          ]
        }
      ]
    },
    "polynomialArray": {
      "title": "Polynomial Representation Schema",
      "description": "The array of terms are of the format: \"x\": X-Term1, X-Term2, X-Term3, X-Term4, ...",
      "type": "array",
      "minItems": 1,
      "items": {"type": "number"},
      "examples": [
        [
          -11.807161859157418,
          -0.42856374982784473,
          0.18120277524667472,
          0.18362183375757013,
          1.1368683772161603E-12
        ]
      ]
    },
    "groundMark": {
      "description": "",
      "type": "object",
      "required": [
        "startTime",
        "startPosition",
        "direction",
        "size"
      ],
      "additionalProperties": false,
      "properties": {
        "startTime": {
          "description": "Start time relative to start of packet",
          "type": "number",
          "minimum": 0
        },
        "startPosition": {
          "description": "The X, Z components of the starting position of the skid",
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": {"type": "number"},
          "examples": [
            [
              1,
              0
            ]
          ]
        },
        "direction": {
          "title": "Direction of Skid",
          "description": "The X, Z components of the skid",
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": {"type": "number"},
          "examples": [
            [
              1,
              0
            ]
          ]
        },
        "size": {
          "title": "Size of Skid",
          "description": "The length , width components of the skid in metres",
          "type": "array",
          "minItems": 2,
          "maxItems": 2,
          "items": {"type": "number"},
          "examples": [
            [
              0.215,
              0.06
            ]
          ]
        }
      },
      "examples": [
        {
          "time": 0,
          "startPosition": [
            6.45,
            -3.938
          ],
          "direction": [
            1,
            0
          ],
          "size": [
            0.215,
            0.06
          ]
        }
      ]
    }
  },
  "examples": [
    {
      "created": "2022-08-14T06:10:23.4908526Z",
      "id": "e28fc19b-69ec-4504-b77b-a4e0cca6ef46",
      "type": "live.tracking.ball",
      "packetDetails": {
        "set": 1,
        "game": 1,
        "point": 1,
        "serve": 1,
        "rally": 1,
        "sequence": 1,
        "start": "2022-08-14T06:10:13.7513333Z",
        "end": "2022-08-14T06:10:20.4825333Z"
      },
      "matchDetails": {
        "competitionId": "5817",
        "year": 2022,
        "court": "2",
        "matchId": "LS001",
        "singles": true,
        "wheelchair": false,
        "electronicLineCalling": false,
        "televised": false,
        "format": "BestOfThreeTiebreakSets",
        "round": "RoundOf2",
        "players": [
          {
            "team": 1,
            "player": 1,
            "id": "320922",
            "seed": "",
            "firstName": "Ksenia",
            "lastName": "Laskutova"
          },
          {
            "team": 2,
            "player": 1,
            "id": "00BQ9O",
            "seed": "",
            "firstName": "Marketa",
            "lastName": "Petruzelova"
          }
        ]
      },
      "shots": [
        {
          "eventId": "37D0ED86-F2C6-4E14-82F6-358872D88042",
          "arcs": [
            {
              "type": "Toss",
              "startTime": 0,
              "endTime": 0.7066666666651145,
              "arcParameters": {
                "x": [
                  -11.807161859157418,
                  -0.42856374982784473,
                  0.18120277524667472,
                  0.18362183375757013,
                  1.1368683772161603E-12
                ],
                "y": [
                  -2.100554316537715,
                  0.11979214856364706,
                  -1.1537290631182486,
                  1.0342488257927016,
                  1.1368683772161603E-13
                ],
                "z": [
                  1.1486879336077713,
                  7.8831545534786756,
                  -4.528937816209918,
                  -0.4187572299720159,
                  -4.547473508864641E-13
                ]
              },
              "groundMark": {
                "startTime": 0,
                "startPosition": [
                  6.45,
                  -3.938
                ],
                "direction": [
                  1,
                  0
                ],
                "size": [
                  0.215,
                  0.06
                ]
              }
            }
          ]
        }
      ]
    }
  ]
}
