GEOS 3.6.2
Polygon.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2005 2006 Refractions Research Inc.
8 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 *
10 * This is free software; you can redistribute and/or modify it under
11 * the terms of the GNU Lesser General Public Licence as published
12 * by the Free Software Foundation.
13 * See the COPYING file for more information.
14 *
15 **********************************************************************
16 *
17 * Last port: geom/Polygon.java r320 (JTS-1.12)
18 *
19 **********************************************************************/
20
21#ifndef GEOS_GEOM_POLYGON_H
22#define GEOS_GEOM_POLYGON_H
23
24#include <geos/export.h>
25#include <string>
26#include <vector>
27#include <geos/platform.h>
28#include <geos/geom/Geometry.h> // for inheritance
29#include <geos/geom/Polygonal.h> // for inheritance
30#include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
31#include <geos/geom/Dimension.h> // for Dimension::DimensionType
32
33#include <geos/inline.h>
34
35#include <memory> // for auto_ptr
36
37// Forward declarations
38namespace geos {
39 namespace geom { // geos::geom
40 class Coordinate;
43 class LinearRing;
44 class LineString;
45 }
46}
47
48namespace geos {
49namespace geom { // geos::geom
50
66class GEOS_DLL Polygon: public virtual Geometry, public Polygonal
67{
68
69public:
70
71 friend class GeometryFactory;
72
74 typedef std::vector<const Polygon *> ConstVect;
75
76 virtual ~Polygon();
77
84 virtual Geometry *clone() const { return new Polygon(*this); }
85
87
88 size_t getNumPoints() const;
89
92
94 virtual int getCoordinateDimension() const;
95
98
106
107 bool isEmpty() const;
108
115 bool isSimple() const;
116
119
121 size_t getNumInteriorRing() const;
122
124 const LineString* getInteriorRingN(std::size_t n) const;
125
126 std::string getGeometryType() const;
128 bool equalsExact(const Geometry *other, double tolerance=0) const;
129 void apply_rw(const CoordinateFilter *filter);
130 void apply_ro(CoordinateFilter *filter) const;
131 void apply_rw(GeometryFilter *filter);
132 void apply_ro(GeometryFilter *filter) const;
135
137
138 void normalize();
139
140 int compareToSameClass(const Geometry *p) const; //was protected
141
142 const Coordinate* getCoordinate() const;
143
144 double getArea() const;
145
147 double getLength() const;
148
149 void apply_rw(GeometryComponentFilter *filter);
150
151 void apply_ro(GeometryComponentFilter *filter) const;
152
153 bool isRectangle() const;
154
155protected:
156
157
158 Polygon(const Polygon &p);
159
178 Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles,
179 const GeometryFactory *newFactory);
180
181 LinearRing *shell;
182
183 std::vector<Geometry *> *holes; //Actually vector<LinearRing *>
184
185 Envelope::AutoPtr computeEnvelopeInternal() const;
186
187private:
188
189 void normalize(LinearRing *ring, bool clockwise);
190};
191
192} // namespace geos::geom
193} // namespace geos
194
195#endif // ndef GEOS_GEOM_POLYGON_H
The default implementation of CoordinateSequence.
Definition CoordinateArraySequence.h:37
Definition CoordinateFilter.h:43
Definition CoordinateSequenceFilter.h:58
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:59
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
DimensionType
Definition Dimension.h:31
Definition GeometryComponentFilter.h:43
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition GeometryFilter.h:48
Geometry(const Geometry &geom)
Polygon overrides to check for actual rectangle.
Definition LineString.h:70
Models an OGC SFS LinearRing.
Definition LinearRing.h:57
const LineString * getExteriorRing() const
Returns the exterior ring (shell).
Polygon(LinearRing *newShell, std::vector< Geometry * > *newHoles, const GeometryFactory *newFactory)
double getLength() const
Returns the perimeter of this Polygon.
int getBoundaryDimension() const
Returns 1 (Polygon boundary is a MultiLineString).
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.
Dimension::DimensionType getDimension() const
Returns surface dimension (2).
virtual Geometry * clone() const
Definition Polygon.h:84
double getArea() const
Returns the area of this Geometry.
bool isSimple() const
Tests if a valid polygon is simple. This method always returns true, since a valid polygon is always ...
bool isRectangle() const
Polygon overrides to check for actual rectangle.
void normalize()
Converts this Geometry to normal form (or canonical form).
size_t getNumPoints() const
Returns the count of this Geometrys vertices.
virtual int getCoordinateDimension() const
Returns coordinate dimension.
void apply_rw(CoordinateSequenceFilter &filter)
Geometry * getBoundary() const
Computes the boundary of this geometry.
const Coordinate * getCoordinate() const
Returns a vertex of this Geometry, or NULL if this is the empty geometry.
bool isEmpty() const
Returns whether or not the set of points in this Geometry is empty.
size_t getNumInteriorRing() const
Returns number of interior rings (hole).
CoordinateSequence * getCoordinates() const
Returns this Geometry vertices. Caller takes ownership of the returned object.
void apply_ro(CoordinateSequenceFilter &filter) const
std::vector< const Polygon * > ConstVect
A vector of const Polygon pointers.
Definition Polygon.h:74
const LineString * getInteriorRingN(std::size_t n) const
Get nth interior ring (hole).
Geometry * convexHull() const
Returns the smallest convex Polygon that contains all the points in the Geometry.
std::string getGeometryType() const
Return a string representation of this Geometry type.
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
GeometryTypeId
Geometry types.
Definition Geometry.h:65
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25