示例#1
0
        ///<summary>
        /// Computes the union of a <see cref="IPoint"/> geometry with
        /// another arbitrary <see cref="IGeometry"/>.
        /// Does not copy any component geometries.
        ///</summary>
        ///<param name="pointGeom"></param>
        ///<param name="otherGeom"></param>
        ///<returns></returns>
        public static IGeometry Union(IPuntal pointGeom, IGeometry otherGeom)
        {
            var unioner = new PointGeometryUnion(pointGeom, otherGeom);

            return(unioner.Union());
        }
示例#2
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);
        }