;

PolygonBuilder Class

  • PolygonBuilder
  • class Esri::ArcGISRuntime::PolygonBuilder

    Helper class for building immutable polygon geometries. More...

    Header: #include <PolygonBuilder>
    Since: Esri::ArcGISRuntime 100.0
    Inherits: Esri::ArcGISRuntime::MultipartBuilder

    This class was introduced in Esri::ArcGISRuntime 100.0.

    Public Functions

    PolygonBuilder(const Esri::ArcGISRuntime::Polygon &polygon, QObject *parent = nullptr)
    PolygonBuilder(const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)
    virtual ~PolygonBuilder() override
    Esri::ArcGISRuntime::Polygon toPolygon() const
    Esri::ArcGISRuntime::Polyline toPolyline() const

    Reimplemented Public Functions

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

    Detailed Description

    The initial shape stored in the builder can be initialized in the constructors by passing in existing geometries or collections. Change the contents of the shape by using the mutable PartCollection accessible from the parts() getter. Call the toGeometry method to create a new immutable Polygon from the current state of this builder.

    // create a polygon builder
    PolygonBuilder* polygonBuilder = new PolygonBuilder(SpatialReference(3857), this);
    
    // create a single-part polygon using x/y
    polygonBuilder->addPoint(-18.0, 34.0);
    polygonBuilder->addPoint(-18.0, 35.0);
    polygonBuilder->addPoint(-17.0, 34.0);
    Polygon singlePartPolygonXY(polygonBuilder->toGeometry());
    
    // create a multi-part polygon with same PolygonBuilder
    PartCollection* partCollection = new PartCollection(polygonBuilder->spatialReference(), this);
    
    // create outer poly 1
    Part* part1 = new Part(polygonBuilder->spatialReference(), this);
    part1->addPoint(2.123456789, 3.123456789);
    part1->addPoint(1.123456789, 3.123456789);
    part1->addPoint(1.123456789, 1.123456789);
    partCollection->addPart(part1);
    
    // create outer poly 2
    Part* part2 = new Part(polygonBuilder->spatialReference(), this);
    part2->addPoint(3.123456789, 3.123456789);
    part2->addPoint(4.123456789, 3.123456789);
    part2->addPoint(4.123456789, 1.123456789);
    partCollection->addPart(part2);
    
    polygonBuilder->setParts(partCollection);
    
    Polygon multipartPolygon = polygonBuilder->toPolygon();

    Member Function Documentation

    PolygonBuilder::PolygonBuilder(const Esri::ArcGISRuntime::Polygon &polygon, QObject *parent = nullptr)

    Constructor that takes a polygon and an optional parent.

    See also GeometryBuilder::hasCurves.

    PolygonBuilder::PolygonBuilder(const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)

    Constructor that takes a spatialReference and an optional parent.

    See also GeometryBuilder::hasCurves.

    [override virtual] PolygonBuilder::~PolygonBuilder()

    Destructor.

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

    Reimplements: GeometryBuilder::geometryBuilderType() const.

    Returns the GeometryBuilderType of this builder.

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

    Reimplements: GeometryBuilder::toGeometry() const.

    Returns the Polygon geometry this builder is constructing or modifying.

    Esri::ArcGISRuntime::Polygon PolygonBuilder::toPolygon() const

    Returns the Polygon geometry this builder is constructing or modifying.

    This is a convenience method to avoid casting the return value.

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

    Returns a polyline with the values in the polygon builder.

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