Class GeometryBuilder
 java.lang.Object

 com.esri.arcgisruntime.geometry.GeometryBuilder

 Direct Known Subclasses:
EnvelopeBuilder
,MultipartBuilder
,MultipointBuilder
,PointBuilder
public abstract class GeometryBuilder extends 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
hasM()
Indicates if this builder has mvalues.boolean
hasZ()
Indicates if this builder has zvalues.boolean
isEmpty()
Indicates if any coordinates have been added to this builder.boolean
isSketchValid()
Checks if this builder contains sufficient points to show a valid graphical sketch.void
replaceGeometry(Geometry geometry)
Replaces the geometry currently stored in this builder with the given 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. Parameters:
geometry
 the geometry to use as the starting point for further modifications Returns:
 the new geometry builder
 Throws:
IllegalArgumentException
 if geometry is null Since:
 100.1.0

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:
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

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

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 zvalues. Zvalues are generally used as a zcoordinate, indicating height or elevation. NaN is a valid zvalue.If true, zvalues are stored for each vertex of the constructed Geometry. Geometries with zvalues are created by using setters or constructors that take a zvalue as a parameter.
 Returns:
 true if this builder contains zvalues, false otherwise
 Since:
 100.0.0
 See Also:
Geometry.hasZ()

hasM
public boolean hasM()
Indicates if this builder has mvalues. Mvalues are often referred to as measures, and are used in linear referencing workflows on linear datasets. NaN is a valid mvalue.If true, mvalues are stored for each vertex of the constructed Geometry. Geometries with mvalues are created by using setters or constructors that take an mvalue as a parameter.
 Returns:
 true if this builder has mvalues, 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()
Checks if this builder contains sufficient points to show a valid graphical sketch. This can be used as an initial lightweight check to see if a current builder may produce the target geometry; for example, it may be used to determine the state of a button. The exact requirements vary depending on the type of geometry produced by the builder: PointBuilder must contain nonNaN x,y coordinates.
 MultipointBuilder must contain at least one valid Point.
 PolylineBuilder must contain at least two valid Points in a part (other parts may be empty).
 PolygonBuilder must contain at least three valid Points in a part (other parts may be empty).
 EnvelopeBuilder must contain nonNaN minimum and maximum x and y values.
Note that this is not equivalent to topological simplicity, enforced by the
GeometryEngine.simplify(Geometry)
method, required for geometries to be saved in a geodatabase, or used in some service operations). Returns:
 true if
toGeometry()
would return a geometry that is a valid sketch, false otherwise  Since:
 100.0.0

replaceGeometry
public void replaceGeometry(Geometry geometry)
Replaces the geometry currently stored in this builder with the given geometry. This method can be used as an alternative to creating a new builder instance from an existing geometry. 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

