> For the complete documentation index, see [llms.txt](https://docs.datacake.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.datacake.de/lorawan/payload-decoders/location-and-gps.md).

# Location and GPS

## Create a Database Field

We need to create a Database Field that stores the Location on your Datacake Device. Add a new field an select the Type "Geo Location":

![](https://2221155863-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LNA8_b8wmabHgJ0QXoJ%2F-MFv_tgdbn5SAFeIG0Kh%2F-MFvaSXhX64wzaEr7fH4%2FBildschirmfoto%202020-08-29%20um%2021.02.45.png?alt=media\&token=8b08cb1e-45b6-4e4b-a18b-fe41104220dc)

## Decode Location Data

In order to be able to record location data into a field on your Datacake device, you need to format the location data according to the format required by Datacake.

In the following example, we assume that your device is forwarding the location as two separate measurement values - latitude and longitude.

```javascript
function Decoder(bytes, port) {
    var lat = (bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3]) / 1000000;
    var lon = (bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7]) / 1000000;   
    
    return ...
}
```

Datacake requires Location to be send as a joined data package.

```javascript
var value = "(" + lat + "," + lon + ")"
// value = "(5.235262,21.9399536)"
```

In a complete example, this will look like the following:

```javascript
function Decoder(bytes, port) {

    var datacakeFields = [];

    var lat = (bytes[0] << 24 | bytes[1] << 16 | bytes[2] << 8 | bytes[3]) / 1000000;
    var lon = (bytes[4] << 24 | bytes[5] << 16 | bytes[6] << 8 | bytes[7]) / 1000000;

    datacakeFields.push({
        field: "LOCATION",
        value: "(" + lat + "," + lon + ")"
    });
    
    return datacakeFields;
}
```

Note: The above example how to parse the bytes into Latitude and Longitude is taken from the Dragino LGT92 LoRaWAN Tracker.


---

# 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.datacake.de/lorawan/payload-decoders/location-and-gps.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.
