Changeset 8408
- Timestamp:
- 08/03/12 15:04:27 (12 years ago)
- Location:
- branches/RoutePlanning
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/HeuristicLab.Algorithms.GraphRouting.csproj
r8350 r8408 58 58 <ItemGroup> 59 59 <Compile Include="AStarAlgorithm.cs" /> 60 <Compile Include="AStarAlgorithmV2.cs" /> 60 61 <Compile Include="DijkstraAlgorithm.cs" /> 61 62 <Compile Include="GraphRoutingAlgorithm.cs" /> -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning.Test/Program.cs
r8350 r8408 11 11 class Program { 12 12 static void Main(string[] args) { 13 // For testing openstreetmap data is used 14 // http://www.openstreetmap.org 15 // Map data © OpenStreetMap contributors, CC BY-SA 16 13 17 string file1 = @"..\..\OsmTestFiles\test.osm"; 14 18 string file2 = @"..\..\OsmTestFiles\testNode1.osm"; … … 18 22 string file6 = @"C:\dev\osmfiles\oberosterreich.highway.osm"; 19 23 20 Test(file5, 529102170, 1001363194, true, false); 21 //Test(file6, 529102170, 1001363194, true, false); 22 //Test(file6, 529102170, 31372732, false, true); // inz - hgb 24 //TestD(file5, 529102170, 1001363194, true, false); // inz - inz 25 //Test(file5, 529102170, 1001363194, true, false); // inz - inz 26 //Test(file6, 529102170, 1001363194, true, false); // inz - inz 27 28 IDataSource ds = TestLoad(file6); 29 Graph.Graph graph = new Graph.Graph(ds); 30 TestRouter(new AStarAlgorithm(graph), 529102170, 31372732, false); // inz - hgb 31 TestRouter(new AStarAlgorithmV2(graph), 529102170, 31372732, false); // inz - hgb 32 33 //TestLoadAndRouter(file6, typeof(DijkstraAlgorithm), 529102170, 31372732, false, false); // inz - hgb 34 //TestLoadAndRouter(file6, typeof(AStarAlgorithm), 529102170, 31372732, false, false); // inz - hgb 35 //TestLoadAndRouter(file6, typeof(AStarAlgorithmV2), 529102170, 31372732, false, false); // inz - hgb 36 23 37 System.Console.Read(); 24 38 } 25 39 26 private static void Test(string filepath, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) { 40 private static long[] TestRouter(IRouter router, long sourceNodeId, long targetNodeId, bool showResult) { 41 Console.WriteLine("Test Router BEGIN ---------------------------------"); 42 Console.WriteLine("Type: " + router.GetType()); 43 44 Console.Write("Calculate route ... "); 45 var sw = Stopwatch.StartNew(); 46 long[] result = router.Calculate(sourceNodeId, targetNodeId); 47 sw.Stop(); 48 Console.WriteLine("done."); 49 Console.WriteLine("Execution Time: {0}", sw.Elapsed); 50 Console.WriteLine(); 51 if (showResult) { 52 Console.WriteLine("Result: "); 53 foreach (long i in result) System.Console.Write(i + "; "); 54 Console.WriteLine(); 55 Console.WriteLine(); 56 } 57 Console.WriteLine("==================================================="); 58 Console.WriteLine(); 59 return result; 60 } 61 62 private static IDataSource TestLoad(string filepath) { 27 63 FileInfo file = new FileInfo(filepath); 28 Console.WriteLine("Test BEGIN ------------------------------"); 64 Console.WriteLine("Test Load Data BEGIN ------------------------------"); 65 Console.WriteLine("File name: {0}", file.Name); 66 Console.WriteLine(); 67 Console.Write("Loading data ... "); 68 var sw = Stopwatch.StartNew(); 69 XmlDataSource xmlDs = new XmlDataSource(filepath); 70 sw.Stop(); 71 Console.WriteLine("done."); 72 Console.WriteLine("Time: {0}", sw.Elapsed); 73 Console.WriteLine(); 74 Console.WriteLine("==================================================="); 75 Console.WriteLine(); 76 return xmlDs; 77 } 78 79 private static void TestLoadAndRouter(string filepath, Type routerType, long sourceNodeId, long targetNodeId, bool showResult, bool writeResultFile) { 80 FileInfo file = new FileInfo(filepath); 81 Console.WriteLine("Test Load and Route BEGIN -------------------------"); 29 82 Console.WriteLine("File name: {0}", file.Name); 30 83 Console.WriteLine(); … … 37 90 Console.WriteLine(); 38 91 Graph.Graph graph = new Graph.Graph(xmlDs); 39 //IRouter router = new DijkstraAlgorithm(graph); 40 IRouter router = new AStarAlgorithm(graph); 92 IRouter router = (IRouter)Activator.CreateInstance(routerType, graph); 41 93 Console.Write("Calculate route ... "); 42 94 sw = Stopwatch.StartNew(); … … 59 111 WriteGPXFile(graph, result, resultFile); 60 112 } 61 Console.WriteLine("========================================= ");113 Console.WriteLine("==================================================="); 62 114 Console.WriteLine(); 63 115 } -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Graph/Graph.cs
r8369 r8408 61 61 public float GetWeight(Way edge, Vertex<Node> source, Vertex<Node> target) { 62 62 double distance = Utils.Distance(source.Node.Point, target.Node.Point); 63 int speed = 0; 64 65 //TODO: 66 HighwayType highwayType = edge.HighwayTag; 67 switch (highwayType) { 68 case HighwayType.bridleway: 69 case HighwayType.bus_guideway: 70 case HighwayType.raceway: 71 case HighwayType.cycleway: 72 case HighwayType.footway: 73 case HighwayType.steps: 74 case HighwayType.null_type: 75 speed = 1; 76 break; 77 78 case HighwayType.path: 79 case HighwayType.service: 80 case HighwayType.pedestrian: 81 case HighwayType.living_street: 82 speed = 15; 83 break; 84 85 case HighwayType.road: 86 case HighwayType.track: 87 speed = 30; 88 break; 89 90 case HighwayType.tertiary: 91 case HighwayType.tertiary_link: 92 case HighwayType.secondary: 93 case HighwayType.secondary_link: 94 speed = 80; 95 break; 96 97 case HighwayType.unclassified: 98 case HighwayType.residential: 99 speed = 50; 100 break; 101 102 case HighwayType.trunk: 103 case HighwayType.trunk_link: 104 case HighwayType.primary: 105 case HighwayType.primary_link: 106 speed = 100; 107 break; 108 case HighwayType.motorway: 109 case HighwayType.motorway_link: 110 speed = 130; 111 break; 112 113 default: 114 speed = 1; 115 break; 116 } 117 63 int speed = edge.GetMaxSpeed(); 118 64 double weight = (distance / speed) * 3.6; 119 65 return (float)weight; -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj
r8314 r8408 81 81 <None Include="Properties\AssemblyInfo.cs.frame" /> 82 82 </ItemGroup> 83 <ItemGroup />84 83 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 85 84 <PropertyGroup> -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Osm/Way.cs
r8369 r8408 94 94 95 95 //public bool CanBeTraversed(Vehicle) {} 96 97 public int GetMaxSpeed() { 98 int speed = 0; 99 100 //TODO: 101 HighwayType highwayType = HighwayTag; 102 switch (highwayType) { 103 case HighwayType.bridleway: 104 case HighwayType.bus_guideway: 105 case HighwayType.raceway: 106 case HighwayType.cycleway: 107 case HighwayType.footway: 108 case HighwayType.steps: 109 case HighwayType.null_type: 110 speed = 1; 111 break; 112 113 case HighwayType.path: 114 case HighwayType.service: 115 case HighwayType.pedestrian: 116 case HighwayType.living_street: 117 speed = 15; 118 break; 119 120 case HighwayType.road: 121 case HighwayType.track: 122 speed = 30; 123 break; 124 125 case HighwayType.tertiary: 126 case HighwayType.tertiary_link: 127 case HighwayType.secondary: 128 case HighwayType.secondary_link: 129 speed = 80; 130 break; 131 132 case HighwayType.unclassified: 133 case HighwayType.residential: 134 speed = 50; 135 break; 136 137 case HighwayType.trunk: 138 case HighwayType.trunk_link: 139 case HighwayType.primary: 140 case HighwayType.primary_link: 141 speed = 100; 142 break; 143 case HighwayType.motorway: 144 case HighwayType.motorway_link: 145 speed = 130; 146 break; 147 148 default: 149 speed = 1; 150 break; 151 } 152 return speed; 153 } 96 154 } 97 155 }
Note: See TracChangeset
for help on using the changeset viewer.