Пример #1
0
 /// <summary>
 /// Returns a stop with a given id. If there is no stop with the given
 /// id, returns null.
 /// </summary>
 public static TFStop SearchStopWithId(ITransitFeedData data, string id)
 {
     if (data.Stops.ContainsKey(id))
     {
         return(data.Stops[id]);
     }
     else
     {
         return(null);
     }
 }
Пример #2
0
        /// <summary>
        /// Returns all of the top level stations that a given RouteType stops
        /// at.
        /// </summary>
        public static IEnumerable <TFStop> SearchStationsWithRouteType(ITransitFeedData data, TFRouteType type)
        {
            // RouteType is stored in the route object. Trace this through to
            // the list of stops that have that RouteType.
            var routes = data.Routes.Where(m => m.Value.Type == type);
            var trips  = routes.SelectMany(r => r.Value.Trips);
            var stops  = trips.SelectMany(t => t.Stops);

            // Convert to HashSet to remove any duplicate stops that might
            // be added through the select statements.
            var distinctStops = stops.ToHashSet();

            // From these stops, need to follow up to the highest level parent.
            // This ensures that we're returning the actual station and not
            // individual platforms.
            var stations = new HashSet <TFStop>();

            foreach (var s in distinctStops)
            {
                stations.Add(HighestParentStop(s));
            }

            return(stations);
        }