diff options
Diffstat (limited to 'OsmAndBuilder/models/OsmAndPoint.ts')
| -rw-r--r-- | OsmAndBuilder/models/OsmAndPoint.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/OsmAndBuilder/models/OsmAndPoint.ts b/OsmAndBuilder/models/OsmAndPoint.ts new file mode 100644 index 0000000..a051205 --- /dev/null +++ b/OsmAndBuilder/models/OsmAndPoint.ts @@ -0,0 +1,42 @@ +import { BaseBuilder } from 'gpx-builder'; +const { Point, PointOptions } = BaseBuilder.MODELS; + +export interface OsmAndPointOptions extends PointOptions { + atemp?: number; + bearing?: number; + cad?: number; + course?: number; + depth?: number; + hr?: number; + speed?: number; + wtemp?: number; +} + +export class OsmAndPoint extends Point { + /** + * Extended garmin point. + * + * @see https://www8.garmin.com/xmlschemas/TrackPointExtensionv2.xsd + */ + + public constructor( + lat: number, + lon: number, + options: OsmAndPointOptions = {}, + ) { + super(lat, lon, options); + const { background, color, icon } = options; + + const ext = 'osmand'; + const data = { + ...(typeof background === 'string' ? { [`${ext}:background`]: background } : {}), + ...(typeof color === 'string' ? { [`${ext}:color`]: color } : {}), + ...(typeof icon === 'string' ? { [`${ext}:icon`]: icon } : {}), + }; + + this.extensions = { + ...this.extensions, + ...(Object.keys(data).length > 0 ? data : {}), + }; + } +} |
