/// <summary>
        /// Encapsulates the actual unioning of two polygonal geometries.
        /// </summary>
        /// <param name="g0">A geometry to union</param>
        /// <param name="g1">A geometry to union</param>
        /// <param name="unionStrategy">A </param>
        /// <returns>The union of the inputs</returns>
        private static Geometry UnionActual(Geometry g0, Geometry g1, UnionStrategy unionStrategy)
        {
            var union     = unionStrategy.Union(g0, g1);
            var unionPoly = RestrictToPolygons(union);

            return(unionPoly);
        }
 /// <summary>
 /// Creates a new instance to union
 /// the given collection of <see cref="Geometry"/>s.
 /// </summary>
 /// <param name="polys">A collection of <see cref="IPolygonal"/> <see cref="Geometry"/>s</param>
 /// <param name="unionStrategy"></param>
 public CascadedPolygonUnion(ICollection <Geometry> polys, UnionStrategy unionStrategy)
 {
     _inputPolys    = polys;
     _unionStrategy = unionStrategy;
     // guard against null input
     if (_inputPolys == null)
     {
         _inputPolys = new List <Geometry>();
     }
     _countInput     = _inputPolys.Count;
     _countRemainder = _countInput;
 }
        /// <summary>
        /// Creates a new instance for unioning the given geometries.
        /// </summary>
        /// <param name="g0">A geometry to union</param>
        /// <param name="g1">A geometry to union</param>
        /// <param name="unionFun">Function to union two geometries</param>
        public OverlapUnion(Geometry g0, Geometry g1, UnionStrategy unionFun)
        {
            if (g0 == null)
            {
                throw new ArgumentNullException(nameof(g0));
            }

            _g0          = g0;
            _g1          = g1;
            _geomFactory = g0.Factory;
            _unionFun    = unionFun;
        }
        /// <summary>
        /// Computes the union of
        /// a collection of <see cref="Geometry"/>s.
        /// </summary>
        /// <param name="polys">A collection of <see cref="IPolygonal"/> <see cref="Geometry"/>s.</param>
        /// <param name="unionStrategy">A strategy to perform the unioning.</param>
        /// <returns>The union of the <paramref name="polys"/></returns>
        public static Geometry Union(ICollection <Geometry> polys, UnionStrategy unionStrategy)
        {
            var op = new CascadedPolygonUnion(polys, unionStrategy);

            return(op.Union());
        }
        /// <summary>
        /// Union a pair of geometries,
        /// using the more performant overlap union algorithm if possible.
        /// </summary>
        /// <param name="g0">A geometry to union</param>
        /// <param name="g1">A geometry to union</param>
        /// <param name="unionFun">Function to union two geometries</param>
        /// <returns>The union of the inputs</returns>
        public static Geometry Union(Geometry g0, Geometry g1, UnionStrategy unionFun)
        {
            var union = new OverlapUnion(g0, g1, unionFun);

            return(union.Union());
        }