[classificator] Added hwtag-nofoot as a forbidden road for pedestrians.

This commit is contained in:
vng 2015-04-10 15:53:46 +03:00 committed by Alex Zolotarev
parent 185d0c4120
commit 9e117ddadd
6 changed files with 64 additions and 46 deletions

View file

@ -331,6 +331,7 @@ world +
{}
hwtag +
lit -
nofoot -
oneway -
private -
{}

View file

@ -993,3 +993,4 @@ shop|beauty;[shop=beauty];;name;int_name;992;
shop|sports;[shop=sports];;name;int_name;993;
route|ferry|motor_vehicle;[route=ferry];;name;int_name;994;
railway|rail|motor_vehicle;[railway=rail];;name;int_name;995;
hwtag|nofoot;[hwtag=nofoot];;name;int_name;996;

Can't render this file because it has a wrong number of fields in line 371.

View file

@ -993,3 +993,4 @@ shop|beauty
shop|sports
route|ferry|motor_vehicle
railway|rail|motor_vehicle
hwtag|nofoot

View file

@ -26,6 +26,10 @@ namespace
vector<string> path(arr, arr + N);
return classif().GetTypeByPath(path);
}
uint32_t GetType(StringIL const & lst)
{
return classif().GetTypeByPath(lst);
}
}
UNIT_TEST(OsmType_SkipDummy)
@ -124,10 +128,9 @@ UNIT_TEST(OsmType_Combined)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * arrT[] = { "building" };
TEST_EQUAL(params.m_Types.size(), 2, (params));
TEST(params.IsTypeExist(GetType(arr[3])), ());
TEST(params.IsTypeExist(GetType(arrT)), ());
TEST(params.IsTypeExist(GetType({ "building" })), ());
string s;
params.name.GetString(0, s);
@ -154,9 +157,8 @@ UNIT_TEST(OsmType_Address)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * arrT[] = { "building", "address" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(arrT)), ());
TEST(params.IsTypeExist(GetType({ "building", "address" })), ());
TEST_EQUAL(params.house.Get(), "223/5", ());
}
@ -181,9 +183,8 @@ UNIT_TEST(OsmType_PlaceState)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * arrT[] = { "place", "state", "USA" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(arrT)), ());
TEST(params.IsTypeExist(GetType({ "place", "state", "USA" })), ());
string s;
TEST(params.name.GetString(0, s), ());
@ -232,9 +233,8 @@ UNIT_TEST(OsmType_AlabamaRiver)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * arrT[] = { "waterway", "river" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(arrT)), ());
TEST(params.IsTypeExist(GetType({ "waterway", "river" })), ());
}
UNIT_TEST(OsmType_Synonyms)
@ -282,9 +282,8 @@ UNIT_TEST(OsmType_Synonyms)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * arrT[] = { "amenity", "atm" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(arrT)), ());
TEST(params.IsTypeExist(GetType({ "amenity", "atm" })), ());
}
// "NO" tag test.
@ -301,9 +300,8 @@ UNIT_TEST(OsmType_Synonyms)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * arrT[] = { "building" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(arrT)), ());
TEST(params.IsTypeExist(GetType({ "building" })), ());
}
}
@ -322,8 +320,7 @@ UNIT_TEST(OsmType_Capital)
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_Types.size(), 1, (params));
char const * type[] = { "place", "city", "capital" };
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType({ "place", "city", "capital" })), ());
}
{
@ -339,8 +336,7 @@ UNIT_TEST(OsmType_Capital)
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_Types.size(), 1, (params));
char const * type[] = { "place", "city" };
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType({ "place", "city" })), ());
}
}
@ -396,9 +392,8 @@ UNIT_TEST(OsmType_Layer)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * type[] = { "highway", "motorway", "bridge" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType({ "highway", "motorway", "bridge" })), ());
TEST_EQUAL(params.layer, 2, ());
}
@ -415,9 +410,8 @@ UNIT_TEST(OsmType_Layer)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * type[] = { "highway", "trunk", "tunnel" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType({ "highway", "trunk", "tunnel" })), ());
TEST_EQUAL(params.layer, -1, ());
}
@ -433,9 +427,8 @@ UNIT_TEST(OsmType_Layer)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * type[] = { "highway", "secondary", "bridge" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType({ "highway", "secondary", "bridge" })), ());
TEST_EQUAL(params.layer, 1, ());
}
@ -451,9 +444,8 @@ UNIT_TEST(OsmType_Layer)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * type[] = { "highway", "primary", "tunnel" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType({ "highway", "primary", "tunnel" })), ());
TEST_EQUAL(params.layer, -1, ());
}
@ -468,9 +460,8 @@ UNIT_TEST(OsmType_Layer)
FeatureParams params;
ftype::GetNameAndType(&e, params);
char const * type[] = { "highway", "living_street" };
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(type)), ());
TEST(params.IsTypeExist(GetType(arr[0])), ());
TEST_EQUAL(params.layer, 0, ());
}
}
@ -500,6 +491,7 @@ UNIT_TEST(OsmType_Hwtag)
{ "hwtag", "oneway" },
{ "hwtag", "private" },
{ "hwtag", "lit" },
{ "hwtag", "nofoot" },
};
{
@ -525,6 +517,7 @@ UNIT_TEST(OsmType_Hwtag)
{ "highway", "primary" },
{ "access", "private" },
{ "lit", "no" },
{ "foot", "no" },
};
XMLElement e;
@ -533,10 +526,27 @@ UNIT_TEST(OsmType_Hwtag)
FeatureParams params;
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_Types.size(), 3, (params));
TEST_EQUAL(params.m_Types.size(), 4, (params));
TEST(params.IsTypeExist(GetType(arr[1])), ());
TEST(params.IsTypeExist(GetType(tags[0])), ());
TEST(params.IsTypeExist(GetType(tags[1])), ());
TEST(params.IsTypeExist(GetType(tags[3])), ());
}
{
char const * arr[][2] = {
{ "foot", "yes" },
{ "highway", "primary" },
};
XMLElement e;
FillXmlElement(arr, ARRAY_SIZE(arr), &e);
FeatureParams params;
ftype::GetNameAndType(&e, params);
TEST_EQUAL(params.m_Types.size(), 1, (params));
TEST(params.IsTypeExist(GetType(arr[1])), ());
}
}
@ -559,18 +569,15 @@ UNIT_TEST(OsmType_Ferry)
TEST_EQUAL(params.m_Types.size(), 2, (params));
char const * type1[] = { "highway", "primary", "bridge" };
uint32_t type = GetType(type1);
uint32_t type = GetType({ "highway", "primary", "bridge" });
TEST(params.IsTypeExist(type), ());
TEST(carModel.IsRoad(type), ());
char const * type2[] = { "route", "ferry", "motorcar" };
type = GetType(type2);
type = GetType({ "route", "ferry", "motorcar" });
TEST(params.IsTypeExist(type), ());
TEST(carModel.IsRoad(type), ());
char const * type3[] = { "route", "ferry" };
type = GetType(type3);
type = GetType({ "route", "ferry" });
TEST(!params.IsTypeExist(type), ());
TEST(!carModel.IsRoad(type), ());
}

