mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -17,9 +17,9 @@
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
|
||||
#include "std/boost_geometry.hpp"
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/register/ring.hpp>
|
||||
#include "std/boost_geometry.hpp"
|
||||
|
||||
BOOST_GEOMETRY_REGISTER_POINT_2D(m2::PointD, double, boost::geometry::cs::cartesian, x, y)
|
||||
BOOST_GEOMETRY_REGISTER_RING(std::vector<m2::PointD>)
|
||||
@@ -32,8 +32,7 @@ using namespace feature;
|
||||
|
||||
namespace
|
||||
{
|
||||
double CalculateOverlapPercentage(std::vector<m2::PointD> const & lhs,
|
||||
std::vector<m2::PointD> const & rhs)
|
||||
double CalculateOverlapPercentage(std::vector<m2::PointD> const & lhs, std::vector<m2::PointD> const & rhs)
|
||||
{
|
||||
if (!boost::geometry::intersects(lhs, rhs))
|
||||
return 0.0;
|
||||
@@ -49,7 +48,10 @@ double CalculateOverlapPercentage(std::vector<m2::PointD> const & lhs,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
bool FilterFeatureDefault(feature::FeatureBuilder const &) { return true; }
|
||||
bool FilterFeatureDefault(feature::FeatureBuilder const &)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
HierarchyPlace::HierarchyPlace(FeatureBuilder const & fb)
|
||||
: m_id(MakeCompositeId(fb))
|
||||
@@ -78,8 +80,7 @@ bool HierarchyPlace::Contains(HierarchyPlace const & smaller) const
|
||||
if (smaller.IsPoint())
|
||||
return Contains(smaller.GetCenter());
|
||||
|
||||
return smaller.GetArea() <= GetArea() &&
|
||||
CalculateOverlapPercentage(m_polygon, smaller.m_polygon) > 80.0;
|
||||
return smaller.GetArea() <= GetArea() && CalculateOverlapPercentage(m_polygon, smaller.m_polygon) > 80.0;
|
||||
}
|
||||
|
||||
bool HierarchyPlace::Contains(m2::PointD const & point) const
|
||||
@@ -87,10 +88,7 @@ bool HierarchyPlace::Contains(m2::PointD const & point) const
|
||||
return boost::geometry::covered_by(point, m_polygon);
|
||||
}
|
||||
|
||||
HierarchyLinker::HierarchyLinker(Node::Ptrs && nodes)
|
||||
: m_nodes(std::move(nodes)), m_tree(MakeTree4d(m_nodes))
|
||||
{
|
||||
}
|
||||
HierarchyLinker::HierarchyLinker(Node::Ptrs && nodes) : m_nodes(std::move(nodes)), m_tree(MakeTree4d(m_nodes)) {}
|
||||
|
||||
// static
|
||||
HierarchyLinker::Tree4d HierarchyLinker::MakeTree4d(Node::Ptrs const & nodes)
|
||||
@@ -106,7 +104,8 @@ HierarchyLinker::Node::Ptr HierarchyLinker::FindPlaceParent(HierarchyPlace const
|
||||
Node::Ptr parent = nullptr;
|
||||
auto minArea = std::numeric_limits<double>::max();
|
||||
auto const point = place.GetCenter();
|
||||
m_tree.ForEachInRect({point, point}, [&](auto const & candidateNode) {
|
||||
m_tree.ForEachInRect({point, point}, [&](auto const & candidateNode)
|
||||
{
|
||||
// https://wiki.openstreetmap.org/wiki/Simple_3D_buildings
|
||||
// An object with tag 'building:part' is a part of a relation with outline 'building' or
|
||||
// is contained in a object with tag 'building'. This case is second. We suppose a building part is
|
||||
@@ -160,8 +159,7 @@ HierarchyLinker::Node::Ptrs HierarchyLinker::Link()
|
||||
return m_nodes;
|
||||
}
|
||||
|
||||
HierarchyEntryEnricher::HierarchyEntryEnricher(std::string const & osm2FtIdsPath,
|
||||
std::string const & countryFullPath)
|
||||
HierarchyEntryEnricher::HierarchyEntryEnricher(std::string const & osm2FtIdsPath, std::string const & countryFullPath)
|
||||
: m_featureGetter(countryFullPath)
|
||||
{
|
||||
CHECK(m_osm2FtIds.ReadFromFile(osm2FtIdsPath), (osm2FtIdsPath));
|
||||
@@ -185,14 +183,11 @@ std::optional<m2::PointD> HierarchyEntryEnricher::GetFeatureCenter(CompositeId c
|
||||
if (!ftPtr)
|
||||
continue;
|
||||
|
||||
CHECK(m.emplace(base::Underlying(ftPtr->GetGeomType()), feature::GetCenter(*ftPtr)).second,
|
||||
(id, optIds));
|
||||
CHECK(m.emplace(base::Underlying(ftPtr->GetGeomType()), feature::GetCenter(*ftPtr)).second, (id, optIds));
|
||||
}
|
||||
|
||||
for (auto type : {
|
||||
base::Underlying(feature::GeomType::Point),
|
||||
base::Underlying(feature::GeomType::Area),
|
||||
base::Underlying(feature::GeomType::Line)})
|
||||
for (auto type : {base::Underlying(feature::GeomType::Point), base::Underlying(feature::GeomType::Area),
|
||||
base::Underlying(feature::GeomType::Line)})
|
||||
{
|
||||
if (m.count(type) != 0)
|
||||
return m[type];
|
||||
@@ -201,25 +196,24 @@ std::optional<m2::PointD> HierarchyEntryEnricher::GetFeatureCenter(CompositeId c
|
||||
return {};
|
||||
}
|
||||
|
||||
HierarchyLinesBuilder::HierarchyLinesBuilder(HierarchyLinker::Node::Ptrs && trees)
|
||||
: m_trees(std::move(trees))
|
||||
{
|
||||
}
|
||||
HierarchyLinesBuilder::HierarchyLinesBuilder(HierarchyLinker::Node::Ptrs && trees) : m_trees(std::move(trees)) {}
|
||||
|
||||
void HierarchyLinesBuilder::SetGetMainTypeFunction(GetMainTypeFn const & getMainType)
|
||||
{
|
||||
m_getMainType = getMainType;
|
||||
}
|
||||
|
||||
void HierarchyLinesBuilder::SetGetNameFunction(GetNameFn const & getName) { m_getName = getName; }
|
||||
void HierarchyLinesBuilder::SetGetNameFunction(GetNameFn const & getName)
|
||||
{
|
||||
m_getName = getName;
|
||||
}
|
||||
|
||||
void HierarchyLinesBuilder::SetCountry(storage::CountryId const & country)
|
||||
{
|
||||
m_countryName = country;
|
||||
}
|
||||
|
||||
void HierarchyLinesBuilder::SetHierarchyEntryEnricher(
|
||||
std::unique_ptr<HierarchyEntryEnricher> && enricher)
|
||||
void HierarchyLinesBuilder::SetHierarchyEntryEnricher(std::unique_ptr<HierarchyEntryEnricher> && enricher)
|
||||
{
|
||||
m_enricher = std::move(enricher);
|
||||
}
|
||||
@@ -231,11 +225,7 @@ std::vector<HierarchyEntry> HierarchyLinesBuilder::GetHierarchyLines()
|
||||
|
||||
std::vector<HierarchyEntry> lines;
|
||||
for (auto const & tree : m_trees)
|
||||
{
|
||||
tree_node::PreOrderVisit(tree, [&](auto const & node) {
|
||||
lines.emplace_back(Transform(node));
|
||||
});
|
||||
}
|
||||
tree_node::PreOrderVisit(tree, [&](auto const & node) { lines.emplace_back(Transform(node)); });
|
||||
|
||||
return lines;
|
||||
}
|
||||
@@ -274,18 +264,14 @@ HierarchyLinker::Node::Ptrs BuildHierarchy(std::vector<feature::FeatureBuilder>
|
||||
base::EraseIf(fbs, [&](auto const & fb) { return !filter->IsAccepted(fb); });
|
||||
HierarchyLinker::Node::Ptrs places;
|
||||
places.reserve(fbs.size());
|
||||
base::Transform(fbs, std::back_inserter(places), [](auto const & fb) {
|
||||
return tree_node::MakeTreeNode(HierarchyPlace(fb));
|
||||
});
|
||||
base::Transform(fbs, std::back_inserter(places),
|
||||
[](auto const & fb) { return tree_node::MakeTreeNode(HierarchyPlace(fb)); });
|
||||
auto nodes = HierarchyLinker(std::move(places)).Link();
|
||||
// We leave only the trees.
|
||||
base::EraseIf(nodes, [](auto const & node) {
|
||||
return node->HasParent();
|
||||
});
|
||||
base::EraseIf(nodes, [](auto const & node) { return node->HasParent(); });
|
||||
return nodes;
|
||||
}
|
||||
|
||||
|
||||
void AddChildrenTo(HierarchyLinker::Node::Ptrs & trees,
|
||||
std::function<std::vector<HierarchyPlace>(CompositeId const &)> const & fn)
|
||||
{
|
||||
@@ -293,7 +279,8 @@ void AddChildrenTo(HierarchyLinker::Node::Ptrs & trees,
|
||||
{
|
||||
CHECK(!tree->HasParent(), ());
|
||||
|
||||
tree_node::PostOrderVisit(tree, [&](auto const & n) {
|
||||
tree_node::PostOrderVisit(tree, [&](auto const & n)
|
||||
{
|
||||
auto const id = n->GetData().GetCompositeId();
|
||||
auto const & places = fn(id);
|
||||
for (auto place : places)
|
||||
@@ -309,16 +296,15 @@ void FlattenBuildingParts(HierarchyLinker::Node::Ptrs & trees)
|
||||
{
|
||||
for (auto & tree : trees)
|
||||
{
|
||||
|
||||
CHECK(!tree->HasParent(), ());
|
||||
|
||||
std::vector<
|
||||
std::pair<hierarchy::HierarchyLinker::Node::Ptr, hierarchy::HierarchyLinker::Node::Ptr>>
|
||||
std::vector<std::pair<hierarchy::HierarchyLinker::Node::Ptr, hierarchy::HierarchyLinker::Node::Ptr>>
|
||||
buildingPartsTrees;
|
||||
|
||||
static auto const & buildingPartChecker = ftypes::IsBuildingPartChecker::Instance();
|
||||
std::function<void(hierarchy::HierarchyLinker::Node::Ptr const &)> visit;
|
||||
visit = [&](auto const & n) {
|
||||
visit = [&](auto const & n)
|
||||
{
|
||||
if (buildingPartChecker(n->GetData().GetTypes()))
|
||||
{
|
||||
CHECK(n->HasParent(), ());
|
||||
@@ -337,7 +323,8 @@ void FlattenBuildingParts(HierarchyLinker::Node::Ptrs & trees)
|
||||
for (auto const & buildingAndParts : buildingPartsTrees)
|
||||
{
|
||||
Unlink(buildingAndParts.second, buildingAndParts.first);
|
||||
tree_node::PostOrderVisit(buildingAndParts.second, [&](auto const & buildingPartNode) {
|
||||
tree_node::PostOrderVisit(buildingAndParts.second, [&](auto const & buildingPartNode)
|
||||
{
|
||||
CHECK(buildingPartChecker(buildingPartNode->GetData().GetTypes()), ());
|
||||
buildingPartNode->RemoveChildren();
|
||||
tree_node::Link(buildingPartNode, buildingAndParts.first);
|
||||
|
||||
Reference in New Issue
Block a user