Beispiel #1
0
        /// <summary>
        /// Executes the actual algorithm.
        /// </summary>
        protected override void DoRun()
        {
            var tiles = new Dictionary <TileIndex, RoutingTile>();

            _polygons = new List <Polygon>();

            _edgeVisitor.Visit += (id, startWeight, endWeight, shape) =>
            {
                this.AddEdgeVisit(tiles, startWeight, endWeight, shape);
            };
            _edgeVisitor.Run();

            var tileList = tiles.Values.ToList();

            tileList = UpdateForWalking(tileList, _level, _walkingSpeed, _limits.Max());
            if (tileList == null)
            {
                return;
            }

            foreach (var isochroneLimit in _limits)
            {
                var tilesWithin = tileList.Where(t => t.Weight < isochroneLimit).ToList();
                if (tilesWithin.Count > 0)
                {
                    var polygonOfTileIndexes = TilesToPolygon.TileSetToPolygon(tilesWithin);
                    _polygons.Add(new Polygon {
                        ExteriorRing = TileHelper.ToWorldCoordinates(polygonOfTileIndexes, _level)
                    });
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Executes the actual algorithm.
        /// </summary>
        protected override void DoRun()
        {
            var tiles = new Dictionary <TileIndex, RoutingTile>();

            _polygons = new List <Polygon>();

            _edgeVisitor.Visit += (path) =>
            {
                var e         = path.Edge;
                var endWeight = path.Weight;
                if (e == Constants.NO_EDGE ||
                    path.From == null)
                {
                    return(false);
                }
                var startWeight = path.From.Weight;

                // Calculate weight at start vertex.
                uint edgeId;
                if (e > 0)
                {
                    edgeId = (uint)e - 1;
                }
                else
                {
                    edgeId = (uint)((-e) - 1);
                }
                var edge  = _graph.GetEdge(edgeId);
                var shape = _graph.GetShape(edge);

                this.AddEdgeVisit(tiles, startWeight, endWeight, shape);

                return(false);
            };
            _edgeVisitor.Run();

            var tileList = tiles.Values.ToList();

            tileList = UpdateForWalking(tileList, _level, _walkingSpeed, _limits.Max());

            foreach (var isochroneLimit in _limits)
            {
                var tilesWithin          = tileList.Where(t => t.Weight < isochroneLimit).ToList();
                var polygonOfTileIndexes = TilesToPolygon.TileSetToPolygon(tilesWithin);
                _polygons.Add(new Polygon {
                    ExteriorRing = TileHelper.ToWorldCoordinates(polygonOfTileIndexes, _level)
                });
            }
        }