@siva-sub/mcp-public-transport
Version:
A Model Context Protocol server for Singapore transport data with real-time information and routing
107 lines (106 loc) • 3.01 kB
TypeScript
import { OneMapService } from './onemap.js';
import { LTAService } from './lta.js';
import { WeatherService, WeatherConditions, WeatherAdvisory } from './weather.js';
import { CacheService } from './cache.js';
export interface RouteInstruction {
direction: string;
streetName: string;
distance: number;
coordinates: string;
duration: number;
distanceText: string;
bearing: string;
fromBearing: string;
mode: 'walking' | 'driving' | 'cycling';
instruction: string;
}
export interface RouteSegment {
mode: 'WALK' | 'BUS' | 'MRT' | 'LRT' | 'DRIVE';
duration: number;
distance: number;
instructions: RouteInstruction[];
startLocation: {
latitude: number;
longitude: number;
name?: string;
};
endLocation: {
latitude: number;
longitude: number;
name?: string;
};
line?: string;
service?: string;
operator?: string;
stations?: string[];
stops?: string[];
realTimeInfo?: any;
platformInfo?: {
platform?: string;
direction?: string;
};
}
export interface JourneyPlan {
summary: {
totalTime: number;
totalDistance: number;
totalCost: number;
walkingTime: number;
walkingDistance: number;
transfers: number;
modes: string[];
};
segments: RouteSegment[];
weatherImpact: {
conditions: WeatherConditions;
advisories: WeatherAdvisory[];
adjustedWalkingTime: number;
};
disruptions: {
current: any[];
warnings: string[];
alternatives?: string;
};
confidence: number;
timestamp: string;
}
export interface RoutingPreferences {
minimizeTransfers: boolean;
minimizeWalkingTime: boolean;
minimizeTotalTime: boolean;
allowDriving: boolean;
accessibilityRequired: boolean;
maxWalkingDistance: number;
departureTime?: string;
}
export declare class EnhancedRoutingService {
private oneMapService;
private ltaService;
private weatherService;
private cache;
private timeout;
private oneMapClient;
constructor(oneMapService: OneMapService, ltaService: LTAService, weatherService: WeatherService, cache: CacheService, timeout?: number);
planOptimalJourney(origin: {
latitude: number;
longitude: number;
name?: string;
}, destination: {
latitude: number;
longitude: number;
name?: string;
}, preferences?: RoutingPreferences): Promise<JourneyPlan[]>;
private generatePublicTransportRoute;
private generateDrivingRoute;
private generateHybridRoute;
private parseRouteInstructions;
private parseOneMapRoute;
private calculateRouteSummary;
private calculateWeatherImpact;
private getCurrentDisruptions;
private generateDisruptionWarnings;
private calculateRouteConfidence;
private sortRoutesByPreferences;
private estimateTransportCost;
private estimateDrivingCost;
}