///<summary> /// Gets the union of the input geometries. /// If no input geometries were provided, a POINT EMPTY is returned. ///</summary> ///<returns>a Geometry containing the union</returns> /// <returns>an empty GEOMETRYCOLLECTION if no geometries were provided in the input</returns> public IGeometry Union() { if (_geomFact == null) { return(null); } IGeometry unionPoints = null; if (_points.Count > 0) { IGeometry ptGeom = _geomFact.BuildGeometry(convertPoints(_points).ToList()); unionPoints = UnionNoOpt(ptGeom); } IGeometry unionLines = null; if (_lines.Count > 0) { IGeometry lineGeom = _geomFact.BuildGeometry(convertLineStrings(_lines).ToList()); 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 */ IGeometry unionLA = UnionWithNull(unionLines, unionPolygons); IGeometry union = null; if (unionPoints == null) { union = unionLA; } else if (unionLA == null) { union = unionPoints; } else { union = PointGeometryUnion.Union((IPoint)unionPoints, unionLA); } if (union == null) { return(_geomFact.CreateGeometryCollection(null)); } return(union); }
///<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(IPoint pointGeom, IGeometry otherGeom) { PointGeometryUnion unioner = new PointGeometryUnion(pointGeom, otherGeom); return unioner.Union(); }
///<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(IPoint pointGeom, IGeometry otherGeom) { PointGeometryUnion unioner = new PointGeometryUnion(pointGeom, otherGeom); return(unioner.Union()); }