diff options
| author | Camil Staps | 2026-02-02 18:38:26 +0100 |
|---|---|---|
| committer | Camil Staps | 2026-02-02 18:38:26 +0100 |
| commit | 4029b88e2c79eaed519c829e373ac916f426f311 (patch) | |
| tree | 617fd189c60a5e80b61b417c1c77c154ae1bd149 /OsmAndBuilder/models | |
Diffstat (limited to 'OsmAndBuilder/models')
| -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 : {}), + }; + } +} |
