GEOS  3.7.2
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/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 unique_ptr<>
31 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
32 
33 #include <geos/inline.h>
34 
35 #include <memory> // for unique_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  ~Polygon() override;
77 
84  Geometry *clone() const override { return new Polygon(*this); }
85 
86  CoordinateSequence* getCoordinates() const override;
87 
88  size_t getNumPoints() const override;
89 
91  Dimension::DimensionType getDimension() const override;
92 
94  int getCoordinateDimension() const override;
95 
97  int getBoundaryDimension() const override;
98 
105  Geometry* getBoundary() const override;
106 
107  bool isEmpty() const override;
108 
115  bool isSimple() const override;
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 override;
127  GeometryTypeId getGeometryTypeId() const override;
128  bool equalsExact(const Geometry *other, double tolerance=0) const override;
129  void apply_rw(const CoordinateFilter *filter) override;
130  void apply_ro(CoordinateFilter *filter) const override;
131  void apply_rw(GeometryFilter *filter) override;
132  void apply_ro(GeometryFilter *filter) const override;
133  void apply_rw(CoordinateSequenceFilter& filter) override;
134  void apply_ro(CoordinateSequenceFilter& filter) const override;
135 
136  Geometry* convexHull() const override;
137 
138  void normalize() override;
139 
140  Geometry* reverse() const override;
141 
142  int compareToSameClass(const Geometry *p) const override; //was protected
143 
144  const Coordinate* getCoordinate() const override;
145 
146  double getArea() const override;
147 
149  double getLength() const override;
150 
151  void apply_rw(GeometryComponentFilter *filter) override;
152 
153  void apply_ro(GeometryComponentFilter *filter) const override;
154 
155  bool isRectangle() const override;
156 
157 protected:
158 
159 
160  Polygon(const Polygon &p);
161 
180  Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles,
181  const GeometryFactory *newFactory);
182 
183  LinearRing *shell;
184 
185  std::vector<Geometry *> *holes; //Actually vector<LinearRing *>
186 
187  Envelope::Ptr computeEnvelopeInternal() const override;
188 
189 private:
190 
191  void normalize(LinearRing *ring, bool clockwise);
192 };
193 
194 } // namespace geos::geom
195 } // namespace geos
196 
197 #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:75
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:177
Definition: CoordinateFilter.h:43
Definition: LineString.h:70
Definition: Polygonal.h:37
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
Geometry * clone() const override
Definition: Polygon.h:84
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43