# GeometryBuilder Class

Base class for classes used to create immutable geometries. More...

Header: | #include <GeometryBuilder> |

Since: | Esri::ArcGISRuntime 100.0 |

Inherits: | Object |

Inherited By: | Esri::ArcGISRuntime::EnvelopeBuilder, Esri::ArcGISRuntime::MultipartBuilder, Esri::ArcGISRuntime::MultipointBuilder, and Esri::ArcGISRuntime::PointBuilder |

## Public Functions

~GeometryBuilder() | |

Envelope | extent() const |

virtual GeometryBuilderType | geometryBuilderType() const |

bool | hasM() const |

bool | hasZ() const |

bool | isEmpty() const |

bool | isSketchValid() const |

void | replaceGeometry(const Geometry &geometry) |

SpatialReference | spatialReference() const |

virtual Geometry | toGeometry() const |

- 31 public functions inherited from QObject

## Static Public Members

GeometryBuilder * | create(const Geometry &geometry, QObject *parent = nullptr) |

GeometryBuilder * | create(GeometryType geometryType, const SpatialReference &spatialReference, QObject *parent = nullptr) |

- 10 static public members inherited from QObject

### Additional Inherited Members

- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 1 signal inherited from Esri::ArcGISRuntime::Object
- 2 signals inherited from QObject
- 1 public variable inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject

## Detailed Description

Base class for classes used to create immutable geometries.

Each type of Geometry has a corresponding builder class. For example, PolygonBuilder creates Polygons. Create a new empty builder in order to build up the shape of a geometry step by step. Alternatively for editing workflows, initialize the builder by passing the existing Geometry to be edited into the builder constructor, and then make the required changes. In both cases, call toGeometry to return a new immutable Geometry based on the current state of the geometry in the builder. The state of a builder can be completely overwritten by calling replaceGeometry.

Set the spatial reference of a builder either explicitly by specifying a SpatialReference object in the constructor, or is set implicitly from other constructor arguments. Once set, the spatial reference cannot be changed. When building geometries, the spatial reference of any objects or coordinates added to the builder must be compatible with the spatial reference of the builder; added items are not reprojected. The spatial reference of added objects may be null, in which case the added object is assumed to have the same spatial reference as the builder it is added to.

A number of other methods provide information about the geometry currently being constructed. A new builder will be empty (isEmpty is true). The hasZ and hasM methods indicate if the builder allows adding z- and m-values for each coordinate in the geometry.

## Member Function Documentation

### GeometryBuilder::~GeometryBuilder()

Destructor.

`[static] `

GeometryBuilder *GeometryBuilder::create(const Geometry &*geometry*, QObject **parent* = nullptr)

Creates and returns a geometry builder from a geometry.

*geometry*- The geometry to be used as the starting point for further modifications.*parent*- An optional parent.

This function was introduced in Esri::ArcGISRuntime 100.1.

`[static] `

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

Creates and returns a geometry builder from a geometry type and spatial reference.

*geometryType*- The geometry type of the builder.*spatialReference*- The spatial reference of the builder.*parent*- An optional parent.

This function was introduced in Esri::ArcGISRuntime 100.1.

### Envelope GeometryBuilder::extent() const

Returns the extent of the builder's geometry.

`[virtual] `

GeometryBuilderType GeometryBuilder::geometryBuilderType() const

Returns the type of this geometry builder.

### bool GeometryBuilder::hasM() const

Returns whether the builder's geometry contains m-values.

### bool GeometryBuilder::hasZ() const

Returns whether the builder's geometry contains z-coordinate values.

### bool GeometryBuilder::isEmpty() const

Returns whether the builder's geometry is empty.

### bool GeometryBuilder::isSketchValid() const

Returns whether the builder's geometry is valid.

Performs the following checks on the geometry in the builder:

- For Point: Contains x and y coordinates.
- For Polyline: Contains at least one part, each with two or more vertices.
- For Polygon: Contains at least one part, each with three or more vertices which form a closed ring.
- For Multipoint: Contains at least one vertex.
- For Envelope: Contains xMin, yMin, xMax, and yMax coordinates.

### void GeometryBuilder::replaceGeometry(const Geometry &*geometry*)

Replaces the content of an existing *geometry* with the geometry in this builder.

An empty Geometry may be passed to reset the builder's geometry. Note that this won't change the SpatialReference.

### SpatialReference GeometryBuilder::spatialReference() const

The spatial reference associated with the builder's geometry.

`[virtual] `

Geometry GeometryBuilder::toGeometry() const

Returns the geometry this builder is constructing or modifying.