 java.lang.Object

 com.esri.arcgisruntime.geometry.Geometry

 com.esri.arcgisruntime.geometry.Multipart

 com.esri.arcgisruntime.geometry.Polygon

 All Implemented Interfaces:
JsonSerializable
public final class Polygon extends Multipart
A multipart shape used to represent an area.Polygon geometries represent the shape and location of areas, for example, a country, island, or a lake. They can be used as the geometry of features and graphics, or as input or output of tasks or geoprocessing operations, such as the output of a drivetime analysis or a
GeometryEngine.buffer(Iterable, Iterable, boolean)
operation.Each part of a multipart polygon is a series of connected segments forming a closed ring. Each part must not cross any other part but may lie completely inside or outside another part. For example, a polygon representing the state of Hawaii would comprise eight disjoint parts, one representing each island. A polygon representing the country of South Africa, which completely surrounds the enclave of Lesotho, would comprise two parts, one contained inside the other.
Like
Polyline
, thePolygon
class is aMultipart
, which provides members for iterating the segments and points of each part in a polygon. Unlike parts in aPolyline
, however, each part of a polygon defines a closed area, so the end point of the last segment in the part is always in the same location as the start point of the first segment, forming a closed boundary.When defining a polygon part, there is no need to explicitly close it by repeating the start point as the last point. Polygon's parts are always interpreted as enclosed areas by this API.
Interior rings created to make donut polygons should be counterclockwise in direction to have the correct topology.
If there is ever a doubt about the topological correctness of a polygon, call
GeometryEngine.simplify(Geometry)
to correct any issues. This is especially true if you pass a polygon to ArcGIS Server for a geoprocessing task to avoid any ArcGIS Server errors being thrown. You can also callGeometryEngine#simplify(Geometry)
to rectify polygons that may be selfintersecting, have rings which are partially contained in each other, or contain incorrect ring orientations.Polygon
is immutable. To build a new polygon one point at a time, or modify an existing polygon, use aPolygonBuilder
.A
Polygon
can be used as the geometry of aFeature
orGraphic
. To obtain the geometry, useFeature.getGeometry()
orGraphic.getGeometry()
. Since:
 100.0.0
 See Also:
Geometry
,PolygonBuilder


Constructor Summary
Constructors Constructor Description Polygon(Part part)
Creates a new immutable Polygon containing a copy of the given Part.Polygon(PartCollection parts)
Creates a new immutable Polygon containing a copy of the given PartCollection.Polygon(PartCollection parts, SpatialReference spatialReference)
Creates a new Polygon containing a copy of the given PartCollection, and with the given SpatialReference.Polygon(Part part, SpatialReference spatialReference)
Creates a new Polygon containing a copy of the given Part, and with the given SpatialReference.Polygon(PointCollection points)
Creates a new immutable Polygon containing a copy of the Points in the given PointCollection.Polygon(PointCollection points, SpatialReference spatialReference)
Creates a new Polygon containing a copy of the Points in the given PointCollection, and with the given SpatialReference.

Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Polyline
toPolyline()
Returns a new Polyline representing the boundary of this Polygon.
Methods inherited from class com.esri.arcgisruntime.geometry.Geometry
equals, equals, fromJson, fromJson, getDimension, getExtent, getGeometryType, getSpatialReference, getUnknownJson, getUnsupportedJson, hasCurves, hashCode, hasM, hasZ, isEmpty, toJson




Constructor Detail

Polygon
public Polygon(PointCollection points)
Creates a new immutable Polygon containing a copy of the Points in the given PointCollection. The SpatialReference of the new Polygon will match that of the given PointCollection. Parameters:
points
 the PointCollection used to initialize the new Polygon Since:
 100.0.0

Polygon
public Polygon(PointCollection points, SpatialReference spatialReference)
Creates a new Polygon containing a copy of the Points in the given PointCollection, and with the given SpatialReference.This overload can be used to create a new Polygon with a specific SpatialReference from an existing PointCollection that has a null SpatialReference (the points are assigned the given SpatialReferencethey are not projected).
 Parameters:
points
 the PointCollection containing points copied to the new PolygonspatialReference
 the SpatialReference of the new Polygon Throws:
ArcGISRuntimeException
 if the SpatialReference ofpoints
does not match thespatialReference
 Since:
 100.0.0

Polygon
public Polygon(Part part)
Creates a new immutable Polygon containing a copy of the given Part. The SpatialReference of the new Polygon will match that of the given Part. Parameters:
part
 the Part used to initialize the new Polygon Since:
 100.0.0

Polygon
public Polygon(Part part, SpatialReference spatialReference)
Creates a new Polygon containing a copy of the given Part, and with the given SpatialReference. Parameters:
part
 the Part to copy to the new PolygonspatialReference
 the SpatialReference of the new Polygon Throws:
ArcGISRuntimeException
 if the SpatialReference ofpart
does not match thespatialReference
 Since:
 100.0.0

Polygon
public Polygon(PartCollection parts)
Creates a new immutable Polygon containing a copy of the given PartCollection. The SpatialReference of the new Polygon will match that of the given PartCollection. Parameters:
parts
 the PartCollection used to initialize the new Polygon Since:
 100.0.0

Polygon
public Polygon(PartCollection parts, SpatialReference spatialReference)
Creates a new Polygon containing a copy of the given PartCollection, and with the given SpatialReference. Parameters:
parts
 the PartCollection to be copied to the new PolygonspatialReference
 the SpatialReference of the new Polygon Throws:
ArcGISRuntimeException
 if the SpatialReference ofpart
does not matchspatialReference
 Since:
 100.0.0


Method Detail

toPolyline
public Polyline toPolyline()
Returns a new Polyline representing the boundary of this Polygon. Returns:
 a new Polyline
 Since:
 100.0.0

