public static List <Tuple <BusRoute, string[], string[]> > DeformatRoutes(CompactFormatReader reader)
        {
            List <Tuple <BusRoute, string[], string[]> > result = new List <Tuple <BusRoute, string[], string[]> >();

            CompactFormatReader[] routeReader;
            List <string>         stops;
            List <string>         shapes;

            while ((routeReader = reader.Next()) != null)
            {
                BusRoute route = new BusRoute();
                route.ID          = routeReader[0].ReadString();
                route.Name        = routeReader[1].ReadString();
                route.Description = routeReader[2].ReadString();
                route.Agency      = routeReader[3].ReadString();
                stops             = new List <string>();
                shapes            = new List <string>();
                CompactFormatReader[] subReader;
                while ((subReader = routeReader[4].Next()) != null)
                {
                    stops.Add(subReader[0].ReadString());
                }
                while ((subReader = routeReader[5].Next()) != null)
                {
                    shapes.Add(subReader[0].ReadString());
                }
                result.Add(new Tuple <BusRoute, string[], string[]>(route, stops.ToArray(), shapes.ToArray()));
            }
            return(result);
        }
        public static List <BusStop> DeformatStops(CompactFormatReader reader)
        {
            List <BusStop> result = new List <BusStop>();

            CompactFormatReader[] stopReader;
            List <string>         routes;

            while ((stopReader = reader.Next()) != null)
            {
                BusStop stop = new BusStop();
                stop.ID        = stopReader[0].ReadString();
                stop.Direction = (StopDirection)stopReader[1].ReadInt();
                stop.Position  = new BasicGeoposition()
                {
                    Latitude = double.Parse(stopReader[2].ReadString()), Longitude = double.Parse(stopReader[3].ReadString())
                };
                stop.Name         = stopReader[4].ReadString();
                stop.Code         = stopReader[5].ReadString();
                stop.LocationType = stopReader[6].ReadInt();
                routes            = new List <string>();
                CompactFormatReader[] routeReader;
                while ((routeReader = stopReader[7].Next()) != null)
                {
                    routes.Add(routeReader[0].ReadString());
                }
                stop.Routes = routes.ToArray();
                result.Add(stop);
            }
            return(result);
        }
예제 #3
0
        public static async Task LoadPendingDownloads()
        {
            var file = await ApplicationData.Current.LocalCacheFolder.GetFileAsync("PendingDownloadsCache.txt");

            string encodedText = await FileIO.ReadTextAsync(file);

            CompactFormatReader reader = new CompactFormatReader(encodedText);

            PendingDownloadsCache.Clear();
            CompactFormatReader[] routeReader;
            while ((routeReader = reader.Next()) != null)
            {
                List <string> item = new List <string>();
                foreach (var subReader in routeReader)
                {
                    item.Add(subReader.ReadString());
                }
                PendingDownloadsCache.Add(item);
            }
        }
예제 #4
0
 public void Deformat(CompactFormatReader reader, string stopId)
 {
     Stop = stopId;
     Days.Clear();
     TechnicalDays.Clear();
     DaySchedules.Clear();
     CompactFormatReader[] items;
     while ((items = reader.Next()) != null)
     {
         ServiceDay  nextDay          = (ServiceDay)items[0].ReadInt();
         ServiceDay  nextTechnicalDay = (ServiceDay)items[1].ReadInt();
         DaySchedule schedule         = new DaySchedule()
         {
             Stop = stopId
         };
         schedule.Deformat(items[2]);
         Days.Add(nextDay);
         TechnicalDays.Add(nextTechnicalDay);
         DaySchedules.Add(schedule);
     }
 }
        public static List <Tuple <TransitAgency, string[]> > DeformatAgencies(CompactFormatReader reader)
        {
            List <Tuple <TransitAgency, string[]> > result = new List <Tuple <TransitAgency, string[]> >();

            CompactFormatReader[] agencyReader;
            List <string>         routes;

            while ((agencyReader = reader.Next()) != null)
            {
                TransitAgency agency = new TransitAgency();
                agency.ID   = agencyReader[0].ReadString();
                agency.Name = agencyReader[1].ReadString();
                agency.Url  = agencyReader[2].ReadString();
                routes      = new List <string>();
                CompactFormatReader[] routeReader;
                while ((routeReader = agencyReader[3].Next()) != null)
                {
                    routes.Add(routeReader[0].ReadString());
                }
                result.Add(new Tuple <TransitAgency, string[]>(agency, routes.ToArray()));
            }
            return(result);
        }
