ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / UpdateMsByDistance Method
The input polyline.
The index of the part from which to start.
The index of the point (relative to the part) from which to start.
The index of the part from which to end.
The index of the point (relative to the part) from which to end.
The start M-value.
The end M-value.
The method to use when updating M-values. You can use a combination of update methods by using the bitwise OR operator. For example, to interpolate between the input points and to extrapolate before the input points, useUpdateMMethod.Interpolate | UpdateMMethod.ExtrapolateBefore.
Determines whether distances between parts of the polyline should be ignored or not.
Example

In This Topic
    UpdateMsByDistance Method (GeometryEngine)
    In This Topic
    Updates M-values along the shortest path between the specified vertices. The interpolation ratio is determined by the input M-values and Euclidean distance along that path.
    Syntax
    Public Function UpdateMsByDistance( _
       ByVal polyline As Polyline, _
       ByVal fromPartIndex As Integer, _
       ByVal fromPointIndex As Integer, _
       ByVal toPartIndex As Integer, _
       ByVal toPointIndex As Integer, _
       ByVal fromM As Double, _
       ByVal toM As Double, _
       ByVal updateMMethod As UpdateMMethod, _
       ByVal ignoreGaps As Boolean _
    ) As Polyline

    Parameters

    polyline
    The input polyline.
    fromPartIndex
    The index of the part from which to start.
    fromPointIndex
    The index of the point (relative to the part) from which to start.
    toPartIndex
    The index of the part from which to end.
    toPointIndex
    The index of the point (relative to the part) from which to end.
    fromM
    The start M-value.
    toM
    The end M-value.
    updateMMethod
    The method to use when updating M-values. You can use a combination of update methods by using the bitwise OR operator. For example, to interpolate between the input points and to extrapolate before the input points, useUpdateMMethod.Interpolate | UpdateMMethod.ExtrapolateBefore.
    ignoreGaps
    Determines whether distances between parts of the polyline should be ignored or not.

    Return Value

    A polyline with updated M-values. If the input polyline is empty, then it is returned unchanged.
    Exceptions
    ExceptionDescription
    The input polyline is null.
    The geometry is not M-Aware.
    The spatial reference is an image coordinate system.
    fromPartIndex or fromPointIndex or toPartIndex or toPointIndex is negative.
    toPartIndex is less than fromPartIndex.
    The extrapolation range is invalid.
    fromPartIndex or toPartIndex is greater than or equal to the number of parts in the multipart.
    fromPointIndex or toPointIndex is greater than or equal to the number of points in the specified part.
    Example
    Update M-values along the shortest path between the specified vertices - UpdateMsByDistance
    string json = "{\"hasM\":true,\"paths\":[[[-8,2,1],[-8,5,8],[-5,5,0],[-5,7,12]]],\"spatialReference\":{\"wkid\":4326}}";
    Polyline polyline = PolylineBuilderEx.FromJson(json);
    
    Polyline outputPolyline = GeometryEngine.Instance.UpdateMsByDistance(polyline, 0, 0, 0, 2, 10, 20, UpdateMMethod.Interpolate, true);
    // The xy-coordinates don't change.
    // The M-values of the vertices in outputPolyline are { 10, 15, 20, 12 }
    
    json = "{\"hasM\":true,\"paths\":[[[-8,2,1],[-8,5,8],[-5,5,0],[-5,7,12]],[[3,2,20],[7,2,30],[7,4,10],[13,4,5]]]}";
    polyline = PolylineBuilderEx.FromJson(json);
    
    outputPolyline = GeometryEngine.Instance.UpdateMsByDistance(polyline, 0, 2, 1, 1, 10, 20, UpdateMMethod.ExtrapolateBefore, true);
    // The M-values of the vertices in part 0 of outputPolyline are { -5, 2.5, 10, 5 }
    // The M-values of the vertices in part 1 of outputPolyline are { 20, 20, 10, 5 }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also