Fixed bug with very long house number (Try Colombia for example).

This commit is contained in:
vng 2012-10-04 22:16:01 +03:00 committed by Alex Zolotarev
parent 3c802db64e
commit 1f008f1b0e
2 changed files with 11 additions and 4 deletions

View file

@ -42,9 +42,9 @@ public:
template <class TSink> void Write(TSink & sink) const
{
int n;
if (strings::to_int(m_s, n) && n >= 0)
WriteVarUint(sink, static_cast<uint32_t>((n << 1) | numeric_bit));
uint64_t n;
if (strings::to_uint64(m_s, n) && ((n << 1) >> 1) == n)
WriteVarUint(sink, ((n << 1) | numeric_bit));
else
{
size_t const sz = m_s.size();

View file

@ -71,8 +71,15 @@ void FeatureParamsBase::AddHouseName(string const & s)
house.Set(house.IsEmpty() ? s : house.Get() + " \"" + s + "\"");
}
void FeatureParamsBase::AddHouseNumber(string const & s)
void FeatureParamsBase::AddHouseNumber(string const & ss)
{
// Remove trailing zero's from house numbers.
// It's important for debug checks of serialized-deserialized feature.
string s(ss);
uint64_t n;
if (strings::to_uint64(s, n))
s = strings::to_string(n);
house.Set(house.IsEmpty() ? s : s + " \"" + house.Get() + "\"");
}