Parse and manage orienteering courses data with Javascript/Typescript
deno add @orienteering-js/course
npx jsr add @orienteering-js/course
yarn dlx jsr add @orienteering-js/course
pnpm dlx jsr add @orienteering-js/course
bunx jsr add @orienteering-js/course
import {
parseIOFXML3CourseExport,
parseGPXRoutechoicesOCADExport,
} from "@orienteering-js/course";
import { readFileSync } from "node:fs";
const courseFile = readFileSync("course.xml");
const routechoicesFile = readFileSync("routechoices.gpx");
const parser = new DOMParser();
const courseDocument = parser.parseFromString(courseFile, "text/xml");
const [controls, legs] = parseIOFXML3CourseExport(courseDocument, 0);
const routechoicesDocument = parser.parseFromString(
routechoicesFile,
"text/xml"
);
const legsWithRoutechoices = parseGPXRoutechoicesOCADExport(
routechoicesDocument,
legs
);
legsWithRoutechoices.forEach((leg) => {
console.log(leg.routechoices);
});