Parameters
- geometry1
- The base geometry.
- geometry2
- The comparison geometry.
Return Value
True if the geometry1 crosses geometry2.
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.0); bool crosses = GeometryEngine.Instance.Crosses(pt, pt2); // crosses = false crosses = GeometryEngine.Instance.Crosses(pt, pt); // crosses = 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); crosses = GeometryEngine.Instance.Crosses(line1, pt2); // crosses = false crosses = GeometryEngine.Instance.Crosses(pt2, line1); // crosses = false // end pt of line crosses = GeometryEngine.Instance.Crosses(line1, pt); // crosses = 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); crosses = GeometryEngine.Instance.Crosses(poly1, pt); // crosses = false crosses = GeometryEngine.Instance.Crosses(pt, poly1); // crosses = false // // 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); crosses = GeometryEngine.Instance.Crosses(line1, line2); // crosses = true // // line and polygon // crosses = GeometryEngine.Instance.Crosses(poly1, line1); // crosses = true // // polygon and polygon // Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4)); Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); crosses = GeometryEngine.Instance.Crosses(poly1, poly2); // crosses = false
Target Platforms: Windows 11, Windows 10