Options
All
  • Public
  • Public/Protected
  • All
Menu

The tracking information associated to a given event

Hierarchy

  • GameState

Index

Constructors

Properties

awayTeam: PlayerState[] = []

the away team player positions, it includes all the position of the player of the away team that are on the field in the current frame

ballPosition: number[] = ...

The position of the ball, as x, y, z, the position is normalized so that the lower left corner is 0, 0, the center of the field is (50, 50) and the upper right corner is 100,100

ballSpeed: number = 0

The speed in km/h for the ball, may be 0 if the tracking format doesnt offer the tracking speed.

gameTime: number

the state game time in seconds since the start of the period (may contain milliseconds), it starts from 0 on every period start.

homeTeam: PlayerState[] = []

the home team player positions, it includes all the position of the player of the home team that are on the field in the current frame

inGame?: boolean

True if the ball is in play, out if the game is stopped (for a foul, a throw in or other...)

period: number

the state period of the game (1 is first half, 2 second half...). The meaning may vary depending on the sport, the mapping between sport and length is available in the game object.

possession: 1 | 2

The team that has the possession of the ball, 1 home team, 2 away team, null unknown

worldTime: number

the timestamp in milliseconds for this state, it's a UTC timestamp in milliseconds.

Methods

  • Returns the details (player list, team id and attacking direction) of the attacking team (the team WITH ball possession). If the tracking data do not support possession this function will return an empty players object

    Returns TeamDetail

    an TeamDetail object containing details about the attacking team

  • Returns the details (player list, team id and attacking direction) of the defending team (the team without ball possession). If the tracking data do not support possession this function will return an empty players object

    Returns TeamDetail

    an TeamDetail object containing details about the defending team

  • defendersAhead(x: number): number
  • Returns the number of defenders (team without ball possession) ahead the given x coordinate in the given moment, the function consider both team as they are attacking from left to right.

    Parameters

    • x: number

      the coordinate to compare the positions against in % (0 friendly goal, 100 opponents goal)

    Returns number

    the number of defenders ahead a certain field position

  • defendersBehind(x: number): number
  • Returns the number of defenders (team without ball possession) behind the given x coordinate in the given moment, the function consider both team as they are attacking from left to right.

    Parameters

    • x: number

      the coordinate to compare the positions against in % (0 friendly goal, 100 opponents goal)

    Returns number

    the number of defenders behind a certain field position

  • defendersBehindBall(): number
  • Returns the number of defenders (team without possession) behind the ball in the given moment, the function takes care of handling the attacking direction.

    Returns number

    the number of defenders behind the ball

  • defendersInZone(zone: Zone): number
  • Returns the number of defenders (team without ball possession) in a given zone, the function consider both team as they are attacking from left to right.

    Parameters

    • zone: Zone

      the NORMALIZED zone to check (the left goal area is ALWAYS the defensive one)

    Returns number

    the number of defenders in a given zone

  • dump(highlightId?: string): string
  • Dumps the field, with ball and players to an utf-8 string.

    Parameters

    • Optional highlightId: string

      optional player to highlight

    Returns string

    a string representation of the field

  • eventX(x: number, teamId: string): number
  • Get an X event coordinate (the team in the event is always attacking left to right) from an absolute tracking coordinate.

    Parameters

    • x: number

      absolute coordinate (as the one in the playerstate objects or in ballPosition)

    • teamId: string

      id of the team

    Returns number

    the final coordinate (may be the same of the source if the team specified is attacking left to right)

  • eventY(y: number, teamId: string): number
  • Get an Y event coordinate (the team in the event is always attacking left to right) from an absolute tracking coordinate.

    Parameters

    • y: number

      absolute coordinate (as the one in the playerstate objects or in ballPosition)

    • teamId: string

      id of the team

    Returns number

    the final coordinate (may be the same of the source if the team specified is attacking left to right)

  • pressingPlayers(distance: number): {}
  • Found the number of players in the team without ball at a distance of less or equal than the provided argument from the ball.

    Parameters

    • distance: number

      distance in meter between the player and the ball

    Returns {}

    an object containing the number of players nearest than "distance" from the ball, the teamId of the pressing team and if it's attacking left to right or right to left.