Dynamic Bay Session

On a driving range, players can practice out in the green and start a player session without a fixed bay. In order to determine which dynamic bay the Player is standing on, the Player will be asked to hit a shot, and claim the shot once a Measurement is received.

1. Create dynamic bay session

A Player session should be established by passing the GPS location instead of the bay id as it is the case in the fixed bay scenario.

Pass the body shown in the example below.

  • gpsLocation: Gps location of the player.
POST /api/session

{
  "gpsLocation": {
    "lat": 52.78979,
    "lon": 12.25245,
    "horizontalAccuracy" : 10
  },
  "targetId": "a43a1e52-180a-4519-95e2-373a5afff414",
  "clubId" : "Driver"
}

Host: https://localsite.trackmanrange.com

A successful response will look like the following example. The session is in the Presession state once it has been established.

{
  "sessionId": "b3c61f6d-53e5-4383-a267-43a8eca0ee9d",
  "player": {
    "id": "5be86359-073c-434b-ad2d-a3932222dabe",
    "name": "Player 1",
    "isTempAccount": false
  },
  "gpsLocation": {
    "lat": 55.72813184053,
    "lon": 12.30750739356,
    "horizontalAccuracy": 10
  },
  "startedAt": "2017-03-10T07:55:02.094817Z",
  "state": "PreSession",
  "hasEnded": false,
  "_links": {
    "self": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/session"
    },
    "endsession": {
      "method": "DELETE",
      "href": "https://localsite.trackmanrange.com/api/session"
    },
    "select_target": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/session/target"
    },
    "select_club": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/session/club"
    },
    "select_bay": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/session/bay"
    },
    "change_gps_location": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/session/location"
    }
    "measurements": {
      "method": "GET",
      "href": "ws://localhost:5000/ws?type=measurements&sessionId=b3c61f6d-53e5-4383-a267-43a8eca0ee9d&ticketId=233758c8-62bd-429e-b4cd-e494dfa0834b"
    },
    "strokes": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/session/strokes?excludeMeasurements=true"
    },
    "strokes_full": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/session/strokes"
    },
    "ticket": {
      "method": "POST",
      "href": "https://localsite.trackmanrange.com/api/tickets"
    }
  }
}

A successful call to the API returns a session id. If the user session is already in progress, it returns the existing session id.

Additionally the response contains links

  • Use the measurements link to open a channel to start receiving the shot measurements.
  • Use the endsession link to end the current player session.
  • Use the select_target link to select another target after the session has started.
  • Use the select_bay link to select dynamic bay id after bay id is received in the measurement.
  • Use the change_gps_location link to update the Gps location of the player.

Refer to the Session Management section to start a session and establish a web socket connection to receive measurements.

2. Claim Bay

When a dynamic bay player session is established, use the measurement link to start receiving a measurement. The measurement message passed to the Web socket will contain the dynamic bay id. When the Player confirms his stroke, the API to select a Bay should be called.

In dynamic bay scenario, the bay is not known at the Session creation time. So when playing on green, the player is required to hit a shot in order to confirm the bay.

To select a bay in dynamic bay scenario:

PUT /api/session/bay

{
  "bayId": "0c8458be-0e30-4002-8047-3106b15139a1"
}

Host: https://localsite.trackmanrange.com

where bayId is a valid bay identifier. Once selected, the bay can not be changed for the entire lifetime of the session.

A successful call to select a bay provides the session information together with the selected bay id. The session is in the Active state once a bay has been selected.

{
  "sessionId": "495ee663-8b2a-4799-ad95-cab7564cad24",
  "player": {
    "id": "5be86359-073c-434b-ad2d-a3932222dabe",
    "name": "Player 1",
    "isTempAccount": false
  },
  "bayId": "0c8458be-0e30-4002-8047-3106b15139a1",
  "gpsLocation": {
    "lat": 55.72813184053,
    "lon": 12.30750739356,
    "horizontalAccuracy": 10
  },
  "startedAt": "2017-03-10T08:23:35.1826727Z",
  "state": "Active",
  "hasEnded": false,
  "_links": {
    "self": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/session"
    },
    "endsession": {
      "method": "DELETE",
      "href": "https://localsite.trackmanrange.com/api/session"
    },
    "select_target": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/session/target"
    },
    "select_club": {
      "method": "PUT",
      "href": "https://localsite.trackmanrange.com/api/session/club"
    },
    "strokes": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/session/strokes?excludeMeasurements=true"
    },
    "strokes_full": {
      "method": "GET",
      "href": "https://localsite.trackmanrange.com/api/session/strokes"
    },
    "ticket": {
      "method": "POST",
      "href": "https://localsite.trackmanrange.com/api/tickets"
    }
  }
}