GEOS 3.3.4

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

Polygon.h
1 /**********************************************************************
2 * $Id: Polygon.h 3185 2011-02-07 15:39:27Z strk $
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://geos.refractions.net
6 *
7 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
8 * Copyright (C) 2005 2006 Refractions Research Inc.
9 * Copyright (C) 2001-2002 Vivid Solutions Inc.
10 *
11 * This is free software; you can redistribute and/or modify it under
12 * the terms of the GNU Lesser General Public Licence as published
13 * by the Free Software Foundation.
14 * See the COPYING file for more information.
15 *
16 **********************************************************************
17 *
18 * Last port: geom/Polygon.java r320 (JTS-1.12)
19 *
20 **********************************************************************/
21
22 #ifndef GEOS_GEOM_POLYGON_H
23 #define GEOS_GEOM_POLYGON_H
24
25 #include <geos/export.h>
26 #include <string>
27 #include <vector>
28 #include <geos/platform.h>
29 #include <geos/geom/Geometry.h> // for inheritance
30 #include <geos/geom/Polygonal.h> // for inheritance
31 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
32 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
33
34 #include <geos/inline.h>
35
36 #include <memory> // for auto_ptr
37
38 // Forward declarations
39 namespace geos {
40 namespace geom { // geos::geom
41 class Coordinate;
42 class CoordinateArraySequence;
43 class CoordinateSequenceFilter;
44 class LinearRing;
45 class LineString;
46 }
47 }
48
49 namespace geos {
50 namespace geom { // geos::geom
51
67 class GEOS_DLL Polygon: public virtual Geometry, public Polygonal
68 {
69
70 public:
71
72 friend class GeometryFactory;
73
75 typedef std::vector<const Polygon *> ConstVect;
76
77 virtual ~Polygon();
78
85 virtual Geometry *clone() const { return new Polygon(*this); }
86
87 CoordinateSequence* getCoordinates() const;
88
89 size_t getNumPoints() const;
90
92 Dimension::DimensionType getDimension() const;
93
95 virtual int getCoordinateDimension() const;
96
98 int getBoundaryDimension() const;
99
106 Geometry* getBoundary() const;
107
108 bool isEmpty() const;
109
116 bool isSimple() const;
117
119 const LineString* getExteriorRing() const;
120
122 size_t getNumInteriorRing() const;
123
125 const LineString* getInteriorRingN(std::size_t n) const;
126
127 std::string getGeometryType() const;
128 virtual GeometryTypeId getGeometryTypeId() const;
129 bool equalsExact(const Geometry *other, double tolerance=0) const;
130 void apply_rw(const CoordinateFilter *filter);
131 void apply_ro(CoordinateFilter *filter) const;
132 void apply_rw(GeometryFilter *filter);
133 void apply_ro(GeometryFilter *filter) const;
134 void apply_rw(CoordinateSequenceFilter& filter);
135 void apply_ro(CoordinateSequenceFilter& filter) const;
136
137 Geometry* convexHull() const;
138
139 void normalize();
140
141 int compareToSameClass(const Geometry *p) const; //was protected
142
143 const Coordinate* getCoordinate() const;
144
145 double getArea() const;
146
148 double getLength() const;
149
150 void apply_rw(GeometryComponentFilter *filter);
151
152 void apply_ro(GeometryComponentFilter *filter) const;
153
154 bool isRectangle() const;
155
156 protected:
157
158
159 Polygon(const Polygon &p);
160
179 Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles,
180 const GeometryFactory *newFactory);
181
182 LinearRing *shell;
183
184 std::vector<Geometry *> *holes; //Actually vector<LinearRing *>
185
186 Envelope::AutoPtr computeEnvelopeInternal() const;
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
197
198 /**********************************************************************
199 * $Log$
200 * Revision 1.7 2006/06/08 17:58:57 strk
201 * Polygon::getNumInteriorRing() return size_t, Polygon::interiorRingN() takes size_t.
202 *
203 * Revision 1.6 2006/05/04 15:49:39 strk
204 * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
205 *
206 * Revision 1.5 2006/04/28 10:55:39 strk
207 * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
208 * which has been made friend of all Geometry derivates. getNumPoints() changed to return
209 * size_t.
210 *
211 * Revision 1.4 2006/04/10 18:15:09 strk
212 * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
213 * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
214 *
215 * Revision 1.3 2006/03/24 09:52:41 strk
216 * USE_INLINE => GEOS_INLINE
217 *
218 * Revision 1.2 2006/03/15 09:12:45 strk
219 * isSimple doc
220 *
221 * Revision 1.1 2006/03/09 16:46:49 strk
222 * geos::geom namespace definition, first pass at headers split
223 *
224 **********************************************************************/