예제 #1
0
        /// <summary>
        /// Add a resulting route for a specific runway exit and size
        /// </summary>
        /// <param name="maxSizeCurrentResult">The maximum size allowed on the current route</param>
        /// <param name="parkingNode">The runway node for this exit</param>
        public void AddResult(XPlaneAircraftCategory maxSizeCurrentResult, TaxiNode parkingNode, Parking parking, TaxiNode entryGroupNode, EntryPoint entryPoint)
        {
            if (!_results.ContainsKey(parkingNode))
            {
                _results[parkingNode] = new Dictionary <XPlaneAircraftCategory, ResultRoute>();
            }

            Dictionary <XPlaneAircraftCategory, ResultRoute> originResults = _results[parkingNode];

            // If no results yet for this node, just add the current route
            if (originResults.Count == 0)
            {
                ResultRoute theRoute = ResultRoute.ExtractRoute(_edges, parkingNode, maxSizeCurrentResult);
                if (!theRoute.HasNode(entryPoint.OnRunwayNode))
                {
                    originResults.Add(maxSizeCurrentResult, theRoute);
                    originResults[maxSizeCurrentResult].RunwayEntryPoint      = entryPoint;
                    originResults[maxSizeCurrentResult].AvailableRunwayLength = entryPoint.TakeoffLengthRemaining;
                }
            }
            else
            {
                XPlaneAircraftCategory minSize = originResults.Min(or => or.Key);
                if (originResults[minSize].Distance > parkingNode.DistanceToTarget)
                {
                    if (minSize > maxSizeCurrentResult)
                    {
                        ResultRoute theRoute = ResultRoute.ExtractRoute(_edges, parkingNode, maxSizeCurrentResult);
                        if (!theRoute.HasNode(entryPoint.OnRunwayNode))
                        {
                            originResults.Add(maxSizeCurrentResult, theRoute);
                            originResults[maxSizeCurrentResult].RunwayEntryPoint      = entryPoint;
                            originResults[maxSizeCurrentResult].AvailableRunwayLength = entryPoint.TakeoffLengthRemaining;

                            originResults[minSize].MinSize = (maxSizeCurrentResult + 1);
                        }
                    }
                    else if (minSize == maxSizeCurrentResult)
                    {
                        ResultRoute theRoute = ResultRoute.ExtractRoute(_edges, parkingNode, maxSizeCurrentResult);
                        if (!theRoute.HasNode(entryPoint.OnRunwayNode))
                        {
                            originResults[minSize] = theRoute;
                            originResults[minSize].RunwayEntryPoint      = entryPoint;
                            originResults[minSize].AvailableRunwayLength = entryPoint.TakeoffLengthRemaining;
                        }
                    }
                }
            }

            // Nasty overkill to make sure parkings with the same 'nearest' node will have routes generated
            foreach (KeyValuePair <XPlaneAircraftCategory, ResultRoute> result in originResults)
            {
                result.Value.AddParking(parking);
            }
        }
예제 #2
0
        /// <summary>
        /// Add a resulting route for a specific runway exit and size
        /// </summary>
        /// <param name="maxSizeCurrentResult">The maximum size allowed on the current route</param>
        /// <param name="runwayExitNode">The runway node for this exit</param>
        /// <param name="pathStartNode">The frist node 'departing' the runway</param>
        /// <param name="r">The runway it self</param>
        public void AddResult(XPlaneAircraftCategory maxSizeCurrentResult, TaxiNode runwayExitNode, TaxiNode pathStartNode, Runway r, double availableRunwayLength)
        {
            if (!_results.ContainsKey(runwayExitNode))
            {
                _results[runwayExitNode] = new Dictionary <XPlaneAircraftCategory, ResultRoute>();
            }

            Dictionary <XPlaneAircraftCategory, ResultRoute> originResults = _results[runwayExitNode];

            // If no results yet for this node, just add the current route
            if (originResults.Count == 0)
            {
                originResults.Add(maxSizeCurrentResult, ResultRoute.ExtractRoute(_edges, pathStartNode, maxSizeCurrentResult));
                originResults[maxSizeCurrentResult].Runway = r;
                originResults[maxSizeCurrentResult].AvailableRunwayLength = availableRunwayLength;
            }
            else
            {
                XPlaneAircraftCategory minSize = originResults.Min(or => or.Key);
                if (originResults[minSize].Distance > pathStartNode.DistanceToTarget)
                {
                    if (minSize > maxSizeCurrentResult)
                    {
                        originResults.Add(maxSizeCurrentResult, ResultRoute.ExtractRoute(_edges, pathStartNode, maxSizeCurrentResult));
                        originResults[maxSizeCurrentResult].Runway = r;
                        originResults[maxSizeCurrentResult].AvailableRunwayLength = availableRunwayLength;
                        originResults[minSize].MinSize = (maxSizeCurrentResult + 1);
                    }
                    else if (minSize == maxSizeCurrentResult)
                    {
                        originResults[minSize]        = ResultRoute.ExtractRoute(_edges, pathStartNode, maxSizeCurrentResult);
                        originResults[minSize].Runway = r;
                        originResults[minSize].AvailableRunwayLength = availableRunwayLength;
                    }
                }
            }
        }