Esempio n. 1
0
 public override bool IsValidEdge(Edge from, Vertex vertex, Edge to)
 {
     if (vertex == null || !vertex.HasFlags(VertexFlags.InaccessibleForCars))
     {
         if (vertex == null)
         {
             return(!to.HasFlags(EdgeFlags.InaccessibleForCarsForward) || !to.HasFlags(EdgeFlags.InaccessibleForCarsReverse));
         }
         if (to.From == vertex)
         {
             return(!to.HasFlags(EdgeFlags.InaccessibleForCarsForward));
         }
         return(!to.HasFlags(EdgeFlags.InaccessibleForCarsReverse));
     }
     return(false);
 }
Esempio n. 2
0
        public override TimeSpan CalculateCost(Edge from, Vertex vertex, Edge to, DateTime time)
        {
            var duration = CalculateBaseCost(to.Distance, GetSpeed(to));

            duration += CalculateCrossingCost(from, vertex, to, time);

            if (vertex.IsTrafficLight || to.HasFlags(EdgeFlags.HasTrafficLights))
            {
                duration += TrafficLightPenalty;
            }

            return(duration);
        }
Esempio n. 3
0
        public override TimeSpan CalculateCost(Edge from, Vertex vertex, Edge to, DateTime time)
        {
            var duration = CalculateBaseCost(to.Distance, GetSpeed(to));

            duration += CalculateCrossingCost(from, vertex, to, time);
            duration += CalculateAngleCost(from, vertex, to, time);

            if (vertex.IsTrafficLight || to.HasFlags(EdgeFlags.HasTrafficLights))
            {
                // http://www.fietsersbondutrecht.nl/uploads/verkeerslichten/20120823%20Verkeerslichten%20voor%20fietsers%20in%20Utrecht%20Waar%20wachten%20we%20op.pdf
                duration += TrafficLightPenalty;
            }
            return(duration);
        }
Esempio n. 4
0
        public override TimeSpan CalculateCost(Edge from, Vertex vertex, Edge to, DateTime time)
        {
            var speed = GetSpeed(to) * 0.9;

            if (speed <= 0)
            {
                throw new InvalidOperationException();
            }
            var duration = CalculateBaseCost(to.Distance, speed);

            duration += CalculateCrossingCost(from, vertex, to, time);
            duration += CalculateAngleCost(from, vertex, to, time);

            if (vertex.IsTrafficLight || to.HasFlags(EdgeFlags.HasTrafficLights))
            {
                duration += TimeSpan.FromSeconds(10.0 + vertex.Edges.Max(e => e.MaximumSpeed) / 2.0);
            }

            return(duration);
        }
Esempio n. 5
0
        private double GetSpeed(Edge edge)
        {
            var baseSpeed = this.MaxSpeed;

            if (edge.Type == RoadType.CyclingPath)
            {
                baseSpeed *= 1.0;                 // fietspaden zijn sneller
            }
            else if (edge.HasFlags(EdgeFlags.HasCycleLane))
            {
                baseSpeed *= 0.98;                 // fietsstroken zijn een beetje sneller
            }
            else if (edge.Type == RoadType.FootPath)
            {
                baseSpeed *= 0.4;                 // Door voetgangers fietsen is helemaal traag.
            }
            else
            {
                baseSpeed *= 0.95;
            }
            return(baseSpeed);
        }
Esempio n. 6
0
 public override bool IsValidEdge(Edge from, Vertex vertex, Edge to)
 {
     return(!to.HasFlags(EdgeFlags.InaccessibleForPedestrians));
 }
Esempio n. 7
0
 public override bool IsAccessible(Edge e)
 {
     return(!e.HasFlags(EdgeFlags.InaccessibleForBikes));
 }