View file

@ -378,7 +378,7 @@ namespace ftype
buffer_vector<uint32_t, 16> m_types;
public:
enum EType { ENTRANCE, HIGHWAY, ADDRESS, ONEWAY, PRIVATE, LIT };
enum EType { ENTRANCE, HIGHWAY, ADDRESS, ONEWAY, PRIVATE, LIT, NOFOOT };
CachedTypes()
{
@ -387,7 +387,12 @@ namespace ftype
for (auto const & e : (StringIL[]) { {"entrance"}, {"highway"} })
m_types.push_back(c.GetTypeByPath(e));
for (auto const & e : (StringIL[]) { {"building", "address"}, {"hwtag", "oneway"}, {"hwtag", "private"}, {"hwtag", "lit"} })
StringIL arr[] =
{
{"building", "address"}, {"hwtag", "oneway"}, {"hwtag", "private"},
{"hwtag", "lit"}, {"hwtag", "nofoot"}
};
for (auto const & e : arr)
m_types.push_back(c.GetTypeByPath(e));
}
@ -403,10 +408,11 @@ namespace ftype
{
/// Process synonym tags to match existing classificator types.
/// @todo We are planning to rewrite classificator <-> tags matching.
TagProcessor(p).ApplyRules<void(string &, string &)>({
{ "atm", "yes", [](string &k, string &v){ k.swap(v); k = "amenity"; }},
{ "restaurant", "yes", [](string &k, string &v){ k.swap(v); k = "amenity"; }},
{ "hotel", "yes", [](string &k, string &v){ k.swap(v); k = "tourism"; }},
TagProcessor(p).ApplyRules<void(string &, string &)>(
{
{ "atm", "yes", [](string &k, string &v) { k.swap(v); k = "amenity"; }},
{ "restaurant", "yes", [](string &k, string &v) { k.swap(v); k = "amenity"; }},
{ "hotel", "yes", [](string &k, string &v) { k.swap(v); k = "tourism"; }},
});
AddLayers(p);
@ -461,12 +467,14 @@ namespace ftype
for (size_t i = 0; i < params.m_Types.size(); ++i)
if (types.IsHighway(params.m_Types[i]))
{
TagProcessor(p).ApplyRules({
{ "oneway", "yes", [&params](){params.AddType(types.Get(CachedTypes::ONEWAY));} },
{ "oneway", "1", [&params](){params.AddType(types.Get(CachedTypes::ONEWAY));} },
{ "oneway", "-1", [&params](){params.AddType(types.Get(CachedTypes::ONEWAY)); params.m_reverseGeometry = true;} },
{ "access", "private", [&params](){params.AddType(types.Get(CachedTypes::PRIVATE));} },
{ "lit", "yes", [&params](){params.AddType(types.Get(CachedTypes::LIT));} },
TagProcessor(p).ApplyRules(
{
{ "oneway", "yes", [&params]() { params.AddType(types.Get(CachedTypes::ONEWAY)); }},
{ "oneway", "1", [&params]() { params.AddType(types.Get(CachedTypes::ONEWAY)); }},
{ "oneway", "-1", [&params]() { params.AddType(types.Get(CachedTypes::ONEWAY)); params.m_reverseGeometry = true; }},
{ "access", "private", [&params]() { params.AddType(types.Get(CachedTypes::PRIVATE)); }},
{ "lit", "yes", [&params]() { params.AddType(types.Get(CachedTypes::LIT)); }},
{ "foot", "no", [&params]() { params.AddType(types.Get(CachedTypes::NOFOOT)); }},
});
break;

View file

@ -144,7 +144,7 @@ CarModel::CarModel()
PedestrianModel::PedestrianModel()
: VehicleModel(classif(), s_pedestrianLimits),
m_noFootType(0) /// @todo Add additional no-foot type
m_noFootType(classif().GetTypeByPath({ "hwtag", "nofoot" }))
{
initializer_list<char const *> arr[] =
{