/// <summary> /// Computes the union of the input geometries. /// </summary> /// <returns> /// <remarks> /// This method discards the input geometries as they are processed. /// In many input cases this reduces the memory retained /// as the operation proceeds. /// Optimal memory usage is achieved /// by disposing of the original input collection /// before calling this method. /// </remarks> /// The union of the input geometries, /// or <c>null</c> if no input geometries were provided /// </returns> /// <exception cref="InvalidOperationException">if this method is called more than once</exception> public Geometry Union() { if (_inputPolys == null) { throw new InvalidOperationException("Union() method cannot be called twice"); } if (_inputPolys.Count == 0) { return(null); } _geomFactory = Factory(); /* * A spatial index to organize the collection * into groups of close geometries. * This makes unioning more efficient, since vertices are more likely * to be eliminated on each round. */ var index = new STRtree <object>(STRtreeNodeCapacity); foreach (var item in _inputPolys) { index.Insert(item.EnvelopeInternal, item); } // To avoiding holding memory remove references to the input geometries, _inputPolys = null; var itemTree = index.ItemsTree(); var unionAll = UnionTree(itemTree); return(unionAll); }
public IGeometry Union() { if (inputPolys.Count == 0) { return(null); } geomFactory = Factory(); /** * A spatial index to organize the collection * into groups of close geometries. * This makes unioning more efficient, since vertices are more likely * to be eliminated on each round. */ var index = new STRtree(StrtreeNodeCapacity); foreach (IGeometry item in inputPolys) { index.Insert(item.EnvelopeInternal, item); } var itemTree = index.ItemsTree(); var unionAll = UnionTree(itemTree); return(unionAll); }
/// <summary> /// Computes the union of the input geometries. /// </summary> /// <returns> /// The union of the input geometries /// or <value>null</value> if no input geometries were provided</returns> public IGeometry Union() { if (_inputPolys.Count == 0) { return(null); } _geomFactory = Factory(); /* * A spatial index to organize the collection * into groups of close geometries. * This makes unioning more efficient, since vertices are more likely * to be eliminated on each round. */ var index = new STRtree <object>(StrtreeNodeCapacity); foreach (IGeometry item in _inputPolys) { index.Insert(item.EnvelopeInternal, item); } var itemTree = index.ItemsTree(); var unionAll = UnionTree(itemTree); //#if UseWorker // System.Diagnostics.Debug.WriteLine(string.Format("CascadedPolygonUnion:\nItemsTree {0}, Threads {1}", itemTree.Count, _numThreadsStarted)); //#endif return(unionAll); }
/// <summary> /// Computes the union of the input geometries. /// </summary> /// <returns> /// <remarks> /// This method discards the input geometries as they are processed. /// In many input cases this reduces the memory retained /// as the operation proceeds. /// Optimal memory usage is achieved /// by disposing of the original input collection /// before calling this method. /// </remarks> /// The union of the input geometries, /// or <c>null</c> if no input geometries were provided /// </returns> /// <exception cref="InvalidOperationException">if this method is called more than once</exception> public IGeometry Union() { if (_inputPolys == null) throw new InvalidOperationException("Union() method cannot be called twice"); if (_inputPolys.Count == 0) return null; _geomFactory = Factory(); /* * A spatial index to organize the collection * into groups of close geometries. * This makes unioning more efficient, since vertices are more likely * to be eliminated on each round. */ var index = new STRtree<object>(StrtreeNodeCapacity); foreach (IGeometry item in _inputPolys) index.Insert(item.EnvelopeInternal, item); // To avoiding holding memory remove references to the input geometries, _inputPolys = null; var itemTree = index.ItemsTree(); var unionAll = UnionTree(itemTree); return unionAll; }