コード例 #1
0
        /// <summary>
        /// Adds a new feature to the heatmap.
        /// </summary>
        /// <param name="heatMap">The heatmap.</param>
        /// <param name="feature">The feature.</param>
        /// <param name="cost">The cost.</param>
        public static void Add(this HeatMap heatMap, IFeature feature, uint cost = 1)
        {
            if (!(feature.Geometry is LineString ls))
            {
                return;
            }

            foreach (var tileId in ls.Tiles(12))
            {
                var tile        = new Tile(tileId);
                var heatmapTile = heatMap.Get(tileId);
                var tilePolygon = tile.ToPolygon();
                try
                {
                    foreach (var segment in tilePolygon.Cut(ls))
                    {
                        heatmapTile.Add(segment, cost);
                    }
                }
                catch (Exception e)
                {
                }
            }
        }