コード例 #1
0
        /// <summary>
        /// Adds a new schedule entry.
        /// </summary>
        public static void AddEntry(this SchedulesDb db, uint id, DateTime start, DateTime end,
                                    params DayOfWeek[] days)
        {
            if (days == null || days.Length == 0)
            {
                throw new ArgumentOutOfRangeException("days", "Cannot add empty week patterns.");
            }

            db.AddEntry(id, start, end, Weekmask(days));
        }
コード例 #2
0
            /// <summary>
            /// Copies the current schedule to another schedules db.
            /// </summary>
            public uint CopyTo(SchedulesDb otherDb)
            {
                var newScheduleId = otherDb.Add();

                for (var pointer = _id + 1; pointer < _id + 1 + _count; pointer++)
                {
                    var value = _db._data[pointer];
                    otherDb.AddEntry(newScheduleId, value);
                }
                return(newScheduleId);
            }
コード例 #3
0
 /// <summary>
 /// Creates a new transit db.
 /// </summary>
 public TransitDb()
 {
     _agencyAttributes = new AttributesIndex(AttributesIndexMode.ReverseStringIndex);
     _connectionsDb    = new ConnectionsDb();
     _stopsDb          = new StopsDb();
     _stopAttributes   = new AttributesIndex(AttributesIndexMode.ReverseStringIndex);
     _tripsDb          = new TripsDb();
     _tripAttributes   = new AttributesIndex(AttributesIndexMode.ReverseStringIndex);
     _transfersDbs     = new Dictionary <string, TransfersDb>();
     _schedulesDb      = new SchedulesDb();
     _shapesDb         = new ShapesDb();
 }
コード例 #4
0
        /// <summary>
        /// Deserializes from stream.
        /// </summary>
        public static TransitDb Deserialize(Stream stream)
        {
            var version = stream.ReadByte();

            if (version > 2)
            {
                throw new Exception("Cannot deserialize db, version # doesn't match.");
            }

            // read agencies attributes.
            var agencyAttributes = AttributesIndex.Deserialize(new LimitedStream(stream), true);

            // read connections db.
            var connectionsDb = ConnectionsDb.Deserialize(stream);

            // read schedules db.
            var schedulesDb = SchedulesDb.Deserialize(stream);

            // read stop attributes.
            var stopAttributes = AttributesIndex.Deserialize(new LimitedStream(stream), true);

            // read stop db.
            var stopsDb = StopsDb.Deserialize(stream);

            // read transfer db's.
            var transferDbsCount = stream.ReadByte();
            var transferDbs      = new Dictionary <string, TransfersDb>();

            for (var i = 0; i < transferDbsCount; i++)
            {
                var profileName = stream.ReadWithSizeString();
                var transferDb  = TransfersDb.Deserialize(stream);

                transferDbs.Add(profileName, transferDb);
            }

            // read trip attributes.
            var tripAttributes = AttributesIndex.Deserialize(new LimitedStream(stream), true);

            // write trips db.
            var tripsDb = TripsDb.Deserialize(stream);

            ShapesDb shapesDb = null;

            if (version != 1)
            { // write shapes db.
                shapesDb = ShapesDb.Deserialize(stream);
            }

            return(new TransitDb(agencyAttributes, connectionsDb, schedulesDb, stopAttributes, stopsDb, transferDbs,
                                 tripAttributes, tripsDb, shapesDb));
        }
コード例 #5
0
 /// <summary>
 /// Creates a new transit db.
 /// </summary>
 private TransitDb(AttributesIndex agencyAttributes, ConnectionsDb connectionsDb, SchedulesDb schedulesDb, AttributesIndex stopAttributes,
                   StopsDb stopsDb, Dictionary <string, TransfersDb> transferDbs, AttributesIndex tripAttributes, TripsDb tripsDb, ShapesDb shapesDb)
 {
     _agencyAttributes = agencyAttributes;
     _connectionsDb    = connectionsDb;
     _schedulesDb      = schedulesDb;
     _stopAttributes   = stopAttributes;
     _stopsDb          = stopsDb;
     _transfersDbs     = transferDbs;
     _tripAttributes   = tripAttributes;
     _tripsDb          = tripsDb;
     _shapesDb         = shapesDb;
 }
コード例 #6
0
 /// <summary>
 /// Adds a new schedule entry.
 /// </summary>
 public static void AddEntry(this SchedulesDb db, uint id, DateTime day)
 {
     db.AddEntry(id, day, day, day.Weekmask());
 }
コード例 #7
0
 internal Enumerator(SchedulesDb db)
 {
     _db = db;
 }