[core] Use hyphens instead of colons for address ranges

Signed-off-by: zyphlar <zyphlar@gmail.com>
This commit is contained in:
zyphlar
2025-07-15 23:18:18 -07:00
committed by Konstantin Pastbin
parent 24a4edd904
commit 57e86d72e9
4 changed files with 18 additions and 3 deletions

View File

@@ -375,6 +375,17 @@ void GetReadableName(NameParamsIn const & in, NameParamsOut & out)
GetReadableNameImpl(in, in.IsNativeOrSimilarLang(), out); GetReadableNameImpl(in, in.IsNativeOrSimilarLang(), out);
} }
string const GetReadableAddress(string const & address) {
// Instead of housenumber range strings like 123:456, hyphenate like 123 - 456
string out = address;
size_t pos = 0;
while ((pos = out.find(":", pos)) != string::npos) {
out.replace(pos, 1, "\u2009\u2013\u2009"); // thin space + en-dash + thin space
break;
}
return out;
}
/* /*
int8_t GetNameForSearchOnBooking(RegionData const & regionData, StringUtf8Multilang const & src, string & name) int8_t GetNameForSearchOnBooking(RegionData const & regionData, StringUtf8Multilang const & src, string & name)
{ {

View File

@@ -121,6 +121,9 @@ namespace feature
/// - country language name. /// - country language name.
void GetReadableName(NameParamsIn const & in, NameParamsOut & out); void GetReadableName(NameParamsIn const & in, NameParamsOut & out);
/// Format house numbers etc to be more human-readable instead of using symbols like 123:456
std::string const GetReadableAddress(std::string const & address);
/// Returns language id as return result and name for search on booking in the @name parameter, /// Returns language id as return result and name for search on booking in the @name parameter,
/// the priority is the following: /// the priority is the following:
/// - default name; /// - default name;

View File

@@ -51,7 +51,7 @@ void Info::SetFromFeatureType(FeatureType & ft)
bool emptyTitle = false; bool emptyTitle = false;
m_primaryFeatureName = out.GetPrimary(); m_primaryFeatureName = out.GetPrimary();
m_uiAddress = m_address; m_uiAddress = feature::GetReadableAddress(m_address);
if (IsBookmark()) if (IsBookmark())
{ {

View File

@@ -12,6 +12,7 @@
#include "indexer/data_source.hpp" #include "indexer/data_source.hpp"
#include "indexer/feature_algo.hpp" #include "indexer/feature_algo.hpp"
#include "indexer/feature_data.hpp" #include "indexer/feature_data.hpp"
#include "indexer/feature_utils.hpp"
#include "indexer/ftypes_matcher.hpp" #include "indexer/ftypes_matcher.hpp"
#include "indexer/road_shields_parser.hpp" #include "indexer/road_shields_parser.hpp"
#include "indexer/search_string_utils.hpp" #include "indexer/search_string_utils.hpp"
@@ -304,7 +305,7 @@ ftypes::LocalityType GetLocalityIndex(feature::TypesHolder const & types)
// TODO: Format street and house number according to local country's rules. // TODO: Format street and house number according to local country's rules.
string FormatStreetAndHouse(ReverseGeocoder::Address const & addr) string FormatStreetAndHouse(ReverseGeocoder::Address const & addr)
{ {
return addr.GetStreetName() + ", " + addr.GetHouseNumber(); return addr.GetStreetName() + ", " + feature::GetReadableAddress(addr.GetHouseNumber());
} }
// TODO: Share common formatting code for search results and place page. // TODO: Share common formatting code for search results and place page.
@@ -512,7 +513,7 @@ private:
{ {
string streetName; string streetName;
m_ranker.GetBestMatchName(*streetFeature, streetName); m_ranker.GetBestMatchName(*streetFeature, streetName);
name = streetName + ", " + addr.GetHouseNumber(); name = streetName + ", " + feature::GetReadableAddress(addr.GetHouseNumber());
} }
} }
} }