Exemple #1
0
        static void Main(string[] args)
        {
            string configPath = "";
            string osmPath    = "";
            string outputPath = "";
            bool   showHelp   = false;

            OptionSet parameters = new OptionSet()
            {
                { "osm=", v => osmPath = v },
                { "c|config=", v => configPath = v },
                { "o|output=", v => outputPath = v },
                { "h|?|help", v => showHelp = v != null },
            };

            try {
                parameters.Parse(args);
            }
            catch (OptionException e) {
                Console.Write("OSM2Routing: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `osm2routing --help' for more information.");
                return;
            }

            if (showHelp || string.IsNullOrEmpty(osmPath) || string.IsNullOrEmpty(configPath) || string.IsNullOrEmpty(outputPath))
            {
                ShowHelp(parameters);
                return;
            }

            try {
                Console.Write("Loading config file ...");
                RoutingConfig config = new RoutingConfig();
                config.Load(configPath);
                Console.WriteLine("\t\t\tDone.");

                Console.Write("Loading OSM file ...");
                OSMRoutingDB map = new OSMRoutingDB();
                map.Load(config.RoadTypes, osmPath);
                Console.WriteLine("\t\t\tDone.");

                Console.Write("Creating routable OSM file ...");
                OSMDB routableMap = map.BuildRoutableOSM();
                Console.WriteLine("\t\tDone.");

                Console.Write("Saving routable OSM file ...");
                routableMap.Save(outputPath);
                Console.WriteLine("\t\tDone.");
            }
            catch (Exception e) {
                Console.WriteLine("\nError: " + e.Message);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            string configPath = "";
            string osmPath = "";
            string outputPath = "";
            bool showHelp = false;

            OptionSet parameters = new OptionSet() {
                { "osm=",					v => osmPath = v},
                { "c|config=",			v => configPath = v},
                { "o|output=",			v => outputPath = v},
                { "h|?|help",				v => showHelp = v != null},
            };

            try {
                parameters.Parse(args);
            }
            catch (OptionException e) {
                Console.Write("OSM2Routing: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `osm2routing --help' for more information.");
                return;
            }

            if (showHelp || string.IsNullOrEmpty(osmPath) || string.IsNullOrEmpty(configPath) || string.IsNullOrEmpty(outputPath)) {
                ShowHelp(parameters);
                return;
            }

            try {
                Console.Write("Loading config file ...");
                RoutingConfig config = new RoutingConfig();
                config.Load(configPath);
                Console.WriteLine("\t\t\tDone.");

                Console.Write("Loading OSM file ...");
                OSMRoutingDB map = new OSMRoutingDB();
                map.Load(config.RoadTypes, osmPath);
                Console.WriteLine("\t\t\tDone.");

                Console.Write("Creating routable OSM file ...");
                OSMDB routableMap = map.BuildRoutableOSM();
                Console.WriteLine("\t\tDone.");

                Console.Write("Saving routable OSM file ...");
                routableMap.Save(outputPath);
                Console.WriteLine("\t\tDone.");
            }
            catch (Exception e) {
                Console.WriteLine("\nError: " + e.Message);
            }
        }