Skip to content

Commit 33c133a

Browse files
committed
Simplify geometry_n function
1 parent c0f75fd commit 33c133a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/geom-functions.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ class geometry_n_visitor
7070

7171
void operator()(geom::collection_t const &input) const
7272
{
73-
*m_output = input[m_n - 1];
73+
*m_output = input[m_n];
7474
}
7575

7676
template <typename T>
7777
void operator()(geom::multigeometry_t<T> const &input) const
7878
{
79-
m_output->set<T>() = input[m_n - 1];
79+
m_output->set<T>() = input[m_n];
8080
}
8181

8282
template <typename T>
@@ -95,13 +95,13 @@ class geometry_n_visitor
9595

9696
void geometry_n(geometry_t *output, geometry_t const &input, std::size_t n)
9797
{
98-
auto const num = num_geometries(input);
99-
if (n < 1 || n > num) {
98+
auto const max = num_geometries(input);
99+
if (n < 1 || n > max) {
100100
output->reset();
101101
return;
102102
}
103103

104-
input.visit(geometry_n_visitor{output, n});
104+
input.visit(geometry_n_visitor{output, n - 1});
105105
output->set_srid(input.srid());
106106
}
107107

0 commit comments

Comments
 (0)