forked from organicmaps/organicmaps
[core] fix for matching bookmarks on areas. review fixes
This commit is contained in:
parent
928e522c3d
commit
b25c4089b6
3 changed files with 16 additions and 19 deletions
|
@ -61,7 +61,7 @@ namespace feature
|
|||
explicit TypesHolder(GeomType geomType) : m_geomType(geomType) {}
|
||||
explicit TypesHolder(FeatureType & f);
|
||||
|
||||
static TypesHolder FromTypesIndexes(std::vector<uint32_t> const & src);
|
||||
static TypesHolder FromTypesIndexes(std::vector<uint32_t> const & indexes);
|
||||
|
||||
void Assign(uint32_t type)
|
||||
{
|
||||
|
|
|
@ -829,11 +829,8 @@ kml::MarkGroupId Framework::AddCategory(string const & categoryName)
|
|||
|
||||
void Framework::FillPointInfoForBookmark(Bookmark const & bmk, place_page::Info & info) const
|
||||
{
|
||||
feature::TypesHolder types;
|
||||
if (!bmk.GetData().m_featureTypes.empty())
|
||||
types = feature::TypesHolder::FromTypesIndexes(bmk.GetData().m_featureTypes);
|
||||
|
||||
FillPointInfo(info, bmk.GetPivot(), {}, [&types](feature::GeomType geomType, FeatureType & ft)
|
||||
auto types = feature::TypesHolder::FromTypesIndexes(bmk.GetData().m_featureTypes);
|
||||
FillPointInfo(info, bmk.GetPivot(), {}, [&types](FeatureType & ft)
|
||||
{
|
||||
return !types.Empty() && feature::TypesHolder(ft).Equals(types);
|
||||
});
|
||||
|
@ -2316,19 +2313,18 @@ url_scheme::SearchRequest Framework::GetParsedSearchRequest() const
|
|||
FeatureID Framework::GetFeatureAtPoint(m2::PointD const & mercator,
|
||||
FeatureMatcher && matcher /* = nullptr */) const
|
||||
{
|
||||
FeatureID poi, line, area;
|
||||
FeatureID fullMatch, poi, line, area;
|
||||
auto haveBuilding = false;
|
||||
auto fullMatch = false;
|
||||
auto closestDistnceToCenter = numeric_limits<double>::max();
|
||||
auto closestDistanceToCenter = numeric_limits<double>::max();
|
||||
auto currentDistance = numeric_limits<double>::max();
|
||||
indexer::ForEachFeatureAtPoint(m_model.GetDataSource(), [&](FeatureType & ft)
|
||||
{
|
||||
if (fullMatch)
|
||||
if (fullMatch.IsValid())
|
||||
return;
|
||||
if (matcher && matcher(ft.GetGeomType(), ft))
|
||||
|
||||
if (matcher && matcher(ft))
|
||||
{
|
||||
fullMatch = true;
|
||||
poi = ft.GetID();
|
||||
fullMatch = ft.GetID();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2347,13 +2343,14 @@ FeatureID Framework::GetFeatureAtPoint(m2::PointD const & mercator,
|
|||
// Skip/ignore coastlines.
|
||||
if (feature::TypesHolder(ft).Has(classif().GetCoastType()))
|
||||
return;
|
||||
haveBuilding = ftypes::IsBuildingChecker::Instance()(ft);
|
||||
currentDistance = MercatorBounds::DistanceOnEarth(mercator, feature::GetCenter(ft));
|
||||
// Choose first closest object.
|
||||
if (currentDistance >= closestDistnceToCenter)
|
||||
// Choose the first matching building or, if no buildings are matched,
|
||||
// the first among the closest matching non-buildings.
|
||||
if (!haveBuilding && currentDistance >= closestDistanceToCenter)
|
||||
return;
|
||||
area = ft.GetID();
|
||||
haveBuilding = ftypes::IsBuildingChecker::Instance()(ft);
|
||||
closestDistnceToCenter = currentDistance;
|
||||
closestDistanceToCenter = currentDistance;
|
||||
break;
|
||||
case feature::GeomType::Undefined:
|
||||
ASSERT(false, ("case feature::Undefined"));
|
||||
|
@ -2361,7 +2358,7 @@ FeatureID Framework::GetFeatureAtPoint(m2::PointD const & mercator,
|
|||
}
|
||||
}, mercator);
|
||||
|
||||
return poi.IsValid() ? poi : (area.IsValid() ? area : line);
|
||||
return fullMatch.IsValid() ? fullMatch : (poi.IsValid() ? poi : (area.IsValid() ? area : line));
|
||||
}
|
||||
|
||||
osm::MapObject Framework::GetMapObjectByID(FeatureID const & fid) const
|
||||
|
|
|
@ -719,7 +719,7 @@ public:
|
|||
ParsedRoutingData GetParsedRoutingData() const;
|
||||
url_scheme::SearchRequest GetParsedSearchRequest() const;
|
||||
|
||||
using FeatureMatcher = std::function<bool(feature::GeomType geomType, FeatureType & ft)>;
|
||||
using FeatureMatcher = std::function<bool(FeatureType & ft)>;
|
||||
|
||||
private:
|
||||
/// @returns true if command was handled by editor.
|
||||
|
|
Loading…
Add table
Reference in a new issue