Skip to main content
Glama

Bangalore BMTC Mobility Connectivity Platform

by ajeetraina
etaCalculator.js1.04 kB
/** * Calculate estimated time of arrival in minutes * @param {Object} bus The bus location object * @param {Array} stopSequence Array of stops from current stop to target stop * @returns {Number} ETA in minutes */ const calculateETA = (bus, stopSequence) => { // Default speed if not available in the bus object const speedKmh = bus.speed || 15; // 15 km/h as default speed if not available // Calculate total distance in meters let totalDistance = 0; for (let i = 0; i < stopSequence.length - 1; i++) { totalDistance += stopSequence[i + 1].distance; } // Calculate travel time in minutes // Speed is in km/h, distance is in meters // Convert to consistent units: km and hours const distanceKm = totalDistance / 1000; const timeHours = distanceKm / speedKmh; const timeMinutes = timeHours * 60; // Add some buffer for stops, traffic, etc. const buffer = stopSequence.length * 0.5; // 30 seconds per stop return Math.ceil(timeMinutes + buffer); }; module.exports = { calculateETA, };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ajeetraina/bengaluru-bmtc-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server