Changeset 8434
- Timestamp:
- 08/08/12 14:12:50 (12 years ago)
- Location:
- branches/RoutePlanning
- Files:
-
- 1 added
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning.Test/Program.cs
r8429 r8434 133 133 134 134 foreach (long nodeId in route) { 135 Vertex<Node> node = graph.GetVertex(nodeId);135 OsmVertex<Node> node = graph.GetVertex(nodeId); 136 136 writer.WriteStartElement("wpt"); 137 137 writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude)); -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Graph/OsmGraph.cs
r8429 r8434 10 10 } 11 11 12 public Vertex<Node> GetVertex(long id) {13 return new Vertex<Node>(dataSource.GetNode(id));12 public OsmVertex<Node> GetVertex(long id) { 13 return new OsmVertex<Node>(dataSource.GetNode(id)); 14 14 } 15 15 16 public List<Way> GetEdges( Vertex<Node> vertex) {16 public List<Way> GetEdges(OsmVertex<Node> vertex) { 17 17 return dataSource.GetWays(vertex.Node); 18 18 } 19 19 20 20 public Dictionary<long, float> GetNeighbors(long id) { 21 Vertex<Node> vertex = GetVertex(id);21 OsmVertex<Node> vertex = GetVertex(id); 22 22 Dictionary<long, float> neighbors = new Dictionary<long, float>(); 23 23 List<Way> edges = GetEdges(vertex); … … 26 26 27 27 // get all naighbours of current vertex on this edge 28 List< Vertex<Node>> vertices = GetNeighborVerticesOnEdge(edge, vertex);29 foreach ( Vertex<Node> neighbor in vertices) {28 List<OsmVertex<Node>> vertices = GetNeighborVerticesOnEdge(edge, vertex); 29 foreach (OsmVertex<Node> neighbor in vertices) { 30 30 if (edge.CanBeTraversed(vertex.Node, neighbor.Node)) { 31 31 float weight = GetWeight(edge, vertex, neighbor); … … 38 38 39 39 public Dictionary<long, float> GetNeighborsReversed(long id) { 40 Vertex<Node> vertex = GetVertex(id);40 OsmVertex<Node> vertex = GetVertex(id); 41 41 Dictionary<long, float> neighbors = new Dictionary<long, float>(); 42 42 List<Way> edges = GetEdges(vertex); 43 43 foreach (Way edge in edges) { 44 List< Vertex<Node>> vertices = GetNeighborVerticesOnEdge(edge, vertex);45 foreach ( Vertex<Node> neighbor in vertices) {44 List<OsmVertex<Node>> vertices = GetNeighborVerticesOnEdge(edge, vertex); 45 foreach (OsmVertex<Node> neighbor in vertices) { 46 46 if (edge.CanBeTraversed(neighbor.Node, vertex.Node)) { 47 47 float weight = GetWeight(edge, vertex, neighbor); … … 53 53 } 54 54 55 public List< Vertex<Node>> GetNeighborVerticesOnEdge(Way edge,Vertex<Node> vertex) {56 List< Vertex<Node>> neighbors = new List<Vertex<Node>>();55 public List<OsmVertex<Node>> GetNeighborVerticesOnEdge(Way edge, OsmVertex<Node> vertex) { 56 List<OsmVertex<Node>> neighbors = new List<OsmVertex<Node>>(); 57 57 for (int i = 0; i < edge.Nodes.Count; i++) { 58 58 Node node = edge.Nodes[i]; … … 69 69 } 70 70 71 public float GetWeight(Way edge, Vertex<Node> source,Vertex<Node> target) {71 public float GetWeight(Way edge, OsmVertex<Node> source, OsmVertex<Node> target) { 72 72 double distance = Utils.Distance(source.Node.Point, target.Node.Point); 73 73 int speed = edge.GetMaxSpeed(); … … 77 77 78 78 public float EstimatedCosts(long sourceId, long targetId) { 79 Vertex<Node> source = GetVertex(sourceId);80 Vertex<Node> target = GetVertex(targetId);79 OsmVertex<Node> source = GetVertex(sourceId); 80 OsmVertex<Node> target = GetVertex(targetId); 81 81 return EstimatedCosts(source, target); 82 82 } 83 83 84 public float EstimatedCosts( Vertex<Node> source,Vertex<Node> target) {84 public float EstimatedCosts(OsmVertex<Node> source, OsmVertex<Node> target) { 85 85 double distance = Utils.Distance(source.Node.Point, target.Node.Point); 86 86 int speed = 130; -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Graph/OsmVertex.cs
r8424 r8434 1 2 namespace HeuristicLab.Problems.RoutePlanning.Graph { 3 public class Vertex<T> { 1 namespace HeuristicLab.Problems.RoutePlanning.Graph { 2 public class OsmVertex<T> { 4 3 private static long idCounter = 0; 5 4 … … 14 13 } 15 14 16 public Vertex(T node) {15 public OsmVertex(T node) { 17 16 this.node = node; 18 17 this.id = idCounter++; 19 18 } 20 19 21 public static bool operator ==( Vertex<T> v1,Vertex<T> v2) {20 public static bool operator ==(OsmVertex<T> v1, OsmVertex<T> v2) { 22 21 if ((object)v1 == null) { 23 22 if ((object)v2 == null) { … … 32 31 } 33 32 34 public static bool operator !=( Vertex<T> v1,Vertex<T> v2) {33 public static bool operator !=(OsmVertex<T> v1, OsmVertex<T> v2) { 35 34 return !(v1 == v2); 36 35 } 37 36 38 37 public override bool Equals(object obj) { 39 if (obj is Vertex<T>) {40 Vertex<T> graph = (obj asVertex<T>);38 if (obj is OsmVertex<T>) { 39 OsmVertex<T> graph = (obj as OsmVertex<T>); 41 40 return this.Equals(graph); 42 41 } -
branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj
r8429 r8434 59 59 <Compile Include="Graph\OsmGraph.cs" /> 60 60 <Compile Include="Graph\IEdge.cs" /> 61 <Compile Include="Graph\OsmVertex.cs" /> 61 62 <Compile Include="Graph\Route.cs" /> 62 <Compile Include="Graph\Vertex.cs" />63 63 <Compile Include="Osm.Data\XmlDataSource.cs" /> 64 64 <Compile Include="Osm\IDataSource.cs" />
Note: See TracChangeset
for help on using the changeset viewer.