Parameters
- geometry1
- The base geometry.
- geometry2
- The comparison geometry.
Return Value
True if geometry1 and geometry2 are disjoint.
Exception | Description |
---|---|
System.ArgumentNullException | Either geometry1 or geometry2 or both are null. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.InvalidOperationException | Incompatible spatial references between the input geometries. |
// // pt on pt // MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.5); bool disjoint = GeometryEngine.Instance.Disjoint(pt, pt2); // result is true MultipointBuilderEx mpb = new MultipointBuilderEx(); mpb.AddPoint(pt); mpb.AddPoint(pt2); Multipoint multiPoint = mpb.ToGeometry(); disjoint = GeometryEngine.Instance.Disjoint(multiPoint, pt); // result is false // // pt and line // List<MapPoint> list = new List<MapPoint>(); list.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0)); list.Add(MapPointBuilderEx.CreateMapPoint(3.0, 3.0)); list.Add(MapPointBuilderEx.CreateMapPoint(5.0, 1.0)); Polyline line1 = PolylineBuilderEx.CreatePolyline(list); disjoint = GeometryEngine.Instance.Disjoint(line1, pt2); // result is true disjoint = GeometryEngine.Instance.Disjoint(pt2, line1); // result is true // end pt of line disjoint = GeometryEngine.Instance.Disjoint(line1, pt); // result is false // // pt and polygon // 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); disjoint = GeometryEngine.Instance.Disjoint(poly1, pt); // result is true disjoint = GeometryEngine.Instance.Disjoint(pt, poly1); // result is true // // line and line // List<MapPoint> list2 = new List<MapPoint>(); list2.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0)); list2.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0)); list2.Add(MapPointBuilderEx.CreateMapPoint(5.0, 3.0)); Polyline line2 = PolylineBuilderEx.CreatePolyline(list2); disjoint = GeometryEngine.Instance.Disjoint(line1, line2); // result is false // // line and polygon // disjoint = GeometryEngine.Instance.Disjoint(poly1, line1); // result is false disjoint = GeometryEngine.Instance.Disjoint(line1, poly1); // result is false // // polygon and polygon // Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); disjoint = GeometryEngine.Instance.Disjoint(poly1, poly2); // result is false // disjoint3D SpatialReference sr = SpatialReferences.WGS84; MapPoint pt3D_1 = MapPointBuilderEx.CreateMapPoint(1, 1, 1, sr); MapPoint pt3D_2 = MapPointBuilderEx.CreateMapPoint(2, 2, 2, sr); MapPoint pt3D_3 = MapPointBuilderEx.CreateMapPoint(1, 1, 2, sr); MultipointBuilderEx mpbEx = new MultipointBuilderEx(); mpbEx.AddPoint(pt3D_1); mpbEx.AddPoint(pt3D_2); mpbEx.HasZ = true; multiPoint = mpbEx.ToGeometry(); disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_2); // disjoint = false disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_3); // disjoint = true
Target Platforms: Windows 11, Windows 10