MCPcopy Create free account
hub / github.com/comaps/comaps / CalculateOverlapPercentage

Function CalculateOverlapPercentage

generator/hierarchy.cpp:35–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33namespace
34{
35double CalculateOverlapPercentage(std::vector<m2::PointD> const & lhs, std::vector<m2::PointD> const & rhs)
36{
37 if (!boost::geometry::intersects(lhs, rhs))
38 return 0.0;
39
40 using BoostPolygon = boost::geometry::model::polygon<m2::PointD>;
41 std::vector<BoostPolygon> coll;
42 boost::geometry::intersection(lhs, rhs, coll);
43 auto const min = std::min(boost::geometry::area(lhs), boost::geometry::area(rhs));
44 CHECK_GREATER(min, 0.0, (min));
45 auto const binOp = [](double x, BoostPolygon const & y) { return x + boost::geometry::area(y); };
46 auto const sum = std::accumulate(std::cbegin(coll), std::cend(coll), 0.0, binOp);
47 return sum * 100 / min;
48}
49} // namespace
50
51bool FilterFeatureDefault(feature::FeatureBuilder const &)

Callers 1

ContainsMethod · 0.85

Calls 2

cbeginFunction · 0.85
cendFunction · 0.85

Tested by

no test coverage detected