Exemplo n.º 1
0
 /// <summary>
 /// Add a new stop for the running
 /// </summary>
 public void AddStop(Position location)
 {
     if (Open)
     {
         Stops.Add(location);
     }
 }
Exemplo n.º 2
0
        public Bus(List <RoadPoint> route, String name, Canvas parent, Brush color)
        {
            this.Route       = route;
            this.BusLineName = name;
            this.OnBoard     = new HashSet <Passenger>();
            this.Stops       = new List <string>();
            this.Parent      = parent;
            this.BusColor    = color;
            this.traces      = new List <Point[]>();
            this.netComm     = new BusNetComm();
            this.pasb        = new Storyboard();

            BusImage             = new Image();
            BusImage.Source      = new BitmapImage((new Uri(@"Img\bus.bmp", UriKind.Relative)));
            BusImage.Height      = 20;
            BusImage.Width       = 20;
            BusImage.ToolTip     = this.BusLineName;
            BusImage.MouseEnter += MouseOverEventHandler;
            BusImage.MouseLeave += MouseLeaveEventHandler;
            this.Parent.Children.Add(this.BusImage);

            int i = 0;

            this.points = new Point[Route.Count];
            foreach (RoadPoint rd in Route)
            {
                if (rd is RoadStop)
                {
                    RoadStop rs = (RoadStop)rd;
                    Stops.Add(rs.StopName);
                }
                points[i] = rd.Coordinate;
                i++;
            }
        }
Exemplo n.º 3
0
 public LinearGradientBrush(Point relStart, Point relEnd, Color startColor, Color endColor)
 {
     Start = relStart;
     End   = relEnd;
     Stops.Add(new GradientStop(0, startColor));
     Stops.Add(new GradientStop(1, endColor));
 }
Exemplo n.º 4
0
        void AddStop(StopData sd)
        {
            //Do we know about this in ther DB?
            var  stop = GetStop(sd);
            Stop si;

            if (stop != null)
            {
                si = new Stop(stop);
            }
            else
            {
                si = new Stop(sd);
            }


            if (stop != null)
            {
                stopdatabase.DeleteItem(si);
            }
            //Cache and Add
            stopdatabase.SaveItem(si);

            if (!Stops.Contains(sd))
            {
                Stops.Add(sd);
            }
            else
            {
                Stops.Remove(sd);
                Stops.Add(sd);
            }
        }
Exemplo n.º 5
0
 public RadialGradientBrush(Point relCenter, Size relRadius, Color startColor, Color endColor)
 {
     Center = relCenter;
     Focus  = relCenter;
     Radius = relRadius;
     Stops.Add(new GradientStop(0, startColor));
     Stops.Add(new GradientStop(1, endColor));
 }
Exemplo n.º 6
0
 public void Add(Stop stop)
 {
     if (Stops.Count == 0)
     {
         stop.Position = 0;
     }
     Stops.Add(stop);
 }
Exemplo n.º 7
0
        /// <summary>
        /// Called by the underlying <see cref="SvgElement"/> when an element has been added to the
        /// 'Children' collection.
        /// </summary>
        /// <param name="child">The <see cref="SvgElement"/> that has been added.</param>
        /// <param name="index">An <see cref="int"/> representing the index where the element was added to the collection.</param>
        protected override void AddElement(SvgElement child, int index)
        {
            if (child is SvgGradientStop)
            {
                Stops.Add((SvgGradientStop)child);
            }

            base.AddElement(child, index);
        }
        public ColorSpectrumGradient(Gradient source)
        {
            _source = source;
            Angle   = 270;

            foreach (var stop in _source.Stops)
            {
                Stops.Add(new GradientStopClone(stop));
            }
        }
Exemplo n.º 9
0
 public void addStop(String key, Stop newStop)
 {
     if (!Stops.ContainsKey(key))
     {
         //      Console.WriteLine(LongName+"+++++ se agrega la parada"+ newStop.ShortName+ " LLAVE "+key);
         Stops.Add(key, newStop);
     }
     else
     {
         //     Console.WriteLine(LongName + "----- NO se agrega la parada" + newStop.ShortName);
     }
 }
