> For the complete documentation index, see [llms.txt](https://docs.racemap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.racemap.com/api/distance.md).

# \*/distance and locations

API with real-time geolocations, distances, and bearings to a reference device; for maximum stability and minimum delay the data is processed as little as possible

Latest geolocation of every participant, with the straight-line distance and bearing to a reference participant.

**Live sample** <https://racemap.com/api/data/v1/66bf4318d1c783279d183dd3/distance>\
Corresponding map <https://racemap.com/player/100KmDuathlon2018_API-live-sample>

### Reference

### Reference device

* Pass the `deviceId` of a reference participant to calculate `gapDistance` and `bearing` to the other participants, e.g. <https://racemap.com/api/data/v1/66bf4318d1c783279d183dd3/distance?deviceId=66bf4318d1c783279d183e3d>
* Without a `deviceId`, the first participant of the response is the reference.
* `gapDistance` is the straight-line distance in meters. `bearing` is the direction in degrees from the participant to the reference, clockwise from north, between -180 and 180. Both are `0` for the reference.
* `current` is `null` if the participant or the reference has no geolocation within the event time. This also happens for every participant if `deviceId` is not a participant of the event.

![](https://1672210197-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LSRNxaH2Ju9Flr7JhJD%2Fuploads%2Fgit-blob-9412dbed07b8d608885b4f987966b183e9988154%2FgapDistance.png?alt=media)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.racemap.com/api/distance.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
