gpx-builder
Advanced tools
Comparing version 3.5.0 to 3.6.0
# Change Log | ||
All notable changes to this project will be documented in this file. | ||
## v3.6.0 (2020-08-01) | ||
### Added | ||
- [9ada976](https://github.com/fabulator/gpx-builder/commit/9ada976af61489d8b08397bb31613a2efdccba5e) Support for Strava Point | ||
### Changed | ||
- [9ada976](https://github.com/fabulator/gpx-builder/commit/9ada976af61489d8b08397bb31613a2efdccba5e) Change building libraries | ||
- [4d609e5](https://github.com/fabulator/gpx-builder/commit/4d609e53fc6480dd2c0be1d367a28cb50b3e03b2) Update dev dependency semantic-release-config-fabulator to v2 | ||
## [3.5.0] 2020-07-15 | ||
@@ -5,0 +13,0 @@ ### Changed |
@@ -1,4 +0,4 @@ | ||
import { GPXBuildData, Route, Extensions } from '../../types'; | ||
import { Track, Metadata, Point } from './models'; | ||
import { Extensions, GPXBuildData, Route } from '../../types'; | ||
import * as models from './models'; | ||
import { Metadata, Point, Track } from './models'; | ||
export default class BaseBuilder { | ||
@@ -5,0 +5,0 @@ protected data: GPXBuildData; |
@@ -6,564 +6,9 @@ 'use strict'; | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
var Segment = require('./models/Segment.js'); | ||
var Track = require('./models/Track.js'); | ||
var index = require('./models/index.js'); | ||
class Bounds { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_boundsType | ||
*/ | ||
constructor(minlat, minlon, maxlat, maxlon) { | ||
_defineProperty(this, "minlat", void 0); | ||
_defineProperty(this, "minlon", void 0); | ||
_defineProperty(this, "maxlat", void 0); | ||
_defineProperty(this, "maxlon", void 0); | ||
this.minlat = minlat; | ||
this.minlon = minlon; | ||
this.maxlat = maxlat; | ||
this.maxlon = maxlon; | ||
} | ||
toObject() { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} = this; | ||
return { | ||
attributes: { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} | ||
}; | ||
} | ||
} | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Copyright { | ||
/** | ||
* @param author - Owner of licence | ||
* @param year - Year of licence | ||
* @param license - Type of licence | ||
* @see http://www.topografix.com/gpx/1/1/#type_copyrightType | ||
*/ | ||
constructor(author, { | ||
year, | ||
license | ||
}) { | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "year", void 0); | ||
_defineProperty(this, "license", void 0); | ||
this.author = author; | ||
this.year = year || null; | ||
this.license = license || null; | ||
} | ||
toObject() { | ||
const { | ||
author, | ||
year, | ||
license | ||
} = this; | ||
return _objectSpread({ | ||
attributes: { | ||
author | ||
} | ||
}, year ? { | ||
year | ||
} : {}, {}, license ? { | ||
license | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Link { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_linkType | ||
*/ | ||
constructor(href, { | ||
text, | ||
type | ||
}) { | ||
_defineProperty(this, "href", void 0); | ||
_defineProperty(this, "text", void 0); | ||
_defineProperty(this, "type", void 0); | ||
this.href = href; | ||
this.text = text || null; | ||
this.type = type || null; | ||
} | ||
toObject() { | ||
const { | ||
href, | ||
text, | ||
type | ||
} = this; | ||
return _objectSpread$1({ | ||
attributes: { | ||
href | ||
} | ||
}, text ? { | ||
text | ||
} : {}, {}, type ? { | ||
type | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Metadata { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
*/ | ||
// eslint-disable-next-line | ||
constructor({ | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "copyright", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "keywords", void 0); | ||
_defineProperty(this, "bounds", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.name = name || null; | ||
this.desc = desc || null; | ||
this.author = author || null; | ||
this.copyright = copyright || null; | ||
this.link = link || null; | ||
this.time = time || null; | ||
this.keywords = keywords || null; | ||
this.bounds = bounds || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
} = this; | ||
return _objectSpread$2({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Person { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_personType | ||
*/ | ||
constructor({ | ||
name, | ||
email, | ||
link | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "email", void 0); | ||
_defineProperty(this, "link", void 0); | ||
this.name = name || null; | ||
this.email = email || null; | ||
this.link = link || null; | ||
} | ||
toObject() { | ||
const { | ||
name, | ||
email, | ||
link | ||
} = this; | ||
return _objectSpread$3({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread$4({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Segment { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
*/ | ||
constructor(trkpt, extensions = null) { | ||
_defineProperty(this, "trkpt", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.trkpt = trkpt; | ||
this.extensions = extensions || null; | ||
} | ||
setPoints(trkpt) { | ||
this.trkpt = trkpt; | ||
return this; | ||
} | ||
toObject() { | ||
const { | ||
trkpt, | ||
extensions | ||
} = this; | ||
return _objectSpread$5({ | ||
trkpt: trkpt.map(point => point.toObject()) | ||
}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Track { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trkType | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(trkseg, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "number", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
_defineProperty(this, "trkseg", void 0); | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.number = number || null; | ||
this.type = type || null; | ||
this.extensions = extensions || null; | ||
this.trkseg = trkseg || null; | ||
} | ||
setSegments(trkseg) { | ||
this.trkseg = trkseg; | ||
return this; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg | ||
} = this; | ||
return _objectSpread$6({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
number | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
} : {}); | ||
} | ||
} | ||
var models = ({ | ||
__proto__: null, | ||
Bounds: Bounds, | ||
Copyright: Copyright, | ||
Track: Track, | ||
Segment: Segment, | ||
Point: Point, | ||
Metadata: Metadata, | ||
Person: Person, | ||
Link: Link | ||
}); | ||
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class BaseBuilder { | ||
@@ -658,7 +103,7 @@ constructor() { | ||
toObject() { | ||
return _objectSpread$7({}, this.data, { | ||
attributes: _objectSpread$7({ | ||
creator: 'fabulator:gpx-builder', | ||
version: '1.1', | ||
xmlns: 'http://www.topografix.com/GPX/1/1', | ||
return _objectSpread(_objectSpread({}, this.data), {}, { | ||
attributes: _objectSpread({ | ||
'creator': 'fabulator:gpx-builder', | ||
'version': '1.1', | ||
'xmlns': 'http://www.topografix.com/GPX/1/1', | ||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', | ||
@@ -672,4 +117,4 @@ 'xsi:schemaLocation': this.schemaLocation.join(' ') | ||
_defineProperty(BaseBuilder, "MODELS", models); | ||
_defineProperty(BaseBuilder, "MODELS", index); | ||
module.exports = BaseBuilder; |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var BaseBuilder = require('./BaseBuilder.js'); | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
class Bounds { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_boundsType | ||
*/ | ||
constructor(minlat, minlon, maxlat, maxlon) { | ||
_defineProperty(this, "minlat", void 0); | ||
_defineProperty(this, "minlon", void 0); | ||
_defineProperty(this, "maxlat", void 0); | ||
_defineProperty(this, "maxlon", void 0); | ||
this.minlat = minlat; | ||
this.minlon = minlon; | ||
this.maxlat = maxlat; | ||
this.maxlon = maxlon; | ||
} | ||
toObject() { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} = this; | ||
return { | ||
attributes: { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} | ||
}; | ||
} | ||
} | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Copyright { | ||
/** | ||
* @param author - Owner of licence | ||
* @param year - Year of licence | ||
* @param license - Type of licence | ||
* @see http://www.topografix.com/gpx/1/1/#type_copyrightType | ||
*/ | ||
constructor(author, { | ||
year, | ||
license | ||
}) { | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "year", void 0); | ||
_defineProperty(this, "license", void 0); | ||
this.author = author; | ||
this.year = year || null; | ||
this.license = license || null; | ||
} | ||
toObject() { | ||
const { | ||
author, | ||
year, | ||
license | ||
} = this; | ||
return _objectSpread({ | ||
attributes: { | ||
author | ||
} | ||
}, year ? { | ||
year | ||
} : {}, {}, license ? { | ||
license | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Link { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_linkType | ||
*/ | ||
constructor(href, { | ||
text, | ||
type | ||
}) { | ||
_defineProperty(this, "href", void 0); | ||
_defineProperty(this, "text", void 0); | ||
_defineProperty(this, "type", void 0); | ||
this.href = href; | ||
this.text = text || null; | ||
this.type = type || null; | ||
} | ||
toObject() { | ||
const { | ||
href, | ||
text, | ||
type | ||
} = this; | ||
return _objectSpread$1({ | ||
attributes: { | ||
href | ||
} | ||
}, text ? { | ||
text | ||
} : {}, {}, type ? { | ||
type | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Metadata { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
*/ | ||
// eslint-disable-next-line | ||
constructor({ | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "copyright", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "keywords", void 0); | ||
_defineProperty(this, "bounds", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.name = name || null; | ||
this.desc = desc || null; | ||
this.author = author || null; | ||
this.copyright = copyright || null; | ||
this.link = link || null; | ||
this.time = time || null; | ||
this.keywords = keywords || null; | ||
this.bounds = bounds || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
} = this; | ||
return _objectSpread$2({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Person { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_personType | ||
*/ | ||
constructor({ | ||
name, | ||
email, | ||
link | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "email", void 0); | ||
_defineProperty(this, "link", void 0); | ||
this.name = name || null; | ||
this.email = email || null; | ||
this.link = link || null; | ||
} | ||
toObject() { | ||
const { | ||
name, | ||
email, | ||
link | ||
} = this; | ||
return _objectSpread$3({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread$4({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Segment { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
*/ | ||
constructor(trkpt, extensions = null) { | ||
_defineProperty(this, "trkpt", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.trkpt = trkpt; | ||
this.extensions = extensions || null; | ||
} | ||
setPoints(trkpt) { | ||
this.trkpt = trkpt; | ||
return this; | ||
} | ||
toObject() { | ||
const { | ||
trkpt, | ||
extensions | ||
} = this; | ||
return _objectSpread$5({ | ||
trkpt: trkpt.map(point => point.toObject()) | ||
}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Track { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trkType | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(trkseg, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "number", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
_defineProperty(this, "trkseg", void 0); | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.number = number || null; | ||
this.type = type || null; | ||
this.extensions = extensions || null; | ||
this.trkseg = trkseg || null; | ||
} | ||
setSegments(trkseg) { | ||
this.trkseg = trkseg; | ||
return this; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg | ||
} = this; | ||
return _objectSpread$6({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
number | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
} : {}); | ||
} | ||
} | ||
var models = ({ | ||
__proto__: null, | ||
Bounds: Bounds, | ||
Copyright: Copyright, | ||
Track: Track, | ||
Segment: Segment, | ||
Point: Point, | ||
Metadata: Metadata, | ||
Person: Person, | ||
Link: Link | ||
}); | ||
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class BaseBuilder { | ||
constructor() { | ||
_defineProperty(this, "data", void 0); | ||
_defineProperty(this, "schemaLocation", void 0); | ||
this.data = {}; | ||
this.schemaLocation = ['http://www.topografix.com/GPX/1/1', 'http://www.topografix.com/GPX/1/1/gpx.xsd']; | ||
} | ||
/** | ||
* Set metadata object. | ||
* | ||
* @param metadata - Metadata object | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setMetadata(metadata) { | ||
this.data.metadata = metadata.toObject(); | ||
return this; | ||
} | ||
/** | ||
* Set list of waypoints | ||
* | ||
* @param waypoints - Points objects | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setWayPoints(waypoints) { | ||
this.data.wpt = waypoints.map(point => point.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set list of routes. | ||
* | ||
* @param routes - List of routes | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setRoutes(routes) { | ||
this.data.rte = routes; | ||
return this; | ||
} | ||
/** | ||
* Set list of tracks. | ||
* | ||
* @param tracks - List of tracks | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setTracks(tracks) { | ||
this.data.trk = tracks.map(track => track.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set extension Object. | ||
* | ||
* @param extensions - Extensions | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setExtensions(extensions) { | ||
this.data.extensions = extensions; | ||
return this; | ||
} | ||
/** | ||
* Simple method to set list of points to single track and segment. | ||
* | ||
* @param points - list of Points | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setSegmentPoints(points) { | ||
this.setTracks([new Track([new Segment(points)])]); | ||
return this; | ||
} | ||
/** | ||
* Object that can be used to build XML file. | ||
* | ||
* @returns {GPXBuildData} | ||
*/ | ||
toObject() { | ||
return _objectSpread$7({}, this.data, { | ||
attributes: _objectSpread$7({ | ||
creator: 'fabulator:gpx-builder', | ||
version: '1.1', | ||
xmlns: 'http://www.topografix.com/GPX/1/1', | ||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', | ||
'xsi:schemaLocation': this.schemaLocation.join(' ') | ||
}, this.data.attributes) | ||
}); | ||
} | ||
} | ||
_defineProperty(BaseBuilder, "MODELS", models); | ||
// @flow strict | ||
module.exports = BaseBuilder; |
@@ -13,6 +13,6 @@ import { Copyright as CopyrightData } from '../../../types'; | ||
constructor(author: string, { year, license, }: { | ||
license?: string; | ||
year?: number; | ||
license?: string; | ||
}); | ||
toObject(): CopyrightData; | ||
} |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -40,3 +40,3 @@ class Copyright { | ||
} = this; | ||
return _objectSpread({ | ||
return _objectSpread(_objectSpread({ | ||
attributes: { | ||
@@ -47,3 +47,3 @@ author | ||
year | ||
} : {}, {}, license ? { | ||
} : {}), license ? { | ||
license | ||
@@ -50,0 +50,0 @@ } : {}); |
@@ -9,2 +9,2 @@ import Bounds from './Bounds'; | ||
import Track from './Track'; | ||
export { Bounds, Copyright, Track, Segment, Point, Metadata, Person, Link, }; | ||
export { Bounds, Copyright, Track, Segment, Point, Metadata, Person, Link }; |
@@ -5,550 +5,13 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var Bounds = require('./Bounds.js'); | ||
var Copyright = require('./Copyright.js'); | ||
var Link = require('./Link.js'); | ||
var Metadata = require('./Metadata.js'); | ||
var Person = require('./Person.js'); | ||
var Point = require('./Point.js'); | ||
var Segment = require('./Segment.js'); | ||
var Track = require('./Track.js'); | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
class Bounds { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_boundsType | ||
*/ | ||
constructor(minlat, minlon, maxlat, maxlon) { | ||
_defineProperty(this, "minlat", void 0); | ||
_defineProperty(this, "minlon", void 0); | ||
_defineProperty(this, "maxlat", void 0); | ||
_defineProperty(this, "maxlon", void 0); | ||
this.minlat = minlat; | ||
this.minlon = minlon; | ||
this.maxlat = maxlat; | ||
this.maxlon = maxlon; | ||
} | ||
toObject() { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} = this; | ||
return { | ||
attributes: { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} | ||
}; | ||
} | ||
} | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Copyright { | ||
/** | ||
* @param author - Owner of licence | ||
* @param year - Year of licence | ||
* @param license - Type of licence | ||
* @see http://www.topografix.com/gpx/1/1/#type_copyrightType | ||
*/ | ||
constructor(author, { | ||
year, | ||
license | ||
}) { | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "year", void 0); | ||
_defineProperty(this, "license", void 0); | ||
this.author = author; | ||
this.year = year || null; | ||
this.license = license || null; | ||
} | ||
toObject() { | ||
const { | ||
author, | ||
year, | ||
license | ||
} = this; | ||
return _objectSpread({ | ||
attributes: { | ||
author | ||
} | ||
}, year ? { | ||
year | ||
} : {}, {}, license ? { | ||
license | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Link { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_linkType | ||
*/ | ||
constructor(href, { | ||
text, | ||
type | ||
}) { | ||
_defineProperty(this, "href", void 0); | ||
_defineProperty(this, "text", void 0); | ||
_defineProperty(this, "type", void 0); | ||
this.href = href; | ||
this.text = text || null; | ||
this.type = type || null; | ||
} | ||
toObject() { | ||
const { | ||
href, | ||
text, | ||
type | ||
} = this; | ||
return _objectSpread$1({ | ||
attributes: { | ||
href | ||
} | ||
}, text ? { | ||
text | ||
} : {}, {}, type ? { | ||
type | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Metadata { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
*/ | ||
// eslint-disable-next-line | ||
constructor({ | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "copyright", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "keywords", void 0); | ||
_defineProperty(this, "bounds", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.name = name || null; | ||
this.desc = desc || null; | ||
this.author = author || null; | ||
this.copyright = copyright || null; | ||
this.link = link || null; | ||
this.time = time || null; | ||
this.keywords = keywords || null; | ||
this.bounds = bounds || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
} = this; | ||
return _objectSpread$2({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Person { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_personType | ||
*/ | ||
constructor({ | ||
name, | ||
email, | ||
link | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "email", void 0); | ||
_defineProperty(this, "link", void 0); | ||
this.name = name || null; | ||
this.email = email || null; | ||
this.link = link || null; | ||
} | ||
toObject() { | ||
const { | ||
name, | ||
email, | ||
link | ||
} = this; | ||
return _objectSpread$3({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread$4({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Segment { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
*/ | ||
constructor(trkpt, extensions = null) { | ||
_defineProperty(this, "trkpt", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.trkpt = trkpt; | ||
this.extensions = extensions || null; | ||
} | ||
setPoints(trkpt) { | ||
this.trkpt = trkpt; | ||
return this; | ||
} | ||
toObject() { | ||
const { | ||
trkpt, | ||
extensions | ||
} = this; | ||
return _objectSpread$5({ | ||
trkpt: trkpt.map(point => point.toObject()) | ||
}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Track { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trkType | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(trkseg, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "number", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
_defineProperty(this, "trkseg", void 0); | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.number = number || null; | ||
this.type = type || null; | ||
this.extensions = extensions || null; | ||
this.trkseg = trkseg || null; | ||
} | ||
setSegments(trkseg) { | ||
this.trkseg = trkseg; | ||
return this; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg | ||
} = this; | ||
return _objectSpread$6({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
number | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
} : {}); | ||
} | ||
} | ||
exports.Bounds = Bounds; | ||
@@ -555,0 +18,0 @@ exports.Copyright = Copyright; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -37,3 +37,3 @@ class Link { | ||
} = this; | ||
return _objectSpread({ | ||
return _objectSpread(_objectSpread({ | ||
attributes: { | ||
@@ -44,3 +44,3 @@ href | ||
text | ||
} : {}, {}, type ? { | ||
} : {}), type ? { | ||
type | ||
@@ -47,0 +47,0 @@ } : {}); |
@@ -1,6 +0,6 @@ | ||
import { Meta, Extensions } from '../../../types'; | ||
import Person from './Person'; | ||
import { Extensions, Meta } from '../../../types'; | ||
import Bounds from './Bounds'; | ||
import Copyright from './Copyright'; | ||
import Bounds from './Bounds'; | ||
import Link from './Link'; | ||
import Person from './Person'; | ||
export default class Metadata { | ||
@@ -20,13 +20,13 @@ private name; | ||
constructor({ name, desc, author, copyright, link, time, keywords, bounds, extensions, }: { | ||
name?: string; | ||
desc?: string; | ||
author?: Person; | ||
bounds?: Bounds; | ||
copyright?: Copyright; | ||
desc?: string; | ||
extensions?: Extensions; | ||
keywords?: string; | ||
link?: Link; | ||
name?: string; | ||
time?: Date; | ||
keywords?: string; | ||
bounds?: Bounds; | ||
extensions?: Extensions; | ||
}); | ||
toObject(): Meta; | ||
} |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -70,19 +70,19 @@ class Metadata { | ||
} = this; | ||
return _objectSpread({}, name ? { | ||
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
} : {}), desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
} : {}), author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
} : {}), copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
} : {}), link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
} : {}), time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
} : {}), keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
} : {}), bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
} : {}), extensions ? { | ||
extensions | ||
@@ -89,0 +89,0 @@ } : {}); |
@@ -10,8 +10,8 @@ import { Person as PersonData } from '../../../types'; | ||
*/ | ||
constructor({ name, email, link, }: { | ||
name?: string; | ||
constructor({ name, email, link }: { | ||
email?: string; | ||
link?: Link; | ||
name?: string; | ||
}); | ||
toObject(): PersonData; | ||
} |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -38,7 +38,7 @@ class Person { | ||
} = this; | ||
return _objectSpread({}, name ? { | ||
return _objectSpread(_objectSpread(_objectSpread({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}), email ? { | ||
} : {}, {}, link ? { | ||
} : {}), link ? { | ||
link: link.toObject() | ||
@@ -45,0 +45,0 @@ } : {}); |
import { Extensions, WayPoint } from '../../../types'; | ||
import Link from './Link'; | ||
export interface PointOptions { | ||
ageofdgpsdata?: number; | ||
cmt?: string; | ||
desc?: string; | ||
dgpsid?: number; | ||
ele?: number; | ||
time?: Date; | ||
extensions?: Extensions; | ||
fix?: number; | ||
geoidheight?: number; | ||
hdop?: number; | ||
link?: Link; | ||
magvar?: number; | ||
geoidheight?: number; | ||
name?: string; | ||
cmt?: string; | ||
desc?: string; | ||
pdop?: number; | ||
sat?: number; | ||
src?: string; | ||
link?: Link; | ||
sym?: string; | ||
time?: Date; | ||
type?: string; | ||
fix?: number; | ||
sat?: number; | ||
hdop?: number; | ||
vdop?: number; | ||
pdop?: number; | ||
ageofdgpsdata?: number; | ||
dgpsid?: number; | ||
extensions?: Extensions; | ||
} | ||
@@ -24,0 +24,0 @@ export default class Point { |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -128,3 +128,3 @@ class Point { | ||
} = this; | ||
return _objectSpread({ | ||
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({ | ||
attributes: { | ||
@@ -136,37 +136,37 @@ lat, | ||
ele | ||
} : {}, {}, time ? { | ||
} : {}), time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
} : {}), magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
} : {}), geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
} : {}), name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
} : {}), cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
} : {}), desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
} : {}), src ? { | ||
src | ||
} : {}, {}, link ? { | ||
} : {}), link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
} : {}), sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
} : {}), type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
} : {}), fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
} : {}), sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
} : {}), hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
} : {}), vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
} : {}), pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
} : {}), ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
} : {}), dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
} : {}), extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
@@ -173,0 +173,0 @@ } : {}); |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -12,0 +12,0 @@ class Segment { |
@@ -1,2 +0,2 @@ | ||
import { Track as TrackData, Extensions } from '../../../types'; | ||
import { Extensions, Track as TrackData } from '../../../types'; | ||
import Link from './Link'; | ||
@@ -18,10 +18,10 @@ import Segment from './Segment'; | ||
constructor(trkseg: Segment[] | null, { name, cmt, desc, src, link, number, type, extensions, }?: { | ||
name?: string; | ||
cmt?: string; | ||
desc?: string; | ||
src?: string; | ||
extensions?: Extensions; | ||
link?: Link; | ||
name?: string; | ||
number?: number; | ||
src?: string; | ||
type?: string; | ||
extensions?: Extensions; | ||
}); | ||
@@ -28,0 +28,0 @@ setSegments(trkseg: Segment[] | null): this; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -74,19 +74,19 @@ class Track { | ||
} = this; | ||
return _objectSpread({}, name ? { | ||
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
} : {}), cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
} : {}), desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
} : {}), src ? { | ||
src | ||
} : {}, {}, link ? { | ||
} : {}), link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
} : {}), number ? { | ||
number | ||
} : {}, {}, type ? { | ||
} : {}), type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
} : {}), extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
} : {}), trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
@@ -93,0 +93,0 @@ } : {}); |
@@ -6,723 +6,8 @@ 'use strict'; | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
var BaseBuilder = require('../BaseBuilder/BaseBuilder.js'); | ||
var GarminPoint = require('./models/GarminPoint.js'); | ||
class Bounds { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_boundsType | ||
*/ | ||
constructor(minlat, minlon, maxlat, maxlon) { | ||
_defineProperty(this, "minlat", void 0); | ||
_defineProperty(this, "minlon", void 0); | ||
_defineProperty(this, "maxlat", void 0); | ||
_defineProperty(this, "maxlon", void 0); | ||
this.minlat = minlat; | ||
this.minlon = minlon; | ||
this.maxlat = maxlat; | ||
this.maxlon = maxlon; | ||
} | ||
toObject() { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} = this; | ||
return { | ||
attributes: { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} | ||
}; | ||
} | ||
} | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Copyright { | ||
/** | ||
* @param author - Owner of licence | ||
* @param year - Year of licence | ||
* @param license - Type of licence | ||
* @see http://www.topografix.com/gpx/1/1/#type_copyrightType | ||
*/ | ||
constructor(author, { | ||
year, | ||
license | ||
}) { | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "year", void 0); | ||
_defineProperty(this, "license", void 0); | ||
this.author = author; | ||
this.year = year || null; | ||
this.license = license || null; | ||
} | ||
toObject() { | ||
const { | ||
author, | ||
year, | ||
license | ||
} = this; | ||
return _objectSpread({ | ||
attributes: { | ||
author | ||
} | ||
}, year ? { | ||
year | ||
} : {}, {}, license ? { | ||
license | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Link { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_linkType | ||
*/ | ||
constructor(href, { | ||
text, | ||
type | ||
}) { | ||
_defineProperty(this, "href", void 0); | ||
_defineProperty(this, "text", void 0); | ||
_defineProperty(this, "type", void 0); | ||
this.href = href; | ||
this.text = text || null; | ||
this.type = type || null; | ||
} | ||
toObject() { | ||
const { | ||
href, | ||
text, | ||
type | ||
} = this; | ||
return _objectSpread$1({ | ||
attributes: { | ||
href | ||
} | ||
}, text ? { | ||
text | ||
} : {}, {}, type ? { | ||
type | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Metadata { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
*/ | ||
// eslint-disable-next-line | ||
constructor({ | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "copyright", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "keywords", void 0); | ||
_defineProperty(this, "bounds", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.name = name || null; | ||
this.desc = desc || null; | ||
this.author = author || null; | ||
this.copyright = copyright || null; | ||
this.link = link || null; | ||
this.time = time || null; | ||
this.keywords = keywords || null; | ||
this.bounds = bounds || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
} = this; | ||
return _objectSpread$2({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Person { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_personType | ||
*/ | ||
constructor({ | ||
name, | ||
email, | ||
link | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "email", void 0); | ||
_defineProperty(this, "link", void 0); | ||
this.name = name || null; | ||
this.email = email || null; | ||
this.link = link || null; | ||
} | ||
toObject() { | ||
const { | ||
name, | ||
email, | ||
link | ||
} = this; | ||
return _objectSpread$3({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread$4({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Segment { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
*/ | ||
constructor(trkpt, extensions = null) { | ||
_defineProperty(this, "trkpt", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.trkpt = trkpt; | ||
this.extensions = extensions || null; | ||
} | ||
setPoints(trkpt) { | ||
this.trkpt = trkpt; | ||
return this; | ||
} | ||
toObject() { | ||
const { | ||
trkpt, | ||
extensions | ||
} = this; | ||
return _objectSpread$5({ | ||
trkpt: trkpt.map(point => point.toObject()) | ||
}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Track { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trkType | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(trkseg, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "number", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
_defineProperty(this, "trkseg", void 0); | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.number = number || null; | ||
this.type = type || null; | ||
this.extensions = extensions || null; | ||
this.trkseg = trkseg || null; | ||
} | ||
setSegments(trkseg) { | ||
this.trkseg = trkseg; | ||
return this; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg | ||
} = this; | ||
return _objectSpread$6({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
number | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
} : {}); | ||
} | ||
} | ||
var models = ({ | ||
__proto__: null, | ||
Bounds: Bounds, | ||
Copyright: Copyright, | ||
Track: Track, | ||
Segment: Segment, | ||
Point: Point, | ||
Metadata: Metadata, | ||
Person: Person, | ||
Link: Link | ||
}); | ||
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class BaseBuilder { | ||
constructor() { | ||
_defineProperty(this, "data", void 0); | ||
_defineProperty(this, "schemaLocation", void 0); | ||
this.data = {}; | ||
this.schemaLocation = ['http://www.topografix.com/GPX/1/1', 'http://www.topografix.com/GPX/1/1/gpx.xsd']; | ||
} | ||
/** | ||
* Set metadata object. | ||
* | ||
* @param metadata - Metadata object | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setMetadata(metadata) { | ||
this.data.metadata = metadata.toObject(); | ||
return this; | ||
} | ||
/** | ||
* Set list of waypoints | ||
* | ||
* @param waypoints - Points objects | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setWayPoints(waypoints) { | ||
this.data.wpt = waypoints.map(point => point.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set list of routes. | ||
* | ||
* @param routes - List of routes | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setRoutes(routes) { | ||
this.data.rte = routes; | ||
return this; | ||
} | ||
/** | ||
* Set list of tracks. | ||
* | ||
* @param tracks - List of tracks | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setTracks(tracks) { | ||
this.data.trk = tracks.map(track => track.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set extension Object. | ||
* | ||
* @param extensions - Extensions | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setExtensions(extensions) { | ||
this.data.extensions = extensions; | ||
return this; | ||
} | ||
/** | ||
* Simple method to set list of points to single track and segment. | ||
* | ||
* @param points - list of Points | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setSegmentPoints(points) { | ||
this.setTracks([new Track([new Segment(points)])]); | ||
return this; | ||
} | ||
/** | ||
* Object that can be used to build XML file. | ||
* | ||
* @returns {GPXBuildData} | ||
*/ | ||
toObject() { | ||
return _objectSpread$7({}, this.data, { | ||
attributes: _objectSpread$7({ | ||
creator: 'fabulator:gpx-builder', | ||
version: '1.1', | ||
xmlns: 'http://www.topografix.com/GPX/1/1', | ||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', | ||
'xsi:schemaLocation': this.schemaLocation.join(' ') | ||
}, this.data.attributes) | ||
}); | ||
} | ||
} | ||
_defineProperty(BaseBuilder, "MODELS", models); | ||
// @flow strict | ||
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminPoint extends Point { | ||
/** | ||
* Extended garmin point. | ||
* | ||
* @see https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(lat, lon, options = {}) { | ||
super(lat, lon, options); | ||
const { | ||
hr, | ||
cad, | ||
speed, | ||
atemp, | ||
wtemp, | ||
depth, | ||
course, | ||
bearing | ||
} = options; | ||
const extensionPrefix = 'gpxtpx'; | ||
const trackPointExtension = extensionPrefix + ":TrackPointExtension"; | ||
const data = _objectSpread$8({}, hr ? { | ||
[extensionPrefix + ":hr"]: hr | ||
} : {}, {}, cad ? { | ||
[extensionPrefix + ":cad"]: cad | ||
} : {}, {}, speed ? { | ||
[extensionPrefix + ":speed"]: speed | ||
} : {}, {}, atemp ? { | ||
[extensionPrefix + ":atemp"]: atemp | ||
} : {}, {}, wtemp ? { | ||
[extensionPrefix + ":wtemp"]: wtemp | ||
} : {}, {}, depth ? { | ||
[extensionPrefix + ":depth"]: depth | ||
} : {}, {}, course ? { | ||
[extensionPrefix + ":course"]: course | ||
} : {}, {}, bearing ? { | ||
[extensionPrefix + ":bearing"]: bearing | ||
} : {}); | ||
this.extensions = _objectSpread$8({}, this.extensions, {}, Object.keys(data).length > 0 ? { | ||
[trackPointExtension]: data | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminBuilder extends BaseBuilder { | ||
@@ -735,4 +20,4 @@ /** | ||
this.schemaLocation = [...this.schemaLocation, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd', 'http://www.garmin.com/xmlschemas/GpxExtensions/v3', 'http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd']; | ||
this.data = _objectSpread$9({}, this.data, { | ||
attributes: _objectSpread$9({}, this.data.attributes, { | ||
this.data = _objectSpread(_objectSpread({}, this.data), {}, { | ||
attributes: _objectSpread(_objectSpread({}, this.data.attributes), {}, { | ||
'xmlns:gpxtpx': 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', | ||
@@ -746,3 +31,3 @@ 'xmlns:gpxx': 'http://www.garmin.com/xmlschemas/GpxExtensions/v3' | ||
_defineProperty(GarminBuilder, "MODELS", _objectSpread$9({}, BaseBuilder.MODELS, { | ||
_defineProperty(GarminBuilder, "MODELS", _objectSpread(_objectSpread({}, BaseBuilder.MODELS), {}, { | ||
Point: GarminPoint | ||
@@ -749,0 +34,0 @@ })); |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var GarminBuilder = require('./GarminBuilder.js'); | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
class Bounds { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_boundsType | ||
*/ | ||
constructor(minlat, minlon, maxlat, maxlon) { | ||
_defineProperty(this, "minlat", void 0); | ||
_defineProperty(this, "minlon", void 0); | ||
_defineProperty(this, "maxlat", void 0); | ||
_defineProperty(this, "maxlon", void 0); | ||
this.minlat = minlat; | ||
this.minlon = minlon; | ||
this.maxlat = maxlat; | ||
this.maxlon = maxlon; | ||
} | ||
toObject() { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} = this; | ||
return { | ||
attributes: { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} | ||
}; | ||
} | ||
} | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Copyright { | ||
/** | ||
* @param author - Owner of licence | ||
* @param year - Year of licence | ||
* @param license - Type of licence | ||
* @see http://www.topografix.com/gpx/1/1/#type_copyrightType | ||
*/ | ||
constructor(author, { | ||
year, | ||
license | ||
}) { | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "year", void 0); | ||
_defineProperty(this, "license", void 0); | ||
this.author = author; | ||
this.year = year || null; | ||
this.license = license || null; | ||
} | ||
toObject() { | ||
const { | ||
author, | ||
year, | ||
license | ||
} = this; | ||
return _objectSpread({ | ||
attributes: { | ||
author | ||
} | ||
}, year ? { | ||
year | ||
} : {}, {}, license ? { | ||
license | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Link { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_linkType | ||
*/ | ||
constructor(href, { | ||
text, | ||
type | ||
}) { | ||
_defineProperty(this, "href", void 0); | ||
_defineProperty(this, "text", void 0); | ||
_defineProperty(this, "type", void 0); | ||
this.href = href; | ||
this.text = text || null; | ||
this.type = type || null; | ||
} | ||
toObject() { | ||
const { | ||
href, | ||
text, | ||
type | ||
} = this; | ||
return _objectSpread$1({ | ||
attributes: { | ||
href | ||
} | ||
}, text ? { | ||
text | ||
} : {}, {}, type ? { | ||
type | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Metadata { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
*/ | ||
// eslint-disable-next-line | ||
constructor({ | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "copyright", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "keywords", void 0); | ||
_defineProperty(this, "bounds", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.name = name || null; | ||
this.desc = desc || null; | ||
this.author = author || null; | ||
this.copyright = copyright || null; | ||
this.link = link || null; | ||
this.time = time || null; | ||
this.keywords = keywords || null; | ||
this.bounds = bounds || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
} = this; | ||
return _objectSpread$2({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Person { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_personType | ||
*/ | ||
constructor({ | ||
name, | ||
email, | ||
link | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "email", void 0); | ||
_defineProperty(this, "link", void 0); | ||
this.name = name || null; | ||
this.email = email || null; | ||
this.link = link || null; | ||
} | ||
toObject() { | ||
const { | ||
name, | ||
email, | ||
link | ||
} = this; | ||
return _objectSpread$3({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread$4({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Segment { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
*/ | ||
constructor(trkpt, extensions = null) { | ||
_defineProperty(this, "trkpt", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.trkpt = trkpt; | ||
this.extensions = extensions || null; | ||
} | ||
setPoints(trkpt) { | ||
this.trkpt = trkpt; | ||
return this; | ||
} | ||
toObject() { | ||
const { | ||
trkpt, | ||
extensions | ||
} = this; | ||
return _objectSpread$5({ | ||
trkpt: trkpt.map(point => point.toObject()) | ||
}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Track { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trkType | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(trkseg, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "number", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
_defineProperty(this, "trkseg", void 0); | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.number = number || null; | ||
this.type = type || null; | ||
this.extensions = extensions || null; | ||
this.trkseg = trkseg || null; | ||
} | ||
setSegments(trkseg) { | ||
this.trkseg = trkseg; | ||
return this; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg | ||
} = this; | ||
return _objectSpread$6({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
number | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
} : {}); | ||
} | ||
} | ||
var models = ({ | ||
__proto__: null, | ||
Bounds: Bounds, | ||
Copyright: Copyright, | ||
Track: Track, | ||
Segment: Segment, | ||
Point: Point, | ||
Metadata: Metadata, | ||
Person: Person, | ||
Link: Link | ||
}); | ||
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class BaseBuilder { | ||
constructor() { | ||
_defineProperty(this, "data", void 0); | ||
_defineProperty(this, "schemaLocation", void 0); | ||
this.data = {}; | ||
this.schemaLocation = ['http://www.topografix.com/GPX/1/1', 'http://www.topografix.com/GPX/1/1/gpx.xsd']; | ||
} | ||
/** | ||
* Set metadata object. | ||
* | ||
* @param metadata - Metadata object | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setMetadata(metadata) { | ||
this.data.metadata = metadata.toObject(); | ||
return this; | ||
} | ||
/** | ||
* Set list of waypoints | ||
* | ||
* @param waypoints - Points objects | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setWayPoints(waypoints) { | ||
this.data.wpt = waypoints.map(point => point.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set list of routes. | ||
* | ||
* @param routes - List of routes | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setRoutes(routes) { | ||
this.data.rte = routes; | ||
return this; | ||
} | ||
/** | ||
* Set list of tracks. | ||
* | ||
* @param tracks - List of tracks | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setTracks(tracks) { | ||
this.data.trk = tracks.map(track => track.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set extension Object. | ||
* | ||
* @param extensions - Extensions | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setExtensions(extensions) { | ||
this.data.extensions = extensions; | ||
return this; | ||
} | ||
/** | ||
* Simple method to set list of points to single track and segment. | ||
* | ||
* @param points - list of Points | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setSegmentPoints(points) { | ||
this.setTracks([new Track([new Segment(points)])]); | ||
return this; | ||
} | ||
/** | ||
* Object that can be used to build XML file. | ||
* | ||
* @returns {GPXBuildData} | ||
*/ | ||
toObject() { | ||
return _objectSpread$7({}, this.data, { | ||
attributes: _objectSpread$7({ | ||
creator: 'fabulator:gpx-builder', | ||
version: '1.1', | ||
xmlns: 'http://www.topografix.com/GPX/1/1', | ||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', | ||
'xsi:schemaLocation': this.schemaLocation.join(' ') | ||
}, this.data.attributes) | ||
}); | ||
} | ||
} | ||
_defineProperty(BaseBuilder, "MODELS", models); | ||
// @flow strict | ||
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminPoint extends Point { | ||
/** | ||
* Extended garmin point. | ||
* | ||
* @see https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(lat, lon, options = {}) { | ||
super(lat, lon, options); | ||
const { | ||
hr, | ||
cad, | ||
speed, | ||
atemp, | ||
wtemp, | ||
depth, | ||
course, | ||
bearing | ||
} = options; | ||
const extensionPrefix = 'gpxtpx'; | ||
const trackPointExtension = extensionPrefix + ":TrackPointExtension"; | ||
const data = _objectSpread$8({}, hr ? { | ||
[extensionPrefix + ":hr"]: hr | ||
} : {}, {}, cad ? { | ||
[extensionPrefix + ":cad"]: cad | ||
} : {}, {}, speed ? { | ||
[extensionPrefix + ":speed"]: speed | ||
} : {}, {}, atemp ? { | ||
[extensionPrefix + ":atemp"]: atemp | ||
} : {}, {}, wtemp ? { | ||
[extensionPrefix + ":wtemp"]: wtemp | ||
} : {}, {}, depth ? { | ||
[extensionPrefix + ":depth"]: depth | ||
} : {}, {}, course ? { | ||
[extensionPrefix + ":course"]: course | ||
} : {}, {}, bearing ? { | ||
[extensionPrefix + ":bearing"]: bearing | ||
} : {}); | ||
this.extensions = _objectSpread$8({}, this.extensions, {}, Object.keys(data).length > 0 ? { | ||
[trackPointExtension]: data | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminBuilder extends BaseBuilder { | ||
/** | ||
* Garmin builder include extension for speed, hear rate, cadence, ... | ||
*/ | ||
constructor() { | ||
super(); | ||
this.schemaLocation = [...this.schemaLocation, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd', 'http://www.garmin.com/xmlschemas/GpxExtensions/v3', 'http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd']; | ||
this.data = _objectSpread$9({}, this.data, { | ||
attributes: _objectSpread$9({}, this.data.attributes, { | ||
'xmlns:gpxtpx': 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', | ||
'xmlns:gpxx': 'http://www.garmin.com/xmlschemas/GpxExtensions/v3' | ||
}) | ||
}); | ||
} | ||
} | ||
_defineProperty(GarminBuilder, "MODELS", _objectSpread$9({}, BaseBuilder.MODELS, { | ||
Point: GarminPoint | ||
})); | ||
module.exports = GarminBuilder; |
import Point, { PointOptions } from '../../BaseBuilder/models/Point'; | ||
interface GarminPointOptions extends PointOptions { | ||
export interface GarminPointOptions extends PointOptions { | ||
atemp?: number; | ||
bearing?: number; | ||
cad?: number; | ||
course?: number; | ||
depth?: number; | ||
hr?: number; | ||
cad?: number; | ||
speed?: number; | ||
atemp?: number; | ||
wtemp?: number; | ||
depth?: number; | ||
course?: number; | ||
bearing?: number; | ||
} | ||
@@ -20,2 +20,1 @@ export default class GarminPoint extends Point { | ||
} | ||
export {}; |
@@ -6,174 +6,7 @@ 'use strict'; | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
var Point = require('../../BaseBuilder/models/Point.js'); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminPoint extends Point { | ||
@@ -201,21 +34,21 @@ /** | ||
const data = _objectSpread$1({}, hr ? { | ||
const data = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, hr ? { | ||
[extensionPrefix + ":hr"]: hr | ||
} : {}, {}, cad ? { | ||
} : {}), cad ? { | ||
[extensionPrefix + ":cad"]: cad | ||
} : {}, {}, speed ? { | ||
} : {}), speed ? { | ||
[extensionPrefix + ":speed"]: speed | ||
} : {}, {}, atemp ? { | ||
} : {}), atemp ? { | ||
[extensionPrefix + ":atemp"]: atemp | ||
} : {}, {}, wtemp ? { | ||
} : {}), wtemp ? { | ||
[extensionPrefix + ":wtemp"]: wtemp | ||
} : {}, {}, depth ? { | ||
} : {}), depth ? { | ||
[extensionPrefix + ":depth"]: depth | ||
} : {}, {}, course ? { | ||
} : {}), course ? { | ||
[extensionPrefix + ":course"]: course | ||
} : {}, {}, bearing ? { | ||
} : {}), bearing ? { | ||
[extensionPrefix + ":bearing"]: bearing | ||
} : {}); | ||
this.extensions = _objectSpread$1({}, this.extensions, {}, Object.keys(data).length > 0 ? { | ||
this.extensions = _objectSpread(_objectSpread({}, this.extensions), Object.keys(data).length > 0 ? { | ||
[trackPointExtension]: data | ||
@@ -222,0 +55,0 @@ } : {}); |
@@ -10,3 +10,3 @@ 'use strict'; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class XMLCreator { | ||
@@ -13,0 +13,0 @@ constructor(settings = {}) { |
@@ -1,2 +0,4 @@ | ||
import { BaseBuilder, GarminBuilder } from './builder'; | ||
import BaseBuilder from './builder/BaseBuilder'; | ||
import GarminBuilder from './builder/GarminBuilder'; | ||
import StravaBuilder from './builder/StravaBuilder'; | ||
import { CreatorInterface } from './creators/CreatorInterface'; | ||
@@ -12,2 +14,2 @@ import { GPXBuildData } from './types'; | ||
declare function buildGPX(data: GPXBuildData, creator?: CreatorInterface): string; | ||
export { BaseBuilder, GarminBuilder, buildGPX }; | ||
export { BaseBuilder, GarminBuilder, StravaBuilder, buildGPX }; |
@@ -5,830 +5,7 @@ 'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var BaseBuilder = require('./builder/BaseBuilder/BaseBuilder.js'); | ||
var GarminBuilder = require('./builder/GarminBuilder/GarminBuilder.js'); | ||
var StravaBuilder = require('./builder/StravaBuilder/StravaBuilder.js'); | ||
var XMLCreator = require('./creators/XMLCreator.js'); | ||
var _defineProperty = _interopDefault(require('@babel/runtime/helpers/defineProperty')); | ||
var xmlbuilder = require('xmlbuilder'); | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class XMLCreator { | ||
constructor(settings = {}) { | ||
_defineProperty(this, "settings", void 0); | ||
this.settings = settings; | ||
} // eslint-disable-next-line complexity | ||
processXmlItem(dir, key, value) { | ||
if (key === 'attributes') { | ||
Object.keys(value).forEach(attribute => { | ||
dir.attribute(attribute, value[attribute]); | ||
}); | ||
return; | ||
} | ||
if (key === 'email') { | ||
const email = value.split('@'); | ||
dir.ele(key, { | ||
id: email[0], | ||
domain: email[1] | ||
}); | ||
return; | ||
} | ||
if (value instanceof Date) { | ||
dir.ele(key, value.toISOString()); | ||
return; | ||
} | ||
if (Array.isArray(value) && typeof value[0] === 'object') { | ||
value.forEach(item => { | ||
this.generateXmlData(dir.ele(key), item); | ||
}); | ||
return; | ||
} | ||
if (Array.isArray(value)) { | ||
dir.ele(key, value.join(',')); | ||
return; | ||
} | ||
if (typeof value === 'object') { | ||
this.generateXmlData(dir.ele(key), value); | ||
return; | ||
} | ||
dir.ele(key, value); | ||
} | ||
generateXmlData(dir, object) { | ||
Object.keys(object).map(key => { | ||
return { | ||
key, | ||
value: object[key] | ||
}; | ||
}).forEach(({ | ||
key, | ||
value | ||
}) => { | ||
this.processXmlItem(dir, key, value); | ||
}); | ||
} | ||
toString(data) { | ||
const root = xmlbuilder.create('gpx', { | ||
encoding: 'UTF-8' | ||
}); | ||
this.generateXmlData(root, data); | ||
return root.end(_objectSpread({ | ||
allowEmpty: true, | ||
indent: ' ', | ||
newline: '\n', | ||
pretty: true | ||
}, this.settings)); | ||
} | ||
} | ||
class Bounds { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_boundsType | ||
*/ | ||
constructor(minlat, minlon, maxlat, maxlon) { | ||
_defineProperty(this, "minlat", void 0); | ||
_defineProperty(this, "minlon", void 0); | ||
_defineProperty(this, "maxlat", void 0); | ||
_defineProperty(this, "maxlon", void 0); | ||
this.minlat = minlat; | ||
this.minlon = minlon; | ||
this.maxlat = maxlat; | ||
this.maxlon = maxlon; | ||
} | ||
toObject() { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} = this; | ||
return { | ||
attributes: { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon | ||
} | ||
}; | ||
} | ||
} | ||
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Copyright { | ||
/** | ||
* @param author - Owner of licence | ||
* @param year - Year of licence | ||
* @param license - Type of licence | ||
* @see http://www.topografix.com/gpx/1/1/#type_copyrightType | ||
*/ | ||
constructor(author, { | ||
year, | ||
license | ||
}) { | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "year", void 0); | ||
_defineProperty(this, "license", void 0); | ||
this.author = author; | ||
this.year = year || null; | ||
this.license = license || null; | ||
} | ||
toObject() { | ||
const { | ||
author, | ||
year, | ||
license | ||
} = this; | ||
return _objectSpread$1({ | ||
attributes: { | ||
author | ||
} | ||
}, year ? { | ||
year | ||
} : {}, {}, license ? { | ||
license | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$2(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$2(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Link { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_linkType | ||
*/ | ||
constructor(href, { | ||
text, | ||
type | ||
}) { | ||
_defineProperty(this, "href", void 0); | ||
_defineProperty(this, "text", void 0); | ||
_defineProperty(this, "type", void 0); | ||
this.href = href; | ||
this.text = text || null; | ||
this.type = type || null; | ||
} | ||
toObject() { | ||
const { | ||
href, | ||
text, | ||
type | ||
} = this; | ||
return _objectSpread$2({ | ||
attributes: { | ||
href | ||
} | ||
}, text ? { | ||
text | ||
} : {}, {}, type ? { | ||
type | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$3(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$3(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Metadata { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
*/ | ||
// eslint-disable-next-line | ||
constructor({ | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "author", void 0); | ||
_defineProperty(this, "copyright", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "keywords", void 0); | ||
_defineProperty(this, "bounds", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.name = name || null; | ||
this.desc = desc || null; | ||
this.author = author || null; | ||
this.copyright = copyright || null; | ||
this.link = link || null; | ||
this.time = time || null; | ||
this.keywords = keywords || null; | ||
this.bounds = bounds || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions | ||
} = this; | ||
return _objectSpread$3({}, name ? { | ||
name | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, author ? { | ||
author: author.toObject() | ||
} : {}, {}, copyright ? { | ||
copyright: copyright.toObject() | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, keywords ? { | ||
keywords | ||
} : {}, {}, bounds ? { | ||
bounds: bounds.toObject() | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Person { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_personType | ||
*/ | ||
constructor({ | ||
name, | ||
email, | ||
link | ||
}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "email", void 0); | ||
_defineProperty(this, "link", void 0); | ||
this.name = name || null; | ||
this.email = email || null; | ||
this.link = link || null; | ||
} | ||
toObject() { | ||
const { | ||
name, | ||
email, | ||
link | ||
} = this; | ||
return _objectSpread$4({}, name ? { | ||
name | ||
} : {}, {}, email ? { | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Point { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
*/ | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
constructor(lat, lon, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "lat", void 0); | ||
_defineProperty(this, "lon", void 0); | ||
_defineProperty(this, "ele", void 0); | ||
_defineProperty(this, "time", void 0); | ||
_defineProperty(this, "magvar", void 0); | ||
_defineProperty(this, "geoidheight", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "sym", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "fix", void 0); | ||
_defineProperty(this, "sat", void 0); | ||
_defineProperty(this, "hdop", void 0); | ||
_defineProperty(this, "vdop", void 0); | ||
_defineProperty(this, "pdop", void 0); | ||
_defineProperty(this, "ageofdgpsdata", void 0); | ||
_defineProperty(this, "dgpsid", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.lat = lat; | ||
this.lon = lon; | ||
this.ele = ele || null; | ||
this.time = time || null; | ||
this.magvar = magvar || null; | ||
this.geoidheight = geoidheight || null; | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.sym = sym || null; | ||
this.type = type || null; | ||
this.fix = fix || null; | ||
this.sat = sat || null; | ||
this.hdop = hdop || null; | ||
this.vdop = vdop || null; | ||
this.pdop = pdop || null; | ||
this.ageofdgpsdata = ageofdgpsdata || null; | ||
this.dgpsid = dgpsid || null; | ||
this.extensions = extensions || null; | ||
} // eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
toObject() { | ||
const { | ||
lat, | ||
lon, | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions | ||
} = this; | ||
return _objectSpread$5({ | ||
attributes: { | ||
lat, | ||
lon | ||
} | ||
}, ele ? { | ||
ele | ||
} : {}, {}, time ? { | ||
time | ||
} : {}, {}, magvar ? { | ||
magvar | ||
} : {}, {}, geoidheight ? { | ||
geoidheight | ||
} : {}, {}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, sym ? { | ||
sym | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, fix ? { | ||
fix | ||
} : {}, {}, sat ? { | ||
sat | ||
} : {}, {}, hdop ? { | ||
hdop | ||
} : {}, {}, vdop ? { | ||
vdop | ||
} : {}, {}, pdop ? { | ||
pdop | ||
} : {}, {}, ageofdgpsdata ? { | ||
ageofdgpsdata | ||
} : {}, {}, dgpsid ? { | ||
dgpsid | ||
} : {}, {}, extensions && Object.keys(extensions).length > 0 ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Segment { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
*/ | ||
constructor(trkpt, extensions = null) { | ||
_defineProperty(this, "trkpt", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
this.trkpt = trkpt; | ||
this.extensions = extensions || null; | ||
} | ||
setPoints(trkpt) { | ||
this.trkpt = trkpt; | ||
return this; | ||
} | ||
toObject() { | ||
const { | ||
trkpt, | ||
extensions | ||
} = this; | ||
return _objectSpread$6({ | ||
trkpt: trkpt.map(point => point.toObject()) | ||
}, extensions ? { | ||
extensions | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$7(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$7(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class Track { | ||
/** | ||
* @see http://www.topografix.com/gpx/1/1/#type_trkType | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(trkseg, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions | ||
} = {}) { | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "cmt", void 0); | ||
_defineProperty(this, "desc", void 0); | ||
_defineProperty(this, "src", void 0); | ||
_defineProperty(this, "link", void 0); | ||
_defineProperty(this, "number", void 0); | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "extensions", void 0); | ||
_defineProperty(this, "trkseg", void 0); | ||
this.name = name || null; | ||
this.cmt = cmt || null; | ||
this.desc = desc || null; | ||
this.src = src || null; | ||
this.link = link || null; | ||
this.number = number || null; | ||
this.type = type || null; | ||
this.extensions = extensions || null; | ||
this.trkseg = trkseg || null; | ||
} | ||
setSegments(trkseg) { | ||
this.trkseg = trkseg; | ||
return this; | ||
} // eslint-disable-next-line complexity | ||
toObject() { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg | ||
} = this; | ||
return _objectSpread$7({}, name ? { | ||
name | ||
} : {}, {}, cmt ? { | ||
cmt | ||
} : {}, {}, desc ? { | ||
desc | ||
} : {}, {}, src ? { | ||
src | ||
} : {}, {}, link ? { | ||
link: link.toObject() | ||
} : {}, {}, number ? { | ||
number | ||
} : {}, {}, type ? { | ||
type | ||
} : {}, {}, extensions ? { | ||
extensions | ||
} : {}, {}, trkseg ? { | ||
trkseg: trkseg.map(segment => segment.toObject()) | ||
} : {}); | ||
} | ||
} | ||
var models = ({ | ||
__proto__: null, | ||
Bounds: Bounds, | ||
Copyright: Copyright, | ||
Track: Track, | ||
Segment: Segment, | ||
Point: Point, | ||
Metadata: Metadata, | ||
Person: Person, | ||
Link: Link | ||
}); | ||
function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$8(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$8(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class BaseBuilder { | ||
constructor() { | ||
_defineProperty(this, "data", void 0); | ||
_defineProperty(this, "schemaLocation", void 0); | ||
this.data = {}; | ||
this.schemaLocation = ['http://www.topografix.com/GPX/1/1', 'http://www.topografix.com/GPX/1/1/gpx.xsd']; | ||
} | ||
/** | ||
* Set metadata object. | ||
* | ||
* @param metadata - Metadata object | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setMetadata(metadata) { | ||
this.data.metadata = metadata.toObject(); | ||
return this; | ||
} | ||
/** | ||
* Set list of waypoints | ||
* | ||
* @param waypoints - Points objects | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setWayPoints(waypoints) { | ||
this.data.wpt = waypoints.map(point => point.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set list of routes. | ||
* | ||
* @param routes - List of routes | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setRoutes(routes) { | ||
this.data.rte = routes; | ||
return this; | ||
} | ||
/** | ||
* Set list of tracks. | ||
* | ||
* @param tracks - List of tracks | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setTracks(tracks) { | ||
this.data.trk = tracks.map(track => track.toObject()); | ||
return this; | ||
} | ||
/** | ||
* Set extension Object. | ||
* | ||
* @param extensions - Extensions | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setExtensions(extensions) { | ||
this.data.extensions = extensions; | ||
return this; | ||
} | ||
/** | ||
* Simple method to set list of points to single track and segment. | ||
* | ||
* @param points - list of Points | ||
* @returns {BaseBuilder} self | ||
*/ | ||
setSegmentPoints(points) { | ||
this.setTracks([new Track([new Segment(points)])]); | ||
return this; | ||
} | ||
/** | ||
* Object that can be used to build XML file. | ||
* | ||
* @returns {GPXBuildData} | ||
*/ | ||
toObject() { | ||
return _objectSpread$8({}, this.data, { | ||
attributes: _objectSpread$8({ | ||
creator: 'fabulator:gpx-builder', | ||
version: '1.1', | ||
xmlns: 'http://www.topografix.com/GPX/1/1', | ||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', | ||
'xsi:schemaLocation': this.schemaLocation.join(' ') | ||
}, this.data.attributes) | ||
}); | ||
} | ||
} | ||
_defineProperty(BaseBuilder, "MODELS", models); | ||
// @flow strict | ||
function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$9(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$9(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminPoint extends Point { | ||
/** | ||
* Extended garmin point. | ||
* | ||
* @see https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd | ||
*/ | ||
// eslint-disable-next-line complexity | ||
constructor(lat, lon, options = {}) { | ||
super(lat, lon, options); | ||
const { | ||
hr, | ||
cad, | ||
speed, | ||
atemp, | ||
wtemp, | ||
depth, | ||
course, | ||
bearing | ||
} = options; | ||
const extensionPrefix = 'gpxtpx'; | ||
const trackPointExtension = extensionPrefix + ":TrackPointExtension"; | ||
const data = _objectSpread$9({}, hr ? { | ||
[extensionPrefix + ":hr"]: hr | ||
} : {}, {}, cad ? { | ||
[extensionPrefix + ":cad"]: cad | ||
} : {}, {}, speed ? { | ||
[extensionPrefix + ":speed"]: speed | ||
} : {}, {}, atemp ? { | ||
[extensionPrefix + ":atemp"]: atemp | ||
} : {}, {}, wtemp ? { | ||
[extensionPrefix + ":wtemp"]: wtemp | ||
} : {}, {}, depth ? { | ||
[extensionPrefix + ":depth"]: depth | ||
} : {}, {}, course ? { | ||
[extensionPrefix + ":course"]: course | ||
} : {}, {}, bearing ? { | ||
[extensionPrefix + ":bearing"]: bearing | ||
} : {}); | ||
this.extensions = _objectSpread$9({}, this.extensions, {}, Object.keys(data).length > 0 ? { | ||
[trackPointExtension]: data | ||
} : {}); | ||
} | ||
} | ||
function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$a(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$a(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
class GarminBuilder extends BaseBuilder { | ||
/** | ||
* Garmin builder include extension for speed, hear rate, cadence, ... | ||
*/ | ||
constructor() { | ||
super(); | ||
this.schemaLocation = [...this.schemaLocation, 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', 'http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd', 'http://www.garmin.com/xmlschemas/GpxExtensions/v3', 'http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd']; | ||
this.data = _objectSpread$a({}, this.data, { | ||
attributes: _objectSpread$a({}, this.data.attributes, { | ||
'xmlns:gpxtpx': 'http://www.garmin.com/xmlschemas/TrackPointExtension/v1', | ||
'xmlns:gpxx': 'http://www.garmin.com/xmlschemas/GpxExtensions/v3' | ||
}) | ||
}); | ||
} | ||
} | ||
_defineProperty(GarminBuilder, "MODELS", _objectSpread$a({}, BaseBuilder.MODELS, { | ||
Point: GarminPoint | ||
})); | ||
/** | ||
@@ -848,2 +25,3 @@ * Function that create XML string with GPX data. | ||
exports.GarminBuilder = GarminBuilder; | ||
exports.StravaBuilder = StravaBuilder; | ||
exports.buildGPX = buildGPX; |
@@ -9,5 +9,5 @@ export interface Link { | ||
export interface Person { | ||
name?: string; | ||
email?: string; | ||
link?: Link; | ||
name?: string; | ||
} | ||
@@ -18,11 +18,11 @@ export interface Copyright { | ||
}; | ||
license?: string; | ||
year?: number; | ||
license?: string; | ||
} | ||
export interface Bounds { | ||
attributes: { | ||
maxlat: number; | ||
maxlon: number; | ||
minlat: number; | ||
minlon: number; | ||
maxlat: number; | ||
maxlon: number; | ||
}; | ||
@@ -36,13 +36,14 @@ } | ||
export interface Meta { | ||
name?: string; | ||
desc?: string; | ||
author?: Person; | ||
bounds?: Bounds; | ||
copyright?: Copyright; | ||
desc?: string; | ||
extensions?: Extensions; | ||
keywords?: string; | ||
link?: Link; | ||
name?: string; | ||
time?: Date; | ||
keywords?: string; | ||
bounds?: Bounds; | ||
extensions?: Extensions; | ||
} | ||
export interface WayPoint { | ||
ageofdgpsdata?: number; | ||
attributes: { | ||
@@ -52,47 +53,46 @@ lat: number; | ||
}; | ||
cmt?: string; | ||
desc?: string; | ||
dgpsid?: number; | ||
ele?: number; | ||
time?: Date; | ||
extensions?: Extensions; | ||
fix?: number; | ||
geoidheight?: number; | ||
hdop?: number; | ||
link?: Link; | ||
magvar?: number; | ||
geoidheight?: number; | ||
name?: string; | ||
cmt?: string; | ||
desc?: string; | ||
pdop?: number; | ||
sat?: number; | ||
src?: string; | ||
link?: Link; | ||
sym?: string; | ||
time?: Date; | ||
type?: string; | ||
fix?: number; | ||
sat?: number; | ||
hdop?: number; | ||
vdop?: number; | ||
pdop?: number; | ||
ageofdgpsdata?: number; | ||
dgpsid?: number; | ||
extensions?: Extensions; | ||
} | ||
export interface Route { | ||
name?: string; | ||
cmt?: string; | ||
desc?: string; | ||
src?: string; | ||
extensions?: Extensions; | ||
link?: Link; | ||
name?: string; | ||
number?: number; | ||
rtept?: WayPoint[]; | ||
src?: string; | ||
type?: string; | ||
extensions?: Extensions; | ||
rtept?: WayPoint[]; | ||
} | ||
export interface TrackSegment { | ||
extensions?: Extensions; | ||
trkpt: WayPoint[]; | ||
extensions?: Extensions; | ||
} | ||
export interface Track { | ||
name?: string; | ||
cmt?: string; | ||
desc?: string; | ||
src?: string; | ||
extensions?: Extensions; | ||
link?: Link; | ||
name?: string; | ||
number?: number; | ||
src?: string; | ||
trkseg?: TrackSegment[]; | ||
type?: string; | ||
extensions?: Extensions; | ||
trkseg?: TrackSegment[]; | ||
} | ||
@@ -103,7 +103,7 @@ export interface GPXBuildData { | ||
}; | ||
extensions?: Extensions; | ||
metadata?: Meta; | ||
wpt?: WayPoint[]; | ||
rte?: Route[]; | ||
trk?: Track[]; | ||
extensions?: Extensions; | ||
wpt?: WayPoint[]; | ||
} |
{ | ||
"name": "gpx-builder", | ||
"version": "3.5.0", | ||
"version": "3.6.0", | ||
"description": "Builder of GPX files", | ||
"keywords": [ | ||
"gpx", | ||
"garmin", | ||
"gpx-generator", | ||
"gps" | ||
], | ||
"homepage": "https://github.com/fabulator/gpx-builder#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/fabulator/gpx-builder.git" | ||
}, | ||
"license": "Apache-2.0", | ||
"author": "Michal Ozogán <michal@ozogan.eu>", | ||
"main": "dist/index.js", | ||
"jsnext:main": "dist/index.esm.js", | ||
"module": "dist/index.esm.js", | ||
"module": "es/index.js", | ||
"jsnext:main": "es/index.js", | ||
"types": "dist/index.d.ts", | ||
"scripts": { | ||
"lint": "eslint --ext .ts ./src ./tests", | ||
"build": "rollup --config ./rollup.config.js", | ||
"lint": "eslint ./ --ext .js --ext .json --ext .ts", | ||
"lint:export": "npm run lint -- -o ./tests_results/checkstyle/js-checkstyle.xml -f checkstyle", | ||
"tsc": "tsc", | ||
"lint:fix": "npm run lint -- --fix", | ||
"prepublishOnly": "npm run build && npm run tsc && npm run test:build", | ||
"release": "semantic-release", | ||
"test": "jest", | ||
"test:all": "npm run lint && npm run tsc && npm run test", | ||
"test:build": "npm run test -- --config jest.config.build.js", | ||
"build": "rollup --config ./rollup.config.js", | ||
"test:all": "npm run lint && npm run tsc && npm run test", | ||
"prepublishOnly": "npm run build && npm run tsc && npm run test:build", | ||
"release": "semantic-release" | ||
"tsc": "tsc" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/fabulator/gpx-builder.git" | ||
"dependencies": { | ||
"@babel/runtime": "^7.11.0", | ||
"xmlbuilder": "^15.1.1" | ||
}, | ||
"author": "Michal Ozogán <michal@ozogan.eu>", | ||
"license": "Apache-2.0", | ||
"keywords": [ | ||
"gpx", | ||
"garmin", | ||
"gpx-generator", | ||
"gps" | ||
], | ||
"homepage": "https://github.com/fabulator/gpx-builder#readme", | ||
"devDependencies": { | ||
"@socifi/babel-config": "^1.0.0", | ||
"@socifi/commitlint-config": "^1.1.0", | ||
"@socifi/eslint-config": "^2.10.0", | ||
"@socifi/jest-config": "^2.4.1", | ||
"@socifi/rollup-config": "^2.2.2", | ||
"semantic-release-config-fabulator": "^1.3.2" | ||
}, | ||
"dependencies": { | ||
"@babel/runtime": "^7.8.4", | ||
"xmlbuilder": "^15.0.0" | ||
"babel-config-fabulator": "^1.0.0", | ||
"commitlint-config-fabulator": "^1.0.0", | ||
"eslint-config-fabulator": "^1.0.2", | ||
"jest-config-fabulator": "^1.0.0", | ||
"rollup-config-fabulator": "^1.0.0", | ||
"semantic-release-config-fabulator": "^2.5.0" | ||
} | ||
} |
@@ -43,2 +43,20 @@ # GPX builder | ||
You can use Strava format that support power and distance on top of Garmin standard properties. | ||
```typescript | ||
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 library works | ||
@@ -45,0 +63,0 @@ |
/* eslint-disable import/no-duplicates */ | ||
import { GPXBuildData, Route, Extensions } from '../../types'; | ||
import { | ||
Track, | ||
Metadata, | ||
Segment, | ||
Point, | ||
} from './models'; | ||
import { Extensions, GPXBuildData, Route } from '../../types'; | ||
import * as models from './models'; | ||
import { Metadata, Point, Segment, Track } from './models'; | ||
@@ -98,5 +93,5 @@ export default class BaseBuilder { | ||
attributes: { | ||
creator: 'fabulator:gpx-builder', | ||
version: '1.1', | ||
xmlns: 'http://www.topografix.com/GPX/1/1', | ||
'creator': 'fabulator:gpx-builder', | ||
'version': '1.1', | ||
'xmlns': 'http://www.topografix.com/GPX/1/1', | ||
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', | ||
@@ -103,0 +98,0 @@ 'xsi:schemaLocation': this.schemaLocation.join(' '), |
@@ -23,8 +23,3 @@ import { Bounds as BoundsData } from '../../../types'; | ||
public toObject(): BoundsData { | ||
const { | ||
minlat, | ||
minlon, | ||
maxlat, | ||
maxlon, | ||
} = this; | ||
const { minlat, minlon, maxlat, maxlon } = this; | ||
@@ -31,0 +26,0 @@ return { |
@@ -16,9 +16,12 @@ import { Copyright as CopyrightData } from '../../../types'; | ||
*/ | ||
public constructor(author: string, { | ||
year, | ||
license, | ||
}: { | ||
year?: number, | ||
license?: string, | ||
}) { | ||
public constructor( | ||
author: string, | ||
{ | ||
year, | ||
license, | ||
}: { | ||
license?: string; | ||
year?: number; | ||
}, | ||
) { | ||
this.author = author; | ||
@@ -30,7 +33,3 @@ this.year = year || null; | ||
public toObject(): CopyrightData { | ||
const { | ||
author, | ||
year, | ||
license, | ||
} = this; | ||
const { author, year, license } = this; | ||
@@ -37,0 +36,0 @@ return { |
@@ -10,11 +10,2 @@ import Bounds from './Bounds'; | ||
export { | ||
Bounds, | ||
Copyright, | ||
Track, | ||
Segment, | ||
Point, | ||
Metadata, | ||
Person, | ||
Link, | ||
}; | ||
export { Bounds, Copyright, Track, Segment, Point, Metadata, Person, Link }; |
@@ -13,9 +13,12 @@ import { Link as LinkData } from '../../../types'; | ||
*/ | ||
public constructor(href: string, { | ||
text, | ||
type, | ||
}: { | ||
text?: string, | ||
type?: string, | ||
}) { | ||
public constructor( | ||
href: string, | ||
{ | ||
text, | ||
type, | ||
}: { | ||
text?: string; | ||
type?: string; | ||
}, | ||
) { | ||
this.href = href; | ||
@@ -27,7 +30,3 @@ this.text = text || null; | ||
public toObject(): LinkData { | ||
const { | ||
href, | ||
text, | ||
type, | ||
} = this; | ||
const { href, text, type } = this; | ||
@@ -34,0 +33,0 @@ return { |
@@ -1,6 +0,6 @@ | ||
import { Meta, Extensions } from '../../../types'; | ||
import Person from './Person'; | ||
import { Extensions, Meta } from '../../../types'; | ||
import Bounds from './Bounds'; | ||
import Copyright from './Copyright'; | ||
import Bounds from './Bounds'; | ||
import Link from './Link'; | ||
import Person from './Person'; | ||
@@ -26,3 +26,2 @@ export default class Metadata { | ||
/** | ||
@@ -43,11 +42,11 @@ * @see http://www.topografix.com/gpx/1/1/#type_metadataType | ||
}: { | ||
name?: string, | ||
desc?: string, | ||
author?: Person, | ||
copyright?: Copyright, | ||
link?: Link, | ||
time?: Date, | ||
keywords?: string, | ||
bounds?: Bounds, | ||
extensions?: Extensions, | ||
author?: Person; | ||
bounds?: Bounds; | ||
copyright?: Copyright; | ||
desc?: string; | ||
extensions?: Extensions; | ||
keywords?: string; | ||
link?: Link; | ||
name?: string; | ||
time?: Date; | ||
}) { | ||
@@ -67,13 +66,3 @@ this.name = name || null; | ||
public toObject(): Meta { | ||
const { | ||
name, | ||
desc, | ||
author, | ||
copyright, | ||
link, | ||
time, | ||
keywords, | ||
bounds, | ||
extensions, | ||
} = this; | ||
const { name, desc, author, copyright, link, time, keywords, bounds, extensions } = this; | ||
@@ -80,0 +69,0 @@ return { |
@@ -14,11 +14,3 @@ import { Person as PersonData } from '../../../types'; | ||
*/ | ||
public constructor({ | ||
name, | ||
email, | ||
link, | ||
}: { | ||
name?: string, | ||
email?: string, | ||
link?: Link, | ||
}) { | ||
public constructor({ name, email, link }: { email?: string; link?: Link; name?: string }) { | ||
this.name = name || null; | ||
@@ -30,7 +22,3 @@ this.email = email || null; | ||
public toObject(): PersonData { | ||
const { | ||
name, | ||
email, | ||
link, | ||
} = this; | ||
const { name, email, link } = this; | ||
@@ -37,0 +25,0 @@ return { |
@@ -5,21 +5,21 @@ import { Extensions, WayPoint } from '../../../types'; | ||
export interface PointOptions { | ||
ele?: number, | ||
time?: Date, | ||
magvar?: number, | ||
geoidheight?: number, | ||
name?: string, | ||
cmt?: string, | ||
desc?: string, | ||
src?: string, | ||
link?: Link, | ||
sym?: string, | ||
type?: string, | ||
fix?: number, | ||
sat?: number, | ||
hdop?: number, | ||
vdop?: number, | ||
pdop?: number, | ||
ageofdgpsdata?: number, | ||
dgpsid?: number, | ||
extensions?: Extensions, | ||
ageofdgpsdata?: number; | ||
cmt?: string; | ||
desc?: string; | ||
dgpsid?: number; | ||
ele?: number; | ||
extensions?: Extensions; | ||
fix?: number; | ||
geoidheight?: number; | ||
hdop?: number; | ||
link?: Link; | ||
magvar?: number; | ||
name?: string; | ||
pdop?: number; | ||
sat?: number; | ||
src?: string; | ||
sym?: string; | ||
time?: Date; | ||
type?: string; | ||
vdop?: number; | ||
} | ||
@@ -70,3 +70,2 @@ | ||
/** | ||
@@ -76,23 +75,27 @@ * @see http://www.topografix.com/gpx/1/1/#type_wptType | ||
// eslint-disable-next-line complexity, sonarjs/cognitive-complexity | ||
public constructor(lat: number, lon: number, { | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions, | ||
}: PointOptions = {}) { | ||
public constructor( | ||
lat: number, | ||
lon: number, | ||
{ | ||
ele, | ||
time, | ||
magvar, | ||
geoidheight, | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
sym, | ||
type, | ||
fix, | ||
sat, | ||
hdop, | ||
vdop, | ||
pdop, | ||
ageofdgpsdata, | ||
dgpsid, | ||
extensions, | ||
}: PointOptions = {}, | ||
) { | ||
this.lat = lat; | ||
@@ -99,0 +102,0 @@ this.lon = lon; |
@@ -9,3 +9,2 @@ import { Extensions, TrackSegment } from '../../../types'; | ||
/** | ||
@@ -25,6 +24,3 @@ * @see http://www.topografix.com/gpx/1/1/#type_trksegType | ||
public toObject(): TrackSegment { | ||
const { | ||
trkpt, | ||
extensions, | ||
} = this; | ||
const { trkpt, extensions } = this; | ||
@@ -31,0 +27,0 @@ return { |
@@ -1,2 +0,2 @@ | ||
import { Track as TrackData, Extensions } from '../../../types'; | ||
import { Extensions, Track as TrackData } from '../../../types'; | ||
import Link from './Link'; | ||
@@ -28,21 +28,24 @@ import Segment from './Segment'; | ||
// eslint-disable-next-line complexity | ||
public constructor(trkseg: Segment[] | null, { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
}: { | ||
name?: string, | ||
cmt?: string, | ||
desc?: string, | ||
src?: string, | ||
link?: Link, | ||
number?: number, | ||
type?: string, | ||
extensions?: Extensions, | ||
} = {}) { | ||
public constructor( | ||
trkseg: Segment[] | null, | ||
{ | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
}: { | ||
cmt?: string; | ||
desc?: string; | ||
extensions?: Extensions; | ||
link?: Link; | ||
name?: string; | ||
number?: number; | ||
src?: string; | ||
type?: string; | ||
} = {}, | ||
) { | ||
this.name = name || null; | ||
@@ -66,13 +69,3 @@ this.cmt = cmt || null; | ||
public toObject(): TrackData { | ||
const { | ||
name, | ||
cmt, | ||
desc, | ||
src, | ||
link, | ||
number, | ||
type, | ||
extensions, | ||
trkseg, | ||
} = this; | ||
const { name, cmt, desc, src, link, number, type, extensions, trkseg } = this; | ||
@@ -79,0 +72,0 @@ return { |
@@ -1,2 +0,1 @@ | ||
import { GPXBuildData } from '../../types'; | ||
import BaseBuilder from '../BaseBuilder'; | ||
@@ -3,0 +2,0 @@ import GarminPoint from './models/GarminPoint'; |
import Point, { PointOptions } from '../../BaseBuilder/models/Point'; | ||
interface GarminPointOptions extends PointOptions { | ||
hr?: number, | ||
cad?: number, | ||
speed?: number, | ||
atemp?: number, | ||
wtemp?: number, | ||
depth?: number, | ||
course?: number, | ||
bearing?: number, | ||
export interface GarminPointOptions extends PointOptions { | ||
atemp?: number; | ||
bearing?: number; | ||
cad?: number; | ||
course?: number; | ||
depth?: number; | ||
hr?: number; | ||
speed?: number; | ||
wtemp?: number; | ||
} | ||
@@ -23,5 +23,3 @@ | ||
super(lat, lon, options); | ||
const { | ||
hr, cad, speed, atemp, wtemp, depth, course, bearing, | ||
} = options; | ||
const { hr, cad, speed, atemp, wtemp, depth, course, bearing } = options; | ||
@@ -43,7 +41,9 @@ const extensionPrefix = 'gpxtpx'; | ||
...this.extensions, | ||
...(Object.keys(data).length > 0 ? { | ||
[trackPointExtension]: data, | ||
} : {}), | ||
...(Object.keys(data).length > 0 | ||
? { | ||
[trackPointExtension]: data, | ||
} | ||
: {}), | ||
}; | ||
} | ||
} |
import { GPXBuildData } from '../types'; | ||
export interface CreatorInterface { | ||
toString(data: GPXBuildData): string, | ||
toString(data: GPXBuildData): string; | ||
} |
@@ -1,6 +0,8 @@ | ||
import { create } from 'xmlbuilder'; | ||
import { create, XMLElement } from 'xmlbuilder'; | ||
import { GPXBuildData } from '../types'; | ||
import { CreatorInterface } from './CreatorInterface'; | ||
interface Settings {[key: string]: string | boolean} | ||
interface Settings { | ||
[key: string]: string | boolean; | ||
} | ||
@@ -15,3 +17,3 @@ export default class XMLCreator implements CreatorInterface { | ||
// eslint-disable-next-line complexity | ||
private processXmlItem(dir: any, key: string, value: any) { | ||
private processXmlItem(dir: XMLElement, key: string, value: any) { | ||
if (key === 'attributes') { | ||
@@ -58,8 +60,10 @@ Object.keys(value).forEach((attribute) => { | ||
private generateXmlData(dir: any, object: any) { | ||
Object.keys(object).map((key) => { | ||
return { key, value: object[key] }; | ||
}).forEach(({ key, value }) => { | ||
this.processXmlItem(dir, key, value); | ||
}); | ||
private generateXmlData(dir: XMLElement, object: any) { | ||
Object.keys(object) | ||
.map((key) => { | ||
return { key, value: object[key] }; | ||
}) | ||
.forEach(({ key, value }) => { | ||
this.processXmlItem(dir, key, value); | ||
}); | ||
} | ||
@@ -66,0 +70,0 @@ |
@@ -0,9 +1,8 @@ | ||
import BaseBuilder from './builder/BaseBuilder'; | ||
import GarminBuilder from './builder/GarminBuilder'; | ||
import StravaBuilder from './builder/StravaBuilder'; | ||
import { XMLCreator } from './creators'; | ||
import { BaseBuilder, GarminBuilder } from './builder'; | ||
import { CreatorInterface } from './creators/CreatorInterface'; | ||
import { GPXBuildData } from './types'; | ||
import { | ||
GPXBuildData, | ||
} from './types'; | ||
/** | ||
@@ -21,2 +20,2 @@ * Function that create XML string with GPX data. | ||
export { BaseBuilder, GarminBuilder, buildGPX }; | ||
export { BaseBuilder, GarminBuilder, StravaBuilder, buildGPX }; |
150
src/types.ts
export interface Link { | ||
attributes: { | ||
href: string, | ||
}, | ||
text?: string, | ||
type?: string, | ||
href: string; | ||
}; | ||
text?: string; | ||
type?: string; | ||
} | ||
export interface Person { | ||
name?: string, | ||
email?: string, | ||
link?: Link, | ||
email?: string; | ||
link?: Link; | ||
name?: string; | ||
} | ||
@@ -17,6 +17,6 @@ | ||
attributes: { | ||
author: string, | ||
}, | ||
year?: number, | ||
license?: string, | ||
author: string; | ||
}; | ||
license?: string; | ||
year?: number; | ||
} | ||
@@ -26,78 +26,78 @@ | ||
attributes: { | ||
minlat: number, | ||
minlon: number, | ||
maxlat: number, | ||
maxlon: number, | ||
}, | ||
maxlat: number; | ||
maxlon: number; | ||
minlat: number; | ||
minlon: number; | ||
}; | ||
} | ||
export interface Extensions { | ||
[key: string]: {[key: string]: string | number}, | ||
[key: string]: { [key: string]: string | number }; | ||
} | ||
export interface Meta { | ||
name?: string, | ||
desc?: string, | ||
author?: Person, | ||
copyright?: Copyright, | ||
link?: Link, | ||
time?: Date, | ||
keywords?: string, | ||
bounds?: Bounds, | ||
extensions?: Extensions, | ||
author?: Person; | ||
bounds?: Bounds; | ||
copyright?: Copyright; | ||
desc?: string; | ||
extensions?: Extensions; | ||
keywords?: string; | ||
link?: Link; | ||
name?: string; | ||
time?: Date; | ||
} | ||
export interface WayPoint { | ||
ageofdgpsdata?: number; | ||
attributes: { | ||
lat: number, | ||
lon: number, | ||
}, | ||
ele?: number, | ||
time?: Date, | ||
magvar?: number, | ||
geoidheight?: number, | ||
name?: string, | ||
cmt?: string, | ||
desc?: string, | ||
src?: string, | ||
link?: Link, | ||
sym?: string, | ||
type?: string, | ||
fix?: number, | ||
sat?: number, | ||
hdop?: number, | ||
vdop?: number, | ||
pdop?: number, | ||
ageofdgpsdata?: number, | ||
dgpsid?: number, | ||
extensions?: Extensions, | ||
lat: number; | ||
lon: number; | ||
}; | ||
cmt?: string; | ||
desc?: string; | ||
dgpsid?: number; | ||
ele?: number; | ||
extensions?: Extensions; | ||
fix?: number; | ||
geoidheight?: number; | ||
hdop?: number; | ||
link?: Link; | ||
magvar?: number; | ||
name?: string; | ||
pdop?: number; | ||
sat?: number; | ||
src?: string; | ||
sym?: string; | ||
time?: Date; | ||
type?: string; | ||
vdop?: number; | ||
} | ||
export interface Route { | ||
name?: string, | ||
cmt?: string, | ||
desc?: string, | ||
src?: string, | ||
link?: Link, | ||
number?: number, | ||
type?: string, | ||
extensions?: Extensions, | ||
rtept?: WayPoint[], | ||
cmt?: string; | ||
desc?: string; | ||
extensions?: Extensions; | ||
link?: Link; | ||
name?: string; | ||
number?: number; | ||
rtept?: WayPoint[]; | ||
src?: string; | ||
type?: string; | ||
} | ||
export interface TrackSegment { | ||
trkpt: WayPoint[], | ||
extensions?: Extensions, | ||
extensions?: Extensions; | ||
trkpt: WayPoint[]; | ||
} | ||
export interface Track { | ||
name?: string, | ||
cmt?: string, | ||
desc?: string, | ||
src?: string, | ||
link?: Link, | ||
number?: number, | ||
type?: string, | ||
extensions?: Extensions, | ||
trkseg?: TrackSegment[], | ||
cmt?: string; | ||
desc?: string; | ||
extensions?: Extensions; | ||
link?: Link; | ||
name?: string; | ||
number?: number; | ||
src?: string; | ||
trkseg?: TrackSegment[]; | ||
type?: string; | ||
} | ||
@@ -107,9 +107,9 @@ | ||
attributes?: { | ||
[key: string]: string, | ||
}, | ||
metadata?: Meta, | ||
wpt?: WayPoint[], | ||
rte?: Route[], | ||
trk?: Track[], | ||
extensions?: Extensions, | ||
[key: string]: string; | ||
}; | ||
extensions?: Extensions; | ||
metadata?: Meta; | ||
rte?: Route[]; | ||
trk?: Track[]; | ||
wpt?: WayPoint[]; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72
122210
86
2896
1
Updated@babel/runtime@^7.11.0
Updatedxmlbuilder@^15.1.1