GEOS  3.6.1
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
38 namespace geos {
39  namespace geom { // geos::geom
40  class Coordinate;
41  class CoordinateArraySequence;
42  class CoordinateSequenceFilter;
43  class LinearRing;
44  class LineString;
45  }
46 }
47 
48 namespace geos {
49 namespace geom { // geos::geom
50 
66 class GEOS_DLL Polygon: public virtual Geometry, public Polygonal
67 {
68 
69 public:
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 
86  CoordinateSequence* getCoordinates() const;
87 
88  size_t getNumPoints() const;
89 
91  Dimension::DimensionType getDimension() const;
92 
94  virtual int getCoordinateDimension() const;
95 
97  int getBoundaryDimension() const;
98 
105  Geometry* getBoundary() const;
106 
107  bool isEmpty() const;
108 
115  bool isSimple() const;
116 
118  const LineString* getExteriorRing() const;
119 
121  size_t getNumInteriorRing() const;
122 
124  const LineString* getInteriorRingN(std::size_t n) const;
125 
126  std::string getGeometryType() const;
127  virtual GeometryTypeId getGeometryTypeId() 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;
133  void apply_rw(CoordinateSequenceFilter& filter);
134  void apply_ro(CoordinateSequenceFilter& filter) const;
135 
136  Geometry* convexHull() const;
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 
155 protected:
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 
187 private:
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
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:48
std::vector< const Polygon * > ConstVect
A vector of const Polygon pointers.
Definition: Polygon.h:74
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Definition: CoordinateSequenceFilter.h:58
GeometryTypeId
Geometry types.
Definition: Geometry.h:65
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Definition: CoordinateFilter.h:43
Definition: LineString.h:70
Definition: Polygonal.h:32
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Models an OGC SFS LinearRing.
Definition: LinearRing.h:57
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
virtual Geometry * clone() const
Definition: Polygon.h:84
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43