예제 #6
0
        public void Deformat(CompactFormatReader reader)
        {
            List <Tuple <string, string, Tuple <short, string, short?>[]> > data = new List <Tuple <string, string, Tuple <short, string, short?>[]> >();

            CompactFormatReader[] curRouteReader;
            while ((curRouteReader = reader.Next()) != null)
            {
                string curRoute = curRouteReader[0].ReadString();
                CompactFormatReader[] curDirectionReader;
                while ((curDirectionReader = curRouteReader[1].Next()) != null)
                {
                    string sign = curDirectionReader[0].ReadString();
                    List <Tuple <short, string, short?> > trips = new List <Tuple <short, string, short?> >();
                    CompactFormatReader[] curTripReader;
                    while ((curTripReader = curDirectionReader[1].Next()) != null)
                    {
                        trips.Add(new Tuple <short, string, short?>((short)curTripReader[0].ReadInt(), curTripReader[1].ReadString(), (curTripReader.Length > 2) ? new short?((short)curTripReader[2].ReadInt()) : null));
                    }
                    data.Add(new Tuple <string, string, Tuple <short, string, short?>[]>(curRoute, sign, trips.ToArray()));
                }
            }
            Data = data.ToArray();
        }
예제 #7
0
 public static List<Tuple<TransitAgency, string[]>> DeformatAgencies(CompactFormatReader reader)
 {
     List<Tuple<TransitAgency, string[]>> result = new List<Tuple<TransitAgency, string[]>>();
     CompactFormatReader[] agencyReader;
     List<string> routes;
     while ((agencyReader = reader.Next()) != null)
     {
         TransitAgency agency = new TransitAgency();
         agency.ID = agencyReader[0].ReadString();
         agency.Name = agencyReader[1].ReadString();
         agency.Url = agencyReader[2].ReadString();
         routes = new List<string>();
         CompactFormatReader[] routeReader;
         while ((routeReader = agencyReader[3].Next()) != null)
         {
             routes.Add(routeReader[0].ReadString());
         }
         result.Add(new Tuple<TransitAgency, string[]>(agency, routes.ToArray()));
     }
     return result;
 }
예제 #8
0
 public static List<Tuple<BusRoute, string[], string[]>> DeformatRoutes(CompactFormatReader reader)
 {
     List<Tuple<BusRoute, string[], string[]>> result = new List<Tuple<BusRoute, string[], string[]>>();
     CompactFormatReader[] routeReader;
     List<string> stops;
     List<string> shapes;
     while ((routeReader = reader.Next()) != null)
     {
         BusRoute route = new BusRoute();
         route.ID = routeReader[0].ReadString();
         route.Name = routeReader[1].ReadString();
         route.Description = routeReader[2].ReadString();
         route.Agency = routeReader[3].ReadString();
         stops = new List<string>();
         shapes = new List<string>();
         CompactFormatReader[] subReader;
         while ((subReader = routeReader[4].Next()) != null)
         {
             stops.Add(subReader[0].ReadString());
         }
         while ((subReader = routeReader[5].Next()) != null)
         {
             shapes.Add(subReader[0].ReadString());
         }
         result.Add(new Tuple<BusRoute, string[], string[]>(route, stops.ToArray(), shapes.ToArray()));
     }
     return result;
 }
예제 #9
0
 public static List<BusStop> DeformatStops(CompactFormatReader reader)
 {
     List<BusStop> result = new List<BusStop>();
     CompactFormatReader[] stopReader;
     List<string> routes;
     while ((stopReader = reader.Next()) != null)
     {
         BusStop stop = new BusStop();
         stop.ID = stopReader[0].ReadString();
         stop.Direction = (StopDirection)stopReader[1].ReadInt();
         stop.Position = new BasicGeoposition() { Latitude = double.Parse(stopReader[2].ReadString()), Longitude = double.Parse(stopReader[3].ReadString()) };
         stop.Name = stopReader[4].ReadString();
         stop.Code = stopReader[5].ReadString();
         stop.LocationType = stopReader[6].ReadInt();
         routes = new List<string>();
         CompactFormatReader[] routeReader;
         while ((routeReader = stopReader[7].Next()) != null)
         {
             routes.Add(routeReader[0].ReadString());
         }
         stop.Routes = routes.ToArray();
         result.Add(stop);
     }
     return result;
 }
예제 #10
0
 public static async Task LoadPendingDownloads()
 {
     var file = await ApplicationData.Current.LocalCacheFolder.GetFileAsync("PendingDownloadsCache.txt");
     string encodedText = await FileIO.ReadTextAsync(file);
     CompactFormatReader reader = new CompactFormatReader(encodedText);
     PendingDownloadsCache.Clear();
     CompactFormatReader[] routeReader;
     while ((routeReader = reader.Next()) != null)
     {
         List<string> item = new List<string>();
         foreach (var subReader in routeReader)
         {
             item.Add(subReader.ReadString());
         }
         PendingDownloadsCache.Add(item);
     }
 }