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 or empty. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.InvalidOperationException | Incompatible spatial references between the input geometries. |
// // pt on pt // MapPoint pt = MapPointBuilder.CreateMapPoint(1.0, 1.0); MapPoint pt2 = MapPointBuilder.CreateMapPoint(2.0, 2.5); bool disjoint = GeometryEngine.Instance.Disjoint(pt, pt2); // result is true using (MultipointBuilder mpb = new MultipointBuilder()) { mpb.Add(pt); mpb.Add(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(MapPointBuilder.CreateMapPoint(1.0, 1.0)); list.Add(MapPointBuilder.CreateMapPoint(3.0, 3.0)); list.Add(MapPointBuilder.CreateMapPoint(5.0, 1.0)); Polyline line1 = PolylineBuilder.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(MapPointBuilder.CreateMapPoint(3.0, 2.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); Polygon poly1 = PolygonBuilder.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(MapPointBuilder.CreateMapPoint(1.0, 3.0)); list2.Add(MapPointBuilder.CreateMapPoint(3.0, 1.0)); list2.Add(MapPointBuilder.CreateMapPoint(5.0, 3.0)); Polyline line2 = PolylineBuilder.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 = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); Polygon poly2 = PolygonBuilder.CreatePolygon(env); disjoint = GeometryEngine.Instance.Disjoint(poly1, poly2); // result is false // disjoint3D SpatialReference sr = SpatialReferences.WGS84; MapPoint pt3D_1 = MapPointBuilder.CreateMapPoint(1, 1, 1, sr); MapPoint pt3D_2 = MapPointBuilder.CreateMapPoint(2, 2, 2, sr); MapPoint pt3D_3 = MapPointBuilder.CreateMapPoint(1, 1, 2, sr); using (MultipointBuilder mpb = new MultipointBuilder()) { mpb.Add(pt3D_1); mpb.Add(pt3D_2); mpb.HasZ = true; Multipoint multiPoint = mpb.ToGeometry(); disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_2); // disjoint = false disjoint = GeometryEngine.Instance.Disjoint3D(multiPoint, pt3D_3); // disjoint = true }
Target Platforms: Windows 10, Windows 8.1, Windows 7