Beispiel #1
0
 protected internal Worker(CascadedPolygonUnion tool, IList <IGeometry> geoms, int start, int end)
 {
     _tool  = tool;
     _geoms = geoms;
     _start = start;
     _end   = end;
 }
Beispiel #2
0
        /// <summary>
        /// Computes the union of
        /// a collection of <see cref="IGeometry"/>s.
        /// </summary>
        /// <param name="polys">A collection of <see cref="IPolygonal"/> <see cref="IGeometry"/>s.</param>
        /// <returns></returns>
        public static IGeometry Union(ICollection <IGeometry> polys)
        {
            var op = new CascadedPolygonUnion(polys);

            return(op.Union());
        }
Beispiel #3
0
        ///<summary>
        /// Gets the union of the input geometries.
        /// If no input geometries were provided but a <see cref="IGeometryFactory"/> was provided,
        /// an empty <see cref="IGeometryCollection"/> is returned.
        /// <para/>Otherwise, the return value is <c>null</c>
        ///</summary>
        /// <returns>
        /// A Geometry containing the union
        /// or an empty <see cref="IGeometryCollection"/> if no geometries were provided in the input,
        /// or <c>null</c> if not GeometryFactory was provided
        /// </returns>
        public IGeometry Union()
        {
            if (_geomFact == null)
            {
                return(null);
            }

            /**
             * For points and lines, only a single union operation is
             * required, since the OGC model allows self-intersecting
             * MultiPoint and MultiLineStrings.
             * This is not the case for polygons, so Cascaded Union is required.
             */
            IGeometry unionPoints = null;

            if (_points.Count > 0)
            {
                IGeometry ptGeom = _geomFact.BuildGeometry(_points);
                unionPoints = UnionNoOpt(ptGeom);
            }

            IGeometry unionLines = null;

            if (_lines.Count > 0)
            {
                IGeometry lineGeom = _geomFact.BuildGeometry(_lines);
                unionLines = UnionNoOpt(lineGeom);
            }

            IGeometry unionPolygons = null;

            if (_polygons.Count > 0)
            {
                unionPolygons = CascadedPolygonUnion.Union(_polygons);
            }

            /*
             * Performing two unions is somewhat inefficient,
             * but is mitigated by unioning lines and points first
             */
            var       unionLA = UnionWithNull(unionLines, unionPolygons);
            IGeometry union;

            if (unionPoints == null)
            {
                union = unionLA;
            }
            else if (unionLA == null)
            {
                union = unionPoints;
            }
            else
            {
                union = PointGeometryUnion.Union((IPuntal)unionPoints, unionLA);
            }

            if (union == null)
            {
                return(_geomFact.CreateGeometryCollection());
            }

            return(union);
        }