Rename some functions according to coding style.

This commit is contained in:
vng 2012-04-19 15:21:46 +03:00 committed by Alex Zolotarev
parent 0632edae1a
commit 32f645d732
8 changed files with 54 additions and 29 deletions

View file

@ -188,7 +188,7 @@ bool FeatureBuilder1::PreSerialize()
// Clear name for features with invisible texts.
int64_t dummy;
if (!m_Params.name.IsEmpty() && !GetCoastCell(dummy) &&
(feature::DrawableScaleRangeForText(GetFeatureBase()).first == -1))
(feature::GetDrawableScaleRangeForText(GetFeatureBase()).first == -1))
{
m_Params.name.Clear();
}
@ -331,7 +331,7 @@ void FeatureBuilder1::AddOsmId(string const & type, uint64_t osmId)
int FeatureBuilder1::GetMinFeatureDrawScale() const
{
int const minScale = feature::MinDrawableScaleForFeature(GetFeatureBase());
int const minScale = feature::GetMinDrawableScale(GetFeatureBase());
// some features become invisible after merge processing, so -1 is possible
return (minScale == -1 ? 1000 : minScale);

View file

@ -51,7 +51,7 @@ namespace
m_midLoc = m_midLoc / m_locCount;
uint64_t const pointAsInt64 = PointToInt64(m_midLoc.x, m_midLoc.y, m_coordBits);
uint64_t const minScale = feature::MinDrawableScaleForFeature(ft.GetFeatureBase());
uint64_t const minScale = feature::GetMinDrawableScale(ft.GetFeatureBase());
CHECK(minScale <= scales::GetUpperScale(), ("Dat file contain invisible feature"));
uint64_t const order = (minScale << 59) | (pointAsInt64 >> 5);

View file

@ -53,7 +53,7 @@ public:
void CorrectScaleForVisibility(TypesHolder const & types, int & scale) const
{
pair<int, int> const scaleR = feature::DrawableScaleRangeForText(types);
pair<int, int> const scaleR = feature::GetDrawableScaleRangeForText(types);
ASSERT_LESS_OR_EQUAL ( scaleR.first, scaleR.second, () );
// Result types can be without visible texts (matched by category).

View file

@ -254,7 +254,7 @@ bool IsDrawableForIndex(FeatureBase const & f, int level)
return false;
}
int MinDrawableScaleForFeature(FeatureBase const & f)
int GetMinDrawableScale(FeatureBase const & f)
{
int const upBound = scales::GetUpperScale();
@ -267,6 +267,21 @@ int MinDrawableScaleForFeature(FeatureBase const & f)
namespace
{
void AddRange(pair<int, int> & dest, pair<int, int> const & src)
{
if (src.first != -1)
{
ASSERT_GREATER(src.first, -1, ());
ASSERT_GREATER(src.second, -1, ());
dest.first = min(dest.first, src.first);
dest.second = max(dest.second, src.second);
ASSERT_GREATER(dest.first, -1, ());
ASSERT_GREATER(dest.second, -1, ());
}
}
class DoGetScalesRange
{
pair<int, int> m_scales;
@ -278,14 +293,7 @@ namespace
bool operator() (ClassifObject const * p, bool & res)
{
res = true;
pair<int, int> scales = p->GetDrawScaleRange();
if (scales.first != -1)
{
m_scales.first = min(m_scales.first, scales.first);
m_scales.second = max(m_scales.second, scales.second);
}
AddRange(m_scales, p->GetDrawScaleRange());
return false;
}
@ -296,13 +304,23 @@ namespace
};
}
pair<int, int> DrawableScaleRangeForType(uint32_t type)
pair<int, int> GetDrawableScaleRange(uint32_t type)
{
DoGetScalesRange doGet;
(void)classif().ProcessObjects(type, doGet);
return doGet.GetScale();
}
pair<int, int> GetDrawableScaleRange(TypesHolder const & types)
{
pair<int, int> res(1000, -1000);
for (size_t i = 0; i < types.Size(); ++i)
AddRange(res, GetDrawableScaleRange(types[i]));
return (res.first > res.second ? make_pair(-1, -1) : res);
}
namespace
{
bool IsDrawable(feature::TypesHolder const & types, int level)
@ -318,7 +336,7 @@ namespace
}
}
pair<int, int> DrawableScaleRangeForText(feature::TypesHolder const & types)
pair<int, int> GetDrawableScaleRangeForText(feature::TypesHolder const & types)
{
int const upBound = scales::GetUpperScale();
int lowL = -1;
@ -347,9 +365,9 @@ pair<int, int> DrawableScaleRangeForText(feature::TypesHolder const & types)
return make_pair(lowL, highL);
}
pair<int, int> DrawableScaleRangeForText(FeatureBase const & f)
pair<int, int> GetDrawableScaleRangeForText(FeatureBase const & f)
{
return DrawableScaleRangeForText(TypesHolder(f));
return GetDrawableScaleRangeForText(TypesHolder(f));
}
bool IsHighway(vector<uint32_t> const & types)

View file

@ -26,14 +26,17 @@ namespace feature
bool IsDrawableLike(vector<uint32_t> const & type, FeatureGeoType ft);
bool IsDrawableForIndex(FeatureBase const & f, int level);
int MinDrawableScaleForFeature(FeatureBase const & f);
pair<int, int> DrawableScaleRangeForType(uint32_t type);
int GetMinDrawableScale(FeatureBase const & f);
/// @name Get scale range when feature's text is visible.
/// @return [-1, -1] if no any text exists
//@{
pair<int, int> DrawableScaleRangeForText(TypesHolder const & types);
pair<int, int> DrawableScaleRangeForText(FeatureBase const & f);
/// @name Get scale range when feature is visible.
pair<int, int> GetDrawableScaleRange(uint32_t type);
pair<int, int> GetDrawableScaleRange(TypesHolder const & types);
/// @name Get scale range when feature's text is visible.
pair<int, int> GetDrawableScaleRangeForText(TypesHolder const & types);
pair<int, int> GetDrawableScaleRangeForText(FeatureBase const & f);
//@}
/// @return (geometry type, is coastline)

View file

@ -88,7 +88,7 @@ public:
if (f.IsEmptyGeometry(GetGeometryScale()))
return false;
uint32_t const minScale = feature::MinDrawableScaleForFeature(f);
uint32_t const minScale = feature::GetMinDrawableScale(f);
return (m_ScaleRange.first <= minScale && minScale < m_ScaleRange.second);
}

