forked from organicmaps/organicmaps-tmp
[classifier] Added organic=only/yes/limited.
Signed-off-by: Viktor Govako <viktor.govako@gmail.com>
This commit is contained in:
parent
0ac62d12d0
commit
b83a65eab0
9 changed files with 120 additions and 55 deletions
|
@ -7172,6 +7172,42 @@ el:Φάρος
|
|||
sk:Maják
|
||||
fa:فانوس دریایی
|
||||
|
||||
organic-only|organic-yes
|
||||
en:4organic|bio|biological|eco|ecological|healthy
|
||||
ar:بيولوجي|بيولوجي|صحي|بيولوجي|بيئي|طبيعي|عضوي
|
||||
be:эка|натуральная|5натуральныя|натуральны|натуральнае|арганічная|5арганічныя|арганічны|арганічнае|біялагічная|5біялагічныя|біялагічны|біялагічнае|экалагічная|5экалагічныя|экалагічны|экалагічнае|біо|біа|бія|здаровая
|
||||
bg:еко|био|здравословен|биологичен|екологичен|природен|органичен
|
||||
cs:ekologické|bio|zdravé|biologické|environmentální|přírodní|organické
|
||||
da:øko|bio|sundt|biologisk|miljømæssigt|naturligt|organisk
|
||||
de:3Bio|Biologische|biologisch|5Ökologische|Ökologisches|öko|bio|4organische|organisch|naturnah|natürliches|natürlich|gesundes|gesund|umweltfreundlich
|
||||
el:οικολογικό|βιολογικό|υγιεινό|φυσικό
|
||||
es:eco|5ecológicos|ecológica|ecológico|5orgánicos|orgánico|5biológica|biológicos|biológico|bio|natural|saludable
|
||||
fa:اکو|زیستی|سالم|بیولوژیکی|زیست محیطی|طبیعی|ارگانیک
|
||||
fi:eko|bio|terveellinen|biologinen|ekologinen|luonnollinen|orgaaninen
|
||||
fr:saine|bio|biologique|4biologiques|naturelle|nature|naturel|écologique|4écologiques|éco|organique
|
||||
he:אקולוגי|ביו|בריא|ביולוגי|אקולוגי|טבעי|אורגני
|
||||
hu:eco|bio|egészséges|biológiai|környezeti|természetes|organikus
|
||||
id:eco|bio|sehat|biologis|ekologis|alami|organik
|
||||
it:eco|bio|sano|biologico|ambientale|naturale|organico
|
||||
ja:エコ|バイオ|ヘルシー|バイオロジー|エンバイロメンタル|ナチュラル|オーガニック
|
||||
ko:에코|바이오|건강|생물학|생태학적|천연|유기농
|
||||
nb:øko|bio|sunt|biologisk|økologisk|naturlig|organisk
|
||||
nl:eco|bio|healthy|biological|environmental|natural|organic
|
||||
pl:eko|bio|zdrowe|biologiczne|ekologiczne|naturalne|organiczne
|
||||
pt:eco|bio|saudável|biológico|ambiental|natural|orgânico
|
||||
pt-BR:eco|bio|biológico|ambiental|natural|orgânico
|
||||
ro:eco|bio|sănătos|biologic|ambiental|natural|organic
|
||||
ru:здоровая|5здоровые|био|биологическая|5биологические|биологический|биологическое|натуральная|5натуральные|натуральный|натуральное|органическая|5органические|органический|органическое|эко|5экологические|экологический|экологическое
|
||||
sk:eko|bio|zdravé|biologické|ekologické|prírodné|organické
|
||||
sv:eko|bio|hälsosamt|biologiskt|miljövänligt|naturligt|organiskt
|
||||
sw:eco|bio|afya|kibaolojia|kiikolojia|asili|kikaboni
|
||||
th:เชิงนิเวศ|ชีวภาพ|สุขภาพ|ชีวภาพ|ระบบนิเวศ|ธรรมชาติ|อินทรีย์
|
||||
tr:eko|biyo|sağlıklı|biyolojik|ekolojik|doğal|organik
|
||||
uk:здорова|5біологічні|біологічна|біологічне|біологічний|біо|натуральна|5натуральні|натуральний|натуральне|органічна|5органічні|органічний|органічне|еко|5екологічні|екологічний|екологічне
|
||||
vi:sinh thái|sinh học|lành mạnh|sinh học|sinh thái|tự nhiên|hữu cơ
|
||||
zh-Hans:生态的|生物的|健康的|生物的|环境的|自然的|有机的
|
||||
zh-Hant:生態|生物|健康|生物|生態|天然|有機
|
||||
|
||||
shop-copyshop
|
||||
en:Copy Shop|Printer
|
||||
ru:Копировальный центр|печать|полиграфия
|
||||
|
|
|
@ -1120,8 +1120,8 @@ wheelchair|yes;1121;
|
|||
wheelchair|no;1122;
|
||||
wheelchair|limited;1123;
|
||||
building|has_parts;1124;
|
||||
deprecated|deprecated;1125;x
|
||||
deprecated|deprecated;1126;x
|
||||
organic|only;1125;
|
||||
organic|yes;1126;
|
||||
deprecated|deprecated;1127;x
|
||||
deprecated|deprecated;1128;x
|
||||
deprecated|deprecated;1129;x
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 11.
|
|
@ -57,7 +57,9 @@ office=administrative : office=government
|
|||
|
||||
cycleway=opposite_lane : oneway:bicycle=no
|
||||
|
||||
power = transformer : power = substation
|
||||
power=transformer : power=substation
|
||||
|
||||
organic=limited : organic=yes
|
||||
|
||||
diet:vegetarian=yes : cuisine=vegetarian
|
||||
diet:vegetarian=only : cuisine=vegetarian
|
||||
|
|
|
@ -343,11 +343,9 @@ public:
|
|||
bool operator() (uint32_t type) const
|
||||
{
|
||||
std::pair<int, int> const range = feature::GetDrawableScaleRange(type);
|
||||
// We have feature types without any drawing rules.
|
||||
// This case was processed before:
|
||||
// - feature::TypeAlwaysExists;
|
||||
// - FeatureBuilder::RemoveInvalidTypes;
|
||||
// Don't delete them here.
|
||||
|
||||
// Don't remove non-drawable types here, since this case is processed before
|
||||
// feature::TypeAlwaysExists or FeatureBuilder::RemoveInvalidTypes.
|
||||
if (m_doNotRemoveSpecialTypes && range.first == -1)
|
||||
{
|
||||
ASSERT(range.second == -1, ());
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "generator/generator_tests/types_helper.hpp"
|
||||
|
@ -1429,6 +1428,34 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_Cliff)
|
|||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(TestWithClassificator, OsmType_Organic)
|
||||
{
|
||||
{
|
||||
Tags const tags = {
|
||||
{"organic", "only"},
|
||||
{"amenity", "cafe" },
|
||||
};
|
||||
|
||||
auto const params = GetFeatureBuilderParams(tags);
|
||||
|
||||
TEST_EQUAL(params.m_types.size(), 2, (params));
|
||||
TEST(params.IsTypeExist(GetType({"amenity", "cafe"})), (params));
|
||||
TEST(params.IsTypeExist(GetType({"organic", "only"})), (params));
|
||||
}
|
||||
|
||||
{
|
||||
Tags const tags = {
|
||||
{"organic", "no"},
|
||||
{"shop", "bakery" },
|
||||
};
|
||||
|
||||
auto const params = GetFeatureBuilderParams(tags);
|
||||
|
||||
TEST_EQUAL(params.m_types.size(), 1, (params));
|
||||
TEST(params.IsTypeExist(GetType({"shop", "bakery"})), (params));
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_CLASS_TEST(TestWithClassificator, OsmType_SimpleTypesSmoke)
|
||||
{
|
||||
Tags const oneTypes = {
|
||||
|
@ -1826,6 +1853,8 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_SimpleTypesSmoke)
|
|||
{"office", "lawyer"},
|
||||
{"office", "ngo"},
|
||||
{"office", "telecommunication"},
|
||||
{"organic", "only"},
|
||||
{"organic", "yes"},
|
||||
{"piste:lift", "j-bar"},
|
||||
{"piste:lift", "magic_carpet"},
|
||||
{"piste:lift", "platter"},
|
||||
|
@ -1999,11 +2028,12 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_SimpleTypesSmoke)
|
|||
{"wheelchair", "yes"},
|
||||
};
|
||||
|
||||
auto const & cl = classif();
|
||||
for (auto const & type : oneTypes)
|
||||
{
|
||||
auto const params = GetFeatureBuilderParams({type});
|
||||
TEST_EQUAL(params.m_types.size(), 1, (type, params));
|
||||
TEST(params.IsTypeExist(classif().GetTypeByPath({type.m_key, type.m_value})), (type, params));
|
||||
TEST(params.IsTypeExist(cl.GetTypeByPath({type.m_key, type.m_value})), (type, params));
|
||||
}
|
||||
|
||||
Tags const exTypes = {
|
||||
|
@ -2014,7 +2044,7 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_SimpleTypesSmoke)
|
|||
{
|
||||
auto const params = GetFeatureBuilderParams({type});
|
||||
TEST_GREATER(params.m_types.size(), 1, (type, params));
|
||||
TEST(params.IsTypeExist(classif().GetTypeByPath({type.m_key, type.m_value})), (type, params));
|
||||
TEST(params.IsTypeExist(cl.GetTypeByPath({type.m_key, type.m_value})), (type, params));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2243,7 +2273,6 @@ UNIT_CLASS_TEST(TestWithClassificator, OsmType_ComplexTypesSmoke)
|
|||
{{"place", "state", "USA"}, {{"place", "state"}, {"is_in", "USA"}}},
|
||||
{{"place", "state", "USA"}, {{"place", "state"}, {"is_in:country", "USA"}}},
|
||||
{{"place", "state", "USA"}, {{"place", "state"}, {"is_in:country_code", "us"}}},
|
||||
{{"power", "line", "underground"}, {{"power", "line"}, {"location", "underground"}}},
|
||||
{{"railway", "abandoned", "bridge"}, {{"railway", "abandoned"}, {"bridge", "any_value"}}},
|
||||
{{"railway", "abandoned", "tunnel"}, {{"railway", "abandoned"}, {"tunnel", "any_value"}}},
|
||||
{{"railway", "funicular", "bridge"}, {{"railway", "funicular"}, {"bridge", "any_value"}}},
|
||||
|
|
|
@ -12,5 +12,5 @@ namespace ftype
|
|||
{
|
||||
/// Get the types, name and layer for feature with the tree of tags.
|
||||
void GetNameAndType(OsmElement * p, FeatureBuilderParams & params,
|
||||
std::function<bool(uint32_t)> filterType = feature::TypeIsUseful);
|
||||
std::function<bool(uint32_t)> filterType = feature::IsUsefulType);
|
||||
}
|
||||
|
|
|
@ -121,6 +121,7 @@ private:
|
|||
{"hwtag"},
|
||||
{"psurface"},
|
||||
{"internet_access"},
|
||||
{"organic"},
|
||||
{"wheelchair"},
|
||||
{"entrance"},
|
||||
{"cuisine"},
|
||||
|
|
|
@ -233,59 +233,58 @@ namespace
|
|||
}
|
||||
};
|
||||
|
||||
bool HasRoutingExceptionType(uint32_t t)
|
||||
{
|
||||
static uint32_t const s = classif().GetTypeByPath({"route", "shuttle_train"});
|
||||
return s == t;
|
||||
}
|
||||
/// @name Add here classifier types that don't have drawing rules but needed for algorithms.
|
||||
/// @todo The difference between \a TypeAlwaysExists and \a IsUsefulNondrawableType is not
|
||||
/// obvious. TypeAlwaysExists are *indexed* in category search, while IsUsefulNondrawableType are *not*.
|
||||
/// The functions names and set of types looks strange now and definitely should be revised.
|
||||
/// @{
|
||||
|
||||
/// Add here all exception classificator types: needed for algorithms,
|
||||
/// but don't have drawing rules.
|
||||
/// Warning: Geometry of features with always existing types will be indexed in mwm on all
|
||||
/// zoom levels. If you add an always existing type to drawing types, the displacement of icons
|
||||
/// may work not correctly.
|
||||
bool TypeAlwaysExists(uint32_t type, GeomType g = GeomType::Undefined)
|
||||
{
|
||||
if (!classif().IsTypeValid(type))
|
||||
auto const & cl = classif();
|
||||
if (!cl.IsTypeValid(type))
|
||||
return false;
|
||||
|
||||
static uint32_t const internet = classif().GetTypeByPath({"internet_access"});
|
||||
static uint32_t const complexEntry = classif().GetTypeByPath({"complex_entry"});
|
||||
static uint32_t const shuttle = cl.GetTypeByPath({"route", "shuttle_train"});
|
||||
static uint32_t const internet = cl.GetTypeByPath({"internet_access"});
|
||||
static uint32_t const organic = cl.GetTypeByPath({"organic"});
|
||||
static uint32_t const complexEntry = cl.GetTypeByPath({"complex_entry"});
|
||||
|
||||
if ((g == GeomType::Line || g == GeomType::Undefined) && HasRoutingExceptionType(type))
|
||||
if ((g == GeomType::Line || g == GeomType::Undefined) && type == shuttle)
|
||||
return true;
|
||||
|
||||
uint8_t const typeLevel = ftype::GetLevel(type);
|
||||
ftype::TruncValue(type, 1);
|
||||
if (g != GeomType::Line && type == internet)
|
||||
return true;
|
||||
|
||||
if (type == complexEntry)
|
||||
return true;
|
||||
if (g != GeomType::Line)
|
||||
{
|
||||
// Exclude generic 1-arity types like [organic].
|
||||
if (type == internet || (type == organic && typeLevel >= 2))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return (type == complexEntry);
|
||||
}
|
||||
|
||||
/// Add here all exception classificator types: needed for algorithms,
|
||||
/// but don't have drawing rules.
|
||||
bool IsUsefulNondrawableType(uint32_t type, GeomType g = GeomType::Undefined)
|
||||
{
|
||||
if (!classif().IsTypeValid(type))
|
||||
auto const & cl = classif();
|
||||
if (!cl.IsTypeValid(type))
|
||||
return false;
|
||||
|
||||
if (TypeAlwaysExists(type, g))
|
||||
return true;
|
||||
|
||||
static uint32_t const hwtag = classif().GetTypeByPath({"hwtag"});
|
||||
static uint32_t const roundabout = classif().GetTypeByPath({"junction", "roundabout"});
|
||||
static uint32_t const psurface = classif().GetTypeByPath({"psurface"});
|
||||
static uint32_t const wheelchair = classif().GetTypeByPath({"wheelchair"});
|
||||
static uint32_t const cuisine = classif().GetTypeByPath({"cuisine"});
|
||||
static uint32_t const recycling = classif().GetTypeByPath({"recycling"});
|
||||
// Reserved for custom event processing, e.g. fc2018.
|
||||
// static uint32_t const event = classif().GetTypeByPath({"event" });
|
||||
// Exclude generic 1-arity types like [wheelchair].
|
||||
if (ftype::GetLevel(type) < 2)
|
||||
return false;
|
||||
|
||||
// Caching type length to exclude generic [wheelchair].
|
||||
uint8_t const typeLength = ftype::GetLevel(type);
|
||||
static uint32_t const hwtag = cl.GetTypeByPath({"hwtag"});
|
||||
static uint32_t const roundabout = cl.GetTypeByPath({"junction", "roundabout"});
|
||||
static uint32_t const psurface = cl.GetTypeByPath({"psurface"});
|
||||
|
||||
if ((g == GeomType::Line || g == GeomType::Undefined) && type == roundabout)
|
||||
return true;
|
||||
|
@ -297,21 +296,24 @@ namespace
|
|||
return true;
|
||||
}
|
||||
|
||||
if (type == wheelchair && typeLength == 2)
|
||||
return true;
|
||||
static uint32_t const arrTypes[] = {
|
||||
cl.GetTypeByPath({"wheelchair"}),
|
||||
cl.GetTypeByPath({"cuisine"}),
|
||||
cl.GetTypeByPath({"recycling"})
|
||||
};
|
||||
|
||||
if (type == cuisine || type == recycling)
|
||||
return true;
|
||||
|
||||
// Reserved for custom event processing, e.g. fc2018.
|
||||
// if (event == type)
|
||||
// return true;
|
||||
for (uint32_t t : arrTypes)
|
||||
{
|
||||
if (t == type)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/// @}
|
||||
} // namespace
|
||||
|
||||
bool TypeIsUseful(uint32_t type)
|
||||
bool IsUsefulType(uint32_t type)
|
||||
{
|
||||
return IsUsefulNondrawableType(type) || classif().GetObject(type)->IsDrawableAny();
|
||||
}
|
||||
|
@ -395,9 +397,6 @@ bool IsUsefulType(uint32_t t, GeomType geomType, bool emptyName)
|
|||
|
||||
bool HasUsefulType(vector<uint32_t> const & types, GeomType geomType, bool emptyName)
|
||||
{
|
||||
if (types.empty())
|
||||
return false;
|
||||
|
||||
return any_of(types.begin(), types.end(), [&](uint32_t t) {
|
||||
return IsUsefulType(t, geomType, emptyName);
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace feature
|
|||
{
|
||||
class TypesHolder;
|
||||
|
||||
bool TypeIsUseful(uint32_t type);
|
||||
bool IsUsefulType(uint32_t type);
|
||||
bool IsDrawableForIndex(FeatureType & ft, int level);
|
||||
bool IsDrawableForIndex(TypesHolder const & types, m2::RectD limitRect, int level);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue