1 /********************************************************************** 2 * 3 * GEOS - Geometry Engine Open Source 4 * http://geos.osgeo.org 5 * 6 * Copyright (C) 2001-2002 Vivid Solutions Inc. 7 * Copyright (C) 2005 2006 Refractions Research Inc. 8 * 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. 13 * 14 ********************************************************************** 15 * 16 * Last port: geom/LinearRing.java r320 (JTS-1.12) 17 * 18 **********************************************************************/ 19 20 #ifndef GEOS_GEOS_LINEARRING_H 21 #define GEOS_GEOS_LINEARRING_H 22 23 #include <geos/export.h> 24 #include <string> 25 #include <vector> 26 #include <geos/geom/LineString.h> 27 28 #include <geos/inline.h> 29 30 // Forward declarations 31 namespace geos { 32 namespace geom { // geos::geom 33 class Coordinate; 34 class CoordinateArraySequence; 35 } 36 } 37 38 namespace geos { 39 namespace geom { // geos::geom 40 41 /** 42 * \brief 43 * Models an OGC SFS LinearRing. A LinearRing is a LineString which is both 44 * closed and simple. 45 * 46 * In other words, the first and last coordinate in the ring must be equal, 47 * and the interior of the ring must not self-intersect. Either orientation 48 * of the ring is allowed. 49 * 50 * A ring must have either 0 or 4 or more points. The first and last points 51 * must be equal (in 2D). If these conditions are not met, the constructors 52 * throw an {@link geos::util::IllegalArgumentException} 53 */ 54 class GEOS_DLL LinearRing : public LineString { 55 56 public: 57 58 /** \brief 59 * The minimum number of vertices allowed in a valid non-empty ring (= 4). 60 * Empty rings with 0 vertices are also valid. 61 */ 62 static const unsigned int MINIMUM_VALID_SIZE = 4; 63 64 LinearRing(const LinearRing& lr); 65 66 /** 67 * \brief Constructs a LinearRing with the given points. 68 * 69 * @param points points forming a closed and simple linestring, or 70 * <code>null</code> or an empty array to create the empty 71 * geometry. 72 * This array must not contain <code>null</code> elements. 73 * If not null LinearRing will take ownership of points. 74 * 75 * @param newFactory the GeometryFactory used to create this geometry 76 * 77 */ 78 LinearRing(CoordinateSequence* points, 79 const GeometryFactory* newFactory); 80 81 /// Hopefully cleaner version of the above 82 LinearRing(CoordinateSequence::Ptr && points, 83 const GeometryFactory& newFactory); 84 85 std::unique_ptr<Geometry> clone()86 clone() const override 87 { 88 return std::unique_ptr<Geometry>(new LinearRing(*this)); 89 } 90 91 ~LinearRing() override = default; 92 93 /** \brief 94 * Returns <code>Dimension.FALSE</code>, since by definition 95 * LinearRings do not have a boundary. 96 * 97 * @return Dimension::False 98 */ 99 int getBoundaryDimension() const override; 100 101 bool isClosed() const override; 102 103 std::string getGeometryType() const override; 104 105 GeometryTypeId getGeometryTypeId() const override; 106 107 void setPoints(const CoordinateSequence* cl); 108 109 std::unique_ptr<Geometry> reverse() const override; 110 111 protected: 112 113 int getSortIndex()114 getSortIndex() const override 115 { 116 return SORTINDEX_LINEARRING; 117 }; 118 119 120 private: 121 122 void validateConstruction(); 123 }; 124 125 126 } // namespace geos::geom 127 } // namespace geos 128 129 #endif // ndef GEOS_GEOS_LINEARRING_H 130