Returns value form [-1, 1]. Negative values are used as penalty, positive as score. |osmResponse| - nodes, ways and relations from osm; |wayOrRelation| - either way or relation to be compared agains ourGeometry; |ourGeometry| - geometry of a FeatureType;
| 180 | /// |wayOrRelation| - either way or relation to be compared agains ourGeometry; |
| 181 | /// |ourGeometry| - geometry of a FeatureType; |
| 182 | double ScoreGeometry(pugi::xml_document const & osmResponse, pugi::xml_node const & wayOrRelation, |
| 183 | std::vector<m2::PointD> const & ourGeometry) |
| 184 | { |
| 185 | ASSERT(!ourGeometry.empty(), ("Our geometry cannot be empty")); |
| 186 | |
| 187 | auto const their = GetWaysOrRelationsGeometry(osmResponse, wayOrRelation); |
| 188 | |
| 189 | if (bg::is_empty(their)) |
| 190 | return geometry::kPenaltyScore; |
| 191 | |
| 192 | auto const our = geometry::TrianglesToPolygon(ourGeometry); |
| 193 | |
| 194 | if (bg::is_empty(our)) |
| 195 | return geometry::kPenaltyScore; |
| 196 | |
| 197 | auto const score = geometry::GetIntersectionScore(our, their); |
| 198 | |
| 199 | // If area of the intersection is a half of the object area, penalty score will be returned. |
| 200 | if (score <= 0.5) |
| 201 | return geometry::kPenaltyScore; |
| 202 | |
| 203 | return score; |
| 204 | } |
| 205 | } // namespace |
| 206 | |
| 207 | namespace matcher |
no test coverage detected