@geoapify/route-planner-sdk
Version:
A TypeScript SDK for the Geoapify Route Planner API that simplifies route optimization requests, and helps visualize and edit resulting routes.
30 lines (29 loc) • 650 B
JavaScript
import { RouteLegStep } from "./route-leg-step";
export class RouteLeg {
constructor(raw) {
if (raw) {
this.raw = raw;
}
else {
throw new Error("RouteLegData is undefined");
}
}
getRaw() {
return this.raw;
}
getTime() {
return this.raw.time;
}
getDistance() {
return this.raw.distance;
}
getSteps() {
return this.raw.steps.map((step) => new RouteLegStep(step));
}
getFromWaypointIndex() {
return this.raw.from_waypoint_index;
}
getToWaypointIndex() {
return this.raw.to_waypoint_index;
}
}