Exemplo n.º 10
0
        private void ResetStopsAndPoints()
        {
            int i = 0;

            Stops.Clear();
            this.points = new Point[Route.Count];

            foreach (RoadPoint rd in Route)
            {
                if (rd is RoadStop)
                {
                    RoadStop rs = (RoadStop)rd;
                    Stops.Add(rs.StopName);
                }
                points[i] = rd.Coordinate;
                i++;
            }
        }
Exemplo n.º 11
0
        private void LoadStops(List <string[]> stopsData)
        {
            Console.WriteLine(this + "Loading Stops...");
            var watch = Stopwatch.StartNew();

            foreach (var stopData in stopsData)
            {
                var stop = new Stop(int.Parse(stopData[0]), stopData[1], stopData[2], double.Parse(stopData[4]),
                                    double.Parse(stopData[5]));
                if (!Stops.Contains(stop))
                {
                    Stops.Add(stop);
                }
            }
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            var seconds   = elapsedMs * 0.001;

            Console.WriteLine(this.ToString() + Stops.Count + " stops were successfully loaded in " + seconds +
                              " seconds.");
        }
        public void AddStop()
        {
            var stop = new GradientStop
            {
                Color  = ColorUtils.GetRandom(),
                Offset = Offset.Prop(1)
            };

            var lastStop = Stops.LastOrDefault();

            if (lastStop != null && lastStop.RenderOffset > 0.8)
            {
                foreach (var x in Stops)
                {
                    x.Offset = Offset.Prop(x.RenderOffset * 0.8);
                }
            }

            _source.Stops.Add(stop);
            Stops.Add(new GradientStopClone(stop));
        }
        public void LoadStops()
        {
            Transport transport = new Transport();

            List <StopWithLineInfo> stops;

            if (OfflineMode)
            {
                transport._request = new OfflineRequest(Resource.offline_stops_near_cci);
                stops = transport.GetStopsListWithLineInfosOffline();
            }
            else
            {
                stops = transport.GetStopsListWithLineInfo(Longitude.ToString().Replace(',', '.'), Latitude.ToString().Replace(',', '.'), Distance, true);
            }

            Stops.Clear();

            foreach (StopWithLineInfo stop in stops)
            {
                Stops.Add(stop);
            }
        }
Exemplo n.º 14
0
        async Task AddStop(RouteStop stop, bool addToStorage)
        {
            Debug.Assert(stop.Route == this);

            if (addToStorage)
            {
                await AppStorage.Instance.AddRouteStop(stop);
            }

            if (Stops.Count > 0 && stop.Kind != RouteStopKind.EndPoint && HasEndPoint)
            {
                Stops.Insert(Stops.Count - 1, stop);
            }
            else
            {
                Stops.Add(stop);
            }

            Debug.AssertIsNull(CurrentLegs);
            UpdateLegs(true);

            //Debug.AssertNotNull(stop.Leg);
            //RequestLegDuration(stop.Leg);
        }
Exemplo n.º 15
0
        //Lee todas las paradas del archivo Stops y agrega las estaciones
        public void loadStops()
        {
            try
            {
                StreamReader reader = new StreamReader(RELATIVE_PATH_STOPS);


                string line = reader.ReadLine();
                line = reader.ReadLine();


                while (line != null)
                {
                    string[] datos = line.Split(',');

                    if (!datos[6].Equals("0") || !datos[7].Equals("0"))
                    {
                        //                 Stop Id, Plan Version,   Short Name, Long Name, Gps x,    Gps Y
                        Stop a = new Stop((datos[0]), (datos[1]), datos[2], datos[3], datos[6], datos[7]);
                        if (isStop(a.ShortName) == true)
                        {
                            if (!Stations.ContainsKey(datos[0]))
                            {
                                CreateStation(a);
                            }
                        }
                        else
                        {
                            if (!Stops.ContainsKey(datos[0]))
                            {
                                a.Zona = getZona(a);
                                Stops.Add(datos[0], a);
                            }
                        }
                    }
                    else
                    {
                        line = reader.ReadLine();
                    }

                    line = reader.ReadLine();
                }
                reader.Close();
            }
            catch (DirectoryNotFoundException dnf)
            {
                LoadDate.ErrorStop("No se encuentra el archivo stop");
                if (LoadDate.Estado == false)
                {
                    LoadDate.Hide();
                    LoadDate.DialogError();
                    LoadDate.ShowDialog();
                    LoadDate.Estado = true;
                }
            }


            catch (ArgumentException ae)
            {
                LoadDate.ErrorStop("Archivo equivocado de stop");
                if (LoadDate.Estado == false)
                {
                    LoadDate.DialogError();
                    LoadDate.ShowDialog();
                    LoadDate.Estado = true;
                }
            }
            catch (IndexOutOfRangeException ae)
            {
                LoadDate.ErrorStop("Archivo equivocado de stop");
                if (LoadDate.Estado == false)
                {
                    LoadDate.DialogError();
                    LoadDate.ShowDialog();
                    LoadDate.Estado = true;
                }
            }
        }
