using System; using System.Collections.Generic; using System.Text; namespace AtomicCityBusScheduler { public class TransportSystem { public string name; public List cLocation; public List cBusRoute; public List cRoute; public TransportSystem() { cLocation = new List(); cBusRoute = new List(); } public bool checkBusTransit(AtomicCityBusScheduler.Route aRoute, AtomicCityBusScheduler.Route bRoute) { foreach (Routing r in cBusRoute) { if (r.from == aRoute) { foreach (Routing r1 in cBusRoute) { if (r1.to == bRoute) { return true; } } } } return false; } public AtomicCityBusScheduler.Location aLocationAt(string locationName) { return cLocation.Find(delegate(AtomicCityBusScheduler.Location obj) { return obj.name == locationName; }); } public AtomicCityBusScheduler.Route aRouteAt(string locationName) { return cRoute.Find(delegate(AtomicCityBusScheduler.Route obj) { return obj.name == locationName; }); } public Location aLocationNearest(Subgurim.Controles.GLatLng latlon) { double minDistanceSQ = 10^100; Location bestLocation = null; foreach (Location l in cLocation) { double distanceSQ = Math.Pow((latlon.lat - l.latitude), 2) + Math.Pow((latlon.lng - l.longitude), 2); if (distanceSQ < minDistanceSQ) { minDistanceSQ = distanceSQ; bestLocation = l; } } return bestLocation; } } }