Exemplo n.º 1
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();
 }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 internal Enumerator(ShapesDb shapes)
 {
     _shapes = shapes;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Adds a new shape.
 /// </summary>
 public static void Add(this ShapesDb shapesDb, uint stop1, uint stop2, params Coordinate[] coordinates)
 {
     shapesDb.Add(stop1, stop2, new Graphs.Geometric.Shapes.ShapeEnumerable(coordinates));
 }