Exemple #1
0
        public ILineString PerformShortestPathAnalysis(bool usesCondensedGraph)
        {
            try
            {
                // Some validation code first
                if (_analysisLayer == null)
                {
                    throw new ArgumentException("The Analysis has not been created...");
                }

                if (_userClickPointForSource == null)
                {
                    throw new ArgumentException("The User Click Point - Source has not been created...");
                }

                if (_userClickPointsForDestination == null)
                {
                    throw new ArgumentException("The User Click Point - Destination has not been created...");
                }


                // Pass it to the graph factory.
                var gf = new GraphFactory(_analysisLayer);

                // Reconstruct the graph, taking into account where the user wants the source and destination to be. If the condensed flag is
                // set to  true then it uses the 'Superedge' pricniple. If not is just applies a normal Dijsktra approach - slower, but more accurate
                // currently. TODO: Improve the condensed version. Theres currently a logic flaw in there. Oooops.
                if (!gf.ReconstructGraph(_splitSourceLine, _splitDestinationLine,
                                         _userClickPointForSource, _userClickPointsForDestination, Condensed))
                {
                    return(null);
                }

                // Perform the analysis, returning the shortest path as a Linestring.
                return(gf.PerformShortestPathAnalysis(SourcePointForCalculation,
                                                      DestinationPointForCalculation,
                                                      Condensed));
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public ILineString PerformShortestPathAnalysis(bool usesCondensedGraph)
        {
            try
            {
                // Some validation code first
                if (_analysisLayer == null)
                    throw new ArgumentException("The Analysis has not been created...");

                if (_userClickPointForSource == null)
                    throw new ArgumentException("The User Click Point - Source has not been created...");

                if (_userClickPointsForDestination == null)
                    throw new ArgumentException("The User Click Point - Destination has not been created...");

                // Pass it to the graph factory.
                var gf = new GraphFactory(_analysisLayer);

                // Reconstruct the graph, taking into account where the user wants the source and destination to be. If the condensed flag is
                // set to  true then it uses the 'Superedge' pricniple. If not is just applies a normal Dijsktra approach - slower, but more accurate
                // currently. TODO: Improve the condensed version. Theres currently a logic flaw in there. Oooops.
                if (!gf.ReconstructGraph(_splitSourceLine, _splitDestinationLine,
                    _userClickPointForSource, _userClickPointsForDestination, Condensed))
                    return null;

                // Perform the analysis, returning the shortest path as a Linestring.
                return gf.PerformShortestPathAnalysis(SourcePointForCalculation,
                                                      DestinationPointForCalculation,
                                                      Condensed);
            }
            catch (Exception)
            {
                return null;
            }
        }