aerofly-missions
Version:
The Aerofly Missionsgerät converts simulator flight plan files for Aerofly FS 4, Microsoft Flight Simulator, X-Plane, GeoFS, and Garmin / Infinite Flight flight plan files. It also imports SimBrief flight plans.
30 lines (26 loc) • 1.18 kB
text/typescript
import { Units } from "../World/Units.js";
import { GaminFplWaypoint, GarminFpl } from "./GarminFpl.js";
export class Gpx extends GarminFpl {
read(configFileContent: string): void {
this.cruisingAltFt = undefined;
const rteXml = this.getXmlNode(configFileContent, "rte");
const rteptXmls = this.getXmlNodes(rteXml, "rtept");
this.waypoints = rteptXmls.map((xml, index): GaminFplWaypoint => {
const altString = this.getXmlNode(xml, "ele");
const alt = altString ? Number(altString) * Units.feetPerMeter : undefined;
if (alt !== undefined && index !== 0 && index !== rteptXmls.length - 1) {
this.cruisingAltFt =
this.cruisingAltFt !== undefined
? Math.max(this.cruisingAltFt, alt * Units.feetPerMeter)
: alt * Units.feetPerMeter;
}
return {
identifier: this.getXmlNode(xml, "name") || "WP" + index.toFixed().padStart(2, "0"),
type: index === 0 || index === rteptXmls.length - 1 ? "AIRPORT" : "USER WAYPOINT",
lat: Number(this.getXmlAttribute(xml, "lat")),
lon: Number(this.getXmlAttribute(xml, "lon")),
elevationMeter: alt,
};
});
}
}