Example #1
0
        public static void SaveCandidateIncomingConnections(CandidatePoint candidate, string filename)
        {
            int   counter = -1;
            OSMDB result  = new OSMDB();

            OSMNode osmCandidate = new OSMNode(counter--, candidate.MapPoint.Latitude, candidate.MapPoint.Longitude);

            osmCandidate.Tags.Add(new OSMTag("observation", candidate.ObservationProbability.ToString()));
            osmCandidate.Tags.Add(new OSMTag("time", candidate.Layer.TrackPoint.Time.ToString()));
            result.Nodes.Add(osmCandidate);
            foreach (var connection in candidate.IncomingConnections)
            {
                OSMNode from = new OSMNode(counter--, connection.From.MapPoint.Latitude, connection.From.MapPoint.Longitude);
                from.Tags.Add(new OSMTag("observation", connection.From.ObservationProbability.ToString()));
                from.Tags.Add(new OSMTag("time", connection.From.Layer.TrackPoint.Time.ToString()));
                result.Nodes.Add(from);

                OSMWay osmConnection = new OSMWay(counter--, new long[] { from.ID, osmCandidate.ID });
                osmConnection.Tags.Add(new OSMTag("transmission", connection.TransmissionProbability.ToString()));

                result.Ways.Add(osmConnection);
            }

            result.Save(filename);
        }
Example #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);
            }
        }