Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8434


Ignore:
Timestamp:
08/08/12 14:12:50 (12 years ago)
Author:
spimming
Message:

#1894

  • renamed old Vertex<T> to OsmVertex<T>
  • added new Vertex class
Location:
branches/RoutePlanning
Files:
1 added
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning.Test/Program.cs

    r8429 r8434  
    133133
    134134        foreach (long nodeId in route) {
    135           Vertex<Node> node = graph.GetVertex(nodeId);
     135          OsmVertex<Node> node = graph.GetVertex(nodeId);
    136136          writer.WriteStartElement("wpt");
    137137          writer.WriteAttributeString("lat", XmlConvert.ToString(node.Node.Latitude));
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/Graph/OsmGraph.cs

    r8429 r8434  
    1010    }
    1111
    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));
    1414    }
    1515
    16     public List<Way> GetEdges(Vertex<Node> vertex) {
     16    public List<Way> GetEdges(OsmVertex<Node> vertex) {
    1717      return dataSource.GetWays(vertex.Node);
    1818    }
    1919
    2020    public Dictionary<long, float> GetNeighbors(long id) {
    21       Vertex<Node> vertex = GetVertex(id);
     21      OsmVertex<Node> vertex = GetVertex(id);
    2222      Dictionary<long, float> neighbors = new Dictionary<long, float>();
    2323      List<Way> edges = GetEdges(vertex);
     
    2626
    2727        // 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) {
    3030          if (edge.CanBeTraversed(vertex.Node, neighbor.Node)) {
    3131            float weight = GetWeight(edge, vertex, neighbor);
     
    3838
    3939    public Dictionary<long, float> GetNeighborsReversed(long id) {
    40       Vertex<Node> vertex = GetVertex(id);
     40      OsmVertex<Node> vertex = GetVertex(id);
    4141      Dictionary<long, float> neighbors = new Dictionary<long, float>();
    4242      List<Way> edges = GetEdges(vertex);
    4343      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) {
    4646          if (edge.CanBeTraversed(neighbor.Node, vertex.Node)) {
    4747            float weight = GetWeight(edge, vertex, neighbor);
     
    5353    }
    5454
    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>>();
    5757      for (int i = 0; i < edge.Nodes.Count; i++) {
    5858        Node node = edge.Nodes[i];
     
    6969    }
    7070
    71     public float GetWeight(Way edge, Vertex<Node> source, Vertex<Node> target) {
     71    public float GetWeight(Way edge, OsmVertex<Node> source, OsmVertex<Node> target) {
    7272      double distance = Utils.Distance(source.Node.Point, target.Node.Point);
    7373      int speed = edge.GetMaxSpeed();
     
    7777
    7878    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);
    8181      return EstimatedCosts(source, target);
    8282    }
    8383
    84     public float EstimatedCosts(Vertex<Node> source, Vertex<Node> target) {
     84    public float EstimatedCosts(OsmVertex<Node> source, OsmVertex<Node> target) {
    8585      double distance = Utils.Distance(source.Node.Point, target.Node.Point);
    8686      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> {
     1namespace HeuristicLab.Problems.RoutePlanning.Graph {
     2  public class OsmVertex<T> {
    43    private static long idCounter = 0;
    54
     
    1413    }
    1514
    16     public Vertex(T node) {
     15    public OsmVertex(T node) {
    1716      this.node = node;
    1817      this.id = idCounter++;
    1918    }
    2019
    21     public static bool operator ==(Vertex<T> v1, Vertex<T> v2) {
     20    public static bool operator ==(OsmVertex<T> v1, OsmVertex<T> v2) {
    2221      if ((object)v1 == null) {
    2322        if ((object)v2 == null) {
     
    3231    }
    3332
    34     public static bool operator !=(Vertex<T> v1, Vertex<T> v2) {
     33    public static bool operator !=(OsmVertex<T> v1, OsmVertex<T> v2) {
    3534      return !(v1 == v2);
    3635    }
    3736
    3837    public override bool Equals(object obj) {
    39       if (obj is Vertex<T>) {
    40         Vertex<T> graph = (obj as Vertex<T>);
     38      if (obj is OsmVertex<T>) {
     39        OsmVertex<T> graph = (obj as OsmVertex<T>);
    4140        return this.Equals(graph);
    4241      }
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/HeuristicLab.Problems.RoutePlanning.csproj

    r8429 r8434  
    5959    <Compile Include="Graph\OsmGraph.cs" />
    6060    <Compile Include="Graph\IEdge.cs" />
     61    <Compile Include="Graph\OsmVertex.cs" />
    6162    <Compile Include="Graph\Route.cs" />
    62     <Compile Include="Graph\Vertex.cs" />
    6363    <Compile Include="Osm.Data\XmlDataSource.cs" />
    6464    <Compile Include="Osm\IDataSource.cs" />
Note: See TracChangeset for help on using the changeset viewer.