npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gpx-builder

v5.3.0

Published

Builder of GPX files

Downloads

4,260

Readme

GPX builder

npm

This library creates GPX version 1.1 files. I recommend you to check full documentation on topografix. The library has option to use Garmin extensions, so you can add cadence, heart rate, speed and other fitness data to your points.

Integration for Strava allows to use some non-standard metric as power. That XML is not valid by standard, but it's the way that Strava use it.

How to use it

Install:

npm install gpx-builder

Create your first GPX file:

const { buildGPX, GarminBuilder } = require('gpx-builder');

const { Point } = GarminBuilder.MODELS;

const points = [
    new Point(51.02832496166229, 15.515156626701355, {
        ele: 314.715,
        time: new Date('2018-06-10T17:29:35Z'),
        hr: 120,
    }),
    new Point(51.12832496166229, 15.615156626701355, {
        ele: 314.715,
        time: new Date('2018-06-10T17:39:35Z'),
        hr: 121,
    }),
];

const gpxData = new GarminBuilder();

gpxData.setSegmentPoints(points);

console.log(buildGPX(gpxData.toObject()));

Use Strava format that supports power and distance on top of Garmin standard properties.

const { StravaBuilder } = require('gpx-builder');
const { Point } = StravaBuilder.MODELS;

const points = [
    new Point(51.02832496166229, 15.515156626701355, {
        ele: 314.715,
        time: new Date('2018-06-10T17:29:35Z'),
        hr: 120,
        power: 5,
        distance: 1,
    }),
];

How the library works

Library contains two types of classes:

  • Creators - They create xml string from defined Object structure
  • Builders - They offer user friendly way to create data for creators

Library contains three Builders:

Types

What you find in type file are types that are used as object for builders. Eg. you can create object based on WayPoint and use it directly to creator. You can also use Point class in builder section that has more developer friendly constructor. It will convert you data to WayPoint type.