[drape] Render main type overlay draw rules only

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin 2023-02-24 14:43:51 +00:00 committed by Viktor Govako
parent 736f9a8b29
commit c157cb21a2
2 changed files with 33 additions and 12 deletions

View file

@ -299,29 +299,48 @@ bool InitStylist(FeatureType & f, int8_t deviceLang, int const zoomLevel, bool b
return false;
Classificator const & cl = classif();
uint32_t mainOverlayType = 0;
if (types.Size() == 1)
mainOverlayType = *types.cbegin();
else
{
// Determine main overlays type by priority.
// @todo: adjust/optimize depending on the final priorities setup in #4314
int overlayMaxPriority = std::numeric_limits<int>::min();
for (uint32_t t : types)
{
for (auto const & k : cl.GetObject(t)->GetDrawRules())
{
if (k.m_priority > overlayMaxPriority && IsTypeOf(k, Caption | Symbol | Shield | PathText))
{
overlayMaxPriority = k.m_priority;
mainOverlayType = t;
}
}
}
}
auto const & hatchingChecker = IsHatchingTerritoryChecker::Instance();
auto const geomType = types.GetGeomType();
drule::KeysT keys;
size_t idx = 0;
for (uint32_t t : types)
{
cl.GetObject(t)->GetSuitable(zoomLevel, geomType, keys);
drule::KeysT typeKeys;
cl.GetObject(t)->GetSuitable(zoomLevel, geomType, typeKeys);
bool const hasHatching = hatchingChecker(t);
if (hatchingChecker(t))
for (auto & k : typeKeys)
{
while (idx < keys.size())
// Take overlay drules from the main type only.
if (t == mainOverlayType || !IsTypeOf(k, Caption | Symbol | Shield | PathText))
{
if (keys[idx].m_type == drule::area)
keys[idx].m_hatching = true;
++idx;
if (hasHatching && k.m_type == drule::area)
k.m_hatching = true;
keys.push_back(k);
}
}
else
{
// GetSuitable function appends 'keys' vector, so move start index accordingly.
idx = keys.size();
}
}
feature::FilterRulesByRuntimeSelector(f, zoomLevel, keys);
@ -329,6 +348,7 @@ bool InitStylist(FeatureType & f, int8_t deviceLang, int const zoomLevel, bool b
if (keys.empty())
return false;
// Leave only one area drule and an optional hatching drule.
drule::MakeUnique(keys);
s.m_isCoastline = types.Has(cl.GetCoastType());

View file

@ -88,6 +88,7 @@ public:
std::string const & GetName() const { return m_name; }
ClassifObject const * GetObject(size_t i) const;
std::vector<drule::Key> const & GetDrawRules() const { return m_drawRules; }
void GetSuitable(int scale, feature::GeomType gt, drule::KeysT & keys) const;
bool IsDrawable(int scale) const;