GEOS  3.14.0dev
MultiPolygon.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  * Copyright (C) 2005 2006 Refractions Research Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: geom/MultiPolygon.java r320 (JTS-1.12)
18  *
19  **********************************************************************/
20 
21 #pragma once
22 
23 #include <geos/export.h>
24 #include <string>
25 #include <vector>
26 #include <geos/geom/GeometryCollection.h> // for inheritance
27 #include <geos/geom/Polygon.h> // for inheritance
28 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
29 #include <geos/geom/GeometryCollection.h>
30 
31 
32 // Forward declarations
33 namespace geos {
34 namespace geom { // geos::geom
35 class Coordinate;
36 class MultiPoint;
37 class Polygon;
38 }
39 }
40 
41 
42 namespace geos {
43 namespace geom { // geos::geom
44 
45 #ifdef _MSC_VER
46 #pragma warning(push)
47 #pragma warning(disable:4250) // T1 inherits T2 via dominance
48 #endif
49 
58 class GEOS_DLL MultiPolygon: public GeometryCollection {
59 public:
60 
61  friend class GeometryFactory;
62 
63  ~MultiPolygon() override;
64 
67 
68  bool hasDimension(Dimension::DimensionType d) const override {
69  return d == Dimension::A;
70  }
71 
73  return d == Dimension::A;
74  }
75 
77  int getBoundaryDimension() const override;
78 
85  std::unique_ptr<Geometry> getBoundary() const override;
86 
87  const Polygon* getGeometryN(std::size_t n) const override;
88 
89  std::string getGeometryType() const override;
90 
92 
93  std::unique_ptr<MultiPolygon> clone() const
94  {
95  return std::unique_ptr<MultiPolygon>(cloneImpl());
96  };
97 
98  std::unique_ptr<MultiPolygon> reverse() const { return std::unique_ptr<MultiPolygon>(reverseImpl()); }
99 
100 protected:
101 
123  MultiPolygon(std::vector<std::unique_ptr<Polygon>> && newPolys,
124  const GeometryFactory& newFactory);
125 
126  MultiPolygon(std::vector<std::unique_ptr<Geometry>> && newPolys,
127  const GeometryFactory& newFactory);
128 
129  MultiPolygon(const MultiPolygon& mp)
130  : GeometryCollection(mp)
131  {};
132 
133  MultiPolygon* cloneImpl() const override { return new MultiPolygon(*this); }
134 
135  MultiPolygon* reverseImpl() const override;
136 
137  int
138  getSortIndex() const override
139  {
140  return SORTINDEX_MULTIPOLYGON;
141  };
142 
143  bool hasCurvedComponents() const override
144  {
145  return false;
146  }
147 
148 };
149 
150 #ifdef _MSC_VER
151 #pragma warning(pop)
152 #endif
153 
154 } // namespace geos::geom
155 } // namespace geos
DimensionType
Definition: Dimension.h:29
@ A
Dimension value of a surface (2).
Definition: Dimension.h:46
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:51
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:70
Definition: MultiPolygon.h:58
int getBoundaryDimension() const override
Returns 1 (MultiPolygon boundary is MultiLineString)
Dimension::DimensionType getDimension() const override
Returns surface dimension (2)
std::string getGeometryType() const override
Return a string representation of this Geometry type.
GeometryTypeId getGeometryTypeId() const override
Return an integer representation of this Geometry type.
const Polygon * getGeometryN(std::size_t n) const override
Returns a pointer to the nth Geometry in this collection.
MultiPolygon * cloneImpl() const override
Make a deep-copy of this Geometry.
Definition: MultiPolygon.h:133
MultiPolygon * reverseImpl() const override
Make a geometry with coordinates in reverse order.
std::unique_ptr< Geometry > getBoundary() const override
Computes the boundary of this geometry.
bool hasCurvedComponents() const override
Returns whether the Geometry contains curved components.
Definition: MultiPolygon.h:143
bool isDimensionStrict(Dimension::DimensionType d) const override
Checks whether this Geometry consists only of components having dimension d.
Definition: MultiPolygon.h:72
MultiPolygon(std::vector< std::unique_ptr< Polygon >> &&newPolys, const GeometryFactory &newFactory)
Construct a MultiPolygon.
bool hasDimension(Dimension::DimensionType d) const override
Checks whether any component of this geometry has dimension d.
Definition: MultiPolygon.h:68
Represents a linear polygon, which may include holes.
Definition: Polygon.h:61
GeometryTypeId
Geometry types.
Definition: Geometry.h:74
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25