public override bool CanBeTraversedUsingMode(TravelMode Mode) { if (Mode.HasFlag(TravelMode.Walking) && !Mode.HasFlag(TravelMode.Car)) { if (this.Tags.ContainsKey("foot")) { string footValue = this.Tags["foot"]; if (footValue == "no") { return(false); } else { return(true); } } //if (this.Tags.ContainsKey("highway")) //{ // string highwayValue = this.Tags["highway"]; // if (highwayValue == "primary" || highwayValue == "secondary" || highwayValue == "tertiary" || // highwayValue == "unclassified" || highwayValue == "residential" || highwayValue == "service" || // highwayValue == "living_street" || highwayValue == "pedestrian" || highwayValue == "track" || // highwayValue == "footway" || highwayValue == "bridleway" || highwayValue == "steps" || // highwayValue == "path" || highwayValue == "bridleway" || highwayValue == "crossing" || // highwayValue == "trunk_link") // { // return true; // } // else // return false; //} } else if (!Mode.HasFlag(TravelMode.Walking) && (Mode.HasFlag(TravelMode.Car))) { if (this.Tags.ContainsKey("highway")) { string highwayValue = this.Tags["highway"]; if (highwayValue == "motorway" || highwayValue == "trunk" || highwayValue == "primary" || highwayValue == "secondary" || highwayValue == "tertiary" || highwayValue == "unclassified" || highwayValue == "residential" || highwayValue == "motorway_link" || highwayValue == "trunk_link" || highwayValue == "primary_link" || highwayValue == "secondary_link" || highwayValue == "tertiary_link" || highwayValue == "living_street" || highwayValue == "road") { return(true); } else { return(false); } } } return(true); }
/* CConnection */ public override double GetTravelTime(string date, double arrivalTime, TravelMode Mode) { double time = 0; double trafficDelay = 0; if (!CanBeTraversedUsingMode(Mode)) { return(double.PositiveInfinity); } if (arrivalTime > this.SrcArrivalTime) { return(double.PositiveInfinity); } if (ResidualCapacity == 0) { return(double.PositiveInfinity); } if (Mode.HasFlag(Routing.TravelMode.Carpool)) { //ServiceDates.Contains(date) if (!CCValidityStartDayTable.IsValidDate(date, this.Carpooler.Id, this.Carpooler.Activated)) { return(double.PositiveInfinity); } else { time = (DstArrivalTime - SrcArrivalTime); /* For Car, the time is traffic dependent */ if (TrafficReport != null) { double minDistanceFromTraffic; minDistanceFromTraffic = Math.Min(this.TrafficDistanceFromSource, this.TrafficDistanceFromDestination); trafficDelay = addTrafficDelay(time, minDistanceFromTraffic, TrafficReport); } WaitingTime = (SrcArrivalTime - arrivalTime); time += WaitingTime + trafficDelay; DepartureTime = (int)SrcArrivalTime; if (time < 0 || WaitingTime < 0) { throw new Exception("negative time value"); } } } else { time = double.PositiveInfinity; } return(time); }
/* LConnection */ public override double GetTravelTime(string date, double arrivalTime, TravelMode Mode) { double time = 0; if (Mode.HasFlag(Routing.TravelMode.Bus)) { if (!CanBeTraversedUsingMode(Mode)) { time = double.PositiveInfinity; } } else { time = double.PositiveInfinity; } return(time); }
public override bool CanBeTraversedUsingMode(TravelMode Mode) { return(Mode.HasFlag(TravelMode.Bus)); }
/* TConnection */ public override double GetTravelTime(string date, double arrivalTime, TravelMode Mode) { double time = 0; double trafficDelay = 0; if (!CanBeTraversedUsingMode(Mode)) { return(double.PositiveInfinity); } if (Mode.HasFlag(Routing.TravelMode.Bus)) { List <TimeTableEntry> Trips = TimeTable.GetFeasibleTrips(arrivalTime); if (Trips.Count == 0) { return(double.PositiveInfinity); } TimeTableEntry Trip = Trips.First(); /* The "false" condition is added only for TEST A, in order to ignore the feed validity !!!REMEMBER TO REMOVE FOR TEST C!!! */ if (/*(false) &&*/ (!Trip.IsValidDate(date))) { return(double.PositiveInfinity); } else { time = (Trip.DestinationArrivalTime - Trip.SourceDepartureTime); /* For Bus, the time is traffic dependent */ if ((TrafficReport != null) && (TimeTable.Entries.First().RouteType == RouteType.Bus)) { double minDistanceFromTraffic; minDistanceFromTraffic = Math.Min(this.TrafficDistanceFromSource, this.TrafficDistanceFromDestination); trafficDelay = addTrafficDelay(time, minDistanceFromTraffic, TrafficReport); } /* Waiting time */ WaitingTime = (Trip.SourceDepartureTime - arrivalTime); time += WaitingTime + trafficDelay; DepartureTime = Trip.SourceDepartureTime; ArrivalTime = Trip.SourceArrivalTime; DestArrivalTime = Trip.DestinationArrivalTime; DestDepartureTime = Trip.DestinationDepartureTime; if (time < 0 || WaitingTime < 0) { throw new Exception("negative time value"); } } } else { time = double.PositiveInfinity; } return(time); }
/* RConnection */ public override double GetTravelTime(string date, double arrivalTime, TravelMode Mode) { double time = 0; double trafficDelay = 0; if (Mode == TravelMode.Car) { if (!CanBeTraversedUsingMode(Mode)) { return(double.PositiveInfinity); } if (!ValidateTraversal(Mode)) { return(double.PositiveInfinity); } // Assuming that the average driving speed is 40 km/h int maxSpeed = 40; try { if (Tags.ContainsKey("maxspeed")) { string maxSpeedStr = Tags["maxspeed"]; if (maxSpeedStr.Contains(";")) { maxSpeed = int.Parse(maxSpeedStr.Split(';')[0]); } } else { maxSpeed = 40; } } catch (Exception ex) { maxSpeed = 40; } time = (Distance / 1000) / (float)(maxSpeed / 2); time = time * 3600; /* For Car, the time is traffic dependent */ if (TrafficReport != null) { double minDistanceFromTraffic; minDistanceFromTraffic = Math.Min(this.TrafficDistanceFromSource, this.TrafficDistanceFromDestination); trafficDelay = addTrafficDelay(time, minDistanceFromTraffic, TrafficReport); } time += trafficDelay; DepartureTime = (int)arrivalTime; } else if (Mode.HasFlag(Routing.TravelMode.Walking)) { // The average walking speed is considered to be 1.4 m/s. if (!CanBeTraversedUsingMode(Mode)) { return(double.PositiveInfinity); } time = Distance / (float)1.4; DepartureTime = (int)arrivalTime; } else { throw new Exception(); } return(time); }