Free cookie consent management tool by TermsFeed Policy Generator

# Changeset 8308

Ignore:
Timestamp:
07/19/12 19:44:56 (11 years ago)
Message:
• get neighbors for specific node
• method to calculate weight between two nodes
• interface for router
• Dijkstra algorithm initial commit
Location:
branches/RoutePlanning
Files:
4 edited

Unmodified
Removed
• ## branches/RoutePlanning/HeuristicLab.Algorithms.GraphRouting/3.3/HeuristicLab.Algorithms.GraphRouting.csproj

 r8302 {E93A30BD-D4C8-4DEC-8ECF-2BC3CD9F027B} HeuristicLab.Problems.RoutePlanning
• ## branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Graph/Graph.cs

 r8300 } //public Dictionary GetNeighbours(long id) { //  Vertex vertex = GetVertex(id); //  Dictionary neighbors = new Dictionary(); //  IList edges = GetEdges(vertex); //  foreach (Way edge in edges) { public Dictionary GetNeighbors(long id) { Vertex vertex = GetVertex(id); Dictionary neighbors = new Dictionary(); List edges = GetEdges(vertex); foreach (Way edge in edges) { //TODO: check if edge can be traversed (eg. highway tag for car roads, ...) //  } //  return null; //} // get all naighbours of current vertex on this edge List> vertices = GetNeighborVerticesOnEdge(edge, vertex); foreach (Vertex neighbor in vertices) { float weight = GetWeight(edge, vertex, neighbor); neighbors[neighbor.Id] = weight; } } return null; } public List> GetNeighborVerticesOnEdge(Way edge, Vertex vertex) { List> neighbors = new List>(); for (int i = 0; i < edge.Nodes.Count; i++) { Node node = edge.Nodes[i]; if (node.Id == vertex.Node.Id) { if (i > 0) { neighbors.Add(GetVertex(edge.Nodes[i - 1].Id)); } if (i < edge.Nodes.Count - 1) { neighbors.Add(GetVertex(edge.Nodes[i + 1].Id)); } } } return neighbors; } public float GetWeight(Way edge, Vertex source, Vertex target) { double distance = Utils.Distance(source.Node.Point, target.Node.Point); int speed = 0; //TODO: HighwayType highwayType = edge.HighwayTag; switch (highwayType) { case HighwayType.bridleway: case HighwayType.bus_guideway: case HighwayType.raceway: case HighwayType.cycleway: case HighwayType.footway: case HighwayType.steps: case HighwayType.null_type: speed = 1; break; case HighwayType.path: case HighwayType.service: case HighwayType.pedestrian: case HighwayType.living_street: speed = 15; break; case HighwayType.road: case HighwayType.track: speed = 30; break; case HighwayType.tertiary: case HighwayType.tertiary_link: case HighwayType.secondary: case HighwayType.secondary_link: speed = 80; break; case HighwayType.unclassified: case HighwayType.residential: speed = 50; break; case HighwayType.trunk: case HighwayType.trunk_link: case HighwayType.primary: case HighwayType.primary_link: speed = 100; break; case HighwayType.motorway: case HighwayType.motorway_link: speed = 130; break; default: speed = 1; break; } double weight = (distance / speed) * 3.6; return (float)weight; } } }
• ## branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj

 r8300
• ## branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Osm/Node.cs

 r8293 } public PointD Point { get { return point; } } public Node() { point = new PointD();
Note: See TracChangeset for help on using the changeset viewer.