ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / Crosses Method
The base geometry.
The comparison geometry.
Example

In This Topic
    Crosses Method (IGeometryEngine)
    In This Topic
    Returns true if geometry1 crosses geometry2.
    Syntax
    Function Crosses( _
       ByVal geometry1 As Geometry, _
       ByVal geometry2 As Geometry _
    ) As Boolean

    Parameters

    geometry1
    The base geometry.
    geometry2
    The comparison geometry.

    Return Value

    True if the geometry1 crosses geometry2.
    Exceptions
    ExceptionDescription
    Either geometry1 or geometry2 or both are null.
    The method is not implemented for GeometryBag.
    Incompatible spatial references between the input geometries.
    Remarks
    A polyline crosses another polyline if they share only points in common, at least one of which is not an endpoint. A polyline crosses a polygon if at least one path of the polyline is partly inside the polygon and partly outside.

    GeometryEngine Crosses

    Example
    Determine if two geometries cross
    //
    // 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
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also