GEOS  3.10.1
GeometryCollection.h
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/GeometryCollection.java rev. 1.41
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_GEOS_GEOMETRYCOLLECTION_H
21 #define GEOS_GEOS_GEOMETRYCOLLECTION_H
22 
23 #include <geos/export.h>
24 #include <geos/geom/Geometry.h> // for inheritance
25 #include <geos/geom/Envelope.h> // for proper use of unique_ptr<>
26 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
27 
28 #include <geos/inline.h>
29 
30 #include <string>
31 #include <vector>
32 #include <memory> // for unique_ptr
33 
34 // Forward declarations
35 namespace geos {
36 namespace geom { // geos::geom
37 class Coordinate;
38 class CoordinateArraySequence;
39 class CoordinateSequenceFilter;
40 }
41 }
42 
43 namespace geos {
44 namespace geom { // geos::geom
45 
55 class GEOS_DLL GeometryCollection : public Geometry {
56 
57 public:
58  friend class GeometryFactory;
59 
60  typedef std::vector<std::unique_ptr<Geometry>>::const_iterator const_iterator;
61 
62  typedef std::vector<std::unique_ptr<Geometry>>::iterator iterator;
63 
64  const_iterator begin() const;
65 
66  const_iterator end() const;
67 
74  std::unique_ptr<GeometryCollection> clone() const
75  {
76  return std::unique_ptr<GeometryCollection>(cloneImpl());
77  }
78 
79  ~GeometryCollection() override = default;
80 
81  void setSRID(int) override;
82 
96  std::unique_ptr<CoordinateSequence> getCoordinates() const override;
97 
98  bool isEmpty() const override;
99 
107  Dimension::DimensionType getDimension() const override;
108 
109  bool isDimensionStrict(Dimension::DimensionType d) const override;
110 
112  uint8_t getCoordinateDimension() const override;
113 
114  std::unique_ptr<Geometry> getBoundary() const override;
115 
121  int getBoundaryDimension() const override;
122 
123  std::size_t getNumPoints() const override;
124 
125  std::string getGeometryType() const override;
126 
127  GeometryTypeId getGeometryTypeId() const override;
128 
129  bool equalsExact(const Geometry* other,
130  double tolerance = 0) const override;
131 
132  void apply_ro(CoordinateFilter* filter) const override;
133 
134  void apply_rw(const CoordinateFilter* filter) override;
135 
136  void apply_ro(GeometryFilter* filter) const override;
137 
138  void apply_rw(GeometryFilter* filter) override;
139 
140  void apply_ro(GeometryComponentFilter* filter) const override;
141 
142  void apply_rw(GeometryComponentFilter* filter) override;
143 
144  void apply_rw(CoordinateSequenceFilter& filter) override;
145 
146  void apply_ro(CoordinateSequenceFilter& filter) const override;
147 
148  void normalize() override;
149 
150  const Coordinate* getCoordinate() const override;
151 
153  double getArea() const override;
154 
156  double getLength() const override;
157 
159  std::size_t getNumGeometries() const override;
160 
162  const Geometry* getGeometryN(std::size_t n) const override;
163 
171  std::vector<std::unique_ptr<Geometry>> releaseGeometries();
172 
180  std::unique_ptr<GeometryCollection> reverse() const { return std::unique_ptr<GeometryCollection>(reverseImpl()); }
181 
182 protected:
183 
185 
210  GeometryCollection(std::vector<Geometry*>* newGeoms, const GeometryFactory* newFactory);
211 
212  GeometryCollection(std::vector<std::unique_ptr<Geometry>> && newGeoms, const GeometryFactory& newFactory);
213 
215  template<typename T>
216  GeometryCollection(std::vector<std::unique_ptr<T>> && newGeoms, const GeometryFactory& newFactory) :
217  GeometryCollection(toGeometryArray(std::move(newGeoms)), newFactory) {}
218 
219  GeometryCollection* cloneImpl() const override { return new GeometryCollection(*this); }
220 
221  GeometryCollection* reverseImpl() const override;
222 
223  int
224  getSortIndex() const override
225  {
226  return SORTINDEX_GEOMETRYCOLLECTION;
227  };
228 
229  std::vector<std::unique_ptr<Geometry>> geometries;
230 
231  Envelope::Ptr computeEnvelopeInternal() const override;
232 
233  int compareToSameClass(const Geometry* gc) const override;
234 
235 };
236 
237 } // namespace geos::geom
238 } // namespace geos
239 
240 #ifdef GEOS_INLINE
241 # include "geos/geom/GeometryCollection.inl"
242 #endif
243 
244 #endif // ndef GEOS_GEOS_GEOMETRYCOLLECTION_H
Geometry classes support the concept of applying a Geometry filter to the Geometry.
Definition: GeometryFilter.h:47
std::unique_ptr< GeometryCollection > reverse() const
Definition: GeometryCollection.h:180
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
Definition: CoordinateSequenceFilter.h:57
GeometryTypeId
Geometry types.
Definition: Geometry.h:75
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
GeometryCollection(std::vector< std::unique_ptr< T >> &&newGeoms, const GeometryFactory &newFactory)
Convenience constructor to build a GeometryCollection from vector of Geometry subclass pointers...
Definition: GeometryCollection.h:216
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
Definition: CoordinateFilter.h:43
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
Basic namespace for all GEOS functionalities.
Definition: Angle.h:26
std::unique_ptr< GeometryCollection > clone() const
Definition: GeometryCollection.h:74
GeometryCollection * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition: GeometryCollection.h:219
DimensionType
Definition: Dimension.h:31
Definition: GeometryComponentFilter.h:43