| 33 | namespace |
| 34 | { |
| 35 | double 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 | |
| 51 | bool FilterFeatureDefault(feature::FeatureBuilder const &) |