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:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2016-07-12 13:12:36 +0300
committerr.kuznetsov <r.kuznetsov@corp.mail.ru>2016-07-12 15:01:54 +0300
commit25226ee097062222b64ef0e5ef09335d39e57027 (patch)
tree73ebae4188c2636b94df6a7c1c781732e783e892 /drape_frontend
parente97402290f1e181de5ba5c4cafa101faafde1b07 (diff)
Improved hotels displacement
Diffstat (limited to 'drape_frontend')
-rw-r--r--drape_frontend/apply_feature_functors.cpp31
-rw-r--r--drape_frontend/poi_symbol_shape.cpp16
-rw-r--r--drape_frontend/poi_symbol_shape.hpp4
-rw-r--r--drape_frontend/text_shape.cpp17
-rw-r--r--drape_frontend/text_shape.hpp8
5 files changed, 57 insertions, 19 deletions
diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp
index 575fdb7bd7..3091f10cb1 100644
--- a/drape_frontend/apply_feature_functors.cpp
+++ b/drape_frontend/apply_feature_functors.cpp
@@ -201,6 +201,25 @@ m2::PointF GetOffset(CaptionDefProto const * capRule)
return result;
}
+uint16_t CalculateHotelOverlayPriority(BaseApplyFeature::HotelData const & data)
+{
+ // NOTE: m_rating is in format X[.Y], where X = [0;10], Y = [0;9], e.g. 8.7
+ string s = data.m_rating;
+ s.erase(remove(s.begin(), s.end(), '.'), s.end());
+ s.erase(remove(s.begin(), s.end(), ','), s.end());
+ if (s.empty())
+ return 0;
+
+ // Special case for integer ratings.
+ if (s.length() == data.m_rating.length())
+ s += '0';
+
+ uint result = 0;
+ if (strings::to_uint(s, result))
+ return static_cast<uint16_t>(result);
+ return 0;
+}
+
} // namespace
BaseApplyFeature::BaseApplyFeature(TInsertShapeFn const & insertShape, FeatureID const & id,
@@ -345,10 +364,10 @@ void ApplyPointFeature::ProcessRule(Stylist::TRuleWrapper const & rule)
params.m_secondaryTextFont = params.m_primaryTextFont;
params.m_secondaryText = ExtractHotelInfo();
params.m_secondaryOptional = false;
- m_insertShape(make_unique_dp<TextShape>(m_centerPoint, params,
- hasPOI, 0 /* textIndex */,
+ uint16_t const priority = CalculateHotelOverlayPriority(m_hotelData);
+ m_insertShape(make_unique_dp<TextShape>(m_centerPoint, params, hasPOI, 0 /* textIndex */,
true /* affectedByZoomPriority */,
- dp::displacement::kHotelMode));
+ dp::displacement::kHotelMode, priority));
}
}
}
@@ -389,7 +408,11 @@ void ApplyPointFeature::Finish()
m_hotelData.m_isHotel ? dp::displacement::kDefaultMode :
dp::displacement::kAllModes));
if (m_hotelData.m_isHotel)
- m_insertShape(make_unique_dp<PoiSymbolShape>(m_centerPoint, params, dp::displacement::kHotelMode));
+ {
+ uint16_t const priority = CalculateHotelOverlayPriority(m_hotelData);
+ m_insertShape(make_unique_dp<PoiSymbolShape>(m_centerPoint, params,
+ dp::displacement::kHotelMode, priority));
+ }
}
}
diff --git a/drape_frontend/poi_symbol_shape.cpp b/drape_frontend/poi_symbol_shape.cpp
index 5b20fe1226..46ab2394c0 100644
--- a/drape_frontend/poi_symbol_shape.cpp
+++ b/drape_frontend/poi_symbol_shape.cpp
@@ -96,8 +96,11 @@ void Batch<MV>(ref_ptr<dp::Batcher> batcher, drape_ptr<dp::OverlayHandle> && han
namespace df
{
PoiSymbolShape::PoiSymbolShape(m2::PointF const & mercatorPt, PoiSymbolViewParams const & params,
- int displacementMode)
- : m_pt(mercatorPt), m_params(params), m_displacementMode(displacementMode)
+ int displacementMode, uint16_t specialModePriority)
+ : m_pt(mercatorPt)
+ , m_params(params)
+ , m_displacementMode(displacementMode)
+ , m_specialModePriority(specialModePriority)
{}
void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const
@@ -132,11 +135,14 @@ void PoiSymbolShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManag
uint64_t PoiSymbolShape::GetOverlayPriority() const
{
- // Set up maximum priority for shapes which created by user in the editor
- // and in case of a special displacement mode.
- if (m_params.m_createdByEditor || (m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ // Set up maximum priority for shapes which created by user in the editor.
+ if (m_params.m_createdByEditor)
return dp::kPriorityMaskAll;
+ // Special displacement mode.
+ if ((m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ return dp::CalculateSpecialModePriority(m_specialModePriority);
+
// Set up minimal priority for shapes which belong to areas.
if (m_params.m_hasArea)
return 0;
diff --git a/drape_frontend/poi_symbol_shape.hpp b/drape_frontend/poi_symbol_shape.hpp
index 503055c712..d17fd51614 100644
--- a/drape_frontend/poi_symbol_shape.hpp
+++ b/drape_frontend/poi_symbol_shape.hpp
@@ -12,7 +12,8 @@ class PoiSymbolShape : public MapShape
{
public:
PoiSymbolShape(m2::PointF const & mercatorPt, PoiSymbolViewParams const & params,
- int displacementMode = dp::displacement::kAllModes);
+ int displacementMode = dp::displacement::kAllModes,
+ uint16_t specialModePriority = 0xFFFF);
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override;
MapShapeType GetType() const override { return MapShapeType::OverlayType; }
@@ -23,6 +24,7 @@ private:
m2::PointF const m_pt;
PoiSymbolViewParams const m_params;
int const m_displacementMode;
+ uint16_t const m_specialModePriority;
};
} // namespace df
diff --git a/drape_frontend/text_shape.cpp b/drape_frontend/text_shape.cpp
index 3bb4fc8269..08336eac6d 100644
--- a/drape_frontend/text_shape.cpp
+++ b/drape_frontend/text_shape.cpp
@@ -122,15 +122,16 @@ private:
} // namespace
-TextShape::TextShape(m2::PointF const & basePoint, TextViewParams const & params,
- bool hasPOI, size_t textIndex, bool affectedByZoomPriority,
- int displacementMode)
+TextShape::TextShape(m2::PointF const & basePoint, TextViewParams const & params, bool hasPOI,
+ size_t textIndex, bool affectedByZoomPriority, int displacementMode,
+ uint16_t specialModePriority)
: m_basePoint(basePoint)
, m_params(params)
, m_hasPOI(hasPOI)
, m_affectedByZoomPriority(affectedByZoomPriority)
, m_textIndex(textIndex)
, m_displacementMode(displacementMode)
+ , m_specialModePriority(specialModePriority)
{}
void TextShape::Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const
@@ -281,11 +282,15 @@ void TextShape::DrawSubStringOutlined(StraightTextLayout const & layout, dp::Fon
uint64_t TextShape::GetOverlayPriority() const
{
- // Set up maximum priority for shapes which created by user in the editor, in case of disabling displacement,
- // in case of a special displacement mode.
- if (m_params.m_createdByEditor || m_disableDisplacing || (m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ // Set up maximum priority for shapes which created by user in the editor and in case of disabling
+ // displacement.
+ if (m_params.m_createdByEditor || m_disableDisplacing)
return dp::kPriorityMaskAll;
+ // Special displacement mode.
+ if ((m_displacementMode & dp::displacement::kDefaultMode) == 0)
+ return dp::CalculateSpecialModePriority(m_specialModePriority);
+
// Set up minimal priority for shapes which belong to areas
if (m_params.m_hasArea)
return 0;
diff --git a/drape_frontend/text_shape.hpp b/drape_frontend/text_shape.hpp
index 3982c418f0..c5198e1875 100644
--- a/drape_frontend/text_shape.hpp
+++ b/drape_frontend/text_shape.hpp
@@ -16,9 +16,10 @@ class StraightTextLayout;
class TextShape : public MapShape
{
public:
- TextShape(m2::PointF const & basePoint, TextViewParams const & params,
- bool hasPOI, size_t textIndex, bool affectedByZoomPriority,
- int displacementMode = dp::displacement::kAllModes);
+ TextShape(m2::PointF const & basePoint, TextViewParams const & params, bool hasPOI,
+ size_t textIndex, bool affectedByZoomPriority,
+ int displacementMode = dp::displacement::kAllModes,
+ uint16_t specialModePriority = 0xFFFF);
void Draw(ref_ptr<dp::Batcher> batcher, ref_ptr<dp::TextureManager> textures) const override;
MapShapeType GetType() const override { return MapShapeType::OverlayType; }
@@ -48,6 +49,7 @@ private:
bool m_disableDisplacing = false;
int m_displacementMode;
+ uint16_t m_specialModePriority;
};
} // namespace df