1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 21:51:17 +01:00
GPXSee/src/map/ENC/rastertile.h

56 lines
1.5 KiB
C++

#ifndef ENC_RASTERTILE_H
#define ENC_RASTERTILE_H
#include <QPixmap>
#include "map/projection.h"
#include "map/transform.h"
#include "mapdata.h"
class TextItem;
namespace ENC {
class RasterTile
{
public:
RasterTile(const Projection &proj, const Transform &transform, int zoom,
const QRect &rect, qreal ratio, const QList<MapData::Line*> &lines,
const QList<MapData::Poly*> &polygons, const QList<MapData::Point*> &points)
: _proj(proj), _transform(transform), _zoom(zoom), _rect(rect),
_ratio(ratio), _pixmap(rect.width() * ratio, rect.height() * ratio),
_lines(lines), _polygons(polygons), _points(points) {}
int zoom() const {return _zoom;}
QPoint xy() const {return _rect.topLeft();}
const QPixmap &pixmap() const {return _pixmap;}
void render();
private:
QPointF ll2xy(const Coordinates &c) const
{return _transform.proj2img(_proj.ll2xy(c));}
QPainterPath painterPath(const Polygon &polygon) const;
QPolygonF polyline(const QVector<Coordinates> &path) const;
void processPoints(QList<TextItem*> &textItems);
void processLines(QList<TextItem*> &textItems);
void drawBitmapPath(QPainter *painter, const QImage &img,
const Polygon &polygon);
void drawPolygons(QPainter *painter);
void drawLines(QPainter *painter);
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
Projection _proj;
Transform _transform;
int _zoom;
QRect _rect;
qreal _ratio;
QPixmap _pixmap;
QList<MapData::Line*> _lines;
QList<MapData::Poly*> _polygons;
QList<MapData::Point*> _points;
};
}
#endif // ENC_RASTERTILE_H