fabulator/gpx-builder

There is no constructor for Routes

Closed this issue · 1 comments

jaybo commented

Maybe this is my lack understanding regarding Typescript, but all types have constructors exported except the Route type.

So I end up writing code like this for Routes:

    let waypoints = this.convertGeojsonArrayToGPXWaypoints(feature.geometry.coordinates);
    let route = {
        rtept: waypoints,
    };
    Object.assign(route, ...feature.properties);

Instead of something more obvious like this for Tracks:

    let trackSeg = new Segment(coords);
    let track = new Track([trackSeg], ...feature.properties);

Also, a note in README.md regarding why there are Points and also WayPoints would be helpful for novices like me.

Hello, thank for input. You're right, it wasn't right. I have add Route class to list of models:

const { Route, Point } = BaseBuilder.MODELS;

const gpxData = new BaseBuilder();

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


const route = new Route({ name: 'x', rtept: points });

gpxData.setRoutes([route]);

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

I also put to README.md infor about points vs waypoits. Thruth to be told, it's not a best design since it confused me also.

It's in new release v4.0.0