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

Function GetSimilarity

libs/search/geocoder.cpp:269–278  ·  view source on GitHub ↗

@brief Computes the average similarity between |rect| and |pivot|. By similarity between two rects we mean a fraction of the area of rects intersection to the area of the smallest rect. @return [0, 1]

Source from the content-addressed store, hash-verified

267/// rects intersection to the area of the smallest rect.
268/// @return [0, 1]
269double GetSimilarity(m2::RectD const & pivot, m2::RectD const & rect)
270{
271 double const area = min(Area(pivot), Area(rect));
272 if (area == 0.0)
273 return 0.0;
274 m2::RectD p = pivot;
275 if (!p.Intersect(rect))
276 return 0.0;
277 return Area(p) / area;
278}
279
280// Returns shortest distance from the |pivot| to the |rect|.
281//

Callers 2

OrderCountriesMethod · 0.85
LeaveTopLocalitiesMethod · 0.85

Calls 2

AreaFunction · 0.70
IntersectMethod · 0.45

Tested by

no test coverage detected