public void CanCutPolygonWithCorrectZ_Top4666() { // Tests the work-around for TOP-4666 // TODO: Report ArcObjects bug to Esri Inc. IFeature polygonFeature = TestUtils.CreateMockFeature("PolygonTop4666.xml"); var cutLine = (IPolyline) TestUtils.ReadGeometryFromXml( TestUtils.GetGeometryTestDataPath("CutLineTop4666.xml")); GeometryUtils.EnsureSpatialReference( cutLine, polygonFeature.Shape.SpatialReference); var cutter = new FeatureCutter(new[] { polygonFeature }); Stopwatch watch = Stopwatch.StartNew(); cutter.Cut(cutLine); watch.Stop(); Console.WriteLine("Cut large feature: {0}ms", watch.ElapsedMilliseconds); Assert.AreEqual(5, cutter.ResultGeometriesByFeature[polygonFeature].Count); foreach (IGeometry geometry in cutter.ResultGeometriesByFeature[ polygonFeature]) { var polygon = (IPolygon)geometry; Assert.False(GeometryUtils.HasUndefinedZValues(polygon)); GeometryUtils.Simplify(polygon); Assert.False(GeometryUtils.HasUndefinedZValues(polygon)); foreach (IPoint point in GeometryUtils.GetPoints( (IPointCollection)polygon)) { Assert.AreNotEqual(0, point.Z); } IPolyline resultAsPolyline = GeometryFactory.CreatePolyline(polygon); IPolyline zDifference = ReshapeUtils.GetZOnlyDifference(resultAsPolyline, cutLine); // ArcObjects uses the cutLine's Z also at the intersection points. // Do the same in CustomIntersect? Assert.IsNull(zDifference); } }
public void CanCalculateDifferenceInLargeGeometry() { const int manyPointsPerPart = 123456; const int holes = 3; IPolygon poly2a = CreatePunchedSquarePolygon("2a", manyPointsPerPart, holes, 1); GeometryUtils.Simplify(poly2a, true, true); IPolygon poly2b = GeometryFactory.Clone(poly2a); var watch = new Stopwatch(); watch.Start(); IPolyline line2a = GeometryFactory.CreatePolyline(poly2a); IPolyline line2b = GeometryFactory.CreatePolyline(poly2b); watch.Stop(); Console.WriteLine(@"Created polylines in {0} ms", watch.ElapsedMilliseconds); watch.Reset(); watch.Start(); IPolyline result = ReshapeUtils.GetZOnlyDifference(line2a, line2b); watch.Stop(); Assert.IsNull(result); Console.WriteLine(@"Calculate Z-only difference (no changes) in {0} ms", watch.ElapsedMilliseconds); var comparison = new GeometryComparison(line2a, line2b); watch.Reset(); watch.Start(); IDictionary <WKSPointZ, VertexIndex> differences = comparison.GetDifference(true); watch.Stop(); Console.WriteLine(@"Calculate Difference (no changes) in {0} ms", watch.ElapsedMilliseconds); Assert.AreEqual(0, differences.Count); }
public void CanCalculateDifferenceInHugeLockergestein() { string filePath = TestData.GetHugeLockergesteinPolygonPath(); var poly1 = (IPolygon)ReadGeometryFromXML(filePath); Console.WriteLine(@"{0}: {1}", @"Intersection Tests with 'Huge Lockergestein'", GetVertexString(poly1)); IPolygon poly2 = GeometryFactory.Clone(poly1); var watch = new Stopwatch(); watch.Start(); IPolyline result = ReshapeUtils.GetZOnlyDifference( GeometryFactory.CreatePolyline(poly1), GeometryFactory.CreatePolyline(poly2)); watch.Stop(); Console.WriteLine( @"Calculated Z difference in huge Lockergestein (no difference) in {0} ms", watch.ElapsedMilliseconds); Assert.IsNull(result); // Change few points in Z IPoint point7 = ((IPointCollection)poly2).get_Point(7); point7.Z += 0.01; ((IPointCollection)poly2).UpdatePoint(7, point7); IPoint point8 = ((IPointCollection)poly2).get_Point(8); point8.Z += 0.01; ((IPointCollection)poly2).UpdatePoint(8, point8); watch.Reset(); watch.Start(); result = ReshapeUtils.GetZOnlyDifference( GeometryFactory.CreatePolyline(poly1), GeometryFactory.CreatePolyline(poly2), 0.0); watch.Stop(); Console.WriteLine( @"Calculated Z difference in huge Lockergestein (2 different) in {0} ms", watch.ElapsedMilliseconds); Assert.IsNotNull(result); Assert.IsFalse(result.IsEmpty); double changedLength = ((ISegmentCollection)poly2).Segment[6].Length + ((ISegmentCollection)poly2).Segment[7].Length + ((ISegmentCollection)poly2).Segment[8].Length; Assert.AreEqual(Math.Round(changedLength, 5), Math.Round(result.Length, 5)); GeometryUtils.MoveGeometry(poly2, 0, 0, 0.5); watch.Reset(); watch.Start(); result = ReshapeUtils.GetZOnlyDifference( GeometryFactory.CreatePolyline(poly1), GeometryFactory.CreatePolyline(poly2)); watch.Stop(); Console.WriteLine( @"Calculated Z difference in huge Lockergestein (all different) in {0} ms", watch.ElapsedMilliseconds); Assert.IsNotNull(result); Assert.IsFalse(result.IsEmpty); Assert.AreEqual(Math.Round(poly2.Length, 5), Math.Round(result.Length, 5)); }