forked from organicmaps/organicmaps
[omim] Added localized street name.
This commit is contained in:
parent
e17f21a956
commit
f1b72d5f73
4 changed files with 33 additions and 21 deletions
|
@ -36,7 +36,7 @@ vector<LocalizedName> EditableMapObject::GetLocalizedNames() const
|
|||
return result;
|
||||
}
|
||||
|
||||
vector<string> const & EditableMapObject::GetNearbyStreets() const { return m_nearbyStreets; }
|
||||
vector<LocalizedStreet> const & EditableMapObject::GetNearbyStreets() const { return m_nearbyStreets; }
|
||||
string const & EditableMapObject::GetHouseNumber() const { return m_houseNumber; }
|
||||
|
||||
string EditableMapObject::GetPostcode() const
|
||||
|
@ -85,9 +85,9 @@ void EditableMapObject::SetType(uint32_t featureType)
|
|||
}
|
||||
|
||||
void EditableMapObject::SetID(FeatureID const & fid) { m_featureID = fid; }
|
||||
void EditableMapObject::SetStreet(string const & street) { m_street = street; }
|
||||
void EditableMapObject::SetStreet(LocalizedStreet const & st) { m_street = st; }
|
||||
|
||||
void EditableMapObject::SetNearbyStreets(vector<string> && streets)
|
||||
void EditableMapObject::SetNearbyStreets(vector<LocalizedStreet> && streets)
|
||||
{
|
||||
m_nearbyStreets = move(streets);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ void EditableMapObject::SetBuildingLevels(string const & buildingLevels)
|
|||
m_metadata.Set(feature::Metadata::FMD_BUILDING_LEVELS, buildingLevels);
|
||||
}
|
||||
|
||||
string const & EditableMapObject::GetStreet() const { return m_street; }
|
||||
LocalizedStreet const & EditableMapObject::GetStreet() const { return m_street; }
|
||||
|
||||
void EditableMapObject::SetCuisines(vector<string> const & cuisine)
|
||||
{
|
||||
|
|
|
@ -43,6 +43,14 @@ struct LocalizedName
|
|||
string const m_name;
|
||||
};
|
||||
|
||||
struct LocalizedStreet
|
||||
{
|
||||
string m_defaultName;
|
||||
string m_localizedName;
|
||||
|
||||
bool operator==(LocalizedStreet const & st) const { return m_defaultName == st.m_defaultName; }
|
||||
};
|
||||
|
||||
class EditableMapObject : public MapObject
|
||||
{
|
||||
public:
|
||||
|
@ -55,8 +63,8 @@ public:
|
|||
|
||||
StringUtf8Multilang const & GetName() const;
|
||||
vector<LocalizedName> GetLocalizedNames() const;
|
||||
string const & GetStreet() const;
|
||||
vector<string> const & GetNearbyStreets() const;
|
||||
LocalizedStreet const & GetStreet() const;
|
||||
vector<LocalizedStreet> const & GetNearbyStreets() const;
|
||||
string const & GetHouseNumber() const;
|
||||
string GetPostcode() const;
|
||||
string GetWikipedia() const;
|
||||
|
@ -69,8 +77,8 @@ public:
|
|||
void SetType(uint32_t featureType);
|
||||
void SetID(FeatureID const & fid);
|
||||
// void SetTypes(feature::TypesHolder const & types);
|
||||
void SetStreet(string const & street);
|
||||
void SetNearbyStreets(vector<string> && streets);
|
||||
void SetStreet(LocalizedStreet const & st);
|
||||
void SetNearbyStreets(vector<LocalizedStreet> && streets);
|
||||
/// @returns false if house number fails validation.
|
||||
static bool ValidateHouseNumber(string const & houseNumber);
|
||||
void SetHouseNumber(string const & houseNumber);
|
||||
|
@ -95,8 +103,8 @@ public:
|
|||
|
||||
private:
|
||||
string m_houseNumber;
|
||||
string m_street;
|
||||
vector<string> m_nearbyStreets;
|
||||
LocalizedStreet m_street;
|
||||
vector<LocalizedStreet> m_nearbyStreets;
|
||||
EditableProperties m_editableProperties;
|
||||
};
|
||||
} // namespace osm
|
||||
|
|
|
@ -406,14 +406,14 @@ Editor::SaveResult Editor::SaveEditedFeature(EditableMapObject const & emo)
|
|||
fti.m_feature.ReplaceBy(emo);
|
||||
bool const sameAsInMWM = featureStatus != FeatureStatus::Created &&
|
||||
AreFeaturesEqualButStreet(fti.m_feature, *m_getOriginalFeatureFn(fid)) &&
|
||||
emo.GetStreet() == m_getOriginalFeatureStreetFn(fti.m_feature);
|
||||
emo.GetStreet().m_defaultName == m_getOriginalFeatureStreetFn(fti.m_feature);
|
||||
|
||||
if (featureStatus != FeatureStatus::Untouched)
|
||||
{
|
||||
// A feature was modified and equals to the one in editor.
|
||||
auto const & editedFeatureInfo = m_features[fid.m_mwmId][fid.m_index];
|
||||
if (AreFeaturesEqualButStreet(fti.m_feature, editedFeatureInfo.m_feature) &&
|
||||
emo.GetStreet() == editedFeatureInfo.m_street)
|
||||
emo.GetStreet().m_defaultName == editedFeatureInfo.m_street)
|
||||
{
|
||||
return NothingWasChanged;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ Editor::SaveResult Editor::SaveEditedFeature(EditableMapObject const & emo)
|
|||
|
||||
// TODO: What if local client time is absolutely wrong?
|
||||
fti.m_modificationTimestamp = time(nullptr);
|
||||
fti.m_street = emo.GetStreet();
|
||||
fti.m_street = emo.GetStreet().m_defaultName;
|
||||
|
||||
// Reset upload status so already uploaded features can be uploaded again after modification.
|
||||
fti.m_uploadStatus = {};
|
||||
|
|
|
@ -2448,21 +2448,23 @@ bool Framework::ParseEditorDebugCommand(search::SearchParams const & params)
|
|||
|
||||
namespace
|
||||
{
|
||||
vector<string> FilterNearbyStreets(vector<search::ReverseGeocoder::Street> const & streets,
|
||||
string const & exactFeatureStreet = "")
|
||||
vector<osm::LocalizedStreet> FilterNearbyStreets(vector<search::ReverseGeocoder::Street> const & streets,
|
||||
string const & exactFeatureStreet = "")
|
||||
{
|
||||
vector<string> results;
|
||||
vector<osm::LocalizedStreet> results;
|
||||
// Exact feature street always goes first in Editor UI street list.
|
||||
|
||||
// TODO: Push into result LocalizedStreet object with default and localized street name.
|
||||
if (!exactFeatureStreet.empty())
|
||||
results.push_back(exactFeatureStreet);
|
||||
results.push_back({exactFeatureStreet, ""});
|
||||
// Reasonable number of different nearby street names to display in UI.
|
||||
constexpr size_t kMaxNumberOfNearbyStreetsToDisplay = 8;
|
||||
for (auto const & street : streets)
|
||||
{
|
||||
auto const e = results.end();
|
||||
if (e == find(results.begin(), e, street.m_name))
|
||||
osm::LocalizedStreet const st{street.m_name, ""};
|
||||
if (find(results.begin(), results.end(), st) == results.end())
|
||||
{
|
||||
results.push_back(street.m_name);
|
||||
results.push_back(st);
|
||||
if (results.size() >= kMaxNumberOfNearbyStreetsToDisplay)
|
||||
break;
|
||||
}
|
||||
|
@ -2518,10 +2520,12 @@ bool Framework::GetEditableMapObject(FeatureID const & fid, osm::EditableMapObje
|
|||
street = streets.first[streets.second].m_name;
|
||||
emo.SetNearbyStreets(FilterNearbyStreets(streets.first, street));
|
||||
}
|
||||
emo.SetStreet(street);
|
||||
//TODO: We have to set default and localized name if last one exists.
|
||||
emo.SetStreet({street, ""});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
osm::Editor::SaveResult Framework::SaveEditedMapObject(osm::EditableMapObject const & emo)
|
||||
{
|
||||
if (!m_lastTapEvent)
|
||||
|
|
Loading…
Add table
Reference in a new issue