Skip to content

Commit e51b546

Browse files
committed
Add num_geometries() function to all geometry types
1 parent 337d0ba commit e51b546

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/geom.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ namespace geom {
2929

3030
class nullgeom_t
3131
{
32+
public:
33+
static std::size_t num_geometries() noexcept { return 0; }
34+
35+
constexpr friend bool operator==(nullgeom_t, nullgeom_t) noexcept
36+
{
37+
return true;
38+
}
39+
40+
constexpr friend bool operator!=(nullgeom_t, nullgeom_t) noexcept
41+
{
42+
return false;
43+
}
44+
3245
}; // class nullgeom_t
3346

3447
class point_t
@@ -42,6 +55,8 @@ class point_t
4255

4356
constexpr point_t(double x, double y) noexcept : m_x(x), m_y(y) {}
4457

58+
static std::size_t num_geometries() noexcept { return 1; }
59+
4560
constexpr double x() const noexcept { return m_x; }
4661
constexpr double y() const noexcept { return m_y; }
4762

@@ -83,6 +98,8 @@ class linestring_t : public point_list_t
8398
: point_list_t(list.begin(), list.end())
8499
{}
85100

101+
static std::size_t num_geometries() noexcept { return 1; }
102+
86103
}; // class linestring_t
87104

88105
class ring_t : public point_list_t
@@ -107,6 +124,8 @@ class polygon_t
107124

108125
explicit polygon_t(ring_t &&ring) : m_outer(std::move(ring)) {}
109126

127+
static std::size_t num_geometries() noexcept { return 1; }
128+
110129
ring_t const &outer() const noexcept { return m_outer; }
111130

112131
ring_t &outer() noexcept { return m_outer; }

0 commit comments

Comments
 (0)