From 4029b88e2c79eaed519c829e373ac916f426f311 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Mon, 2 Feb 2026 18:38:26 +0100 Subject: Initial commit --- OsmAndBuilder/models/OsmAndPoint.ts | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 OsmAndBuilder/models/OsmAndPoint.ts (limited to 'OsmAndBuilder/models/OsmAndPoint.ts') 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 : {}), + }; + } +} -- cgit v1.2.3