3 #include "common/rectc.h"
9 static int limitZoom(int zoom
)
11 if (zoom
< OSM::ZOOMS
.min())
12 return OSM::ZOOMS
.min();
13 if (zoom
> OSM::ZOOMS
.max())
14 return OSM::ZOOMS
.max();
20 EmptyMap::EmptyMap(QObject
*parent
) : Map(QString(), parent
)
22 _zoom
= OSM::ZOOMS
.max();
25 QRectF
EmptyMap::bounds()
27 return QRectF(ll2xy(OSM::BOUNDS
.topLeft()), ll2xy(OSM::BOUNDS
.bottomRight()));
30 int EmptyMap::zoomFit(const QSize
&size
, const RectC
&rect
)
33 _zoom
= OSM::ZOOMS
.max();
35 QRectF
tbr(OSM::ll2m(rect
.topLeft()), OSM::ll2m(rect
.bottomRight()));
36 QPointF
sc(tbr
.width() / size
.width(), tbr
.height() / size
.height());
38 _zoom
= limitZoom(OSM::scale2zoom(qMax(sc
.x(), -sc
.y()), TILE_SIZE
));
44 qreal
EmptyMap::resolution(const QRectF
&rect
)
46 return OSM::resolution(rect
.center(), _zoom
, TILE_SIZE
);
49 int EmptyMap::zoomIn()
51 _zoom
= qMin(_zoom
+ 1, OSM::ZOOMS
.max());
55 int EmptyMap::zoomOut()
57 _zoom
= qMax(_zoom
- 1, OSM::ZOOMS
.min());
61 void EmptyMap::draw(QPainter
*painter
, const QRectF
&rect
, Flags flags
)
68 QPointF
EmptyMap::ll2xy(const Coordinates
&c
)
70 qreal scale
= OSM::zoom2scale(_zoom
, TILE_SIZE
);
71 QPointF m
= OSM::ll2m(c
);
72 return QPointF(m
.x() / scale
, m
.y() / -scale
);
75 Coordinates
EmptyMap::xy2ll(const QPointF
&p
)
77 qreal scale
= OSM::zoom2scale(_zoom
, TILE_SIZE
);
78 return OSM::m2ll(QPointF(p
.x() * scale
, -p
.y() * scale
));