mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-28 03:59:15 +02:00
Use asynchronous tiles rendering in IMG maps
On Android devices, the rendering is very slow so use the same approach as already used in Mapsforge maps.
This commit is contained in:
@ -174,6 +174,8 @@ void RasterTile::render()
|
||||
|
||||
qDeleteAll(textItems);
|
||||
|
||||
_valid = true;
|
||||
|
||||
//painter.setPen(Qt::red);
|
||||
//painter.setRenderHint(QPainter::Antialiasing, false);
|
||||
//painter.drawRect(QRect(_xy, _pixmap.size()));
|
||||
@ -185,7 +187,7 @@ void RasterTile::ll2xy(QList<MapData::Poly> &polys)
|
||||
MapData::Poly &poly = polys[i];
|
||||
for (int j = 0; j < poly.points.size(); j++) {
|
||||
QPointF &p = poly.points[j];
|
||||
p = _map->ll2xy(Coordinates(p.x(), p.y()));
|
||||
p = ll2xy(Coordinates(p.x(), p.y()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -193,7 +195,7 @@ void RasterTile::ll2xy(QList<MapData::Poly> &polys)
|
||||
void RasterTile::ll2xy(QList<MapData::Point> &points)
|
||||
{
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
QPointF p(_map->ll2xy(points.at(i).coordinates));
|
||||
QPointF p(ll2xy(points.at(i).coordinates));
|
||||
points[i].coordinates = Coordinates(p.x(), p.y());
|
||||
}
|
||||
}
|
||||
@ -210,8 +212,8 @@ void RasterTile::drawPolygons(QPainter *painter)
|
||||
|
||||
if (poly.raster.isValid()) {
|
||||
RectC r(poly.raster.rect());
|
||||
QPointF tl(_map->ll2xy(r.topLeft()));
|
||||
QPointF br(_map->ll2xy(r.bottomRight()));
|
||||
QPointF tl(ll2xy(r.topLeft()));
|
||||
QPointF br(ll2xy(r.bottomRight()));
|
||||
QSizeF size(QRectF(tl, br).size());
|
||||
|
||||
bool insert = false;
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include <QPixmap>
|
||||
#include "mapdata.h"
|
||||
#include "map/projection.h"
|
||||
#include "map/transform.h"
|
||||
|
||||
class QPainter;
|
||||
class IMGMap;
|
||||
@ -15,20 +17,25 @@ class Style;
|
||||
class RasterTile
|
||||
{
|
||||
public:
|
||||
RasterTile(IMGMap *map, const Style *style, int zoom, const QRect &rect,
|
||||
qreal ratio, const QString &key, const QList<MapData::Poly> &polygons,
|
||||
RasterTile(const Projection &proj, const Transform &transform,
|
||||
const Style *style, int zoom, const QRect &rect, qreal ratio,
|
||||
const QString &key, const QList<MapData::Poly> &polygons,
|
||||
const QList<MapData::Poly> &lines, QList<MapData::Point> &points)
|
||||
: _map(map), _style(style), _zoom(zoom), _rect(rect), _ratio(ratio),
|
||||
_key(key), _pixmap(rect.width() * ratio, rect.height() * ratio),
|
||||
_polygons(polygons), _lines(lines), _points(points) {}
|
||||
: _proj(proj), _transform(transform), _style(style), _zoom(zoom),
|
||||
_rect(rect), _ratio(ratio), _key(key),
|
||||
_pixmap(rect.width() * ratio, rect.height() * ratio), _polygons(polygons),
|
||||
_lines(lines), _points(points), _valid(false) {}
|
||||
|
||||
const QString &key() const {return _key;}
|
||||
QPoint xy() const {return _rect.topLeft();}
|
||||
const QPixmap &pixmap() const {return _pixmap;}
|
||||
bool isValid() const {return _valid;}
|
||||
|
||||
void render();
|
||||
|
||||
private:
|
||||
QPointF ll2xy(const Coordinates &c) const
|
||||
{return _transform.proj2img(_proj.ll2xy(c));}
|
||||
void ll2xy(QList<MapData::Poly> &polys);
|
||||
void ll2xy(QList<MapData::Point> &points);
|
||||
|
||||
@ -42,7 +49,8 @@ private:
|
||||
void processShields(QList<TextItem*> &textItems);
|
||||
void processStreetNames(QList<TextItem*> &textItems);
|
||||
|
||||
IMGMap *_map;
|
||||
Projection _proj;
|
||||
Transform _transform;
|
||||
const Style *_style;
|
||||
int _zoom;
|
||||
QRect _rect;
|
||||
@ -52,6 +60,7 @@ private:
|
||||
QList<MapData::Poly> _polygons;
|
||||
QList<MapData::Poly> _lines;
|
||||
QList<MapData::Point> _points;
|
||||
bool _valid;
|
||||
};
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user