forked from organicmaps/organicmaps
Code review fixes.
This commit is contained in:
parent
5e80faf98e
commit
b6211a050a
4 changed files with 7 additions and 15 deletions
|
@ -1687,36 +1687,29 @@ bool Framework::ShowMapForURL(string const & url)
|
|||
return false;
|
||||
}
|
||||
|
||||
size_t Framework::ForEachFeatureAtPoint(TFeatureTypeFn && fn, m2::PointD const & mercator) const
|
||||
void Framework::ForEachFeatureAtPoint(TFeatureTypeFn && fn, m2::PointD const & mercator) const
|
||||
{
|
||||
constexpr double kSelectRectWidthInMeters = 1.1;
|
||||
constexpr double kMetersToLinearFeature = 3;
|
||||
constexpr int kScale = scales::GetUpperScale();
|
||||
m2::RectD const rect = MercatorBounds::RectByCenterXYAndSizeInMeters(mercator, kSelectRectWidthInMeters);
|
||||
size_t processedFeaturesCount = 0;
|
||||
m_model.ForEachFeature(rect, [&](FeatureType & ft)
|
||||
{
|
||||
switch (ft.GetFeatureType())
|
||||
{
|
||||
case feature::GEOM_POINT:
|
||||
if (rect.IsPointInside(ft.GetCenter()))
|
||||
{
|
||||
fn(ft);
|
||||
++processedFeaturesCount;
|
||||
}
|
||||
break;
|
||||
case feature::GEOM_LINE:
|
||||
if (feature::GetMinDistanceMeters(ft, mercator) < kMetersToLinearFeature)
|
||||
{
|
||||
fn(ft);
|
||||
++processedFeaturesCount;
|
||||
}
|
||||
break;
|
||||
case feature::GEOM_AREA:
|
||||
if (ft.GetLimitRect(kScale).IsPointInside(mercator) && feature::GetMinDistanceMeters(ft, mercator) == 0.0)
|
||||
if (ft.GetLimitRect(kScale).IsPointInside(mercator) &&
|
||||
feature::GetMinDistanceMeters(ft, mercator) == 0.0)
|
||||
{
|
||||
fn(ft);
|
||||
++processedFeaturesCount;
|
||||
}
|
||||
break;
|
||||
case feature::GEOM_UNDEFINED:
|
||||
|
@ -1724,7 +1717,6 @@ size_t Framework::ForEachFeatureAtPoint(TFeatureTypeFn && fn, m2::PointD const &
|
|||
break;
|
||||
}
|
||||
}, kScale);
|
||||
return processedFeaturesCount;
|
||||
}
|
||||
|
||||
unique_ptr<FeatureType> Framework::GetFeatureAtPoint(m2::PointD const & mercator) const
|
||||
|
|
|
@ -494,7 +494,7 @@ public:
|
|||
/// @returns nullptr if no feature was found at the given mercator point.
|
||||
unique_ptr<FeatureType> GetFeatureAtPoint(m2::PointD const & mercator) const;
|
||||
using TFeatureTypeFn = function<void(FeatureType &)>;
|
||||
size_t ForEachFeatureAtPoint(TFeatureTypeFn && fn, m2::PointD const & mercator) const;
|
||||
void ForEachFeatureAtPoint(TFeatureTypeFn && fn, m2::PointD const & mercator) const;
|
||||
/// Set parse to false if you don't need all feature fields ready.
|
||||
unique_ptr<FeatureType> GetFeatureByID(FeatureID const & fid, bool parse = true) const;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ UNIT_TEST(Framework_ForEachFeatureAtPoint_And_Others)
|
|||
"amenity|parking|",
|
||||
"barrier|lift_gate|"
|
||||
};
|
||||
TEST_EQUAL(4, frm.ForEachFeatureAtPoint([&](FeatureType & ft)
|
||||
frm.ForEachFeatureAtPoint([&](FeatureType & ft)
|
||||
{
|
||||
ft.ForEachType([&types](uint32_t type)
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ UNIT_TEST(Framework_ForEachFeatureAtPoint_And_Others)
|
|||
TEST(found != types.end(), ());
|
||||
types.erase(found);
|
||||
});
|
||||
}, MercatorBounds::FromLatLon(53.882663, 27.537788)), ());
|
||||
}, MercatorBounds::FromLatLon(53.882663, 27.537788));
|
||||
TEST_EQUAL(0, types.size(), ());
|
||||
|
||||
ftypes::IsBuildingChecker const & isBuilding = ftypes::IsBuildingChecker::Instance();
|
||||
|
|
|
@ -494,7 +494,7 @@ void DrawWidget::ShowInfoPopup(QMouseEvent * e, m2::PointD const & pt)
|
|||
menu.addAction(QString::fromUtf8(s.c_str()));
|
||||
};
|
||||
|
||||
m_framework->ForEachFeatureAtPoint([&](FeatureType const & ft)
|
||||
m_framework->ForEachFeatureAtPoint([&](FeatureType & ft)
|
||||
{
|
||||
search::AddressInfo const info = m_framework->GetFeatureAddressInfo(ft);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue