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

Method UpdateViewport

libs/map/framework.cpp:1400–1434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1398}
1399
1400void Framework::UpdateViewport(search::Results const & results)
1401{
1402 // Setup viewport according to results.
1403 m2::AnyRectD viewport = m_currentModelView.GlobalRect();
1404 m2::PointD const center = viewport.Center();
1405
1406 double minDistance = numeric_limits<double>::max();
1407 search::Result const * res = nullptr;
1408 for (auto const & r : results)
1409 {
1410 if (r.HasPoint())
1411 {
1412 double const dist = center.SquaredLength(r.GetFeatureCenter());
1413 if (dist < minDistance)
1414 {
1415 minDistance = dist;
1416 res = &r;
1417 }
1418 }
1419 }
1420
1421 if (res)
1422 {
1423 m2::PointD const pt = res->GetFeatureCenter();
1424 if (!viewport.IsPointInside(pt))
1425 {
1426 viewport.SetSizesToIncludePoint(pt);
1427 double constexpr factor = 0.05;
1428 viewport.Inflate(viewport.GetLocalRect().SizeX() * factor, viewport.GetLocalRect().SizeY() * factor);
1429
1430 StopLocationFollow();
1431 ShowRect(viewport);
1432 }
1433 }
1434}
1435
1436void Framework::FillSearchResultsMarks(bool clear, search::Results const & results)
1437{

Calls 9

SquaredLengthMethod · 0.80
SizeXMethod · 0.80
SizeYMethod · 0.80
CenterMethod · 0.45
HasPointMethod · 0.45
GetFeatureCenterMethod · 0.45
IsPointInsideMethod · 0.45
InflateMethod · 0.45

Tested by

no test coverage detected