ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / SnapMsToSpatialReference Method
The input geometry.
Example

In This Topic
    SnapMsToSpatialReference Method (IGeometryEngine)
    In This Topic
    Snaps the M-values to the M-precision (1 / MScale) of the spatial reference associated with the input geometry.
    Syntax
    Geometry SnapMsToSpatialReference( 
       Geometry geometry
    )
    Function SnapMsToSpatialReference( _
       ByVal geometry As Geometry _
    ) As Geometry

    Parameters

    geometry
    The input geometry.

    Return Value

    The geometry with the M-values snapped to the precision of the spatial reference. If the geometry is empty or the spatial reference is null, then the input geometry is returned unchanged.
    Exceptions
    ExceptionDescription
    Geometry is null.
    This geometry is not M-Aware.
    The method is not implemeted for GeometryBag.
    Example
    Snap the M-values to the M-precision of the spatial reference - SnapMsToSpatialReference
    SpatialReference sr = SpatialReferences.WebMercator;  // precision = 1 / MScale = 0.0001
    
    // MapPoint
    MapPointBuilderEx pointBuilder = new MapPointBuilderEx(3, 4, sr);
    pointBuilder.M = 5.00006;
    MapPoint point = pointBuilder.ToGeometry();
    MapPoint outputPoint = GeometryEngine.Instance.SnapMsToSpatialReference(point) as MapPoint;
    // outputPoint.M = 5.0001
    
    // Multipoint
    pointBuilder = new MapPointBuilderEx(-3, -4, sr);
    pointBuilder.M = -5.000007;
    MapPoint point2 = pointBuilder.ToGeometry();
    Multipoint multipoint = MultipointBuilderEx.CreateMultipoint(new MapPoint[] { point, point2 }, AttributeFlags.HasM, sr);
    Multipoint outputMultipoint = GeometryEngine.Instance.SnapMsToSpatialReference(multipoint) as Multipoint;
    // outputMultipoint.Points[0].M = 5.0001, outputMultipoint.Points[1].M = -5
    
    // Polyline
    string json = "{\"hasM\":true,\"paths\":[[[3,2,10.00065],[3,4,15.000325],[5,4,20],[5,2,15.000325],[3,2,10.00065]]],\"spatialReference\":{\"wkid\":3857}}";
    Polyline polyline = PolylineBuilderEx.FromJson(json);
    Polyline outputPolyline = GeometryEngine.Instance.SnapMsToSpatialReference(polyline) as Polyline;
    // The M-values for the vertices in outputPolyline are { 10.0007, 15.0003, 20, 15.0003, 10.0007 }
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.3 or higher.
    See Also