View file

@ -306,7 +306,7 @@ public:
continue;
// Do index only for visible types in mwm.
pair<int, int> const r = feature::DrawableScaleRangeForType(type);
pair<int, int> const r = feature::GetDrawableScaleRange(type);
if (my::between_s(m_scales.first, m_scales.second, r.first) ||
my::between_s(m_scales.first, m_scales.second, r.second))
{

View file

@ -1,6 +1,7 @@
#include "framework.hpp"
#include "../indexer/classificator.hpp"
#include "../indexer/feature_visibility.hpp"
namespace
@ -42,7 +43,11 @@ namespace
{
protected:
virtual double GetResultDistance(double d, feature::TypesHolder const & types) const = 0;
virtual double NeedProcess(feature::TypesHolder const & types) const = 0;
virtual double NeedProcess(feature::TypesHolder const & types) const
{
pair<int, int> const r = feature::GetDrawableScaleRange(types);
return my::between_s(r.first, r.second, m_scale);
}
static double GetCompareEpsilonImpl(feature::EGeomType type, double eps)
{
@ -109,10 +114,6 @@ namespace
{
return (d + GetCompareEpsilonImpl(types.GetGeoType(), m_eps));
}
virtual double NeedProcess(feature::TypesHolder const &) const
{
return true;
}
public:
DoGetFeatureTypes(m2::PointD const & pt, double eps, int scale)
@ -271,6 +272,9 @@ namespace
}
virtual double NeedProcess(feature::TypesHolder const & types) const
{
if (!DoGetFeatureInfoBase::NeedProcess(types))
return false;
return (!m_doLocalities ||
(types.GetGeoType() == feature::GEOM_POINT && m_checker.IsLocality(types)));
}