GEOS 3.15.0beta1
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
35namespace geos {
36namespace geom { // geos::geom
37class Coordinate;
39class LineString;
40}
41}
42
43namespace geos {
44namespace geom { // geos::geom
45
61class GEOS_DLL Polygon: public SurfaceImpl<LinearRing> {
62
63public:
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 std::unique_ptr<Surface> getCurved(const algorithm::LineToCurveParams& params) const {
98 return std::unique_ptr<Surface>(getCurvedImpl(params));
99 }
100
101 std::unique_ptr<Polygon> getLinearized(const algorithm::CurveToLineParams&) const;
102
103 void normalize() override;
104
105 std::unique_ptr<Polygon> reverse() const { return std::unique_ptr<Polygon>(reverseImpl()); }
106
107 double getArea() const override;
108
109 bool isRectangle() const override;
110
119 void orientRings(bool exteriorCW);
120
121protected:
122
123 using SurfaceImpl::SurfaceImpl;
124
125 Surface* getCurvedImpl(const algorithm::LineToCurveParams&) const override;
126
127 Polygon* getLinearizedImpl(const algorithm::CurveToLineParams&) const override { return cloneImpl(); };
128
129 Polygon* cloneImpl() const override { return new Polygon(*this); }
130
131 Polygon* reverseImpl() const override;
132
133 int
134 getSortIndex() const override
135 {
136 return SORTINDEX_POLYGON;
137 };
138
139
140private:
141
142 static void normalize(LinearRing* ring, bool clockwise);
143
144};
145
146} // namespace geos::geom
147} // namespace geos
148
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition CoordinateSequenceFilter.h:56
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:220
Definition LineString.h:66
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::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
double getArea() const override
Returns the area of this Geometry.
std::unique_ptr< CoordinateSequence > getCoordinates() const override
Returns this Geometry vertices. Caller takes ownership of the returned object.
std::unique_ptr< Geometry > getBoundary() const override
Computes the boundary of this geometry.
std::unique_ptr< Polygon > clone() const
Definition Polygon.h:81
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 ...
Polygon * reverseImpl() const override
Make a geometry with coordinates in reverse order.
Polygon * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition Polygon.h:129
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
Definition Surface.h:27
Definition Angle.h:26
GeometryTypeId
Geometry types.
Definition Geometry.h:78
Basic namespace for all GEOS functionalities.
Definition geos.h:38