ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / GetDistancesAtM Method
The multipart from which to get the distances.
Indicates whether the distances should be returned as lengths or ratios along the multipart.
The M-value from which to get the distances.
Example

In This Topic
    GetDistancesAtM Method (IGeometryEngine)
    In This Topic
    Gets a list of distances along the multipart at points with the specified M-value.
    Syntax

    Parameters

    multipart
    The multipart from which to get the distances.
    asRatioOrLength
    Indicates whether the distances should be returned as lengths or ratios along the multipart.
    mValue
    The M-value from which to get the distances.

    Return Value

    A list of distances. If the input M-value is NaN or cannot be found, then an empty list is returned.
    Exceptions
    ExceptionDescription
    The input multipart is null.
    The input multipart is not M-Aware.
    Example
    Get a list of distances along the multipart at points with the specified M-value - GetDistancesAtM
    string json = "{\"hasM\":true,\"paths\":[[[-4,1,1],[-4,3,2],[-2,3,3],[-2,5,1]],[[3,5,1],[3,2,2],[6,2,3],[6,-2,2]]]}";
    Polyline polyline = PolylineBuilderEx.FromJson(json);
    
    // Get the distances as length measured from the start of the multipart
    IReadOnlyList<double> distances = GeometryEngine.Instance.GetDistancesAtM(polyline, AsRatioOrLength.AsLength, 2);
    // distances.Count = 4
    // distances[0] = 2 measured to the point (-4, 3, 2)
    // distances[1] = 5 measured to the point (-2, 4, 2). Its M-value is interpolated from the segment (-2, 3, 3) -> (-2, 5, 1)
    // distances[2] = 9 measured to the point (3, 2, 2) 
    // distances[3] = 16 measured to the point (6, -2, 2)
    
    // Get the distances as a ratio of the distance measured from the start of the multipart and the total length of the multipart
    distances = GeometryEngine.Instance.GetDistancesAtM(polyline, AsRatioOrLength.AsRatio, 2);
    // distances.Count = 4;
    // distances are { 0.125, 0.3125, 0.5625, 1 }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also