# geos::geom::Polygon Class Reference

Represents a linear polygon, which may include holes. More...

`#include <geos.h>`

Inheritance diagram for geos::geom::Polygon:

List of all members.

## Public Types

typedef std::vector< const Polygon * > | ConstVect
| A vector of const Polygon pointers.

## Public Member Functions

virtual Geometry * | clone () const
CoordinateSequence * | getCoordinates () const
| Returns this Geometry vertices. Caller takes ownership of the returned object.
size_t | getNumPoints () const
| Returns the count of this Geometrys vertices.
Dimension::DimensionType | getDimension () const
| Returns surface dimension (2)
int | getBoundaryDimension () const
| Returns 1 (Polygon boundary is a MultiLineString)
Geometry * | getBoundary () const
| Computes the boundary of this geometry.
bool | isEmpty () const
| Returns whether or not the set of points in this Geometry is empty.
bool | isSimple () const
| Tests if a valid polygon is simple. This method always returns true, since a valid polygon is always simple.
const LineString * | getExteriorRing () const
| Returns the exterior ring (shell)
size_t | getNumInteriorRing () const
| Returns number of interior rings (hole)
const LineString * | getInteriorRingN (size_t n) const
| Get nth interior ring (hole)
std::string | getGeometryType () const
| Return a string representation of this Geometry type.
virtual GeometryTypeId | getGeometryTypeId () const
| Return an integer representation of this Geometry type.
bool | equalsExact (const Geometry *other, double tolerance=0) const
| Returns true if the two Geometrys are exactly equal, up to a specified tolerance.
void | apply_rw (const CoordinateFilter *filter)
void | apply_ro (CoordinateFilter *filter) const
void | apply_rw (GeometryFilter *filter)
void | apply_ro (GeometryFilter *filter) const
void | apply_rw (CoordinateSequenceFilter &filter)
void | apply_ro (CoordinateSequenceFilter &filter) const
Geometry * | convexHull () const
| Returns the smallest convex Polygon that contains all the points in the Geometry.
void | normalize ()
| Converts this Geometry to normal form (or canonical form).
int | compareToSameClass (const Geometry *p) const
const Coordinate * | getCoordinate () const
| Returns a vertex of this Geometry, or NULL if this is the empty geometry.
double | getArea () const
| Returns the area of this Geometry.
double | getLength () const
| Returns the perimeter of this `Polygon`
void | apply_rw (GeometryComponentFilter *filter)
void | apply_ro (GeometryComponentFilter *filter) const
bool | isRectangle () const
| Polygon overrides to check for actual rectangle.

## Protected Member Functions

| Polygon (const Polygon &p)
| Polygon (LinearRing *newShell, std::vector< Geometry * > *newHoles, const GeometryFactory *newFactory)
Envelope::AutoPtr | computeEnvelopeInternal () const

## Protected Attributes

LinearRing * | shell
std::vector< Geometry * > * | holes

## Friends

class | GeometryFactory

## Detailed Description

Represents a linear polygon, which may include holes.

The shell and holes of the polygon are represented by LinearRings. In a valid polygon, holes may touch the shell or other holes at a single point. However, no sequence of touching holes may split the polygon into two pieces. The orientation of the rings in the polygon does not matter.

The shell and holes must conform to the assertions specified in the OpenGIS Simple Features Specification for SQL .

## Constructor & Destructor Documentation

geos::geom::Polygon::Polygon | ( | LinearRing * | newShell,
|  | std::vector< Geometry * > * | newHoles,
|  | const GeometryFactory * | newFactory
| ) |  | `[protected]`

Constructs a `Polygon` with the given exterior and interior boundaries.

Parameters:

  newShell | the outer boundary of the new Polygon, or `null` or an empty LinearRing if the empty geometry is to be created.
  newHoles | the LinearRings defining the inner boundaries of the new Polygon, or null or empty LinearRing if the empty geometry is to be created.
  newFactory | the GeometryFactory used to create this geometry

Polygon will take ownership of Shell and Holes LinearRings

## Member Function Documentation

void geos::geom::Polygon::apply_ro | ( | CoordinateSequenceFilter & | filter ) | const`[virtual]`

Performs a read-only operation on the coordinates in this Geometry's CoordinateSequences.

Parameters:

  filter | the filter to apply

Implements geos::geom::Geometry.

void geos::geom::Polygon::apply_rw | ( | CoordinateSequenceFilter & | filter ) | `[virtual]`

Performs an operation on the coordinates in this Geometry's CoordinateSequences.s If the filter reports that a coordinate value has been changed, geometryChanged will be called automatically.

Parameters:

  filter | the filter to apply

Implements geos::geom::Geometry.

virtual Geometry* geos::geom::Polygon::clone | ( | ) | const`[inline, virtual]`

Creates and returns a full copy of this Polygon object. (including all coordinates contained by it).

Returns:
  a clone of this instance

Implements geos::geom::Geometry.

Geometry* geos::geom::Polygon::getBoundary | ( | ) | const`[virtual]`

Computes the boundary of this geometry.

Returns:
  a lineal geometry (which may be empty)

See also:
  Geometry::getBoundary

Implements geos::geom::Geometry.

bool geos::geom::Polygon::isSimple | ( | ) | const`[virtual]`

Tests if a valid polygon is simple. This method always returns true, since a valid polygon is always simple.

Returns:
  `true`

Reimplemented from geos::geom::Geometry.

The documentation for this class was generated from the following file:

- Polygon.h