ArcGIS Runtime SDK for iOS: AGSPolygon Class Reference
ArcGIS Runtime SDK for iOS  100.11
AGSPolygon Class Reference

Description

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. A polygon 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 drive-time analysis or an AGSGeometryEngine::bufferWithGeometry:distance: operation.

Each part of a multipart polygon is a series of connected AGSSegment objects 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, the polygon class is an AGSMultipart, which provides members for iterating the segments and points of each part in a polygon. Unlike parts in a polyline, 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. Polygons parts are always interpreted as enclosed areas by ArcGIS Runtime.

Interior rings to make donut polygons should be counter-clockwise in direction to have the correct topology.

If there is ever a doubt about the topological correctness of a polygon, call the AGSGeometryEngine::simplifyWithGeometry: method 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 or to rectify polygons that may be self-intersecting, have rings which are partially contained in each other, or contain incorrect ring orientations.

Polygons are based upon the parent AGSGeometry class. The geometry object is immutable which means that you can not change its shape once it is created. If you need to create a new polygon or modify it once it has been created, use the AGSPolygonBuilder class.

A polygon can be used as the geometry of an AGSFeature or AGSGraphic. To obtain the geometry on these objects, use AGSGeoElement::geometry.

See also
AGSPolygonBuilder to construct or modify polygons programmatically.
AGSSketchEditor to construct or modify geometries interactively by sketching on a map.
AGSGeometryEngine to perform operations on geometries.
Inheritance diagram for AGSPolygon:
AGSMultipart AGSGeometry AGSObject <AGSJSONSerializable>

Instance Methods

(BOOL) - isEqualToGeometry:
 
(BOOL) - isEqualToGeometry:
 
(BOOL) - isEqualToGeometry:tolerance:
 
(AGSPolygonBuilder *) - toBuilder
 
(nullable id) - toJSON:
 
(AGSPolyline *) - toPolyline
 

Class Methods

(nullable id< AGSJSONSerializable >) + fromJSON:error:
 
(instancetype) + polygonWithPoints:
 

Properties

AGSGeometryDimension dimension
 
BOOL empty
 
AGSEnvelopeextent
 
AGSGeometryType geometryType
 
BOOL hasCurves
 
BOOL hasM
 
BOOL hasZ
 
AGSPartCollectionparts
 
AGSSpatialReferencespatialReference
 
NSDictionary< NSString *, id > * unknownJSON
 
NSDictionary< NSString *, id > * unsupportedJSON
 

Method Documentation

◆ fromJSON:error:

+ (nullable id<AGSJSONSerializable>) fromJSON: (id)  JSONObject
error: (NSError **)  error 
staticrequiredinherited

Initializes and returns an object from its JSON representation.

Parameters
JSONObjectNSDictionary or NSArray containing the JSON.
errorencountered during the operation, if any.
Since
100

◆ isEqualToGeometry: [1/2]

- (BOOL) isEqualToGeometry: (AGSGeometry *)  other

Compares whether two geometries are equal.

Parameters
otherThe other geometry object to compare this geometry object to.
Returns
YES if the geometries are equal.
Since
100

◆ isEqualToGeometry: [2/2]

- (BOOL) isEqualToGeometry: (AGSPolygon *)  other

Compares whether two polygon geometries are equal.

Parameters
otherpolygon to compare this polygon to
Returns
YES if the polygons are equal
Since
100

◆ isEqualToGeometry:tolerance:

- (BOOL) isEqualToGeometry: (AGSGeometry *)  other
tolerance: (double)  tolerance 

Compares two geometry objects for equality to within some tolerance.

Parameters
otherThe other geometry object to compare this geometry object to.
toleranceThe tolerance.
Returns
YES if the geometries are equal within the given tolerance, otherwise NO.
Since
100

◆ polygonWithPoints:

+ (instancetype) polygonWithPoints: (NSArray< AGSPoint * > *)  points

Initializes a polygon.

Parameters
pointsfor the geometry to be constructed
Since
100

◆ toBuilder

- (AGSPolygonBuilder*) toBuilder

Returns a builder using a copy of this geometry as a starting off point. The builder can then be modified to produce a new geometry.

Returns
builder that can be used to build polygon geometries.
Since
100
Note
Operations on the builder affect only its own internal copy of the geometry. They do not affect this geometry.

Implements AGSGeometry.

◆ toJSON:

- (nullable id) toJSON: (NSError **)  error
requiredinherited

Returns JSON representation for this object.

Parameters
errorencountered during the operation, if any.
Returns
NSDictionary or NSArray containing the JSON.
Since
100

Reimplemented in AGSPortalItem.

◆ toPolyline

- (AGSPolyline*) toPolyline

Property Documentation

◆ dimension

- (AGSGeometryDimension) dimension
readnonatomicassigninherited

The dimension of this geometry object.

Note
Will return AGSGeometryDimension::AGSGeometryDimensionUnknown if an error occurs.
Since
100

◆ empty

- (BOOL) empty
readnonatomicassigninherited

Indicates whether this geometry has any vertices.

Since
100

◆ extent

- (AGSEnvelope*) extent
readnonatomicstronginherited

Smallest, rectangular bounding-box that covers the geometry.

Since
100

◆ geometryType

- (AGSGeometryType) geometryType
readnonatomicassigninherited

The type of this geometry.

Since
100

◆ hasCurves

- (BOOL) hasCurves
readnonatomicassigninherited

Indicates whether this geometry has curves.

Since
100

◆ hasM

- (BOOL) hasM
readnonatomicassigninherited

Indicates whether this geometry contains m (measure) values.

Since
100

◆ hasZ

- (BOOL) hasZ
readnonatomicassigninherited

Indicates whether this geometry contains z coordinate values. Only 3D geometries contain z values.

Since
100

◆ parts

- (AGSPartCollection*) parts
readnonatomicstronginherited

The parts of this geometry.

Can be iterated through a for-in loop.

AGSPolygon* polygon = ... ; //polygon with 2 parts (rings)
for (AGSPart* part in polygon.parts) {
...
}
AGSPartCollection * parts
Definition: AGSMultipart.h:75
Represents a single part of a multipart geometry (AGSPolygon or AGSPolyline).
Definition: AGSPart.h:59
A multipart shape used to represent an area.
Definition: AGSPolygon.h:78
Since
100

◆ spatialReference

- (AGSSpatialReference*) spatialReference
readnonatomicstronginherited

The spatial reference associated with the gometry. It specifies the coordinate system for the geometry's x, y, and z coordinate values.

Since
100
Note
Geometries that represent geographic locations should always have a spatial reference. Otherwise the coordinates of the geometry are meaningless.

◆ unknownJSON

- (NSDictionary<NSString*,id>*) unknownJSON
readrequirednonatomiccopyinherited

A dictionary of values that was in the source JSON but was unparsed by API.

Returns
NSDictionary containing the unknown JSON.
Since
100

◆ unsupportedJSON

- (NSDictionary<NSString*,id>*) unsupportedJSON
readnonatomiccopyinherited

A dictionary of values that are supported by the REST API, but not exposed through the SDK API.

Returns
NSDictionary containing the unsupported JSON.
Since
100