Exemple #1
0
        public static TripFile GetDefaultTripFile()
        {
            if (_defaultTripFile != null)
            {
                return(_defaultTripFile);
            }

            _defaultTripFile = new TripFile("Trips/burlington.trp");
            var shpFile = new ShapeFile("Trips/burlington.shp");
            var stpFile = new StopFile("Trips/burlington.stp");
            var tmsFile = new TripTimeFile("Trips/burlington.tms");
            var rutFile = GetDefaultRouteFile();

            // Link files
            var watch = Stopwatch.StartNew(); // debug runtime watch

            _defaultTripFile.BindRoutes(rutFile);
            _defaultTripFile.BindShapes(shpFile);
            _defaultTripFile.BindTripTimes(tmsFile);
            _defaultTripFile.BindStops(stpFile);
            Console.WriteLine("Bind Time: " + watch.ElapsedMilliseconds);
            watch.Reset();

            watch.Start();
            _defaultTripFile.MixInStops();
            Console.WriteLine("Mixin Time: " + watch.ElapsedMilliseconds);

            return(_defaultTripFile);
        }
        public StopPage(StopFile file)
        {
            //Console.WriteLine("DEBUG > StopPage > Filepath: " + filepath);
            handler     = new StopPageHandler(file);
            DataContext = handler;

            InitializeComponent();
        }
        public StopPageHandler(StopFile file)
        {
            MemOffsetFallback = "21D1A394"; // PCSX2 CCZ's eng patch
            fileType          = Enum.FileType.KH2_00BATTLE;
            subBarName        = "stop";
            stringToFind      = subBarName;

            findAddress();
            Console.WriteLine("DEBUG > StopPageHandler > Processing file...");
            StopFileLoaded = file;
            processFile();
            Console.WriteLine("DEBUG > StopPageHandler > File processed!");
        }
Exemple #4
0
 protected virtual void OnStopFile(StopFileEventArgs sea)
 {
     StopFile?.Invoke(this, sea);
 }
        static void Main(string[] args)
        {
            /* TODO DO NOT FORGET TO PUT THIS BACK
             * string path = "";
             *
             * if (args.Length > 0) path = args[0];
             * else {
             * Console.WriteLine("Current directory is " + Directory.GetCurrentDirectory());
             * Console.Write("Enter a directory or leave blank for the above: ");
             * path = Console.ReadLine();
             * } */

            string path = @"C:\Users\Nixill\Documents\Git\NXS-GTFS";

            if (path != "")
            {
                Directory.SetCurrentDirectory(path);
            }

            // Get the configuration
            Console.WriteLine("Reading config...");
            Config.Load();

            // Make sure we have directories
            Console.WriteLine("Creating folders...");
            Directory.CreateDirectory("gtfs");
            Directory.CreateDirectory("shapes");
            Directory.CreateDirectory("trip-times");
            Directory.CreateDirectory("trips");

            // Initialize lists of things
            List <CompleteRelation>          agencies = new List <CompleteRelation>();
            List <ICompleteOsmGeo>           stops    = new List <ICompleteOsmGeo>();
            Dictionary <long, RouteRelation> routes   = new Dictionary <long, RouteRelation>();

            Console.WriteLine("Reading map file...");
            using (FileStream fileStream = File.OpenRead("map.osm")) {
                // Open the map file
                XmlOsmStreamSource xmlSrc = new XmlOsmStreamSource(fileStream);

                // We'll keep the whole thing so we can iterate over it multiple times
                var src = (from osmGeo in xmlSrc select osmGeo).ToComplete();

                // Iterate through the file to get all the agencies
                // Other things will be added later
                foreach (var obj in src)
                {
                    if (obj.Tags != null)
                    {
                        // Get agencies
                        // Routes are added within each agency
                        if (obj.Type == OsmGeoType.Relation && obj.Tags.Contains("type", "network"))
                        {
                            agencies.Add((CompleteRelation)obj);
                        }

                        // Get stops
                        else if (obj.Type != OsmGeoType.Relation && obj.Tags.Contains("public_transport", "platform"))
                        {
                            stops.Add(obj);
                        }
                    }
                }

                Console.WriteLine("");

                // Now make the agency file
                Console.WriteLine("Found " + agencies.Count + " agency(ies).");
                Console.WriteLine("Writing agency.txt...");
                AgencyFile.Create(agencies, routes);
                Console.WriteLine("Done.");

                Console.WriteLine("");

                // Now make the stops file
                Console.WriteLine("Found " + stops.Count + " stop(s).");
                Console.WriteLine("Writing stops.txt...");
                StopFile.Create(stops);
                Console.WriteLine("Done.");

                Console.WriteLine("");

                // Now make the routes file
                Console.WriteLine("Found " + routes.Count + " route(s).");
                Console.WriteLine("Writing routes.txt...");
                RoutesFile.Create(routes.Values);
                Console.WriteLine("Done.");

                Console.WriteLine("");

                // Now make the trips file
                Console.WriteLine("Writing trips.txt by merging existing files...");
                TripsFile.Create();
                Console.WriteLine("Done.");

                Console.WriteLine("");

                // Now make the times file
                Console.WriteLine("Writing stop_times.txt by merging existing files...");
                TimesFile.Create();
                Console.WriteLine("Done.");

                Console.WriteLine("");

                // Now make the trips file
                Console.WriteLine("Writing shapes.txt by merging existing files...");
                ShapesFile.Create();
                Console.WriteLine("Done.");

                Console.WriteLine("");

                // Now the calendar files
                Console.WriteLine("Writing calendar.txt and calendar_dates.txt...");
                CalendarFile.Create();
                Console.WriteLine("Done.");
            }
        }