2021-04-10 15:27:40 +02:00
|
|
|
#ifndef IMG_RASTERTILE_H
|
|
|
|
#define IMG_RASTERTILE_H
|
2020-04-26 01:17:54 +02:00
|
|
|
|
2021-04-13 20:30:27 +02:00
|
|
|
#include <QPixmap>
|
2020-04-26 01:17:54 +02:00
|
|
|
#include "mapdata.h"
|
2022-06-02 18:31:40 +02:00
|
|
|
#include "map/projection.h"
|
|
|
|
#include "map/transform.h"
|
2020-04-26 01:17:54 +02:00
|
|
|
|
|
|
|
class QPainter;
|
2021-04-10 15:27:40 +02:00
|
|
|
class IMGMap;
|
2020-04-26 01:17:54 +02:00
|
|
|
class TextItem;
|
2021-04-10 15:27:40 +02:00
|
|
|
|
|
|
|
namespace IMG {
|
|
|
|
|
2020-04-26 01:17:54 +02:00
|
|
|
class Style;
|
|
|
|
|
|
|
|
class RasterTile
|
|
|
|
{
|
|
|
|
public:
|
2023-05-19 19:33:22 +02:00
|
|
|
RasterTile(const Projection &proj, const Transform &transform, MapData *data,
|
|
|
|
int zoom, const QRect &rect, qreal ratio, const QString &key)
|
|
|
|
: _proj(proj), _transform(transform), _data(data), _zoom(zoom),
|
|
|
|
_rect(rect), _ratio(ratio), _key(key),
|
|
|
|
_pixmap(rect.width() * ratio, rect.height() * ratio), _valid(false) {}
|
2020-04-26 01:17:54 +02:00
|
|
|
|
|
|
|
const QString &key() const {return _key;}
|
2022-05-10 01:05:30 +02:00
|
|
|
QPoint xy() const {return _rect.topLeft();}
|
2021-04-13 20:30:27 +02:00
|
|
|
const QPixmap &pixmap() const {return _pixmap;}
|
2022-06-02 18:31:40 +02:00
|
|
|
bool isValid() const {return _valid;}
|
2020-04-26 01:17:54 +02:00
|
|
|
|
|
|
|
void render();
|
|
|
|
|
|
|
|
private:
|
2023-05-19 19:33:22 +02:00
|
|
|
void fetchData(QList<MapData::Poly> &polygons, QList<MapData::Poly> &lines,
|
|
|
|
QList<MapData::Point> &points);
|
2022-06-02 18:31:40 +02:00
|
|
|
QPointF ll2xy(const Coordinates &c) const
|
|
|
|
{return _transform.proj2img(_proj.ll2xy(c));}
|
2020-11-15 22:37:49 +01:00
|
|
|
void ll2xy(QList<MapData::Poly> &polys);
|
|
|
|
void ll2xy(QList<MapData::Point> &points);
|
|
|
|
|
2023-05-19 19:33:22 +02:00
|
|
|
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons);
|
|
|
|
void drawLines(QPainter *painter, const QList<MapData::Poly> &lines);
|
2020-04-26 01:17:54 +02:00
|
|
|
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
|
|
|
|
|
2023-05-19 19:33:22 +02:00
|
|
|
void processPolygons(const QList<MapData::Poly> &polygons,
|
|
|
|
QList<TextItem *> &textItems);
|
|
|
|
void processLines(QList<MapData::Poly> &lines,
|
2023-07-31 23:36:14 +02:00
|
|
|
QList<TextItem*> &textItems, const QImage &arrow, const QImage &waterArrow);
|
2023-05-19 19:33:22 +02:00
|
|
|
void processPoints(QList<MapData::Point> &points,
|
|
|
|
QList<TextItem*> &textItems);
|
|
|
|
void processShields(const QList<MapData::Poly> &lines,
|
|
|
|
QList<TextItem*> &textItems);
|
|
|
|
void processStreetNames(const QList<MapData::Poly> &lines,
|
2023-07-31 23:36:14 +02:00
|
|
|
QList<TextItem*> &textItems, const QImage &arrow, const QImage &waterArrow);
|
2020-04-26 01:17:54 +02:00
|
|
|
|
2022-06-02 18:31:40 +02:00
|
|
|
Projection _proj;
|
|
|
|
Transform _transform;
|
2023-05-19 19:33:22 +02:00
|
|
|
MapData *_data;
|
2020-04-26 01:17:54 +02:00
|
|
|
int _zoom;
|
2022-05-10 01:05:30 +02:00
|
|
|
QRect _rect;
|
|
|
|
qreal _ratio;
|
2020-04-26 01:17:54 +02:00
|
|
|
QString _key;
|
2021-04-13 20:30:27 +02:00
|
|
|
QPixmap _pixmap;
|
2022-06-02 18:31:40 +02:00
|
|
|
bool _valid;
|
2020-04-26 01:17:54 +02:00
|
|
|
};
|
|
|
|
|
2021-04-10 15:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // IMG_RASTERTILE_H
|