Complete Note#1 in the http://wiki.osgeo.org/wiki/GEOS_Provenance_Review to get out...
[geos.git] / include / geos / geom / LinearRing.h
blobaecaa00a24b62ec61380ec5c3854fdb575e61e09
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2001-2002 Vivid Solutions Inc.
7 * Copyright (C) 2005 2006 Refractions Research Inc.
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
14 **********************************************************************
16 * Last port: geom/LinearRing.java r320 (JTS-1.12)
18 **********************************************************************/
20 #ifndef GEOS_GEOS_LINEARRING_H
21 #define GEOS_GEOS_LINEARRING_H
23 #include <geos/export.h>
24 #include <string>
25 #include <vector>
26 #include <geos/platform.h>
27 #include <geos/geom/LineString.h>
29 #include <geos/inline.h>
31 // Forward declarations
32 namespace geos {
33 namespace geom { // geos::geom
34 class Coordinate;
35 class CoordinateArraySequence;
39 namespace geos {
40 namespace geom { // geos::geom
42 /**
43 * \brief
44 * Models an OGC SFS <code>LinearRing</code>.
46 * A LinearRing is a LineString which is both closed and simple.
47 * In other words,
48 * the first and last coordinate in the ring must be equal,
49 * and the interior of the ring must not self-intersect.
50 * Either orientation of the ring is allowed.
52 * A ring must have either 0 or 4 or more points.
53 * The first and last points must be equal (in 2D).
54 * If these conditions are not met, the constructors throw
55 * an {@link IllegalArgumentException}
57 class GEOS_DLL LinearRing : public LineString {
59 public:
61 /**
62 * The minimum number of vertices allowed in a valid non-empty ring (= 4).
63 * Empty rings with 0 vertices are also valid.
65 static const unsigned int MINIMUM_VALID_SIZE = 4;
67 LinearRing(const LinearRing &lr);
69 /**
70 * \brief Constructs a <code>LinearRing</code> with the given points.
72 * @param points points forming a closed and simple linestring, or
73 * <code>null</code> or an empty array to create the empty
74 * geometry.
75 * This array must not contain <code>null</code> elements.
76 * If not null LinearRing will take ownership of points.
78 * @param newFactory the GeometryFactory used to create this geometry
81 LinearRing(CoordinateSequence* points,
82 const GeometryFactory *newFactory);
84 /// Hopefully cleaner version of the above
85 LinearRing(CoordinateSequence::AutoPtr points,
86 const GeometryFactory *newFactory);
88 virtual Geometry *clone() const { return new LinearRing(*this); }
90 virtual ~LinearRing();
92 /** \brief
93 * Returns <code>Dimension.FALSE</code>, since by definition
94 * LinearRings do not have a boundary.
96 * @return Dimension::False
98 int getBoundaryDimension() const;
100 /** \brief
101 * Returns <code>true</code>, since by definition LinearRings
102 * are always simple.
104 * @return <code>true</code>
106 * @see Geometry::isSimple
108 bool isSimple() const;
110 bool isClosed() const;
112 std::string getGeometryType() const;
114 virtual GeometryTypeId getGeometryTypeId() const;
116 void setPoints(CoordinateSequence* cl);
118 Geometry* reverse() const;
120 private:
122 void validateConstruction();
126 } // namespace geos::geom
127 } // namespace geos
129 //#ifdef GEOS_INLINE
130 //# include "geos/geom/LinearRing.inl"
131 //#endif
133 #endif // ndef GEOS_GEOS_LINEARRING_H
135 /**********************************************************************
136 * $Log$
137 * Revision 1.4 2006/04/11 11:16:25 strk
138 * Added LineString and LinearRing constructors by auto_ptr
140 * Revision 1.3 2006/04/10 17:35:44 strk
141 * Changed LineString::points and Point::coordinates to be wrapped
142 * in an auto_ptr<>. This should close bugs #86 and #89
144 * Revision 1.2 2006/03/24 09:52:41 strk
145 * USE_INLINE => GEOS_INLINE
147 * Revision 1.1 2006/03/09 16:46:49 strk
148 * geos::geom namespace definition, first pass at headers split
150 **********************************************************************/