Esempio n. 1
0
        public void Initialize(Shape shape)
        {
            if (Shape != null) return;

            Shape = shape;
            _firstStop = new Lazy<OrderedStop>(() => shape.Stops.First());
            _lastStop = new Lazy<OrderedStop>(() => shape.Stops.Last());
            _startTime = new Lazy<DateTime>(() => Points[_firstStop.Value].First().Read.Date);
            _endTime = new Lazy<DateTime>(() => Points[_lastStop.Value].Last().Read.Date);
            _duration = new Lazy<TimeSpan>(() => _endTime.Value - _startTime.Value);
        }
Esempio n. 2
0
        private static IEnumerable<Trip> GetTrips(string id, Shape shape)
        {
            List<Trip> trips = new List<Trip>();

            string query = string.Format("select distinct TripId from dbo.Trips where ShapeId = '{0}'", id);
            DataTable tripTable = Database.SelectQuery(query);

            foreach (DataRow row in tripTable.Rows)
            {
                string tripId = Convert.ToString(row["TripId"]);
                Trip trip = new Trip(tripId, shape.Id);
                trip.Stops =  GetStops(tripId, trip).ToList();
                trip.Stops.Sort(new OrderedStopComparer());

                trips.Add(trip);
            }

            return trips;
        }
Esempio n. 3
0
 public bool Equals(Shape other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return other.Id.EqualsIgnoreCase(Id);
 }
Esempio n. 4
0
        private static IEnumerable<Shape> GetShapes(string id, Route route)
        {
            List<Shape> shapes = new List<Shape>();

            string query = string.Format("select distinct ShapeId from (select *, (select top 1 t.RouteId from dbo.Trips t where t.ShapeId = s.ShapeId) as RouteId from dbo.Shapes s) z where z.RouteId = '{0}'", id);
            DataTable shapeTable = Database.SelectQuery(query);

            foreach (DataRow row in shapeTable.Rows)
            {
                string shapeId = Convert.ToString(row["ShapeId"]);
                Shape shape = new Shape(shapeId, route.Id);
                shape.Trips = GetTrips(shapeId, shape).ToList();

                shapes.Add(shape);
            }

            return shapes;
        }