This document is archived and information here might be outdated.  Recommended version.


Polygon Class (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Classes > P > Polygon Class
ArcGIS Developer Help

PolygonClass Class

A collection of rings ordered by their containment relationship; optionally has measure, height and ID attributes.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Extended Error Information

Use the ISupportErrorInfo method InterfaceSupportsErrorInfo to determine if the object supports extended error information. If the object supports extended error info, VC++ developers should use the OLE/COM IErrorInfo interface to access the ErrorInfo object. Visual Basic developers should use the global error object Err to retrieve this extended error information.

Interfaces

Interfaces Description
IArea Provides access to members that return properties common to rings and polygons.
IArea3D Provides access to members that return properties common to MultiPatches.
IAreaGeodetic Provides access to members that calculate ellipsoidal area of polygons using various perimeter densification methods.
IClone (esriSystem) Provides access to members that control cloning of objects.
IConstructCurve Provides access to members that construct a curve using other geometries and measures.
IConstructCurve2 Provides access to members that construct a curve using other geometries and measures.
ICurve Provides access to properties and methods of all 1 dimensional curves (polylines, segments, boundaries of polygons, etc.).
ICurve3D Provides access to members that define operations common to curves with Zs.
IGeometry Provides access to members that describe properties and behavior of all geometric objects.
IGeometry2 Provides access to members that extend the IGeometry interface with a more sophisticated projection method.
IGeometry3 Provides rapid access to a geometry's extent in the x-y plane.
IGeometry4 Provides access to methods that indicate if a geometry has been changed (edited, projected, etc).
IGeometry5 Provides access to members that extend the IGeometry interface with a more sophisticated projection method.
IGeometryCollection Provides access to members that can be used for accessing, adding and removing individual geometries of a multi-part geometry (Multipoint, Polyline, Polygon, MultiPatch, and GeometryBag).
IHitTest Provides access to members that locate a part of a geometry closest to a point.
IHitTest3D Provides access to members that locate a part of a geometry closest to a point.
IMAware Indicator interface that identifies geometric objects that can have persistent M values attached to their vertices.
IMCollection Provides access to members that control operations on M-aware multipoints, polylines, polygons and multipatches.
IMSegmentation Provides access to members for defining an M-based linear coordinate system on a polyline or polygon.
IMSnap Provides access to a method that snaps ms of the geometry to the precision of the spatial reference associated with the geometry.
IPersist (esriSystem)
IPersistStream (esriSystem)
IPointCollection Provides access to members that manipulate the points of a Multipoint, Path, Ring, Polyline, Polygon, TriangleFan, TriangleStrip, or MultiPatch.
IPointCollection4 Provides access to members that manipulate the points of a Multipoint, Path, Ring, Polyline, Polygon, TriangleFan, TriangleStrip, or MultiPatch.
IPointIDAware Indicator interface that identifies geometries that can have persistent point ID values attached to coordinates.
IPolycurve Provides access to members that define operations common to polylines and the boundaries of polygons.
IPolycurve2 Provides access to members that extend IPolycurve with additional splitting and densification methods.
IPolycurve3D Provides access to members that define operations common to polycurves with Zs.
IPolycurveGeodetic Provides various geodetic operations on curves.
IPolygon Provides access to members that identify a polygon and permit controlled access to its inner and outer rings.
IPolygon2 Provides access to members that extend the IPolygon interface.
IPolygon3 Provides access to members that extend the IPolygon2 interface.
IPolygon4 Provides access to members that extend the IPolygon3 interface.
IPolygon5 Provides additional operations on polygons. Note that IPolygon5 does not inherit from IPolygon4.
IProximityOperator Provides access to members that find the 2D distance between two geometries.
IProximityOperator3D Provides access to members that find the 3D distance between two geometries with Zs.
IRelationalOperator Provides access to members that determine if a certain spatial relationship exists between two geometries.
IRelationalOperator2 Additional relational functions.
IRelationalOperator3D Provides access to members that determine if a certain spatial relationship exists between two geometries with Zs.
IRelationalOperator3D2 Provides access to members that determine if a certain spatial relationship exists between two geometries with Zs.
ISegmentCollection Provides access to members that manipulate the segments of a path, ring, polyline, or polygon.
ISpatialIndex2 Provides access to members that create a temporary spatial index for improving performance of "Disjoint" and some other relational operators.
ISupportErrorInfo (esriSystem)
ITopologicalOperator Provides access to members for constructing new geometries based upon topological relationships between existing geometries.
ITopologicalOperator2 Provides access to members that extend the ITopologicalOperator interface.
ITopologicalOperator3 Provides additional information on non-simple geometries.
ITopologicalOperator4 Provides additional information on non-simple geometries.
ITopologicalOperator6 .
ITransform2D Provides access to methods for transforming geometries using either specific parameters or arbitrary transformation objects (affine transformations, geographic transformations, etc.).
ITransform3D Provides access to methods for transforming 3D geometries using either specific parameters or arbitrary transformation objects.
IXMLSerialize (esriSystem) Provides access to members that XML serialize and deserialize an object to/from XML.
IZ Provides access to members that identify geometric objects that can have 3D coordinates and defines operations on such objects.
IZ2 Provides access to additional members that identify geometric objects that can have 3D coordinates and defines operations on such objects.
IZAware Indicator interface that identifies geometries that can have persistent Z values attached to their vertices.
IZCollection Provides access to operations on Z-aware geometries.
[C#]

 

 

        private static object _missing = Type.Missing;

 

        public static IGeometry GetPolygonGeometry()

        {

            const double RingVertexCount = 9;

            const double RingDegrees = 360.0;

            const double VectorComponentOffset = 0.0000001;

            const double RingRadius = 5;

 

            IPoint[] centerPointArray = new IPoint[5];

            centerPointArray[0] = ConstructPoint3D(7.5, 7.5, 7.5);

            centerPointArray[1] = ConstructPoint3D(-7.5, -7.5, 7.5);

            centerPointArray[2] = ConstructPoint3D(0, 0, 0);

            centerPointArray[3] = ConstructPoint3D(7.5, -7.5, -7.5);

            centerPointArray[4] = ConstructPoint3D(-7.5, 7.5, -7.5);

 

            IGeometryCollection geometryCollection = new PolygonClass();

 

            for (int i = 0; i < centerPointArray.Length; i++)

            {

                   IPoint centerPoint = centerPointArray[i];

 

                   IPointCollection outerPointCollection = new RingClass();

                   IPointCollection innerPointCollection = new RingClass();

 

                   IVector3D upperAxisVector3D = ConstructVector3D(0, 0, 10);

                   IVector3D lowerAxisVector3D = ConstructVector3D(0, 0, -10);

 

                   lowerAxisVector3D.XComponent += VectorComponentOffset;

 

                   IVector3D normalVector3D = 
                          upperAxisVector3D.CrossProduct(lowerAxisVector3D) as IVector3D;

 

                   normalVector3D.Magnitude = RingRadius;

 

                   double rotationAngleInRadians = 
                          GetRadians(RingDegrees / RingVertexCount);

 

                   for (int j = 0; j < RingVertexCount; j++)

                   {

                          normalVector3D.Rotate(
                                 -1 * rotationAngleInRadians, upperAxisVector3D

                          );

 

                          outerPointCollection.AddPoint(

                                 ConstructPoint3D(

                                        centerPoint.X + normalVector3D.XComponent,

                                        centerPoint.Y + normalVector3D.YComponent,

                                        centerPoint.Z
                                 ), 
                                 ref _missing, ref _missing
                          );

 

                          innerPointCollection.AddPoint(

                                 ConstructPoint3D(

                                        centerPoint.X + 0.5 * normalVector3D.XComponent,

                                        centerPoint.Y + 0.5 * normalVector3D.YComponent,

                                        centerPoint.Z

                                 ), 
                                 ref _missing, ref _missing
                          );

                   }

 

                   outerPointCollection.AddPoint(
                          outerPointCollection.get_Point(0),

                          ref _missing, ref _missing
                   );

                   innerPointCollection.AddPoint(
                          innerPointCollection.get_Point(0),

                          ref _missing, ref _missing
                   );

 

                   ICurve innerCurve = innerPointCollection as ICurve;

                   innerCurve.ReverseOrientation();

 

                   geometryCollection.AddGeometry(
                          outerPointCollection as IGeometry,

                          ref _missing, ref _missing
                   );

                   geometryCollection.AddGeometry(
                          innerPointCollection as IGeometry,

                          ref _missing, ref _missing
                   );

            }

 

            MakeZAware(geometryCollection as IGeometry);

 

            ITopologicalOperator topologicalOperator =
                   geometryCollection as ITopologicalOperator;

           
           
topologicalOperator.Simplify();

 

            return geometryCollection as IGeometry;

        }

        private static IPoint ConstructPoint3D(double x, double y, double z)

        {

            IPoint point = ConstructPoint2D(x, y);

            point.Z = z;

           
return point;

        }

        private static IPoint ConstructPoint2D(double x, double y)

        {

            IPoint point = new PointClass();

            point.PutCoords(x, y);
 

            return point;

        }

        private static void MakeZAware(IGeometry geometry)

        {

            IZAware zAware = geometry as IZAware;

            zAware.ZAware = true;

        }

 

        private static IVector3D ConstructVector3D(
               double xComponent, double yComponent, double zComponent
        )

        {

            IVector3D vector3D = new Vector3DClass();

            vector3D.SetComponents(xComponent, yComponent, zComponent);

            return vector3D;

        }

        private static double GetRadians(double decimalDegrees)

        {

            return decimalDegrees * (Math.PI / 180);

        }