ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / QueryFirstLastM Method
The input polyline.
The first M-value that is not NaN.
The last M-value that is not NaN.
Example

In This Topic
    QueryFirstLastM Method (GeometryEngine)
    In This Topic
    Gets the first and last defined M-values in the polyline.
    Syntax
    public void QueryFirstLastM( 
       Polyline polyline,
       out double firstM,
       out double lastM
    )
    Public Sub QueryFirstLastM( _
       ByVal polyline As Polyline, _
       ByRef firstM As Double, _
       ByRef lastM As Double _
    ) 

    Parameters

    polyline
    The input polyline.
    firstM
    The first M-value that is not NaN.
    lastM
    The last M-value that is not NaN.

    Return Value

    The first and last defined M-values in the polyline. If the polyline is empty or all the M-values are NaN, then NaN values are returned.
    Exceptions
    ExceptionDescription
    Polyline is null.
    This geometry is not M-Aware.
    Example
    Get the first and last defined M-values in a polyline - QueryFirstLastM
    string json = "{\"hasM\":true,\"paths\":[[[5,4,6],[6,4,5],[8,6,7]],[[0,0,1],[0,1,0],[1,1,-1],[1,0,-2]]]}";
    Polyline polyline = PolylineBuilderEx.FromJson(json);
    
    double firstM, lastM;
    GeometryEngine.Instance.QueryFirstLastM(polyline, out firstM, out lastM);
    // firstM = 6, lastM = -2
    
    json = "{\"hasM\":true,\"paths\":[[[5,4,null],[6,4,5],[8,6,7]],[[0,0,1],[0,1,0],[1,1,-1],[1,0,null]]]}";
    polyline = PolylineBuilderEx.FromJson(json);
    
    GeometryEngine.Instance.QueryFirstLastM(polyline, out firstM, out lastM);
    // firstM = 5, lastM = -1
    
    json = "{\"hasM\":true,\"paths\":[[[5,4,null],[6,4,null],[8,6,null]],[[0,0,null],[0,1,null],[1,1,null],[1,0,null]]]}";
    polyline = PolylineBuilderEx.FromJson(json);
    
    GeometryEngine.Instance.QueryFirstLastM(polyline, out firstM, out lastM);
    // firstM and lastM are NaN
    
    json = "{\"hasM\":true,\"paths\":[]}";
    polyline = PolylineBuilderEx.FromJson(json);
    
    GeometryEngine.Instance.QueryFirstLastM(polyline, out firstM, out lastM);
    // firstM and lastM are NaN
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also