GEOS  3.8.0dev
Polygon.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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/geom/Geometry.h> // for inheritance
28 #include <geos/geom/Polygonal.h> // for inheritance
29 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
30 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
31 
32 #include <geos/inline.h>
33 
34 #include <memory> // for unique_ptr
35 
36 // Forward declarations
37 namespace geos {
38 namespace geom { // geos::geom
39 class Coordinate;
40 class CoordinateArraySequence;
41 class CoordinateSequenceFilter;
42 class LinearRing;
43 class LineString;
44 }
45 }
46 
47 namespace geos {
48 namespace geom { // geos::geom
49 
65 class GEOS_DLL Polygon: public virtual Geometry, public Polygonal {
66 
67 public:
68 
69  friend class GeometryFactory;
70 
72  typedef std::vector<const Polygon*> ConstVect;
73 
74  ~Polygon() override;
75 
82  Geometry*
83  clone() const override
84  {
85  return new Polygon(*this);
86  }
87 
88  CoordinateSequence* getCoordinates() const override;
89 
90  size_t getNumPoints() const override;
91 
93  Dimension::DimensionType getDimension() const override;
94 
96  int getCoordinateDimension() const override;
97 
99  int getBoundaryDimension() const override;
100 
107  Geometry* getBoundary() const override;
108 
109  bool isEmpty() const override;
110 
112  const LineString* getExteriorRing() const;
113 
115  size_t getNumInteriorRing() const;
116 
118  const LineString* getInteriorRingN(std::size_t n) const;
119 
120  std::string getGeometryType() const override;
121  GeometryTypeId getGeometryTypeId() const override;
122  bool equalsExact(const Geometry* other, double tolerance = 0) const override;
123  void apply_rw(const CoordinateFilter* filter) override;
124  void apply_ro(CoordinateFilter* filter) const override;
125  void apply_rw(GeometryFilter* filter) override;
126  void apply_ro(GeometryFilter* filter) const override;
127  void apply_rw(CoordinateSequenceFilter& filter) override;
128  void apply_ro(CoordinateSequenceFilter& filter) const override;
129  void apply_rw(GeometryComponentFilter* filter) override;
130  void apply_ro(GeometryComponentFilter* filter) const override;
131 
132  Geometry* convexHull() const override;
133 
134  void normalize() override;
135 
136  Geometry* reverse() const override;
137 
138  int compareToSameClass(const Geometry* p) const override; //was protected
139 
140  const Coordinate* getCoordinate() const override;
141 
142  double getArea() const override;
143 
145  double getLength() const override;
146 
147  bool isRectangle() const override;
148 
149 protected:
150 
151 
152  Polygon(const Polygon& p);
153 
172  Polygon(LinearRing* newShell, std::vector<Geometry*>* newHoles,
173  const GeometryFactory* newFactory);
174 
175  LinearRing* shell;
176 
177  std::vector<Geometry*>* holes; //Actually vector<LinearRing *>
178 
179  Envelope::Ptr computeEnvelopeInternal() const override;
180 
181  int
182  getSortIndex() const override
183  {
184  return SORTINDEX_POLYGON;
185  };
186 
187 
188 private:
189 
190  void normalize(LinearRing* ring, bool clockwise);
191 };
192 
193 } // namespace geos::geom
194 } // namespace geos
195 
196 #endif // ndef GEOS_GEOM_POLYGON_H
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
std::vector< const Polygon * > ConstVect
A vector of const Polygon pointers.
Definition: Polygon.h:72
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Definition: CoordinateSequenceFilter.h:58
GeometryTypeId
Geometry types.
Definition: Geometry.h:74
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Definition: CoordinateFilter.h:43
Definition: LineString.h:69
Definition: Polygonal.h:37
Represents a linear polygon, which may include holes.
Definition: Polygon.h:65
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:56
Geometry * clone() const override
Definition: Polygon.h:83
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43