Ejemplo n.º 1
0
        public VehicleDetail?GetVehicleDetails(RealTimeArrival arrival)
        {
            if (arrival.Route == LinkRouteId)
            {
                return(GetLinkVehicleDetails(arrival));
            }
            VehicleDetail result;

            foreach (var group in VehicleGroups)
            {
                if (group.TryGetVehicleDetails(arrival, out result))
                {
                    return(result);
                }
            }
            if (arrival.Vehicle != null)
            {
                result = new VehicleDetail();
                string[] parts = arrival.Vehicle.Split('_');
                if (parts.Length == 2)
                {
                    int prefix;
                    int postfix;
                    if (int.TryParse(parts[0], out prefix) && int.TryParse(parts[1], out postfix))
                    {
                        switch (prefix)
                        {
                        case 1:
                            result.AgencyFunded = result.AgencyOperated = "King County Metro";
                            break;

                        case 40:
                            result.AgencyFunded   = "Sound Transit";
                            result.AgencyOperated = "Unknown";
                            break;
                        }
                        result.VehicleNumber  = postfix.ToString();
                        result.VehicleName    = "Unknown";
                        result.SeatedCapacity = "Unknown";
                        return(result);
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        private VehicleDetail GetLinkVehicleDetails(RealTimeArrival arrival)
        {
            var  day       = arrival.ScheduledArrivalTime?.GetServiceDay();
            bool threeCars = false;

            if (day.HasValue && (day.Value == ServiceDay.Saturday || day.Value == ServiceDay.Sunday))
            {
                threeCars = true;
            }
            else if (ThreeCarLinkTrips.Contains(arrival.Trip))
            {
                threeCars = true;
            }
            VehicleDetail result = new VehicleDetail()
            {
                AgencyFunded = "Sound Transit", AgencyOperated = "King County Metro", SeatedCapacity = "Unknown", VehicleName = (threeCars ? "3" : "2") + " Car Link Train", VehicleNumber = "Unknown"
            };

            result.ImageUri = new Uri(threeCars ? "http://ww2.hdnux.com/photos/03/71/66/1023397/4/628x471.jpg" : "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8d/2-car_Central_Link_train_in_Tukwila.jpg/320px-2-car_Central_Link_train_in_Tukwila.jpg");
            return(result);
        }
 public bool TryGetVehicleDetails(RealTimeArrival arrival, out VehicleDetail detail)
 {
     detail = new VehicleDetail();
     if (arrival.Vehicle != null)
     {
         string[] parts = arrival.Vehicle.Split('_');
         if (parts.Length == 2)
         {
             int prefix;
             int postfix;
             if (int.TryParse(parts[0], out prefix) && int.TryParse(parts[1], out postfix) && ((NumberPrefix == prefix && NumberMin <= postfix && NumberMax >= postfix && !(ExcludedNumbers?.Contains(postfix) ?? false)) || (IncludedNumbers?.Contains(postfix) ?? false)))
             {
                 detail.AgencyFunded = FundedBy;
                 detail.AgencyOperated = OperatedBy;
                 detail.VehicleName = Name;
                 detail.SeatedCapacity = Capacity.ToString();
                 detail.ImageUri = new Uri(Image);
                 detail.VehicleNumber = postfix.ToString();
                 return true;
             }
         }
     }
     return false;
 }
Ejemplo n.º 4
0
 public bool TryGetVehicleDetails(RealTimeArrival arrival, out VehicleDetail detail)
 {
     detail = new VehicleDetail();
     if (arrival.Vehicle != null)
     {
         string[] parts = arrival.Vehicle.Split('_');
         if (parts.Length == 2)
         {
             int prefix;
             int postfix;
             if (int.TryParse(parts[0], out prefix) && int.TryParse(parts[1], out postfix) && ((NumberPrefix == prefix && NumberMin <= postfix && NumberMax >= postfix && !(ExcludedNumbers?.Contains(postfix) ?? false)) || (IncludedNumbers?.Contains(postfix) ?? false)))
             {
                 detail.AgencyFunded   = FundedBy;
                 detail.AgencyOperated = OperatedBy;
                 detail.VehicleName    = Name;
                 detail.SeatedCapacity = Capacity.ToString();
                 detail.ImageUri       = new Uri(Image);
                 detail.VehicleNumber  = postfix.ToString();
                 return(true);
             }
         }
     }
     return(false);
 }
 public VehicleDetail? GetVehicleDetails(RealTimeArrival arrival)
 {
     if (arrival.Route == LinkRouteId)
         return GetLinkVehicleDetails(arrival);
     VehicleDetail result;
     foreach (var group in VehicleGroups)
     {
         if (group.TryGetVehicleDetails(arrival, out result))
             return result;
     }
     if (arrival.Vehicle != null)
     {
         result = new VehicleDetail();
         string[] parts = arrival.Vehicle.Split('_');
         if (parts.Length == 2)
         {
             int prefix;
             int postfix;
             if (int.TryParse(parts[0], out prefix) && int.TryParse(parts[1], out postfix))
             {
                 switch (prefix)
                 {
                     case 1:
                         result.AgencyFunded = result.AgencyOperated = "King County Metro";
                         break;
                     case 40:
                         result.AgencyFunded = "Sound Transit";
                         result.AgencyOperated = "Unknown";
                         break;
                 }
                 result.VehicleNumber = postfix.ToString();
                 result.VehicleName = "Unknown";
                 result.SeatedCapacity = "Unknown";
                 return result;
             }
         }
     }
     return null;
 }
 private VehicleDetail GetLinkVehicleDetails(RealTimeArrival arrival)
 {
     var day = arrival.ScheduledArrivalTime?.GetServiceDay();
     bool threeCars = false;
     if (day.HasValue && (day.Value == ServiceDay.Saturday || day.Value == ServiceDay.Sunday))
         threeCars = true;
     else if (ThreeCarLinkTrips.Contains(arrival.Trip))
         threeCars = true;
     VehicleDetail result = new VehicleDetail() { AgencyFunded = "Sound Transit", AgencyOperated = "King County Metro", SeatedCapacity = "Unknown", VehicleName = (threeCars ? "3" : "2") + " Car Link Train", VehicleNumber = "Unknown" };
     result.ImageUri = new Uri(threeCars ? "http://ww2.hdnux.com/photos/03/71/66/1023397/4/628x471.jpg" : "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8d/2-car_Central_Link_train_in_Tukwila.jpg/320px-2-car_Central_Link_train_in_Tukwila.jpg");
     return result;
 }