PolylineBuilder Class

  • PolylineBuilder
  • class Esri::ArcGISRuntime::PolylineBuilder

    The polyline builder allows you to create and modify Polyline geometries incrementally. More...

    Header: #include <PolylineBuilder.h>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::MultipartBuilder

    Public Functions

    PolylineBuilder(const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)
    PolylineBuilder(const Esri::ArcGISRuntime::Polyline &polyline, QObject *parent = nullptr)
    virtual ~PolylineBuilder() override
    Esri::ArcGISRuntime::Polyline toPolyline() const

    Reimplemented Public Functions

    virtual Esri::ArcGISRuntime::GeometryBuilderType geometryBuilderType() const override
    virtual Esri::ArcGISRuntime::Geometry toGeometry() const override

    Detailed Description

    Polyline geometries are immutable and cannot be changed directly once created. The polyline builder allows you to change the contents of the shape by using the mutable PartCollection that is accessible from MultipartBuilder::parts. Each Part, in the collection, comprises a collection of segments that make the Part. You can add or remove a Part from the PartCollection, or you can create a new or edit the segment vertices of an existing Part. Use GeometryBuilder::toGeometry to return the new Polyline from the builder.

    // create a PolylineBuilder and a single-part polyline
    PolylineBuilder* builder = new PolylineBuilder(SpatialReference(4326), this);
    builder->addPoint(-117.0, 34.0);
    builder->addPoint(-118.0, 34.0);
    Polyline singleLine = builder->toPolyline();
    
    // create a multi-part polyline using the same PolylineBuilder
    Part* part1 = new Part(builder->spatialReference(), this);
    Part* part2 = new Part(builder->spatialReference(), this);
    part1->addPoint(-116.0, 33.0);
    part1->addPoint(-116.5, 33.5);
    part2->addPoint(-115.0, 33.0);
    part2->addPoint(-115.5, 33.5);
    PartCollection* pCollection = new PartCollection(builder->spatialReference(), this);
    pCollection->addPart(part1);
    pCollection->addPart(part2);
    builder->setParts(pCollection);
    Polyline multiPart = builder->toPolyline();

    Member Function Documentation

    [explicit] PolylineBuilder::PolylineBuilder(const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)

    Creates a new empty polyline builder with the specified SpatialReference.

    • spatialReference - The builder's spatial reference.
    • parent - The optional parent QObject.

    The SpatialReference cannot be changed after instantiation.

    [explicit] PolylineBuilder::PolylineBuilder(const Esri::ArcGISRuntime::Polyline &polyline, QObject *parent = nullptr)

    Creates a new polyline builder by copying the parts from the specified Polyline.

    • polyline - A polyline object.
    • parent - The optional parent QObject.

    The SpatialReference of the new polyline builder will match that of the given Polyline. Use this constructor in workflows that create a modified version of an existing geometry, for example feature or graphic editing workflows. Polylines with curves are supported.

    See also GeometryBuilder::hasCurves.

    [override virtual] PolylineBuilder::~PolylineBuilder()

    Destructor.

    [override virtual] Esri::ArcGISRuntime::GeometryBuilderType PolylineBuilder::geometryBuilderType() const

    Reimplements: GeometryBuilder::geometryBuilderType() const.

    Gets the GeometryBuilderType of this builder.

    [override virtual] Esri::ArcGISRuntime::Geometry PolylineBuilder::toGeometry() const

    Reimplements: GeometryBuilder::toGeometry() const.

    Returns the polyline geometry this builder is constructing or modifying.

    Esri::ArcGISRuntime::Polyline PolylineBuilder::toPolyline() const

    Returns the polyline geometry this builder is constructing or modifying. This is a convenience method to avoid having to cast the return value.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.