示例#1
0
        /// <summary>
        /// Calculcates the metrics.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public override Dictionary<string, double> Calculate(Vehicle vehicle, AggregatedPoint p)
        {
            Dictionary<string, double> result = new Dictionary<string, double>();
            result.Add(DISTANCE_KEY, 0);
            result.Add(TIME_KEY, 0);

            Aggregated next = p;
            while (next != null)
            {
                if (next is AggregatedPoint)
                {
                    AggregatedPoint point = (next as AggregatedPoint);
                    this.CalculatePointMetrics(vehicle, result, point);
                }
                if (next is AggregatedArc)
                {
                    AggregatedArc arc = (next as AggregatedArc);
                    this.CalculateArcMetrics(vehicle, result, arc);
                }

                next = next.GetNext();
            }

            return result;
        }
 /// <summary>
 /// Does the metric calculations.
 /// </summary>
 /// <param name="vehicle"></param>
 /// <param name="p"></param>
 /// <returns></returns>
 public abstract Dictionary<string, double> Calculate(VehicleEnum vehicle, AggregatedPoint p);
        /// <summary>
        /// Generates instructions.
        /// </summary>
        /// <param name="point"></param>
        /// <param name="interpreter"></param>
        /// <param name="languageGenerator"></param>
        /// <returns></returns>
        public static List<Instruction> Generate(AggregatedPoint point, IRoutingInterpreter interpreter, ILanguageGenerator languageGenerator)
        {
            if (point == null) { throw new ArgumentNullException("route"); }
            if (interpreter == null) { throw new ArgumentNullException("interpreter"); }
            if (languageGenerator == null) { throw new ArgumentNullException("languageGenerator"); }

            MicroPlanning.MicroPlanner planner = new MicroPlanning.MicroPlanner(languageGenerator, interpreter);
            return planner.Plan(point);
        }
 /// <summary>
 /// Generates instructions.
 /// </summary>
 /// <param name="aggregatePoint"></param>
 /// <param name="interpreter"></param>
 /// <returns></returns>
 public static List<Instruction> Generate(AggregatedPoint aggregatePoint, IRoutingInterpreter interpreter)
 {
     return InstructionGenerator.Generate(aggregatePoint, interpreter,
         new OsmSharp.Routing.Instructions.LanguageGeneration.Defaults.SimpleEnglishLanguageGenerator());
 }
示例#5
0
        /// <summary>
        /// Plans all the messages in the aggregated 
        /// </summary>
        /// <param name="p"></param>
        public List<Instruction> Plan(AggregatedPoint p)
        {
            // set the current aggregated object.
            _current = p;

            // loop until the current object is null.
            while (_current != null)
            {
                while (_current != null)
                {
                    // plan the current message.
                    this.PlanNewMessage(_current);

                    // get the next object.
                    _current = _current.GetNext();
                }

                // show the latest success anyway.
                if (_latest_final >= 0)
                { // do the latest succes.
                    this.Success(_latest_machine);

                    // get the next object.
                    if (_current != null)
                    {
                        _current = _current.GetNext();
                    }
                }
                else if(_messagesStack.Count > 0)
                { // no machine matches everything until the end of the route.
                    throw new MicroPlannerException("No machine could be found matching the current stack of messages!", _messagesStack);
                }
            }

            // return the instructions list accumulated in the scentence planner.
            return this.SentencePlanner.Instructions;
        }
示例#6
0
        /// <summary>
        /// Calculate metrics for a given turn.
        /// </summary>
        /// <param name="vehicle"></param>
        /// <param name="result"></param>
        /// <param name="point"></param>
        private void CalculatePointMetrics(Vehicle vehicle, Dictionary<string, double> result, AggregatedPoint point)
        {
            if (point.Angle != null)
            {
                if (AggregatedHelper.IsTurn(point.Angle.Direction))
                {
                    // no calculations for distance.

                    // update the time.
                    Second second = 0;
                    // ESTIMATE THE INCREASE IN TIME.
                    // TODO: ASSUMED DRIVING ON THE RIGHT; UPDATE TO MAKE CONFIGURABLE.
                    switch (point.Angle.Direction)
                    {
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.Left:
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SharpLeft:
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SlightlyLeft:
                            second = 25;
                            break;
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.Right:
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SharpRight:
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.SlightlyRight:
                            second = 5;
                            break;
                        case OsmSharp.Math.Geo.Meta.RelativeDirectionEnum.TurnBack:
                            second = 30;
                            break;
                    }
                    result[TIME_KEY] = result[TIME_KEY] + second.Value;
                }
                else
                {
                    if (point.ArcsNotTaken != null && point.ArcsNotTaken.Count > 0)
                    { // very simple estimate.
                        Second second = 0;

                        second = 5;

                        result[TIME_KEY] = result[TIME_KEY] + second.Value;

                    }
                }
            }
        }
 /// <summary>
 /// Generates instructions.
 /// </summary>
 /// <param name="point"></param>
 /// <param name="interpreter"></param>
 /// <param name="language_generator"></param>
 /// <returns></returns>
 public static List<Instruction> Generate(AggregatedPoint point, IRoutingInterpreter interpreter, ILanguageGenerator language_generator)
 {
     MicroPlanning.MicroPlanner planner = new MicroPlanning.MicroPlanner(language_generator, interpreter);
     return planner.Plan(point);
 }