All Implemented Interfaces:
JsonSerializable

public final class Polyline extends Multipart
A multipart shape used to represent a linear feature.

Polyline geometries represent the shape and location of linear features such as a street in a road network, a contour line representing an elevation value, or a hiking trail. They can be used to define geometry for features and graphics, or as input or output for tasks or geoprocessing operations, such as the output of a network trace.

A Polyline is composed of a series of connected segments, where each segment defines a continuous line between a start and an end point. You can define a new Polyline from a collection of Point to create a series of straight LineSegment connecting the points you specified. You can use PolylineBuilder to build a polyline one point at a time or to modify an existing Polyline.

Additionally, Polyline can have multiple parts. Each part is a series of connected segments, but the parts can be disjoint. For example, a polyline representing a street that ends and then starts again a block later. Parts can also intersect at one or more vertices. For example, in a polyline representing a river and its tributaries. The Polyline class inherits from Multipart, which provides members for iterating the segments and points of each part in a Polyline.

Polyline inherits from Geometry. Geometry is immutable, meaning that its shape cannot be changed after it is created. If you need to modify a Polyline after it has been created, use PolylineBuilder instead. GeometryBuilder.toGeometry() provides the polyline object.

A Polyline can be used as the geometry of a feature or graphic. To obtain the geometry, use Feature.getGeometry() or Graphic.getGeometry().

Since:
100.0.0
See Also:
  • Constructor Details

    • Polyline

      public Polyline(PointCollection points)
      Creates a new immutable Polyline containing a copy of the Points in the given PointCollection. The SpatialReference of the new Polyline will match that of the given PointCollection.
      Parameters:
      points - the PointCollection used to initialise the new Polyline
      Since:
      100.0.0
    • Polyline

      public Polyline(PointCollection points, SpatialReference spatialReference)
      Creates a new Polyline containing a copy of the Points in the given PointCollection, and with the given SpatialReference.

      This overload can be used to create a new Polyline with a specific SpatialReference from an existing PointCollection that has a null SpatialReference (the points are assigned the given SpatialReference-they are not projected).

      Parameters:
      points - the PointCollection containing points copied to the new Polyline
      spatialReference - the SpatialReference of the new Polyline
      Throws:
      ArcGISRuntimeException - if the SpatialReference of points does not match the match the spatialReference argument.
      Since:
      100.0.0
    • Polyline

      public Polyline(Part part)
      Creates a new immutable Polyline containing a copy of the given Part. The SpatialReference of the new Polyline will match that of the given Part.
      Parameters:
      part - the Part used to initialise the new Polyline
      Since:
      100.0.0
    • Polyline

      public Polyline(Part part, SpatialReference spatialReference)
      Creates a new Polyline containing a copy of the given Part, and with the given SpatialReference.
      Parameters:
      part - the Part to copy to the new Polyline
      spatialReference - the SpatialReference of the new Polyline
      Throws:
      ArcGISRuntimeException - if the SpatialReference of part does not match the match the spatialReference argument.
      Since:
      100.0.0
    • Polyline

      public Polyline(PartCollection parts)
      Creates a new immutable Polyline containing a copy of the given PartCollection. The SpatialReference of the new Polyline will match that of the given PartCollection.
      Parameters:
      parts - the PartCollection used to initialise the new Polyline
      Since:
      100.0.0
    • Polyline

      public Polyline(PartCollection parts, SpatialReference spatialReference)
      Creates a new Polyline containing a copy of the given PartCollection, and with the given SpatialReference.
      Parameters:
      parts - the PartCollection to be copied to the new Polyline
      spatialReference - the SpatialReference of the new Polyline
      Throws:
      ArcGISRuntimeException - if the SpatialReference of parts does not match the match the spatialReference argument.
      Since:
      100.0.0