forked from organicmaps/organicmaps
[generator] make CountrySpecifier::GetLevel nonvirtual with underlying virtual GetSpecificCountryLevel
This commit is contained in:
parent
f0c1baf5f0
commit
fc663f4fad
4 changed files with 18 additions and 21 deletions
|
@ -14,6 +14,12 @@ PlaceLevel CountrySpecifier::GetLevel(Region const & region) const
|
|||
if (placeLevel != PlaceLevel::Unknown)
|
||||
return placeLevel;
|
||||
|
||||
return GetSpecificCountryLevel(region);
|
||||
}
|
||||
|
||||
PlaceLevel CountrySpecifier::GetSpecificCountryLevel(Region const & region) const
|
||||
{
|
||||
auto const placeType = region.GetPlaceType();
|
||||
if (region.GetAdminLevel() == AdminLevel::Two &&
|
||||
(placeType == PlaceType::Country || placeType == PlaceType::Unknown))
|
||||
{
|
||||
|
|
|
@ -12,16 +12,16 @@ namespace regions
|
|||
class CountrySpecifier
|
||||
{
|
||||
public:
|
||||
virtual ~CountrySpecifier() = default;
|
||||
|
||||
virtual void AdjustRegionsLevel(Node::PtrList & outers);
|
||||
PlaceLevel GetLevel(Region const & region) const;
|
||||
|
||||
virtual PlaceLevel GetLevel(Region const & region) const;
|
||||
// Return -1 - |l| is under place of |r|, 0 - undefined relation, 1 - |r| is under place of |l|.
|
||||
// Non-transitive.
|
||||
virtual int RelateByWeight(LevelRegion const & l, LevelRegion const & r) const;
|
||||
|
||||
virtual ~CountrySpecifier() = default;
|
||||
static PlaceLevel GetLevel(PlaceType placeType);
|
||||
private:
|
||||
virtual PlaceLevel GetSpecificCountryLevel(Region const & region) const;
|
||||
};
|
||||
} // namespace regions
|
||||
} // namespace generator
|
||||
|
|
|
@ -57,7 +57,7 @@ void RusSpecifier::MarkMoscowSubregionsByAdministrativeOkrugs(Node::Ptr & tree)
|
|||
|
||||
if (adminLevel > AdminLevel::Five)
|
||||
return;
|
||||
|
||||
|
||||
for (auto & subtree : tree->GetChildren())
|
||||
MarkMoscowSubregionsByAdministrativeOkrugs(subtree);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ void RusSpecifier::MarkMoscowSuburbsByAdministrativeDistrics(Node::Ptr & tree)
|
|||
|
||||
if (PlaceLevel::Suburb == region.GetLevel())
|
||||
region.SetLevel(PlaceLevel::Sublocality);
|
||||
|
||||
|
||||
for (auto & subtree : tree->GetChildren())
|
||||
MarkMoscowSuburbsByAdministrativeDistrics(subtree);
|
||||
}
|
||||
|
@ -114,23 +114,14 @@ void RusSpecifier::MarkAllSuburbsToSublocalities(Node::Ptr & tree)
|
|||
|
||||
if (level == PlaceLevel::Suburb)
|
||||
region.SetLevel(PlaceLevel::Sublocality);
|
||||
|
||||
|
||||
for (auto & subtree : tree->GetChildren())
|
||||
MarkAllSuburbsToSublocalities(subtree);
|
||||
}
|
||||
|
||||
PlaceLevel RusSpecifier::GetLevel(Region const & region) const
|
||||
{
|
||||
auto placeLevel = CountrySpecifier::GetLevel(region.GetPlaceType());
|
||||
if (placeLevel != PlaceLevel::Unknown)
|
||||
return placeLevel;
|
||||
|
||||
return GetRussiaPlaceLevel(region.GetAdminLevel());
|
||||
}
|
||||
|
||||
// static
|
||||
PlaceLevel RusSpecifier::GetRussiaPlaceLevel(AdminLevel adminLevel)
|
||||
PlaceLevel RusSpecifier::GetSpecificCountryLevel(Region const & region) const
|
||||
{
|
||||
AdminLevel adminLevel = region.GetAdminLevel();
|
||||
switch (adminLevel)
|
||||
{
|
||||
case AdminLevel::Two:
|
||||
|
|
|
@ -16,9 +16,11 @@ class RusSpecifier final : public CountrySpecifier
|
|||
public:
|
||||
// CountrySpecifier overrides:
|
||||
void AdjustRegionsLevel(Node::PtrList & outers) override;
|
||||
PlaceLevel GetLevel(Region const & region) const override;
|
||||
|
||||
|
||||
private:
|
||||
PlaceLevel GetSpecificCountryLevel(Region const & region) const override;
|
||||
|
||||
void AdjustMoscowAdministrativeDivisions(Node::PtrList & outers);
|
||||
void AdjustMoscowAdministrativeDivisions(Node::Ptr const & tree);
|
||||
void MarkMoscowSubregionsByAdministrativeOkrugs(Node::Ptr & node);
|
||||
|
@ -28,8 +30,6 @@ private:
|
|||
void MarkMoscowAdministrativeDistric(Node::Ptr & node);
|
||||
void MarkAllSuburbsToSublocalities(Node::Ptr & tree);
|
||||
|
||||
static PlaceLevel GetRussiaPlaceLevel(AdminLevel adminLevel);
|
||||
|
||||
bool m_moscowRegionWasProcessed{false};
|
||||
bool m_moscowCityWasProcessed{false};
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue