-
-
Notifications
You must be signed in to change notification settings - Fork 477
Expand file tree
/
Copy pathgeom.cpp
More file actions
46 lines (37 loc) · 1.06 KB
/
geom.cpp
File metadata and controls
46 lines (37 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This file is part of osm2pgsql (https://osm2pgsql.org/).
*
* Copyright (C) 2006-2026 by the osm2pgsql developer community.
* For a full list of authors see the git log.
*/
#include "geom.hpp"
#include <algorithm>
#include <numeric>
namespace geom {
void point_list_t::remove_duplicates()
{
auto const it = std::unique(begin(), end());
erase(it, end());
}
bool operator==(polygon_t const &a, polygon_t const &b) noexcept
{
return (a.outer() == b.outer()) && (a.inners() == b.inners());
}
bool operator!=(polygon_t const &a, polygon_t const &b) noexcept
{
return !(a == b);
}
std::size_t dimension(collection_t const &geom)
{
return std::accumulate(geom.cbegin(), geom.cend(), 0ULL,
[](std::size_t max, auto const &member) {
return std::max(max, dimension(member));
});
}
std::size_t dimension(geometry_t const &geom)
{
return geom.visit([](auto const &input) { return dimension(input); });
}
} // namespace geom