Exemplo n.º 16
0
 public void AddStop(string name, int num)
 {
     //判断是否添加重复stop
     Stops.Add(new Stop(name, num));
 }
Exemplo n.º 17
0
        /// <summary>
        /// Reads GTFS (General/Google Transit Feed Specification) data from
        /// a given location, loading it in to the TransitFeed object for
        /// storage in a database.
        /// </summary>
        /// <remarks>
        /// The GTFS data that will be loaded looks like the following.
        ///
        ///  +--------+
        ///  | Routes |
        ///  +--------+
        ///       ^                            +------+
        ///       |                            |      |
        ///  +--------+   +------------+   +-------+  |
        ///  | Trips  |<--| Stop Times |-->| Stops |<-+
        ///  +--------+   +------------+   +-------+
        ///       |
        ///       +-----------------+
        ///       |                 |
        ///       v                 v
        /// +----------+   +----------------+
        /// | Calendar |   | Calendar Dates |
        /// +----------+   +----------------+
        ///
        /// To most easily add references to the data as it is loaded, it will
        /// be read in the following order (class names in brackets):
        ///   - Routes (TransitFeedRoute)
        ///   - Calendar (TransitFeedServiceCalendar)
        ///   - Calendar Dates (TransitFeedServiceCalendarException)
        ///   - Trips (TransitFeedTrip)
        ///   - Stops (TransitFeedStop)
        ///   - Stop Times (TransitFeedStopTime)
        /// </remarks>
        public TransitFeedData Read(string gtfsFilePath)
        {
            // Routes
            var routesPath = Path.Combine(gtfsFilePath, Constants.Files.Routes);
            var routesTime = ReadFile(routesPath, (csv) =>
            {
                var id    = csv.GetField(Constants.Fields.RouteId);
                var route = new TransitFeedRoute
                {
                    ShortName = csv.GetField(Constants.Fields.RouteShortName).NullIfWhitespace(),
                    LongName  = csv.GetField(Constants.Fields.RouteLongName).NullIfWhitespace(),
                    Type      = csv.GetField <RouteType>(Constants.Fields.RouteType),
                    Color     = csv.GetField(Constants.Fields.RouteColor).NullIfWhitespace()
                };

                Routes.Add(id, route);
            });

            Console.WriteLine($"Read: Routes ({routesTime.TotalMilliseconds}ms)");

            // Calendar
            var calendarPath = Path.Combine(gtfsFilePath, Constants.Files.Calendar);
            var calendarTime = ReadFile(calendarPath, (csv) =>
            {
                var serviceId = csv.GetField(Constants.Fields.ServiceId);

                var startDate = DateTimeOffset.ParseExact(csv.GetField(Constants.Fields.StartDate), Constants.Formats.Date, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal);
                var endDate   = DateTimeOffset.ParseExact(csv.GetField(Constants.Fields.EndDate), Constants.Formats.Date, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal);

                var calendar = new TransitFeedServiceCalendar
                {
                    Monday    = csv.GetField <bool>(Constants.Fields.Monday),
                    Tuesday   = csv.GetField <bool>(Constants.Fields.Tuesday),
                    Wednesday = csv.GetField <bool>(Constants.Fields.Wednesday),
                    Thursday  = csv.GetField <bool>(Constants.Fields.Thursday),
                    Friday    = csv.GetField <bool>(Constants.Fields.Friday),
                    Saturday  = csv.GetField <bool>(Constants.Fields.Saturday),
                    Sunday    = csv.GetField <bool>(Constants.Fields.Sunday),
                    StartDate = startDate,
                    EndDate   = endDate
                };

                Calendar.Add(serviceId, calendar);
            });

            Console.WriteLine($"Read: Calendar ({calendarTime.TotalMilliseconds}ms)");

            // Calendar Date
            var calendarDatePath = Path.Combine(gtfsFilePath, Constants.Files.CalendarDates);
            var calendarDateTime = ReadFile(calendarDatePath, (csv) =>
            {
                var id   = csv.GetField(Constants.Fields.ServiceId);
                var date = DateTimeOffset.ParseExact(csv.GetField(Constants.Fields.Date), Constants.Formats.Date, CultureInfo.InvariantCulture.DateTimeFormat, DateTimeStyles.AssumeUniversal);

                var calendarException = new TransitFeedServiceCalendarException
                {
                    ServiceId     = id,
                    Date          = date,
                    ExceptionType = csv.GetField <CalendarExceptionType>(Constants.Fields.ExceptionType)
                };

                CalendarExceptions.Add(calendarException);
            });

            Console.WriteLine($"Read: Calendar Dates ({calendarDateTime.TotalMilliseconds}ms)");

            // Trips
            var tripsPath = Path.Combine(gtfsFilePath, Constants.Files.Trips);
            var tripsTime = ReadFile(tripsPath, (csv) =>
            {
                var id        = csv.GetField(Constants.Fields.TripId);
                var routeId   = csv.GetField(Constants.Fields.RouteId);
                var serviceId = csv.GetField(Constants.Fields.ServiceId);

                var trip = new TransitFeedTrip
                {
                    Id        = id,
                    RouteId   = routeId,
                    ServiceId = serviceId,
                    Headsign  = csv.GetField(Constants.Fields.TripHeadsign).NullIfWhitespace(),
                    Direction = csv.GetField(Constants.Fields.DirectionId).NullIfWhitespace()
                };

                Trips.Add(id, trip);
            });

            Console.WriteLine($"Read: Trips ({tripsTime.TotalMilliseconds}ms)");

            // Stops
            var stopsPath = Path.Combine(gtfsFilePath, Constants.Files.Stops);
            var stopsTime = ReadFile(stopsPath, (csv) =>
            {
                var id   = csv.GetField(Constants.Fields.StopId);
                var stop = new TransitFeedStop
                {
                    Code      = csv.GetField(Constants.Fields.StopCode).NullIfWhitespace(),
                    Name      = csv.GetField(Constants.Fields.StopName).NullIfWhitespace(),
                    Latitude  = csv.GetField <float>(Constants.Fields.StopLat),
                    Longitude = csv.GetField <float>(Constants.Fields.StopLon),
                    Type      = csv.GetField(Constants.Fields.LocationType).NullIfWhitespace(),
                    ParentId  = csv.GetField(Constants.Fields.ParentStation).NullIfWhitespace(),
                    Platform  = csv.GetField(Constants.Fields.PlatformCode).NullIfWhitespace()
                };

                Stops.Add(id, stop);
            });

            Console.WriteLine($"Read: Stops ({stopsTime.TotalMilliseconds}ms)");

            // Stop Times
            var stopTimesPath = Path.Combine(gtfsFilePath, Constants.Files.StopTimes);
            var stopTimesTime = ReadFile(stopTimesPath, (csv) =>
            {
                var stopTime = new TransitFeedStopTime
                {
                    TripId        = csv.GetField(Constants.Fields.TripId),
                    StopId        = csv.GetField(Constants.Fields.StopId),
                    ArrivalTime   = TimeSpanParser.ParseStopTime(csv.GetField(Constants.Fields.ArrivalTime)),
                    DepartureTime = TimeSpanParser.ParseStopTime(csv.GetField(Constants.Fields.DepartureTime)),
                    Sequence      = csv.GetField <int>(Constants.Fields.StopSequence),
                    PickupType    = csv.GetField <PickupDropOffType>(Constants.Fields.PickupType),
                    DropOffType   = csv.GetField <PickupDropOffType>(Constants.Fields.DropOffType)
                };

                StopTimes.Add(stopTime);
            });

            Console.WriteLine($"Read: StopTimes ({stopTimesTime.TotalMilliseconds}ms)");

            return(this);
        }