ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / MovePointAlongLine Method
The multipart along which the point will be moved.
The distance to move the point.
Set the asRatio flag to be true if you want the distance to be a ratio of the curve length.
The offset distance.
Determines how and from where a segment is to be extended.
Example

In This Topic
    MovePointAlongLine Method (IGeometryEngine)
    In This Topic
    Constructs a point the specified distance along a polyline or polygon.
    Syntax

    Parameters

    multipart
    The multipart along which the point will be moved.
    distanceAlong
    The distance to move the point.
    asRatio
    Set the asRatio flag to be true if you want the distance to be a ratio of the curve length.
    offset
    The offset distance.
    extensionType
    Determines how and from where a segment is to be extended.
    Exceptions
    ExceptionDescription
    Multipart is null.
    Multipart is empty.
    Occurs if asRatio is true and the geometry has a 2d and 3d distance of 0.
    Remarks
    A positive offset distance will create a point on the right side of the curve and a negative offset will create a point on the left side of the curve.
    Example
    MovePointAlongLine
    LineSegment line = LineBuilderEx.CreateLineSegment(MapPointBuilderEx.CreateMapPoint(0, 3), MapPointBuilderEx.CreateMapPoint(5.0, 3.0));
    Polyline polyline = PolylineBuilderEx.CreatePolyline(line);
    bool simple = GeometryEngine.Instance.IsSimpleAsFeature(polyline);
    
    // ratio = false
    MapPoint pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 0.0, SegmentExtensionType.NoExtension);
    // pt = 1.0, 3.0
    
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, -1.0, SegmentExtensionType.NoExtension);
    // pt = 1.0, 4.0
    
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 1.0, false, 2.0, SegmentExtensionType.NoExtension);
    // pt = 1.0, 1.0
    
    // ratio = true
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtensionType.NoExtension);
    // pt = 2.5, 3.0
    
    // move past the line
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtensionType.NoExtension);
    // pt = 5.0, 3.0
    
    // move past the line with extension at "to" point
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 7, false, 0, SegmentExtensionType.ExtendEmbeddedAtTo);
    // pt = 7.0, 3.0
    
    // negative distance with extension at "from" point
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, -2, false, 0, SegmentExtensionType.ExtendEmbeddedAtFrom);
    // pt = -2.0, 3.0
    
    // ratio = true
    pt = GeometryEngine.Instance.MovePointAlongLine(polyline, 0.5, true, 0, SegmentExtensionType.NoExtension);
    // pt = 2.5, 3.0
    
    // line with Z
    List<Coordinate3D> coords3D = new List<Coordinate3D> { new Coordinate3D(0, 0, 0), new Coordinate3D(1113195, 1118890, 5000) };
    Polyline polylineZ = PolylineBuilderEx.CreatePolyline(coords3D, SpatialReferences.WebMercator);
    // polylineZ.HasZ = true
    
    // ratio = true, no offset
    pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 0.5, true, 0, SegmentExtensionType.NoExtension);
    // pt.X = 556597.5
    // pt.Y = 559445
    // pt.Z = 2500
    
    // ratio = true, past the line with "to" extension, no offset
    pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, 1.5, true, 0, SegmentExtensionType.ExtendEmbeddedAtTo);
    // pt.X = 1669792.5
    // pt.Y = 1678335
    // pt.Z = 7500
    
    // ratio = true, negative distance past the line with no extension, no offset
    pt = GeometryEngine.Instance.MovePointAlongLine(polylineZ, -1.5, true, 0, SegmentExtensionType.NoExtension);
    // pt.X = 0
    // pt.Y = 0
    // pt.Z = -7500
    
    // polyline with Z but 2d distance = 0
    MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(5, 5, 0);
    MapPoint pt4 = MapPointBuilderEx.CreateMapPoint(5, 5, 10);
    List<MapPoint> pts = new List<MapPoint>() { pt3, pt4 };
    
    polyline = PolylineBuilderEx.CreatePolyline(pts);
    // polyline.HasZ = true
    // polyline.Length3D = 10
    // polyline.Length = 0
    
    MapPoint result = GeometryEngine.Instance.MovePointAlongLine(polyline, 2, false, 0, SegmentExtensionType.NoExtension);
    // result = 5, 5, 2
    
    // polyline with length2d = 0 and length3d = 0
    MapPoint pt5 = MapPointBuilderEx.CreateMapPoint(5, 5, 10);
    MapPoint pt6 = MapPointBuilderEx.CreateMapPoint(5, 5, 10);
    pts.Clear();
    pts.Add(pt5);
    pts.Add(pt6);
    
    polyline = PolylineBuilderEx.CreatePolyline(pts);
    // polyline.HasZ = true
    // polyline.Length3D = 0
    // polyline.Length = 0
    
    result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtensionType.NoExtension);
    // result = 5, 5, 10
    
    result = GeometryEngine.Instance.MovePointAlongLine(polyline, 3, true, 0, SegmentExtensionType.ExtendEmbeddedAtFrom);
    // result = 5, 5, 10
    
    // polyline with Z and M
    List<MapPoint> inputPoints = new List<MapPoint>()
    {
        MapPointBuilderEx.CreateMapPoint(1, 2, 3, 4),
        MapPointBuilderEx.CreateMapPoint(1, 2, 33, 44),
    };
    
    Polyline polylineZM = PolylineBuilderEx.CreatePolyline(inputPoints, SpatialReferences.WGS84);
    // polylineZM.HasZ = true
    // polylineZM.HasM = true
    
    // ratio = true, no offset
    MapPoint pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.5, true, 0, SegmentExtensionType.NoExtension);
    // pointAlong = 1, 2, 18, 24
    
    // ratio = true with offset
    pointAlong = GeometryEngine.Instance.MovePointAlongLine(polylineZM, 0.2, true, 2.23606797749979, SegmentExtensionType.NoExtension);
    // pointAlong = 1, 2, 9, 12
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also