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

Function ScoreGeometry

libs/editor/feature_matcher.cpp:182–204  ·  view source on GitHub ↗

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;

Source from the content-addressed store, hash-verified

180/// |wayOrRelation| - either way or relation to be compared agains ourGeometry;
181/// |ourGeometry| - geometry of a FeatureType;
182double 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
207namespace matcher

Callers 1

GetBestOsmWayOrRelationFunction · 0.85

Calls 5

ASSERTFunction · 0.85
TrianglesToPolygonFunction · 0.85
GetIntersectionScoreFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected