[classificator] Added “junction=roundabout” type for routing algorithm.

This commit is contained in:
vng 2014-10-30 16:41:38 +03:00 committed by Alex Zolotarev
parent a471524c3f
commit 51cd6d2cb7
7 changed files with 77 additions and 20 deletions

View file

@ -336,6 +336,9 @@ world +
internet_access +
wlan -
{}
junction +
roundabout -
{}
landuse +
allotments -
basin -

View file

@ -987,3 +987,4 @@ amenity|waste_disposal;[amenity=waste_disposal];;name;int_name;986;
amenity|bbq;[amenity=bbq];;name;int_name;987;
hwtag|private;[hwtag=private];;name;int_name;988;
route|ferry|motorcar;[route=ferry];;name;int_name;989;
junction|roundabout;[junction=roundabout];;name;int_name;990;
Can't render this file because it has a wrong number of fields in line 371.

View file

@ -987,3 +987,4 @@ amenity|waste_disposal
amenity|bbq
hwtag|private
route|ferry|motorcar
junction|roundabout

View file

@ -86,6 +86,7 @@ public:
inline size_t GetPointsCount() const { return GetGeometry().size(); }
inline size_t GetPolygonsCount() const { return m_polygons.size(); }
inline size_t GetTypesCount() const { return m_params.m_Types.size(); }
//@}
/// @name Iterate through polygons points.

View file

@ -25,7 +25,6 @@ UNIT_TEST(FBuilder_ManyTypes)
classificator::Load();
FeatureBuilder1 fb1;
FeatureParams params;
char const * arr1[][1] = {
@ -40,13 +39,10 @@ UNIT_TEST(FBuilder_ManyTypes)
{ "place", "region" },
{ "place", "city" },
{ "place", "town" },
{ "railway", "rail" },
{ "hwtag", "oneway" },
};
AddTypes(params, arr2);
params.FinishAddingTypes();
params.AddHouseNumber("75");
params.AddHouseName("Best House");
params.name.AddString(0, "Name");
@ -66,6 +62,42 @@ UNIT_TEST(FBuilder_ManyTypes)
TEST(fb2.CheckValid(), ());
TEST_EQUAL(fb1, fb2, ());
TEST_EQUAL(fb2.GetTypesCount(), 7, ());
}
UNIT_TEST(FBuilder_LineTypes)
{
FeatureBuilder1 fb1;
FeatureParams params;
char const * arr2[][2] = {
{ "railway", "rail" },
{ "highway", "motorway" },
{ "hwtag", "oneway" },
{ "junction", "roundabout" },
};
AddTypes(params, arr2);
params.FinishAddingTypes();
fb1.SetParams(params);
fb1.AddPoint(m2::PointD(0, 0));
fb1.AddPoint(m2::PointD(1, 1));
fb1.SetLinear();
TEST(fb1.RemoveInvalidTypes(), ());
TEST(fb1.CheckValid(), ());
FeatureBuilder1::buffer_t buffer;
TEST(fb1.PreSerialize(), ());
fb1.Serialize(buffer);
FeatureBuilder1 fb2;
fb2.Deserialize(buffer);
TEST(fb2.CheckValid(), ());
TEST_EQUAL(fb1, fb2, ());
TEST_EQUAL(fb2.GetTypesCount(), 4, ());
}
UNIT_TEST(FVisibility_RemoveNoDrawableTypes)

View file

@ -104,7 +104,7 @@ namespace
drule::KeysT & m_keys;
public:
DrawRuleGetter(int scale, feature::EGeomType ft, drule::KeysT & keys)
DrawRuleGetter(int scale, EGeomType ft, drule::KeysT & keys)
: m_scale(scale), m_ft(ft), m_keys(keys)
{
}
@ -126,7 +126,7 @@ namespace
pair<int, bool> GetDrawRule(FeatureBase const & f, int level,
drule::KeysT & keys)
{
feature::TypesHolder types(f);
TypesHolder types(f);
ASSERT ( keys.empty(), () );
Classificator const & c = classif();
@ -232,11 +232,29 @@ namespace
return false;
}
};
/// Add here all exception classificator types: needed for algorithms,
/// but don't have drawing rules.
bool TypeAlwaysExists(uint32_t t, EGeomType g = GEOM_UNDEFINED)
{
static const uint32_t s1 = classif().GetTypeByPath({ "junction", "roundabout" });
static const uint32_t s2 = classif().GetTypeByPath({ "hwtag" });
if (g == GEOM_LINE || g == GEOM_UNDEFINED)
{
if (s1 == t) return true;
ftype::TruncValue(t, 1);
if (s2 == t) return true;
}
return false;
}
}
bool IsDrawableAny(uint32_t type)
{
return classif().GetObject(type)->IsDrawableAny();
return (TypeAlwaysExists(type) || classif().GetObject(type)->IsDrawableAny());
}
bool IsDrawableLike(vector<uint32_t> const & types, EGeomType ft)
@ -254,9 +272,9 @@ bool IsDrawableForIndex(FeatureBase const & f, int level)
{
Classificator const & c = classif();
feature::TypesHolder types(f);
TypesHolder types(f);
if (types.GetGeoType() == feature::GEOM_AREA && !types.Has(c.GetCoastType()))
if (types.GetGeoType() == GEOM_AREA && !types.Has(c.GetCoastType()))
if (!scales::IsGoodForLevel(level, f.GetLimitRect()))
return false;
@ -270,16 +288,19 @@ bool IsDrawableForIndex(FeatureBase const & f, int level)
namespace
{
class CheckNonDrawableType
class IsNonDrawableType
{
Classificator & m_c;
EGeomType m_type;
public:
CheckNonDrawableType(EGeomType ft) : m_c(classif()), m_type(ft) {}
IsNonDrawableType(EGeomType ft) : m_c(classif()), m_type(ft) {}
bool operator() (uint32_t t)
{
if (TypeAlwaysExists(t, m_type))
return false;
IsDrawableLikeChecker doCheck(m_type);
if (m_c.ProcessObjects(t, doCheck))
return false;
@ -300,7 +321,7 @@ namespace
bool RemoveNoDrawableTypes(vector<uint32_t> & types, EGeomType ft)
{
types.erase(remove_if(types.begin(), types.end(), CheckNonDrawableType(ft)), types.end());
types.erase(remove_if(types.begin(), types.end(), IsNonDrawableType(ft)), types.end());
return !types.empty();
}
@ -309,7 +330,7 @@ int GetMinDrawableScale(FeatureBase const & f)
int const upBound = scales::GetUpperStyleScale();
for (int level = 0; level <= upBound; ++level)
if (feature::IsDrawableForIndex(f, level))
if (IsDrawableForIndex(f, level))
return level;
return -1;
@ -373,7 +394,7 @@ pair<int, int> GetDrawableScaleRange(TypesHolder const & types)
namespace
{
bool IsDrawableForRules(feature::TypesHolder const & types, int level, int rules)
bool IsDrawableForRules(TypesHolder const & types, int level, int rules)
{
Classificator const & c = classif();
@ -386,7 +407,7 @@ namespace
}
}
pair<int, int> GetDrawableScaleRangeForRules(feature::TypesHolder const & types, int rules)
pair<int, int> GetDrawableScaleRangeForRules(TypesHolder const & types, int rules)
{
int const upBound = scales::GetUpperStyleScale();
int lowL = -1;
@ -432,4 +453,4 @@ bool TypeSetChecker::IsEqual(uint32_t type) const
return (m_type == type);
}
}
} // namespace feature

View file

@ -475,10 +475,8 @@ void Drawer::Draw(di::FeatureInfo const & fi)
// draw road numbers
if (isPath && !fi.m_styler.m_refText.empty() && m_level >= 12)
{
for (list<di::PathInfo>::const_iterator i = fi.m_pathes.begin(); i != fi.m_pathes.end(); ++i)
drawPathNumber(*i, fi.m_styler);
}
for (auto n : fi.m_pathes)
drawPathNumber(n, fi.m_styler);
}
int Drawer::ThreadSlot() const