ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / QueryPointAndDistance Method / QueryPointAndDistance(Segment,SegmentExtensionType,MapPoint,AsRatioOrLength,Double,Double,LeftOrRightSide) Method
The curve on which to find the closest point. The curve may be extended.
Describes if, how and where to extend segments.
The input point.
Determines whether the distanceAlongCurve is returned as a ratio of the curve length or as length from the start point.
Describes how far along the closest point is along the curve, either as a ratio or length.
Describes how far the point is from the curve.
Describes if the point is on the left or right side of the curve. The direction of the curve determines its left and right sides. If the point is on the curve, then LeftSide is returned.
Example

In This Topic
    QueryPointAndDistance(Segment,SegmentExtensionType,MapPoint,AsRatioOrLength,Double,Double,LeftOrRightSide) Method
    In This Topic
    Finds the point on the curve closest to inPoint, then copies that point to outPoint. Also calculates related items.
    Syntax

    Parameters

    segment
    The curve on which to find the closest point. The curve may be extended.
    extensionType
    Describes if, how and where to extend segments.
    inPoint
    The input point.
    asRatioOrLength
    Determines whether the distanceAlongCurve is returned as a ratio of the curve length or as length from the start point.
    distanceAlongCurve
    Describes how far along the closest point is along the curve, either as a ratio or length.
    distanceFromCurve
    Describes how far the point is from the curve.
    whichSide
    Describes if the point is on the left or right side of the curve. The direction of the curve determines its left and right sides. If the point is on the curve, then LeftSide is returned.

    Return Value

    MapPoint representing the closest point on the curve.
    Exceptions
    ExceptionDescription
    Either segment or inPoint or both are null or empty.
    Spatial reference of segmentis an image coordinate system.
    Example
    QueryPointAndDistance
    // Horizontal line segment
    List<MapPoint> linePts = new List<MapPoint>();
    linePts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, SpatialReferences.WGS84));
    linePts.Add(MapPointBuilderEx.CreateMapPoint(11.0, 1.0, SpatialReferences.WGS84));
    Polyline polyline = PolylineBuilderEx.CreatePolyline(linePts);
    bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(polyline);
    
    // Don't extent the segment
    SegmentExtensionType extension = SegmentExtensionType.NoExtension;
    
    // A point on the line segment
    MapPoint inPoint = MapPointBuilderEx.CreateMapPoint(2, 1, SpatialReferences.WGS84);
    
    double distanceAlongCurve, distanceFromCurve;
    LeftOrRightSide whichSide;
    AsRatioOrLength asRatioOrLength = AsRatioOrLength.AsLength;
    
    MapPoint outPoint = GeometryEngine.Instance.QueryPointAndDistance(polyline, extension, inPoint, asRatioOrLength, out distanceAlongCurve, out distanceFromCurve, out whichSide);
    // outPoint = 2, 1
    // distanceAlongCurve = 1
    // distanceFromCurve = 0
    // whichSide = GeometryEngine.Instance.LeftOrRightSide.LeftSide
    
    
    // Extend infinitely in both directions
    extension = SegmentExtensionType.ExtendTangents;
    
    // A point on the left side
    inPoint = MapPointBuilderEx.CreateMapPoint(16, 6, SpatialReferences.WGS84);
    asRatioOrLength = AsRatioOrLength.AsRatio;
    
    outPoint = GeometryEngine.Instance.QueryPointAndDistance(polyline, extension, inPoint, asRatioOrLength, out distanceAlongCurve, out distanceFromCurve, out whichSide);
    // outPoint = 16, 1
    // distanceAlongCurve = 1.5
    // distanceFromCurve = 5
    // whichSide = GeometryEngine.Instance.LeftOrRightSide.LeftSide
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also