Mapstache.Utf8Grid.FillPolygon C# (CSharp) Метод

FillPolygon() публичный Метод

public FillPolygon ( SqlGeography geography, int i, object data = null ) : void
geography SqlGeography
i int
data object
Результат void
        public void FillPolygon(SqlGeography geography,int i, object data=null)
        {
            using (var gp = _graphicsPathBuilder.Build(geography))
              using (var brush = Utf8Grid.CreateBrush(i))
              {
                  _graphics.FillPath(brush,gp);
              }
            if (data!=null)
            {
                this.Data.Add(i.ToString(),data);
            }
        }

Usage Example

Пример #1
0
        public ActionResult States(int x,int y, int z)
        {
            var key = string.Format(@"states\{0}\{1}\{1}", x, y, z);
            var cachedJson = this.HttpContext.Cache[key] as string;
            if (cachedJson != null)
            {
                return new ContentResult() {Content = cachedJson, ContentType = "application/json"};
            }

            const int utfgridResolution = 2;

            using (var utf8Grid = new Utf8Grid(utfgridResolution, x, y, z))
            {
                var bbox = GetBoundingBoxInLatLngWithMargin(x, y, z);
                if (bbox.Bottom > 0)
                {
                    var states = new StatesRepository().Query(bbox.ToSqlGeography());
                    int i = 1;
                    foreach (var state in states)
                    {
                        var geography = (SqlGeography) state["geom"];
                        var projected = ((SqlGeography) state["geom"]).FromLonLat().MakeValid();
                        var wkt = projected.STAsText().ToSqlString().Value;
                        utf8Grid.FillPolygon(geography, i,
                                             new {NAME = state["STATE_NAME"], POP2005 = state["POP2000"], Wkt = wkt});
                        i = i + 1;
                    }
                }
                cachedJson = utf8Grid.CreateUtfGridJson();
                this.HttpContext.Cache.Insert(key, cachedJson);
                return new ContentResult() { Content = cachedJson, ContentType = "application/json" };
            }
        }
All Usage Examples Of Mapstache.Utf8Grid::FillPolygon