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:
authorvng <viktor.govako@gmail.com>2015-11-17 18:38:39 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:02:55 +0300
commit330aee183867f37c2954c4011f9f2a4e55f8e9a2 (patch)
treeffea7d81e4bf535198a821b920d3290d76175e7a /indexer/feature_data.cpp
parent880238bedc6f998a8653fd95be3fbe9a8833c98f (diff)
[generator] Pass address tokens to the search index generation step.
Diffstat (limited to 'indexer/feature_data.cpp')
-rw-r--r--indexer/feature_data.cpp59
1 files changed, 49 insertions, 10 deletions
diff --git a/indexer/feature_data.cpp b/indexer/feature_data.cpp
index ffaf297270..a0bf7e1091 100644
--- a/indexer/feature_data.cpp
+++ b/indexer/feature_data.cpp
@@ -171,6 +171,10 @@ struct IsBadChar
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// FeatureParams implementation
+/////////////////////////////////////////////////////////////////////////////////////////
+
bool FeatureParams::AddName(string const & lang, string const & s)
{
if (IsDummyName(s))
@@ -218,29 +222,59 @@ bool FeatureParams::AddHouseNumber(string const & ss)
return true;
}
-void FeatureParams::AddStreetAddress(string const & s)
+void FeatureParams::AddStreet(string s)
{
- m_street = s;
-
// Erase bad chars (\n) because we write addresses to txt file.
- m_street.erase(remove_if(m_street.begin(), m_street.end(), IsBadChar()), m_street.end());
+ s.erase(remove_if(s.begin(), s.end(), IsBadChar()), s.end());
// Osm likes to put house numbers into addr:street field.
- size_t i = m_street.find_last_of("\t ");
+ size_t i = s.find_last_of("\t ");
if (i != string::npos)
{
- ++i;
uint64_t n;
- if (strings::to_uint64(m_street.substr(i), n))
- m_street.erase(i);
+ if (strings::to_uint64(s.substr(i+1), n))
+ s.erase(s.find_last_not_of("\t ", i)+1);
+ }
+
+ m_addrTags.Add(AddressData::FAD_STREET, s);
+}
+
+void FeatureParams::AddAddress(string const & s)
+{
+ size_t i = s.find_first_of("\t ");
+ if (i != string::npos)
+ {
+ string const house = s.substr(0, i);
+ if (feature::IsHouseNumber(house))
+ {
+ AddHouseNumber(house);
+ i = s.find_first_not_of("\t ", i);
+ }
+ else
+ i = 0;
}
+ else
+ i = 0;
+
+ AddStreet(s.substr(i, s.size()-i));
+}
+
+void FeatureParams::AddPlace(string const & s)
+{
+ m_addrTags.Add(AddressData::FAD_PLACE, s);
+}
+
+void FeatureParams::AddPostcode(string const & s)
+{
+ m_addrTags.Add(AddressData::FAD_POSTCODE, s);
}
bool FeatureParams::FormatFullAddress(m2::PointD const & pt, string & res) const
{
- if (!m_street.empty() && !house.IsEmpty())
+ string const street = GetStreet();
+ if (!street.empty() && !house.IsEmpty())
{
- res = m_street + "|" + house.Get() + "|"
+ res = street + "|" + house.Get() + "|"
+ strings::to_string_dac(MercatorBounds::YToLat(pt.y), 8) + "|"
+ strings::to_string_dac(MercatorBounds::XToLon(pt.x), 8) + '\n';
return true;
@@ -249,6 +283,11 @@ bool FeatureParams::FormatFullAddress(m2::PointD const & pt, string & res) const
return false;
}
+string FeatureParams::GetStreet() const
+{
+ return m_addrTags.Get(AddressData::FAD_STREET);
+}
+
void FeatureParams::SetGeomType(feature::EGeomType t)
{
switch (t)