Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Zolotarev <alex@maps.me>2016-04-08 09:59:21 +0300
committerAlex Zolotarev <alex@maps.me>2016-04-11 13:56:34 +0300
commit961fce7fe5a9de881cd788466c51bbe4e9aca4ae (patch)
treee2ef82f91929b2f8cdc249e156e666b75c7dc693
parent07abd0ef5043e6a5f945cf0a930cc4f97a03dee9 (diff)
[generator] Normalize house numbers full-width digits.
-rw-r--r--indexer/feature_data.cpp30
-rw-r--r--indexer/feature_data.hpp2
-rw-r--r--std/algorithm.hpp1
3 files changed, 23 insertions, 10 deletions
diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp
index c4284fb55e..242803e505 100644
--- a/indexer/feature_data.cpp
+++ b/indexer/feature_data.cpp
@@ -5,6 +5,7 @@
#include "base/assert.hpp"
#include "base/stl_add.hpp"
+#include "base/string_utils.hpp"
#include "std/algorithm.hpp"
#include "std/bind.hpp"
@@ -262,20 +263,31 @@ bool FeatureParams::AddHouseName(string const & s)
return false;
}
-bool FeatureParams::AddHouseNumber(string const & ss)
+bool FeatureParams::AddHouseNumber(string houseNumber)
{
- if (!feature::IsHouseNumber(ss))
+ ASSERT(!houseNumber.empty(), ("This check should be done by the caller."));
+ ASSERT_NOT_EQUAL(houseNumber.front(), ' ', ("Trim should be done by the caller."));
+
+ // Negative house numbers are not supported.
+ if (houseNumber.front() == '-' || houseNumber.find(u8"-") == 0)
return false;
- // Remove trailing zero's from house numbers.
+ // Replace full-width digits, mostly in Japan, by ascii-ones.
+ strings::NormalizeDigits(houseNumber);
+
+ // Remove leading zeroes 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);
+ size_t i = 0;
+ while (i < houseNumber.size() && houseNumber[i] != '0')
+ ++i;
+ houseNumber.erase(0, i);
- house.Set(s);
- return true;
+ if (any_of(houseNumber.cbegin(), houseNumber.cend(), IsDigit))
+ {
+ house.Set(houseNumber);
+ return true;
+ }
+ return false;
}
void FeatureParams::AddStreet(string s)
diff --git a/indexer/feature_data.hpp b/indexer/feature_data.hpp
index 901c67b216..93521b212b 100644
--- a/indexer/feature_data.hpp
+++ b/indexer/feature_data.hpp
@@ -224,7 +224,7 @@ public:
bool AddName(string const & lang, string const & s);
bool AddHouseName(string const & s);
- bool AddHouseNumber(string const & s);
+ bool AddHouseNumber(string houseNumber);
/// @name Used in storing full street address only.
//@{
diff --git a/std/algorithm.hpp b/std/algorithm.hpp
index 46d9c64fef..d70be39125 100644
--- a/std/algorithm.hpp
+++ b/std/algorithm.hpp
@@ -7,6 +7,7 @@
#include <algorithm>
using std::all_of;
+using std::any_of;
using std::binary_search;
using std::copy;
using std::equal;