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 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.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(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); 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(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); 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(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); crosses = GeometryEngine.Instance.Crosses(line1, line2); // crosses = true // // line and polygon // crosses = GeometryEngine.Instance.Crosses(poly1, line1); // crosses = true // // polygon and polygon // Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); Polygon poly2 = PolygonBuilder.CreatePolygon(env); crosses = GeometryEngine.Instance.Crosses(poly1, poly2); // crosses = false
Target Platforms: Windows 10, Windows 8.1, Windows 7