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.simplify(Geometry)
to correct any issues.
The polygon builder allows you to change the contents of the shape using the PartCollection
that you
can access from the MultipartBuilder.getParts()
. Each Part
, in this PartCollection
,
comprises a collection of segments that make edges of the Part
. You can add or remove a
Part
from the PartCollection
, or you can create a new or edit the segment vertices of an
existing Part
. Use GeometryBuilder.toGeometry()
to return the new Polygon
from the builder.
- Since:
- 100.0.0
-
Constructor Summary
ConstructorDescriptionPolygonBuilder
(Part part) Creates a new PolygonBuilder containing the given Part.PolygonBuilder
(PartCollection parts) Creates a new PolygonBuilder containing the Parts in the given PartCollection.PolygonBuilder
(PartCollection parts, SpatialReference spatialReference) Creates a new PolygonBuilder containing the Parts in the given PartCollection, and with the given SpatialReference.PolygonBuilder
(Part part, SpatialReference spatialReference) Creates a new PolygonBuilder containing the given Part, and with the given SpatialReference.PolygonBuilder
(PointCollection points) Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection.PolygonBuilder
(PointCollection points, SpatialReference spatialReference) Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection, and with the given SpatialReference.PolygonBuilder
(Polygon polygon) Creates a new polygon builder by copying the parts from the specifiedPolygon
.PolygonBuilder
(SpatialReference spatialReference) Creates a new empty polygon builder with the specifiedSpatialReference
. -
Method Summary
Modifier and TypeMethodDescriptionReturns a new Polygon based on the current state of this builder.Creates a polyline with the values in the polygon builder.Methods inherited from class com.esri.arcgisruntime.geometry.MultipartBuilder
addPart, addPart, addPart, addParts, addPoint, addPoint, addPoint, addPoints, addPointsToPart, addPointToPart, getParts, replaceGeometry
Methods inherited from class com.esri.arcgisruntime.geometry.GeometryBuilder
create, create, getBuilderType, getExtent, getSpatialReference, hasCurves, hasM, hasZ, isEmpty, isSketchValid
-
Constructor Details
-
PolygonBuilder
Creates a new empty polygon builder with the specifiedSpatialReference
.The
SpatialReference
cannot be changed after instantiation.- Parameters:
spatialReference
- the SpatialReference of the new builder. May be null.- Since:
- 100.0.0
-
PolygonBuilder
Creates a new polygon builder by copying the parts from the specifiedPolygon
.The
SpatialReference
of the new polygon builder will match that of the givenPolygon
. Use this constructor in workflows that create a modified version of an existing geometry. Polygons with curves are supported.- Parameters:
polygon
- the polygon used to initialize the new builder, may be null- Since:
- 100.0.0
- See Also:
-
PolygonBuilder
Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection. The SpatialReference of the new builder will match that of the given PointCollection.- Parameters:
points
- the PointCollection used to initialise the new builder- Since:
- 100.0.0
-
PolygonBuilder
Creates a new PolygonBuilder containing a copy of the Points in the given PointCollection, and with the given SpatialReference.This overload can be used to initialize a PolygonBuilder with a specific SpatialReference from an existing PointCollection that has a null SpatialReference (the points are assigned the given SpatialReference-they are not projected).
- Parameters:
points
- the PointCollection containing points copied to the new builderspatialReference
- the SpatialReference of the new builder- Throws:
ArcGISRuntimeException
- if the SpatialReference ofpoints
does not match the match thespatialReference
argument.- Since:
- 100.0.0
-
PolygonBuilder
Creates a new PolygonBuilder containing the given Part. The SpatialReference of the new builder will match that of the given Part.- Parameters:
part
- the Part used to initialise the new builder- Since:
- 100.0.0
-
PolygonBuilder
Creates a new PolygonBuilder containing the given Part, and with the given SpatialReference.- Parameters:
part
- the Part to add to the new builderspatialReference
- the SpatialReference of the new builder- Since:
- 100.0.0
-
PolygonBuilder
Creates a new PolygonBuilder containing the Parts in the given PartCollection. The SpatialReference of the new builder will match that of the given PartCollection.- Parameters:
parts
- the PartCollection containing Parts to add to the new builder- Since:
- 100.0.0
-
PolygonBuilder
Creates a new PolygonBuilder containing the Parts in the given PartCollection, and with the given SpatialReference.- Parameters:
parts
- the PartCollection containing Parts to add to the new builderspatialReference
- the SpatialReference of the new builder- Since:
- 100.0.0
-
-
Method Details
-
toGeometry
Returns a new Polygon 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 Polygon each time.Any gaps between the Segments in each part of the returned Polygon will be filled by new connecting LineSegments.
- Specified by:
toGeometry
in classGeometryBuilder
- Returns:
- a new Polygon based on the current state of this builder
- Since:
- 100.0.0
-
toPolyline
Creates a polyline with the values in the polygon builder.- Returns:
- a polyline with the values in this builder
- Since:
- 100.1.0
-