Beispiel #1
0
        /// <summary>
        /// Tries to calculate a tree starting at the given location.
        /// </summary>
        public static Result <Tree> TryCalculateTree(this RouterBase router, Profile profile, RouterPoint origin, float max)
        {
            if (!router.SupportsAll(profile))
            {
                return(new Result <Tree>(string.Format("Profile {0} not supported.",
                                                       profile.Name)));
            }

            if (profile.Metric != ProfileMetric.TimeInSeconds)
            {
                return(new Result <Tree>(string.Format("Profile {0} not supported, only profiles with metric TimeInSeconds are supported.",
                                                       profile.Name)));
            }

            // get the weight handler.
            var weightHandler = router.GetDefaultWeightHandler(profile);
            var getFactor     = router.GetDefaultGetFactor(profile);

            // calculate isochrones.
            var treeBuilder = new TreeBuilder(
                new DykstraEdgeVisitor(router.Db.Network.GeometricGraph,
                                       getFactor, origin.ToEdgePaths <float>(router.Db, weightHandler, true), max));

            treeBuilder.Run();

            return(new Result <Tree>(treeBuilder.Tree));
        }