public void CheckIntersection(Geometry baseGeom, Geometry testGeom) { // this line can be used to test for the presence of noding failures for // non-tricky cases // Geometry star = rr2; Console.WriteLine("Star:"); Console.WriteLine(baseGeom); Console.WriteLine("Rectangle:"); Console.WriteLine(testGeom); // test to see whether the basic overlay code fails try { var intTrial = baseGeom.Intersection(testGeom); NetTopologySuite.Utilities.Assert.IsTrue(intTrial != null); } catch (Exception) { _failureCount++; } // this will throw an intersection if a robustness error occurs, // stopping the run var intersection = SnapIfNeededOverlayOp.Intersection(baseGeom, testGeom); Console.WriteLine("Intersection:"); Console.WriteLine(intersection); }
public void PerformCascadedPolygonUnion() { var reader = new ShapefileReader("tnp_pol.shp"); var collection = reader.ReadAll().Where(e => e is IPolygon).ToList(); var u1 = collection[0]; for (var i = 1; i < collection.Count; i++) { u1 = SnapIfNeededOverlayOp.Overlay(u1, collection[i], SpatialFunction.Union); } var u2 = CascadedPolygonUnion.Union(collection); if (!u1.Equals(u2)) { Assert.Fail("failure"); } }
/// <summary> /// Computes a unary union with no extra optimization, and no short-circuiting. /// </summary> /// <remarks> /// Due to the way the overlay operations are implemented, this is still efficient in the case of linear and puntal geometries. /// </remarks> /// <param name="g0">A geometry</param> /// <returns>The union of the input geometry</returns> private Geometry UnionNoOpt(Geometry g0) { var empty = _geomFact.CreatePoint(); return(SnapIfNeededOverlayOp.Overlay(g0, empty, SpatialFunction.Union)); }
protected override Geometry Overlay(Geometry geom0, Geometry geom1, SpatialFunction opCode) { return(SnapIfNeededOverlayOp.Overlay(geom0, geom1, opCode)); }