PolygonBuilder

The polygon builder allows you to create and modify Polygon geometries incrementally. Polygon geometries are immutable and cannot be changed directly once created. A polygon is a closed area shape defined by one or more parts. Each part in a polygon is a connected sequence of Segment instances that start and end at the same point (a closed ring). If a polygon has more than one ring, the rings may be separate from one another or they may nest inside one another, but they should not overlap. Note: interior rings, to make donut polygons, should be counter-clockwise in direction to be topology correct. If there is ever a doubt about the topological correctness of a polygon, call GeometryEngine.simplifyOrNull to correct any issues.

The polygon builder allows you to change the contents of the shape using the MutablePartCollection that you can access from the MultipartBuilder.parts. Each MutablePart, in this MutablePartCollection, comprises a collection of segments that make edges of the MutablePart. You can add or remove a MutablePart from the MutablePartCollection, or you can create a new or edit the segment vertices of an existing MutablePart. Use GeometryBuilder.toGeometry to return the new Polygon from the builder.

Since

200.1.0

Constructors

Link copied to clipboard
constructor(polygon: Polygon?, block: PolygonBuilder.() -> Unit = {})

Creates a new polygon builder by copying the parts from the specified Polygon.

constructor(spatialReference: SpatialReference? = null, block: PolygonBuilder.() -> Unit = {})

Creates a new empty polygon builder with the specified SpatialReference.

constructor(mutableParts: Iterable<MutablePart>, block: PolygonBuilder.() -> Unit = {})

Creates a polygon builder with a list of MutablePart.

constructor(points: Iterable<Point>, spatialReference: SpatialReference? = null, block: PolygonBuilder.() -> Unit = {})

Creates a polygon builder with a list of points.

Inherited properties

Link copied to clipboard

The extent for the geometry being constructed in the geometry builder.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

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.

Link copied to clipboard

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:

Link copied to clipboard

New parts for the multipart builder. The collection of parts for the multipart builder. Changes to the collection are reflected in the multipart builder.

Link copied to clipboard

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.

Functions

Link copied to clipboard
open override fun replaceGeometry(geometry: Polygon?)

Replaces the geometry currently stored in the geometry builder with the new geometry. 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 null. Geometries with curves are supported.

Link copied to clipboard
open override fun toGeometry(): Polygon

Returns Geometry that the geometry builder is constructing or modifying.

Link copied to clipboard

Creates a polyline with the values in the polygon builder.

Inherited functions

Link copied to clipboard
fun addPoint(point: Point): Int
fun addPoint(x: Double, y: Double): Int
fun addPoint(x: Double, y: Double, z: Double): Int

Adds a new point to the end of the last part of the multipart. If there are no parts then an initial part is created and the point added to that. The point becomes the end point of a line segment in the part.