Touches Method (GeometryEngine)
Returns true if geometry1 touches geometry2.
Parameters
- geometry1
- The base geometry.
- geometry2
- The comparison geometry.
Return Value
True if geometry1 touches geometry2.
Polygon touches another Polygon
// two disjoint polygons
Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(4.0, 4.0), MapPointBuilderEx.CreateMapPoint(8, 8));
Polygon poly1 = PolygonBuilderEx.CreatePolygon(env);
Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(5, 5));
Polygon poly2 = PolygonBuilderEx.CreatePolygon(env2);
bool touches = GeometryEngine.Instance.Touches(poly1, poly2); // touches = false
// another polygon that touches the first
Envelope env3 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(4, 4));
Polygon poly3 = PolygonBuilderEx.CreatePolygon(env3);
touches = GeometryEngine.Instance.Touches(poly1, poly3); // touches = true
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.