forked from organicmaps/organicmaps
Fix initial model rect: if empty, return MercatorBounds. Check for maximum screen scale level (limited by MercatorBounds).
This commit is contained in:
parent
9263e8a91c
commit
9292651e89
3 changed files with 44 additions and 22 deletions
|
@ -18,11 +18,6 @@
|
|||
namespace model
|
||||
{
|
||||
|
||||
FeaturesFetcher::FeaturesFetcher()
|
||||
{
|
||||
Clean();
|
||||
}
|
||||
|
||||
void FeaturesFetcher::InitClassificator()
|
||||
{
|
||||
Platform & p = GetPlatform();
|
||||
|
@ -57,12 +52,22 @@ void FeaturesFetcher::RemoveMap(string const & fName)
|
|||
|
||||
void FeaturesFetcher::Clean()
|
||||
{
|
||||
m_rect = m2::RectD(MercatorBounds::minX,
|
||||
MercatorBounds::minY,
|
||||
MercatorBounds::maxX,
|
||||
MercatorBounds::maxY);
|
||||
// m_rect.MakeEmpty();
|
||||
m_rect.MakeEmpty();
|
||||
m_multiIndex.Clean();
|
||||
}
|
||||
|
||||
m2::RectD FeaturesFetcher::GetWorldRect() const
|
||||
{
|
||||
if (m_rect == m2::RectD())
|
||||
{
|
||||
// rect is empty when now countries are loaded
|
||||
// return max global rect
|
||||
return m2::RectD(MercatorBounds::minX,
|
||||
MercatorBounds::minY,
|
||||
MercatorBounds::maxX,
|
||||
MercatorBounds::maxY);
|
||||
}
|
||||
return m_rect;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace model
|
|||
index_t m_multiIndex;
|
||||
|
||||
public:
|
||||
FeaturesFetcher();
|
||||
|
||||
void InitClassificator();
|
||||
|
||||
|
@ -56,7 +55,7 @@ namespace model
|
|||
}
|
||||
|
||||
void AddWorldRect(m2::RectD const & r) { m_rect.Add(r); }
|
||||
m2::RectD GetWorldRect() const { return m_rect; }
|
||||
m2::RectD GetWorldRect() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -127,13 +127,13 @@ void Navigator::ScaleToPoint(m2::PointD const & pt, double factor, double /*time
|
|||
|
||||
if (pt.x != m_Screen.PixelRect().maxX())
|
||||
{
|
||||
/// start scaling point is 1 / factor way between pt and right border
|
||||
// start scaling point is 1 / factor way between pt and right border
|
||||
startPt.x = pt.x + ((m_Screen.PixelRect().maxX() - pt.x) / factor);
|
||||
endPt.x = m_Screen.PixelRect().maxX();
|
||||
}
|
||||
else
|
||||
{
|
||||
/// start scaling point is 1 - 1/factor way between left border and pt
|
||||
// start scaling point is 1 - 1/factor way between left border and pt
|
||||
startPt.x = pt.x + (m_Screen.PixelRect().minX() - pt.x) / factor;
|
||||
endPt.x = m_Screen.PixelRect().minX();
|
||||
}
|
||||
|
@ -152,15 +152,28 @@ void Navigator::ScaleToPoint(m2::PointD const & pt, double factor, double /*time
|
|||
ScaleImpl(pt, endPt, pt, startPt);
|
||||
}
|
||||
|
||||
void Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2, m2::PointD const & oldPt1, m2::PointD const & oldPt2)
|
||||
namespace
|
||||
{
|
||||
bool CheckMaxScale(ScreenBase const & screen)
|
||||
{
|
||||
m2::RectD const r = screen.GlobalRect();
|
||||
return ((r.SizeX() <= (MercatorBounds::maxX - MercatorBounds::minX)) ||
|
||||
(r.SizeY() <= (MercatorBounds::maxY - MercatorBounds::minY)));
|
||||
}
|
||||
}
|
||||
|
||||
void Navigator::ScaleImpl(m2::PointD const & newPt1, m2::PointD const & newPt2,
|
||||
m2::PointD const & oldPt1, m2::PointD const & oldPt2)
|
||||
{
|
||||
math::Matrix<double, 3, 3> newM = m_Screen.GtoPMatrix() * ScreenBase::CalcTransform(oldPt1, oldPt2, newPt1, newPt2);
|
||||
ScreenBase TmpScreen = m_Screen;
|
||||
TmpScreen.SetGtoPMatrix(newM);
|
||||
TmpScreen.Rotate(TmpScreen.GetAngle());
|
||||
if ((TmpScreen.GlobalRect().SizeX() <= (MercatorBounds::maxX - MercatorBounds::minX))
|
||||
|| ((TmpScreen.GlobalRect().SizeY() <= (MercatorBounds::maxY - MercatorBounds::minY))))
|
||||
m_Screen = TmpScreen;
|
||||
|
||||
ScreenBase tmp = m_Screen;
|
||||
tmp.SetGtoPMatrix(newM);
|
||||
tmp.Rotate(tmp.GetAngle());
|
||||
|
||||
// limit max scale to MercatorBounds
|
||||
if (CheckMaxScale(tmp))
|
||||
m_Screen = tmp;
|
||||
}
|
||||
|
||||
void Navigator::DoScale(m2::PointD const & pt1, m2::PointD const & pt2, double /*timeInSec*/)
|
||||
|
@ -191,7 +204,12 @@ void Navigator::StopScale(m2::PointD const & pt1, m2::PointD const & pt2, double
|
|||
|
||||
void Navigator::Scale(double scale)
|
||||
{
|
||||
m_Screen.Scale(scale);
|
||||
ScreenBase tmp = m_Screen;
|
||||
tmp.Scale(scale);
|
||||
|
||||
// limit max scale to MercatorBounds
|
||||
if (CheckMaxScale(tmp))
|
||||
m_Screen = tmp;
|
||||
}
|
||||
|
||||
void Navigator::Rotate(double angle)
|
||||
|
|
Loading…
Add table
Reference in a new issue