Class GeometryBuilder
 java.lang.Object

 com.esri.arcgisruntime.geometry.GeometryBuilder

 Direct Known Subclasses:
EnvelopeBuilder
,MultipartBuilder
,MultipointBuilder
,PointBuilder
public abstract class GeometryBuilder extends java.lang.Object
Base class for builders that allow immutable geometries to be defined incrementally. Each type of Geometry has a correspondingtype
of builder  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, 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 callingreplaceGeometry(Geometry)
.The SpatialReference of a builder is either set explicitly by specifying a SpatialReference object in some constructors, or is set implicitly from other constructor arguments. Once set, SpatialReference cannot be changed. When building geometries, the SpatialReference of any objects or coordinates added to the builder must be compatible with the
SpatialReference
of the builder; added items are not reprojected. The SpatialReference of added items may be null, in which case the object is assumed to have the same SpatialReference 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
. ThehasZ()
andhasM()
methods indicate if the builder allows adding z and m values for each coordinate in the geometry. Since:
 100.0.0
 See Also:
Geometry
,GeometryBuilderType


Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static GeometryBuilder
create(Geometry geometry)
Creates a geometry builder using the given geometry as a starting point for further modifications.static GeometryBuilder
create(GeometryType geometryType, SpatialReference spatialReference)
Creates a geometry builder which builds geometries of the given type.GeometryBuilderType
getBuilderType()
Gets the subtype of this builder instance.Envelope
getExtent()
Gets an Envelope representing the current extent of the Geometry being constructed.SpatialReference
getSpatialReference()
Gets theSpatialReference
of this instance.boolean
hasCurves()
Gets a value indicating whether the geometry builder currently contains any curve segments.boolean
hasM()
Indicates if this builder has m values.boolean
hasZ()
Indicates if this builder has z values.boolean
isEmpty()
Indicates if any coordinates have been added to this builder.boolean
isSketchValid()
Check if a geometry builder contains sufficient points to show a valid graphical sketch.void
replaceGeometry(Geometry geometry)
Replaces the geometry currently stored in this builder with the new geometry.abstract Geometry
toGeometry()
Returns a newGeometry
based on the current state of this builder.



Method Detail

create
public static GeometryBuilder create(Geometry geometry)
Creates a geometry builder using the given geometry as a starting point for further modifications.Prior to v100.12, only geometries without curves could be used; passing in a geometry where
Geometry.hasCurves()
is true would throw an exception.From v100.12, geometries with curves are supported.
 Parameters:
geometry
 the geometry to use as the starting point for further modifications Returns:
 the new geometry builder
 Throws:
java.lang.IllegalArgumentException
 if geometry is null Since:
 100.1.0
 See Also:
hasCurves()

create
public static GeometryBuilder create(GeometryType geometryType, SpatialReference spatialReference)
Creates a geometry builder which builds geometries of the given type. Parameters:
geometryType
 the builder's geometry typespatialReference
 the builder's spatial reference; may be null Returns:
 the new geometry builder
 Throws:
java.lang.IllegalArgumentException
 if geometryType is null Since:
 100.1.0

getSpatialReference
public SpatialReference getSpatialReference()
Gets theSpatialReference
of this instance. Once set, the SpatialReference of a GeometryBuilder cannot be changed. Ensure that all objects set into the builder have a compatible SpatialReference; objects with incompatible SpatialReferences may cause exceptions. Returns:
 the spatial reference of this instance
 Since:
 100.0.0
 See Also:
hasCurves()

getExtent
public Envelope getExtent()
Gets an Envelope representing the current extent of the Geometry being constructed. Returns:
 the current extent of the geometry being constructed
 Since:
 100.0.0

hasCurves
public boolean hasCurves()
Gets a value indicating whether the geometry builder currently contains any curve segments.The ArcGIS Platform supports polygon and polyline geometries that contain curve segments (sometimes known as true curves or nonlinear segments). Curves may be present in certain types of data  for example Mobile Map Packages (MMPKs), or geometry JSON.
Prior to 100.12, only
LineSegment
instances were supported when creating new geometries using aMultipartBuilder
. Attempting to add curve geometries to aMultipartBuilder
would cause an error.From 100.12, you can use curves in a
MultipartBuilder
. New segment typesCubicBezierSegment
andEllipticArcSegment
represent different types of curve that can be added to polygon and polyline geometries. Returns:
 true if this GeometryBuilder contains curved segments; false otherwise
 Since:
 100.12.0
 See Also:
Part.hasCurves()
,Geometry.hasCurves()
,Segment.isCurve()

getBuilderType
public GeometryBuilderType getBuilderType()
Gets the subtype of this builder instance. This indicates which type of geometries the builder can create; each type of builder creates a singleGeometryType
. Returns:
 the builder subtype
 Since:
 100.0.0

hasZ
public boolean hasZ()
Indicates if this builder has z values. 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.
 Returns:
 true if this builder contains z values, false otherwise
 Since:
 100.0.0
 See Also:
Geometry.hasZ()

hasM
public boolean hasM()
Indicates if this builder has m values. 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.
 Returns:
 true if this builder has m values, false otherwise
 Since:
 100.0.0
 See Also:
Geometry.hasM()

isEmpty
public boolean isEmpty()
Indicates if any coordinates have been added to this builder. An empty builder may have a valid SpatialReference set, but contains no coordinates. Returns:
 true if no coordinates have been added to this instance, false otherwise
 Since:
 100.0.0
 See Also:
Geometry.isEmpty()

isSketchValid
public boolean isSketchValid()
Check if a geometry builder contains sufficient points to show a valid graphical sketch.This can be used as an initial lightweight check to see if the current state of a builder will produce a nonempty 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:
 A
PointBuilder
must contain nonNaN x,y coordinates.  A
MultipointBuilder
must contain at least one validPoint
.  A
PolylineBuilder
must contain at least onePart
. EachPart
it contains must have: At least two valid points, or
 At least one
Segment
whereSegment.isCurve()
is true.
 A
PolygonBuilder
must contain at least onePart
. EachPart
it contains must have: At least three valid points, or
 At least one
Segment
whereSegment.isCurve()
is true.
 An
EnvelopeBuilder
must contain nonNaN minimum and maximum x and y values.
GeometryEngine.simplify(Geometry)
and checked usingGeometryEngine.isSimple(Geometry)
. Geometries must be topologically simple to be successfully saved in a geodatabase, or used in some service operations.Does not check the spatial reference. Will return false if an error occurs.
Prior to v100.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 v100.12, a
PolygonBuilder
required at least three valid Points in each part, and at least one part. Returns:
 true if
toGeometry()
would return a geometry that is a valid sketch, false otherwise  Since:
 100.0.0
 A

replaceGeometry
public void replaceGeometry(Geometry geometry)
Replaces the geometry currently stored in this builder with the new geometry. This method can be used as an alternative to creating a new builder instance from an existing geometry.This does not update the spatial reference of the builder. If the geometry is null, the builder is cleared.
Prior to v100.12, only geometries without curves could be used; passing in a geometry where
Geometry.hasCurves()
is true would throw an exception.From v100.12, geometries with curves are supported.
 Parameters:
geometry
 the new geometry to replace the existing geometry with Since:
 100.0.0

toGeometry
public abstract Geometry toGeometry()
Returns a newGeometry
based on the current state of this builder. This method can be called as many times as required for any specific instance; it does not affect the state of the builder, and returns a new Geometry each time. Returns:
 a new Geometry based on the current state of this builder
 Since:
 100.0.0

