UNPKG

@geoapify/route-planner-sdk

Version:

TypeScript SDK for the Geoapify Route Planner API. Supports route optimization, delivery planning, and timeline visualization in browser and Node.js

26 lines (25 loc) 700 B
export class RoutePlannerFormatter { static toPrettyDistance(meters) { if (meters > 10000) { return `${(meters / 1000).toFixed(1)} km`; } if (meters > 5000) { return `${(meters / 1000).toFixed(2)} km`; } return `${meters} m`; } static toPrettyTime(sec_num) { let hours = Math.floor(sec_num / 3600); let minutes = Math.floor((sec_num - (hours * 3600)) / 60); if (sec_num === 0) { return '0'; } if (!hours) { return minutes + 'min'; } if (!minutes) { return hours + 'h'; } return hours + 'h ' + minutes + 'm'; } }