public void RoutingConfigLoadReadsRoadTypes() { RoutingConfig target = new RoutingConfig(); // <route-type name="residental" speed="50"> // <required-tag key="highway" value="residental" /> // </route-type> // <route-type name="bad-track" speed="20"> // <required-tag key="highway" value="track" /> // <required-tag key="grade" value="5" /> // </route-type> target.Load(new MemoryStream(TestData.config_road_types)); Assert.Equal(2, target.RoadTypes.Count); Assert.Equal("residental", target.RoadTypes[0].Name); Assert.Equal(50, target.RoadTypes[0].Speed); Assert.Contains(new OSMTag("highway", "residental"), target.RoadTypes[0].RequiredTags); Assert.Equal("bad-track", target.RoadTypes[1].Name); Assert.Equal(20, target.RoadTypes[1].Speed); Assert.Contains(new OSMTag("highway", "track"), target.RoadTypes[1].RequiredTags); Assert.Contains(new OSMTag("grade", "5"), target.RoadTypes[1].RequiredTags); }
public void RoutingConfigLoadReadsOptionalOnewayAttribute() { RoutingConfig target = new RoutingConfig(); // <route-type name="residental" speed="50"> // <required-tag key="highway" value="residental" /> // </route-type> // <route-type name="trunk" speed="20" oneway="yes"> // <required-tag key="highway" value="trunk" /> // </route-type> // <route-type name="trunk" speed="20" oneway="no"> // <required-tag key="highway" value="trunk" /> // </route-type> // <route-type name="trunk" speed="20" oneway="other-value"> // <required-tag key="highway" value="trunk" /> // </route-type> target.Load(new MemoryStream(TestData.config_oneway)); Assert.Equal(4, target.RoadTypes.Count); Assert.Equal(false, target.RoadTypes[0].Oneway); Assert.Equal(true, target.RoadTypes[1].Oneway); Assert.Equal(false, target.RoadTypes[2].Oneway); Assert.Equal(false, target.RoadTypes[3].Oneway); }
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); } }
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); } }
public void RoutingConfigContructorInitializesFields() { RoutingConfig target = new RoutingConfig(); Assert.NotNull(target.RoadTypes); }
public void RoutingConfigLoadThrowsExceptionForConfigWithWrongRootElement() { RoutingConfig target = new RoutingConfig(); Assert.Throws<XmlException>(delegate { target.Load(new MemoryStream(TestData.config_wrong_root_element)); }); }
public void RoutingConfigLoadThrowsExceptionForConfigWithOtherVersionThan1() { RoutingConfig target = new RoutingConfig(); Assert.Throws<XmlException>(delegate { target.Load(new MemoryStream(TestData.config_wrong_version)); }); }
public void RoutingConfigLoadThrowsExceptionForConfigWithMissingVersionAttribute() { RoutingConfig target = new RoutingConfig(); Assert.Throws<XmlException>(delegate { target.Load(new MemoryStream(TestData.config_missing_version)); }); }