protected internal Worker(CascadedPolygonUnion tool, IList <Geometry> geoms, int start, int end) { _tool = tool; _geoms = geoms; _start = start; _end = end; }
/// <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> /// <returns></returns> public static Geometry Union(ICollection <Geometry> polys) { var op = new CascadedPolygonUnion(polys); return(op.Union()); }
/// <summary> /// Gets the union of the input geometries. /// If no input geometries were provided but a <see cref="GeometryFactory"/> was provided, /// an empty <see cref="GeometryCollection"/> is returned. /// <para/>Otherwise, the return value is <c>null</c> /// </summary> /// <returns> /// A Geometry containing the union /// or an empty <see cref="GeometryCollection"/> if no geometries were provided in the input, /// or <c>null</c> if not GeometryFactory was provided /// </returns> public Geometry 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. */ Geometry unionPoints = null; if (_points.Count > 0) { var ptGeom = _geomFact.BuildGeometry(_points); unionPoints = UnionNoOpt(ptGeom); } Geometry unionLines = null; if (_lines.Count > 0) { var lineGeom = _geomFact.BuildGeometry(_lines); unionLines = UnionNoOpt(lineGeom); } Geometry 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); Geometry 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); }