ArcGIS Pro 3.7 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
    Function SnapMsToSpatialReference( _
       ByVal geometry As Geometry _
    ) As Geometry
    Geometry SnapMsToSpatialReference( 
       Geometry 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(3, 4, sr)
      {
        M = 5.00006
      };
      MapPoint point = pointBuilder.ToGeometry();
      MapPoint outputPoint = GeometryEngine.Instance.SnapMsToSpatialReference(point) as MapPoint;
      // outputPoint.M = 5.0001
    
      // Multipoint
      MapPointBuilderEx mapPointBuilderEx = new(-3, -4, sr)
      {
        M = -5.000007
      };
      pointBuilder = mapPointBuilderEx;
      MapPoint point2 = pointBuilder.ToGeometry();
      Multipoint multipoint = MultipointBuilderEx.CreateMultipoint([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 = 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 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.3 or higher.
    See Also