OffsetMs Method (GeometryEngine)
Parameters
- geometry
- The input geometry. Cannot be a GeometryBag.
- offset
- The offset value to add to each M-value.
Return Value
A geometry with the offset value added to each of the M-values. If is NaN or is empty, then the input geometry is returned unchanged.
Add an offset value to each of the M-values - OffsetMs
// Create a polyline and add an offset of 2 to each of the M-values
MapPointBuilderEx pointBuilder = new MapPointBuilderEx(0, 0);
pointBuilder.M = 1;
MapPoint point1 = pointBuilder.ToGeometry();
pointBuilder.SetValues(2, 2);
pointBuilder.M = 3;
MapPoint point2 = pointBuilder.ToGeometry();
Polyline polyline = PolylineBuilderEx.CreatePolyline(new MapPoint[] { point1, point2 }, AttributeFlags.HasM); ;
Polyline outPolyline = GeometryEngine.Instance.OffsetMs(polyline, 2) as Polyline;
// The xy-values of the points in outPolyline are the same as the points in the input polyline.
// The M-values in outPolyline are { 3, 5 }
// Create an envelope and add an offset of 25 to each of the M-values
EnvelopeBuilderEx envelopeBuilder = new EnvelopeBuilderEx(-5, 1, 2, 4);
envelopeBuilder.MMin = 10;
envelopeBuilder.MMax = 20;
Envelope envelope = envelopeBuilder.ToGeometry();
Envelope outEnvelope = GeometryEngine.Instance.OffsetMs(envelope, 25) as Envelope;
// The xy-values of the points in outEnvelope are the same as the points in the input envelope.
// outEnvelope.MMin = 35, outEnvelope.MMax = 45
// Add a negative offset to the M-values of the envelope
outEnvelope = GeometryEngine.Instance.OffsetMs(envelope, -10) as Envelope;
// The xy-values of the points in outEnvelope are the same as the points in the input envelope.
// outEnvelope.MMin = 0, outEnvelope.MMax = 10
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3.3 or higher.