GEOS  3.13.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 #pragma once
22 
23 #include <geos/export.h>
24 #include <string>
25 #include <vector>
26 #include <geos/geom/Geometry.h> // for inheritance
27 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
28 #include <geos/geom/LinearRing.h>
29 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
30 #include <geos/geom/SurfaceImpl.h>
31 
32 #include <memory> // for unique_ptr
33 
34 // Forward declarations
35 namespace geos {
36 namespace geom { // geos::geom
37 class Coordinate;
38 class CoordinateSequenceFilter;
39 class LineString;
40 }
41 }
42 
43 namespace geos {
44 namespace geom { // geos::geom
45 
61 class GEOS_DLL Polygon: public SurfaceImpl<LinearRing> {
62 
63 public:
64 
65  friend class GeometryFactory;
66 
68  typedef std::vector<const Polygon*> ConstVect;
69 
70  ~Polygon() override = default;
71 
72  std::unique_ptr<CoordinateSequence>
73  getCoordinates() const override;
74 
81  std::unique_ptr<Polygon> clone() const
82  {
83  return std::unique_ptr<Polygon>(cloneImpl());
84  }
85 
92  std::unique_ptr<Geometry> getBoundary() const override;
93 
94  std::string getGeometryType() const override;
96 
97  void normalize() override;
98 
99  std::unique_ptr<Polygon> reverse() const { return std::unique_ptr<Polygon>(reverseImpl()); }
100 
101  double getArea() const override;
102 
103  bool isRectangle() const override;
104 
113  void orientRings(bool exteriorCW);
114 
115 protected:
116 
117  using SurfaceImpl::SurfaceImpl;
118 
119  Polygon* cloneImpl() const override { return new Polygon(*this); }
120 
121  Polygon* reverseImpl() const override;
122 
123  int
124  getSortIndex() const override
125  {
126  return SORTINDEX_POLYGON;
127  };
128 
129 
130 private:
131 
132  void normalize(LinearRing* ring, bool clockwise);
133 
134 };
135 
136 } // namespace geos::geom
137 } // namespace geos
138 
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:70
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition: LinearRing.h:54
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
void normalize() override
std::unique_ptr< Polygon > clone() const
Definition: Polygon.h:81
std::string getGeometryType() const override
Return a string representation of this Geometry type.
std::vector< const Polygon * > ConstVect
A vector of const Polygon pointers.
Definition: Polygon.h:68
Polygon * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition: Polygon.h:119
double getArea() const override
Returns the area of this Geometry.
Polygon * reverseImpl() const override
Make a geometry with coordinates in reverse order.
std::unique_ptr< CoordinateSequence > getCoordinates() const override
Returns this Geometry vertices. Caller takes ownership of the returned object.
bool isRectangle() const override
Polygon overrides to check for actual rectangle.
void orientRings(bool exteriorCW)
Apply a ring ordering convention to this polygon, with interior rings having an opposite orientation ...
std::unique_ptr< Geometry > getBoundary() const override
Computes the boundary of this geometry.
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
GeometryTypeId
Geometry types.
Definition: Geometry.h:73
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25