@@ -32,6 +32,8 @@ point_t interpolate(point_t p1, point_t p2, double frac) noexcept
3232 frac * (p1.y () - p2.y ()) + p2.y ()};
3333}
3434
35+ /* ***************************************************************************/
36+
3537std::string_view geometry_type (geometry_t const &geom)
3638{
3739 using namespace std ::literals::string_view_literals;
@@ -52,12 +54,16 @@ std::string_view geometry_type(geometry_t const &geom)
5254 }});
5355}
5456
57+ /* ***************************************************************************/
58+
5559std::size_t num_geometries (geometry_t const &geom)
5660{
5761 return geom.visit (
58- overloaded{ [&](auto const &input) { return input.num_geometries (); } });
62+ [&](auto const &input) { return input.num_geometries (); });
5963}
6064
65+ /* ***************************************************************************/
66+
6167namespace {
6268
6369class geometry_n_visitor
@@ -67,8 +73,6 @@ class geometry_n_visitor
6773 : m_output(output), m_n(n)
6874 {}
6975
70- void operator ()(nullgeom_t const & /* input*/ ) const { m_output->reset (); }
71-
7276 void operator ()(geom::collection_t const &input) const
7377 {
7478 *m_output = input[m_n];
@@ -113,11 +117,13 @@ geometry_t geometry_n(geometry_t const &input, std::size_t n)
113117 return output;
114118}
115119
120+ /* ***************************************************************************/
121+
116122namespace {
117123
118124void set_to_same_type (geometry_t *output, geometry_t const &input)
119125{
120- input.visit (overloaded{ [&](auto in) { output->set <decltype (in)>(); } });
126+ input.visit ([&](auto in) { output->set <decltype (in)>(); });
121127}
122128
123129class transform_visitor
@@ -233,6 +239,8 @@ geometry_t transform(geometry_t const &input, reprojection const &reprojection)
233239 return output;
234240}
235241
242+ /* ***************************************************************************/
243+
236244namespace {
237245
238246/* *
@@ -335,6 +343,8 @@ geometry_t segmentize(geometry_t const &input, double max_segment_length)
335343 return output;
336344}
337345
346+ /* ***************************************************************************/
347+
338348double area (geometry_t const &geom)
339349{
340350 return std::abs (geom.visit (
@@ -350,6 +360,8 @@ double area(geometry_t const &geom)
350360 }}));
351361}
352362
363+ /* ***************************************************************************/
364+
353365double length (geometry_t const &geom)
354366{
355367 return geom.visit (overloaded{
@@ -366,6 +378,8 @@ double length(geometry_t const &geom)
366378 }});
367379}
368380
381+ /* ***************************************************************************/
382+
369383namespace {
370384
371385class split_visitor
@@ -415,25 +429,6 @@ std::vector<geometry_t> split_multi(geometry_t &&geom, bool split_multi)
415429 return output;
416430}
417431
418- /* *
419- * Add points specified by iterators to the linestring. If linestring is not
420- * empty, do not add the first point returned by *it.
421- */
422- template <typename ITERATOR>
423- static void add_nodes_to_linestring (linestring_t *linestring, ITERATOR it,
424- ITERATOR end)
425- {
426- if (!linestring->empty ()) {
427- assert (it != end);
428- ++it;
429- }
430-
431- while (it != end) {
432- linestring->push_back (*it);
433- ++it;
434- }
435- }
436-
437432/* ***************************************************************************/
438433
439434static void reverse (geom::nullgeom_t * /* output*/ ,
@@ -490,6 +485,25 @@ geometry_t reverse(geometry_t const &input)
490485
491486/* ***************************************************************************/
492487
488+ /* *
489+ * Add points specified by iterators to the linestring. If linestring is not
490+ * empty, do not add the first point returned by *it.
491+ */
492+ template <typename ITERATOR>
493+ static void add_nodes_to_linestring (linestring_t *linestring, ITERATOR it,
494+ ITERATOR end)
495+ {
496+ if (!linestring->empty ()) {
497+ assert (it != end);
498+ ++it;
499+ }
500+
501+ while (it != end) {
502+ linestring->push_back (*it);
503+ ++it;
504+ }
505+ }
506+
493507void line_merge (geometry_t *output, geometry_t const &input)
494508{
495509 if (input.is_linestring ()) {
@@ -672,6 +686,8 @@ geometry_t line_merge(geometry_t const &input)
672686 return output;
673687}
674688
689+ /* ***************************************************************************/
690+
675691/* *
676692 * This helper function is used to calculate centroids of geometry collections.
677693 * It first creates a multi geometry that only contains the geometries of
0 commit comments