# Racemap

Racemap makes the data of it's trackers available via an easy Web API. This URL is individual per event.&#x20;

The data in this API contains each tracker's distance to start and from finish and many other data.&#x20;

## Get Distance from start from leading vehicles

In this example, we want to fetch the distance to finish from the lead vehicle's tracker.&#x20;

First we need to setup a global list with the URL provided by Racemap and name it *Racemap*:

<figure><img src="/files/6ovmL8PO1BVeFRY9qyQO" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/1jrPZ52UfLvDhz2JNLBJ" alt=""><figcaption></figcaption></figure>

In a script, we can now access the data via the *Racemap.Data* variable. We loop through all trackers and find tghe one matching the lead vehicle tracker id. And then fetch the *toFinish* property.&#x20;

```
{{
# Define tracker ID
leadTrackerId = "66bf4318d1c783279d183e37"
leadTrackerFound = false

# Loop through all trackers and pick the one we are interested in
for tracker in Racemap.Data.starters
    if (tracker.id == leadTrackerId)
        leadTrackerFound = true
        distanceToFinish = tracker.current.toFinish
    end
end

# Show texts based on distance
if leadTrackerFound
    if distanceToFinish > 0
        "Distance to Finish: " + ((distanceToFinish / 1000) | Format "####0.0") + "km"
     else 
       "Finished"
     end
else 
    "Tracker not found"
end
}}
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dbnetsoft.com/dbnetsoft/raceresultexchange/scripting/examples/racemap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
