Parameters
- geometry1
- the Geometry instance on the left hand side of the subtraction.
- geometry2
- the Geometry on the right hand side being subtracted.
Exception | Description |
---|---|
System.ArgumentNullException | Either geometry1 or geometry2 or both are null or empty. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.InvalidOperationException | Incompatible spatial references between the input geometries. |
List<MapPoint> polyPts = new List<MapPoint>(); polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 2.0)); polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 6.0)); polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 6.0)); polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 2.0)); Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts); Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); Geometry result = GeometryEngine.Instance.Difference(poly1, poly2); Polygon polyResult = result as Polygon; // polyResult.Area = 10.0 result = GeometryEngine.Instance.Difference(poly2, poly1); polyResult = result as Polygon; // polyResult.Area = 7.0
Target Platforms: Windows 11, Windows 10