Changeset 8308
- Timestamp:
- 07/19/12 19:44:56 (12 years ago)
- Location:
- branches/RoutePlanning
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/HeuristicLab.Algorithms.GraphRouting.csproj
r8302 r8308 49 49 <Reference Include="System" /> 50 50 <Reference Include="System.Core" /> 51 <Reference Include="System.Drawing" /> 51 52 <Reference Include="System.Xml.Linq" /> 52 53 <Reference Include="System.Data.DataSetExtensions" /> … … 56 57 </ItemGroup> 57 58 <ItemGroup> 59 <Compile Include="DijkstraAlgorithm.cs" /> 60 <Compile Include="GraphRoutingAlgorithm.cs" /> 61 <Compile Include="IRouter.cs" /> 58 62 <Compile Include="Plugin.cs" /> 59 63 <Compile Include="Properties\AssemblyInfo.cs" /> … … 63 67 <None Include="Plugin.cs.frame" /> 64 68 <None Include="Properties\AssemblyInfo.cs.frame" /> 69 </ItemGroup> 70 <ItemGroup> 71 <ProjectReference Include="..\..\HeuristicLab.Problems.RoutePlanning\3.3\HeuristicLab.Problems.RoutePlanning.csproj"> 72 <Project>{E93A30BD-D4C8-4DEC-8ECF-2BC3CD9F027B}</Project> 73 <Name>HeuristicLab.Problems.RoutePlanning</Name> 74 </ProjectReference> 65 75 </ItemGroup> 66 76 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Graph/Graph.cs
r8300 r8308 24 24 } 25 25 26 //public Dictionary<long, float> GetNeighbours(long id) { 27 // Vertex<Node> vertex = GetVertex(id); 28 // Dictionary<long, float> neighbors = new Dictionary<long, float>(); 29 // IList<Way> edges = GetEdges(vertex); 30 // foreach (Way edge in edges) { 26 public Dictionary<long, float> GetNeighbors(long id) { 27 Vertex<Node> vertex = GetVertex(id); 28 Dictionary<long, float> neighbors = new Dictionary<long, float>(); 29 List<Way> edges = GetEdges(vertex); 30 foreach (Way edge in edges) { 31 //TODO: check if edge can be traversed (eg. highway tag for car roads, ...) 31 32 32 // } 33 // return null; 34 //} 33 // get all naighbours of current vertex on this edge 34 List<Vertex<Node>> vertices = GetNeighborVerticesOnEdge(edge, vertex); 35 foreach (Vertex<Node> neighbor in vertices) { 36 float weight = GetWeight(edge, vertex, neighbor); 37 neighbors[neighbor.Id] = weight; 38 } 39 } 40 return null; 41 } 35 42 43 public List<Vertex<Node>> GetNeighborVerticesOnEdge(Way edge, Vertex<Node> vertex) { 44 List<Vertex<Node>> neighbors = new List<Vertex<Node>>(); 45 for (int i = 0; i < edge.Nodes.Count; i++) { 46 Node node = edge.Nodes[i]; 47 if (node.Id == vertex.Node.Id) { 48 if (i > 0) { 49 neighbors.Add(GetVertex(edge.Nodes[i - 1].Id)); 50 } 51 if (i < edge.Nodes.Count - 1) { 52 neighbors.Add(GetVertex(edge.Nodes[i + 1].Id)); 53 } 54 } 55 } 56 return neighbors; 57 } 58 59 public float GetWeight(Way edge, Vertex<Node> source, Vertex<Node> target) { 60 double distance = Utils.Distance(source.Node.Point, target.Node.Point); 61 int speed = 0; 62 63 //TODO: 64 HighwayType highwayType = edge.HighwayTag; 65 switch (highwayType) { 66 case HighwayType.bridleway: 67 case HighwayType.bus_guideway: 68 case HighwayType.raceway: 69 case HighwayType.cycleway: 70 case HighwayType.footway: 71 case HighwayType.steps: 72 case HighwayType.null_type: 73 speed = 1; 74 break; 75 76 case HighwayType.path: 77 case HighwayType.service: 78 case HighwayType.pedestrian: 79 case HighwayType.living_street: 80 speed = 15; 81 break; 82 83 case HighwayType.road: 84 case HighwayType.track: 85 speed = 30; 86 break; 87 88 case HighwayType.tertiary: 89 case HighwayType.tertiary_link: 90 case HighwayType.secondary: 91 case HighwayType.secondary_link: 92 speed = 80; 93 break; 94 95 case HighwayType.unclassified: 96 case HighwayType.residential: 97 speed = 50; 98 break; 99 100 case HighwayType.trunk: 101 case HighwayType.trunk_link: 102 case HighwayType.primary: 103 case HighwayType.primary_link: 104 speed = 100; 105 break; 106 case HighwayType.motorway: 107 case HighwayType.motorway_link: 108 speed = 130; 109 break; 110 111 default: 112 speed = 1; 113 break; 114 } 115 116 double weight = (distance / speed) * 3.6; 117 return (float)weight; 118 } 36 119 } 37 120 } -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj
r8300 r8308 65 65 <Compile Include="Osm\OsmBase.cs" /> 66 66 <Compile Include="Osm\PointD.cs" /> 67 <Compile Include="Osm\RectangleD.cs" /> 67 68 <Compile Include="Osm\Relation.cs" /> 68 69 <Compile Include="Osm\RelationMember.cs" /> 69 70 <Compile Include="Osm\TagConstants.cs" /> 71 <Compile Include="Osm\Utils.cs" /> 70 72 <Compile Include="Osm\Way.cs" /> 71 73 <Compile Include="Plugin.cs" /> -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Osm/Node.cs
r8293 r8308 13 13 } 14 14 15 public PointD Point { 16 get { return point; } 17 } 18 15 19 public Node() { 16 20 point = new PointD();
Note: See TracChangeset
for help on using the changeset viewer.