Files
wanderer/web/src/lib/models/gpx/route.ts
Christian Beutel 8d7ed16904 adds route editing
2024-04-22 22:37:13 +02:00

46 lines
1.0 KiB
TypeScript

import Waypoint from './waypoint';
import Link from './link';
export default class Route {
name: string;
cmt: string;
desc: string;
src: string;
number: number;
type: string;
extensions: string;
link?: Link[];
rtept?: Waypoint[];
constructor(object: {
name: string,
cmt: string, desc: string,
src: string,
number: number,
type: string,
extensions: string,
link?: Link | Link[],
rtept?: Waypoint | Waypoint[]
}) {
this.name = object.name;
this.cmt = object.cmt;
this.desc = object.desc;
this.src = object.src;
this.number = object.number;
this.type = object.type;
this.extensions = object.extensions;
if (object.link) {
if (!Array.isArray(object.link)) {
object.link = [object.link];
}
this.link = object.link.map(l => new Link(l));
}
if (object.rtept) {
if (!Array.isArray(object.rtept)) {
this.rtept = [object.rtept];
}
this.rtept = (object.rtept as Waypoint[]).map(rtept => new Waypoint(rtept))
}
}
}