Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mikaello/gpxfaketimer

Create fake timestamps for GPX-files. Useful for debugging or creating anonymized tracks
https://github.com/mikaello/gpxfaketimer

Last synced: 1 day ago
JSON representation

Create fake timestamps for GPX-files. Useful for debugging or creating anonymized tracks

Awesome Lists containing this project

README

        

# GPX fake timer

[![npm](https://img.shields.io/npm/v/@mikaello/gpxfaketimer.svg?style=flat-square)](https://www.npmjs.com/package/@mikaello/gpxfaketimer)

Create timestamps for every trackpoint in a GPX file.

```shell
yarn add @mikaello/gpxfaketimer
```

## Example

```ts
import { createTimestampsEvenly } from "@mikaello/gpxfaketimer";

const exampleGpx = `

Example gpx

Example gpx
1


2376


2375


2376


`;

console.log(createTimestampsEvenly(exampleGpx, 0, 100000));
// => will return the same GPX file, only with inside every trkpt:

/*

Example gpx

Example gpx
1


2376



2375



2376



*/
```

## API

- _`createTimestampsEvenly(gpxContent: string, startTime: number, endTime: number) => string`_:
returns the incoming `gpxContent` enriched with timestamps in every `trkpt`
element. `startTime` and `endTime` are milliseconds since epoch.

## Utility functions

Not specific for GPX, but just as helper functions

_`getUniformDistribution(count: number, intervalStart: number, intervalEnd: number) => number[]`_:
returns an array of length `count` with first element `intervalStart` and last
element `intervalEnd`, all elements in between is evenly distributed between
these extremeties.

## Develop

You can use the [./example](./example) project to ease developing. If you run
`yarn start` from that folder, you will start a server running a small
application which loads the code from this module. Run `yarn dev` in another
terminal to start to continously watch the code and recompile (and reload
server) when any code changes.

Contributions are welcome :-)