Add "shop-convenience" and "shop-supermarket" to classificator.

TODO: Move them upper in types.txt before countries generation.
This commit is contained in:
vng 2011-10-05 17:36:22 +03:00 committed by Alex Zolotarev
parent 9d92a05d3b
commit 770068b9bc
5 changed files with 52 additions and 4 deletions

View file

@ -1020,9 +1020,11 @@ world +
even 17|0|4|92 -
all 17|0|5|93 -
{}
shop 17|3|19|11829 +
bakery 17|2|62|1573 -
hairdresser 17|2|63|1574 -
shop +
bakery 17|2|62|1573 17|3|19|11829 -
hairdresser 17|2|63|1574 17|3|19|11829 -
convenience 17|2|122|1572 17|3|19|11829 -
supermarket 17|2|122|1572 17|3|19|11829 -
{}
historic +
battlefield 17|2|68|1579 17|3|19|11829 -

Binary file not shown.

View file

@ -698,3 +698,5 @@ highway|tertiary_link|area|
highway|unsurfaced|tunnel|
highway|secondary_link|area|
natural|allotments|
shop|convenience|
shop|supermarket|

View file

@ -989,7 +989,9 @@ world 000000000000000000 +
{}
shop 000000000000000000 +
bakery 000000000000000001 -
convenience 000000000000000001 -
hairdresser 000000000000000001 -
supermarket 000000000000000001 -
{}
sport 000000000000000000 +
american_football 000000000000000001 -

View file

@ -36,13 +36,55 @@ uint8_t LoaderImpl::GetHeader()
return header;
}
namespace
{
class TypeConvertor
{
vector<uint32_t> m_inc;
public:
TypeConvertor()
{
char const * arr[][2] = {
{ "shop", "convenience" }, // new type
{ "shop", "hairdresser" }
};
Classificator const & c = classif();
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
{
vector<string> v;
v.push_back(arr[i][0]);
v.push_back(arr[i][1]);
m_inc.push_back(c.GetTypeByPath(v));
}
}
uint32_t Convert(uint32_t t) const
{
size_t const count = m_inc.size();
for (size_t i = 0; i < count; ++i)
if (m_inc[i] == t)
{
// return next type (advance by 1)
ASSERT_LESS ( i+1, count, () );
return m_inc[i+1];
}
return t;
}
};
}
void LoaderImpl::ParseTypes()
{
ArrayByteSource source(DataPtr() + m_TypesOffset);
static TypeConvertor typeC;
size_t const count = m_pF->GetTypesCount();
for (size_t i = 0; i < count; ++i)
m_pF->m_Types[i] = ReadVarUint<uint32_t>(source);
m_pF->m_Types[i] = typeC.Convert(ReadVarUint<uint32_t>(source));
m_CommonOffset = CalcOffset(source);
}