public static IPolygon GeneratePolygon(IGeometry pl)
        {
            if (pl.IsEmpty || (pl is IPolyline) == false)
            {
                return(null);
            }
            var pc1 = (IPointCollection)pl;
            var pg  = new PolygonClass();
            var pc2 = (IPointCollection)pg;

            for (var i = 0; i < pc1.PointCount; i++)
            {
                var pt  = pc1.get_Point(i);
                var pt2 = new PointClass {
                    X = pt.X, Y = pt.Y
                };
                pc2.AddPoint(pt2);
            }

            var pt3 = pc1.get_Point(0);
            var pt4 = new PointClass {
                X = pt3.X, Y = pt3.Y
            };

            pc2.AddPoint(pt4);
            pg.Simplify();
            return(pg);
        }