mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Fixed some corner case map drawing issues
This commit is contained in:
parent
cbdfe4c105
commit
92e772a02b
@ -274,6 +274,7 @@ void MapView::setMap(Map *map)
|
|||||||
|
|
||||||
_map = map;
|
_map = map;
|
||||||
_map->load();
|
_map->load();
|
||||||
|
_map->setBackgroundColor(_backgroundColor);
|
||||||
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
connect(_map, SIGNAL(loaded()), this, SLOT(reloadMap()));
|
||||||
|
|
||||||
digitalZoom(0);
|
digitalZoom(0);
|
||||||
|
@ -622,12 +622,17 @@ void OfflineMap::drawImage(QPainter *painter, const QRectF &rect)
|
|||||||
|
|
||||||
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
void OfflineMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
|
QRectF ir = rect.intersected(bounds());
|
||||||
|
|
||||||
|
if (ir != rect)
|
||||||
|
painter->fillRect(rect, _backgroundColor);
|
||||||
|
|
||||||
if (_ozf.isOpen())
|
if (_ozf.isOpen())
|
||||||
drawOZF(painter, rect);
|
drawOZF(painter, ir);
|
||||||
else if (_tileSize.isValid())
|
else if (_tileSize.isValid())
|
||||||
drawTiled(painter, rect);
|
drawTiled(painter, ir);
|
||||||
else
|
else
|
||||||
drawImage(painter, rect);
|
drawImage(painter, ir);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPointF OfflineMap::ll2xy(const Coordinates &c)
|
QPointF OfflineMap::ll2xy(const Coordinates &c)
|
||||||
|
@ -228,14 +228,18 @@ qreal OnlineMap::zoomOut()
|
|||||||
void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
void OnlineMap::draw(QPainter *painter, const QRectF &rect)
|
||||||
{
|
{
|
||||||
qreal scale = zoom2scale(_zoom);
|
qreal scale = zoom2scale(_zoom);
|
||||||
|
QRectF ir = rect.intersected(bounds());
|
||||||
|
|
||||||
QPoint tile = mercator2tile(QPointF(rect.topLeft().x() * scale,
|
if (ir != rect)
|
||||||
-rect.topLeft().y() * scale), _zoom);
|
painter->fillRect(rect, _backgroundColor);
|
||||||
QPoint tl = QPoint((int)floor(rect.left() / (qreal)TILE_SIZE)
|
|
||||||
* TILE_SIZE, (int)floor(rect.top() / TILE_SIZE) * TILE_SIZE);
|
QPoint tile = mercator2tile(QPointF(ir.topLeft().x() * scale,
|
||||||
|
-ir.topLeft().y() * scale), _zoom);
|
||||||
|
QPoint tl = QPoint((int)floor(ir.left() / (qreal)TILE_SIZE)
|
||||||
|
* TILE_SIZE, (int)floor(ir.top() / TILE_SIZE) * TILE_SIZE);
|
||||||
|
|
||||||
QList<Tile> tiles;
|
QList<Tile> tiles;
|
||||||
QSizeF s(rect.right() - tl.x(), rect.bottom() - tl.y());
|
QSizeF s(ir.right() - tl.x(), ir.bottom() - tl.y());
|
||||||
for (int i = 0; i < ceil(s.width() / TILE_SIZE); i++)
|
for (int i = 0; i < ceil(s.width() / TILE_SIZE); i++)
|
||||||
for (int j = 0; j < ceil(s.height() / TILE_SIZE); j++)
|
for (int j = 0; j < ceil(s.height() / TILE_SIZE); j++)
|
||||||
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
tiles.append(Tile(QPoint(tile.x() + i, tile.y() + j), _zoom));
|
||||||
|
Loading…
Reference in New Issue
Block a user