Exemple #1
0
        public static void DrawPolygon(Graphics graphics, Polygon pol, Brush brush, Pen pen, IViewport viewport)
        {
            if (pol.ExteriorRing == null)
            {
                return;
            }
            if (pol.ExteriorRing.Vertices.Count <= 2)
            {
                return;
            }

            //Use a graphics path instead of DrawPolygon. DrawPolygon has a problem with several interior holes
            var gp = new GraphicsPath();

            //Add the exterior polygon
            gp.AddPolygon(GeometryRenderer.ConvertPoints(GeometryRenderer.WorldToScreen(pol.ExteriorRing, viewport)));
            //Add the interior polygons (holes)
            foreach (LinearRing linearRing in pol.InteriorRings)
            {
                gp.AddPolygon(GeometryRenderer.ConvertPoints(GeometryRenderer.WorldToScreen(linearRing, viewport)));
            }

            // Only render inside of polygon if the brush isn't null or isn't transparent
            if (brush != null && brush != Brushes.Transparent)
            {
                graphics.FillPath(brush, gp);
            }
            // Create an outline if a pen style is available
            if (pen != null)
            {
                graphics.DrawPath(pen, gp);
            }
        }
Exemple #2
0
 public static void Render(Graphics graphics, LineString line, Pen pen, IViewport viewport)
 {
     if (line.Vertices.Count > 1)
     {
         var gp = new GraphicsPath();
         gp.AddLines(GeometryRenderer.ConvertPoints(GeometryRenderer.WorldToScreen(line, viewport)));
         graphics.DrawPath(pen, gp);
     }
 }