Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/22/12 19:14:33 (12 years ago)
Author:
spimming
Message:

#1894:

  • extended datasource interface to get routing graph for a specific vehicle type
  • use ICostCalculator to calculate edge weights
  • moved common enums in own file
  • removed method to estimate cost from graph; use ICostCalculator
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/RoutePlanning/HeuristicLab.Problems.RoutePlanning/3.3/RoutingGraph/Graph.cs

    r8516 r8520  
    33using System.Collections.Generic;
    44using HeuristicLab.Problems.RoutePlanning.Interfaces;
    5 using HeuristicLab.Problems.RoutePlanning.Utilities;
    65namespace HeuristicLab.Problems.RoutePlanning.RoutingGraph {
    76  public class Graph : IGraph {
     
    126125      foreach (Edge<Vertex> edge in edges) {
    127126        // TODO: check if edge can be traversed (eg. highway tag for car roads, ...)
    128         float weight = GetWeight(edge); // TODO:  edge.Weight?
    129         neighbors[edge.Target.Id] = weight;
     127        //float weight = GetWeight(edge); // TODO:  edge.Weight?
     128        //neighbors[edge.Target.Id] = weight;
     129        neighbors[edge.Target.Id] = edge.Weight;
    130130      }
    131131      return neighbors;
     
    136136      foreach (Edge<Vertex> edge in edges) {
    137137        // TODO: check if edge can be traversed (eg. highway tag for car roads, ...)
    138         float weight = GetWeight(edge); // TODO:  edge.Weight?
    139         neighbors[edge.Source.Id] = weight;
     138        //float weight = GetWeight(edge); // TODO:  edge.Weight?
     139        //neighbors[edge.Source.Id] = weight;
     140        neighbors[edge.Source.Id] = edge.Weight;
    140141      }
    141142      return neighbors;
    142143    }
    143144
    144     public float GetWeight(Edge<Vertex> edge) {
    145       //double distance = Utils.Distance(edge.Source.Logitude, edge.Source.Latitude,
    146       //                                 edge.Target.Logitude, edge.Target.Latitude);
     145    //public float GetWeight(Edge<Vertex> edge) {
     146    //  //double distance = Utils.Distance(edge.Source.Logitude, edge.Source.Latitude,
     147    //  //                                 edge.Target.Logitude, edge.Target.Latitude);
    147148
    148       PointD s = new PointD(edge.Source.Logitude, edge.Source.Latitude);
    149       PointD t = new PointD(edge.Target.Logitude, edge.Target.Latitude);
    150       double distance = Utils.LocationDistance(s, t);
     149    //  PointD s = new PointD(edge.Source.Logitude, edge.Source.Latitude);
     150    //  PointD t = new PointD(edge.Target.Logitude, edge.Target.Latitude);
     151    //  double distance = Utils.LocationDistance(s, t);
    151152
    152       int speed = edge.GetMaxSpeed();
    153       double weight = (distance / speed) * 60;
    154       //double weight = (distance / speed) * 3.6;
    155       //double weight = (distance / speed);
    156       //double weight = distance;
    157       return (float)weight;
    158     }
     153    //  //int speed = edge.GetMaxSpeed();
     154    //  //double weight = (distance / speed) * 60;
     155    //  //double weight = (distance / speed) * 3.6;
     156    //  //double weight = (distance / speed);
     157    //  //double weight = distance;
     158    //  //return (float)weight;
     159    //  return (float)1;
     160    //}
    159161
    160     public float EstimatedCosts(long sourceId, long targetId) {
    161       Vertex source = GetVertex(sourceId);
    162       Vertex target = GetVertex(targetId);
    163       return EstimatedCosts(source, target);
    164     }
     162    //public float EstimatedCosts(long sourceId, long targetId) {
     163    //  Vertex source = GetVertex(sourceId);
     164    //  Vertex target = GetVertex(targetId);
     165    //  return EstimatedCosts(source, target);
     166    //}
    165167
    166     public float EstimatedCosts(Vertex source, Vertex target) {
    167       //double distance = Utils.Distance(source.Logitude, source.Latitude,
    168       //                                 target.Logitude, target.Latitude);
     168    //public float EstimatedCosts(Vertex source, Vertex target) {
     169    //  //double distance = Utils.Distance(source.Logitude, source.Latitude,
     170    //  //                                 target.Logitude, target.Latitude);
    169171
    170       PointD s = new PointD(source.Logitude, source.Latitude);
    171       PointD t = new PointD(target.Logitude, target.Latitude);
    172       double distance = Utils.LocationDistance(s, t);
     172    //  PointD s = new PointD(source.Logitude, source.Latitude);
     173    //  PointD t = new PointD(target.Logitude, target.Latitude);
     174    //  double distance = Utils.LocationDistance(s, t);
    173175
    174       //int speed = 130;
    175       //int speed = 10;
    176       int speed = 130;
    177       double costs = (distance / speed) * 60;
    178       //double costs = (distance / speed) * 3.6;
    179       //double costs = (distance / speed);
    180       //double costs = distance;
    181       return (float)costs;
    182     }
     176    //  //int speed = 130;
     177    //  //int speed = 10;
     178    //  int speed = 130;
     179    //  double costs = (distance / speed) * 60;
     180    //  //double costs = (distance / speed) * 3.6;
     181    //  //double costs = (distance / speed);
     182    //  //double costs = distance;
     183    //  return (float)costs;
     184    //}
    183185  }
    184186}
Note: See TracChangeset for help on using the changeset viewer.