GeometryBuilder Class

  • GeometryBuilder
  • class Esri::ArcGISRuntime::GeometryBuilder

    Geometry builders allow you to create and modify geometries incrementally. More...

    Public Functions

    virtual ~GeometryBuilder() override
    Esri::ArcGISRuntime::Envelope extent() const
    virtual Esri::ArcGISRuntime::GeometryBuilderType geometryBuilderType() const
    bool hasCurves() const
    bool hasM() const
    bool hasZ() const
    bool isEmpty() const
    bool isSketchValid() const
    void replaceGeometry(const Esri::ArcGISRuntime::Geometry &geometry)
    Esri::ArcGISRuntime::SpatialReference spatialReference() const
    virtual Esri::ArcGISRuntime::Geometry toGeometry() const

    Static Public Members

    Esri::ArcGISRuntime::GeometryBuilder *create(const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr)
    Esri::ArcGISRuntime::GeometryBuilder *create(Esri::ArcGISRuntime::GeometryType geometryType, const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)

    Detailed Description

    This is the base class for a range of geometry builders, such as a PointBuilder, PolylineBuilder and PolygonBuilder. Each GeometryType has a corresponding type of builder. You can create and modify polygons with PolygonBuilder, envelopes with EnvelopeBuilder, and so on. Use a geometry builder in editing workflows where you need to build up or edit geometry one vertex at a time, for example, when you need to add or edit a vertex from a custom streaming GIS data source. You can either create an empty geometry builder and build up the shape of a Geometry, or you can create a geometry builder with an existing Geometry and modify it.

    When you construct the builder, you can explicitly set its SpatialReference or you can construct the builder with a geometry and the builder will adopt the Geometry::spatialReference. Once set, the SpatialReference cannot be changed. The SpatialReference of any geometry or coordinates added to the builder must be compatible with the SpatialReference of the builder, as they will not be reprojected. The SpatialReference of a geometry added to the builder can be nullptr, in which case the object is assumed to have the same SpatialReference as the builder it is added to.

    There are other ways to create and edit geometries. If you know all the geometry coordinates up front, then you can use geometry constructors, such as Polygon, to create the geometry. If you are going to create a new geometry as a result of a topological operation, such as the buffer operation, then explore the GeometryEngine. If you want your app users to interactively create or edit geometries in the user interface then use the GeometryEditor.

    See also GeometryEditor.

    Member Function Documentation

    [override virtual] GeometryBuilder::~GeometryBuilder()

    Destructor.

    [static, since Esri::ArcGISRuntime 100.1] Esri::ArcGISRuntime::GeometryBuilder *GeometryBuilder::create(const Esri::ArcGISRuntime::Geometry &geometry, QObject *parent = nullptr)

    Returns a geometry builder with the specified geometry as a starting point for further modification.

    • geometry - The geometry to use as the starting point for further modifications.
    • parent - The optional parent QObject.

    Geometries with curves are supported.

    This function was introduced in Esri::ArcGISRuntime 100.1.

    See also hasCurves.

    [static, since Esri::ArcGISRuntime 100.1] Esri::ArcGISRuntime::GeometryBuilder *GeometryBuilder::create(Esri::ArcGISRuntime::GeometryType geometryType, const Esri::ArcGISRuntime::SpatialReference &spatialReference, QObject *parent = nullptr)

    Returns an empty geometry builder which builds geometries of the specified GeometryType.

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

    This function was introduced in Esri::ArcGISRuntime 100.1.

    See also hasCurves.

    Esri::ArcGISRuntime::Envelope GeometryBuilder::extent() const

    Returns the extent of the builder's geometry.

    The extent for the geometry in the builder which is a envelope and contains the same spatial reference as the input geometry.

    [virtual] Esri::ArcGISRuntime::GeometryBuilderType GeometryBuilder::geometryBuilderType() const

    Returns the type of this geometry builder.

    The geometry builder type for a specific geometry builder. Returns GeometryBuilderType::Unknown if an error occurs.

    [since Esri::ArcGISRuntime 100.12] bool GeometryBuilder::hasCurves() const

    Returns true if the geometry builder currently contains any curve segments, false otherwise.

    ArcGIS software supports polygon and polyline geometries that contain curve segments (where Segment::isCurve is true, sometimes known as true curves or nonlinear segments). Curves may be present in certain types of data, such as Mobile Map Packages (MMPKs), or geometry JSON.

    You can use curves in a MultipartBuilder. New segment types, such as CubicBezierSegment and EllipticArcSegment, represent types of curve that can be added to polygon and polyline geometries.

    This function was introduced in Esri::ArcGISRuntime 100.12.

    See also Part::hasCurves, Geometry::hasCurves, and Segment::isCurve.

    bool GeometryBuilder::hasM() const

    Returns true if the geometry builder supports geometries with m values, false otherwise.

    M values are often referred to as measures, and are used in linear referencing workflows on linear datasets. NaN is a valid m value. If true, m values are stored for each vertex of the constructed Geometry. Geometries with m values are created by using setters or constructors that take an m value as a parameter.

    bool GeometryBuilder::hasZ() const

    Returns true if the geometry builder supports geometries with z values, false otherwise.

    Z values are generally used as a z coordinate, indicating height or elevation. NaN is a valid z value. If true, z values are stored for each vertex of the constructed Geometry. Geometries with z values are created by using setters or constructors that take a z value as a parameter.

    bool GeometryBuilder::isEmpty() const

    Returns true if no coordinates have been added to this geometry builder, false otherwise.

    An empty geometry builder may have a valid SpatialReference, even without coordinates.

    bool GeometryBuilder::isSketchValid() const

    Returns true if the geometry builder contains sufficient points to show a valid graphical sketch, false otherwise.

    This can be used as an initial lightweight check to see if the current state of a builder produces a non-empty geometry. For example, it may be used to enable or disable functionality in an editing user interface. The exact requirements vary depending on the type of geometry produced by the builder:

    Note that this is not equivalent to topological simplicity, which is enforced by GeometryEngine::simplify(const Esri::ArcGISRuntime::Geometry&) and checked using GeometryEngine::isSimple(const Esri::ArcGISRuntime::Geometry&). Geometries must be topologically simple to be successfully saved in a geodatabase or used in some service operations.

    It does not check the spatial reference and returns false if an error occurs.

    Prior to Esri.ArcGISRuntime 100.8, only one part of a multipart polygon or polyline was required to have the minimum number (2 for a polyline, 3 for a polygon) of Points, and only LineSegment instances were supported in builders.

    Prior to Esri.ArcGISRuntime 100.12, a PolygonBuilder required at least three valid Points in each Part, and at least one Part.

    void GeometryBuilder::replaceGeometry(const Esri::ArcGISRuntime::Geometry &geometry)

    Replaces the geometry currently stored in the geometry builder with the new geometry.

    • geometry - A geometry object.

    This method can be used as an alternative to creating a new builder from an existing geometry. Note that this does not update the spatial reference of the builder and the builder geometry is cleared if the geometry is empty. Geometries with curves are supported.

    Prior to Esri::ArcGISRuntime 100.12, only geometries without curves could be used; passing in a geometry where Geometry::hasCurves is true would throw an error.

    From Esri::ArcGISRuntime 100.12, geometries with curves are supported.

    Esri::ArcGISRuntime::SpatialReference GeometryBuilder::spatialReference() const

    Returns the spatial reference for the geometry.

    Once set, the SpatialReference of the geometry builder cannot be changed. Ensure that all objects added to the builder have a compatible SpatialReference.

    [virtual] Esri::ArcGISRuntime::Geometry GeometryBuilder::toGeometry() const

    Returns a geometry with the values in the geometry builder.

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