GEOS  3.9.1dev
GeometryCollection.h
Go to the documentation of this file.
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 
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<Geometry>
75  clone() const override
76  {
77  return std::unique_ptr<Geometry>(new GeometryCollection(*this));
78  }
79 
80  ~GeometryCollection() override = default;
81 
82  void setSRID(int) override;
83 
97  std::unique_ptr<CoordinateSequence> getCoordinates() const override;
98 
99  bool isEmpty() const override;
100 
108  Dimension::DimensionType getDimension() const override;
109 
110  bool isDimensionStrict(Dimension::DimensionType d) const override;
111 
113  uint8_t getCoordinateDimension() const override;
114 
115  std::unique_ptr<Geometry> getBoundary() const override;
116 
122  int getBoundaryDimension() const override;
123 
124  std::size_t getNumPoints() const override;
125 
126  std::string getGeometryType() const override;
127 
128  GeometryTypeId getGeometryTypeId() const override;
129 
130  bool equalsExact(const Geometry* other,
131  double tolerance = 0) const override;
132 
133  void apply_ro(CoordinateFilter* filter) const override;
134 
135  void apply_rw(const CoordinateFilter* filter) override;
136 
137  void apply_ro(GeometryFilter* filter) const override;
138 
139  void apply_rw(GeometryFilter* filter) override;
140 
141  void apply_ro(GeometryComponentFilter* filter) const override;
142 
143  void apply_rw(GeometryComponentFilter* filter) override;
144 
145  void apply_rw(CoordinateSequenceFilter& filter) override;
146 
147  void apply_ro(CoordinateSequenceFilter& filter) const override;
148 
149  void normalize() override;
150 
151  const Coordinate* getCoordinate() const override;
152 
154  double getArea() const override;
155 
157  double getLength() const override;
158 
160  std::size_t getNumGeometries() const override;
161 
163  const Geometry* getGeometryN(std::size_t n) const override;
164 
172  std::unique_ptr<Geometry> reverse() const override;
173 
174 protected:
175 
177 
202  GeometryCollection(std::vector<Geometry*>* newGeoms, const GeometryFactory* newFactory);
203 
204  GeometryCollection(std::vector<std::unique_ptr<Geometry>> && newGeoms, const GeometryFactory& newFactory);
205 
207  template<typename T>
208  GeometryCollection(std::vector<std::unique_ptr<T>> && newGeoms, const GeometryFactory& newFactory) :
209  GeometryCollection(toGeometryArray(std::move(newGeoms)), newFactory) {}
210 
211  int
212  getSortIndex() const override
213  {
215  };
216 
217  std::vector<std::unique_ptr<Geometry>> geometries;
218 
219  Envelope::Ptr computeEnvelopeInternal() const override;
220 
221  int compareToSameClass(const Geometry* gc) const override;
222 
223 };
224 
225 } // namespace geos::geom
226 } // namespace geos
227 
228 #ifdef GEOS_INLINE
229 # include "geos/geom/GeometryCollection.inl"
230 #endif
231 
232 #endif // ndef GEOS_GEOS_GEOMETRYCOLLECTION_H
Geometry classes support the concept of applying a Geometry filter to the Geometry.
#define GEOS_DLL
Definition: export.h:28
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
std::unique_ptr< Geometry > clone() const override
Interface for classes which provide operations that can be applied to the coordinates in a Coordinate...
std::vector< std::unique_ptr< Geometry > > geometries
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...
Geometry classes support the concept of applying a coordinate filter to every coordinate in the Geome...
std::vector< std::unique_ptr< Geometry > >::const_iterator const_iterator
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Represents a collection of heterogeneous Geometry objects.
Basic namespace for all GEOS functionalities.
std::vector< std::unique_ptr< Geometry > >::iterator iterator
std::unique_ptr< Envelope > Ptr
Definition: Envelope.h:64