private MultipolygonShape BufferShape(BaseShape shape)
        {
            MultipolygonShape bufferedShape = null;

            if (capstyle == BufferCapType.Round)
            {
                bufferedShape = SqlTypesGeometryHelper.Buffer(shape, Distance, Smoothness, Capstyle, MapUnit, DistanceUnit);
            }
            else
            {
                bufferedShape = shape.Buffer(distance, smoothness, capstyle, mapUnit, distanceUnit);
            }
            return(bufferedShape);
        }
        public static Collection <AreaBaseShape> GetSplitResult(this AreaBaseShape polygon, Collection <LineShape> lines)
        {
            SqlGeometry polygonGeom = SqlGeometry.STGeomFromWKB(new SqlBytes(polygon.GetWellKnownBinary()), 0);

            if (!polygonGeom.STIsValid())
            {
                polygonGeom = polygonGeom.MakeValid();
            }
            //GeometryLibrary library = BaseShape.GeometryLibrary;
            //BaseShape.GeometryLibrary = GeometryLibrary.Unmanaged;
            foreach (var item in lines)
            {
                //MultipolygonShape multipolygon = item.Buffer(0.2, 8, BufferCapType.Square, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
                MultipolygonShape multipolygon     = SqlTypesGeometryHelper.Buffer(item, 0.2, 8, BufferCapType.Square, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
                SqlGeometry       multipolygonGeom = SqlGeometry.STGeomFromWKB(new SqlBytes(multipolygon.GetWellKnownBinary()), 0);
                if (!multipolygonGeom.STIsValid())
                {
                    multipolygonGeom = multipolygonGeom.MakeValid();
                }

                polygonGeom = polygonGeom.STDifference(multipolygonGeom);
            }

            //BaseShape.GeometryLibrary = library;

            byte[]    bytes = polygonGeom.STAsBinary().Value;
            BaseShape shape = BaseShape.CreateShapeFromWellKnownData(bytes) as AreaBaseShape;

            MultipolygonShape splittedMultipolygonShape = shape as MultipolygonShape;
            PolygonShape      splittedPolygonShape      = shape as PolygonShape;

            if (splittedMultipolygonShape == null && splittedPolygonShape != null)
            {
                splittedMultipolygonShape = new MultipolygonShape();
                splittedMultipolygonShape.Polygons.Add(splittedPolygonShape);
                shape = splittedMultipolygonShape;
            }

            Collection <AreaBaseShape> shapes = new Collection <AreaBaseShape>();

            if (splittedMultipolygonShape != null)
            {
                CloseSplittedPolygons(polygon, splittedMultipolygonShape, lines[0], GeographyUnit.DecimalDegree, DistanceUnit.Meter, .3);
                FillShapes(shapes, shape);
            }
            return(shapes);
        }