2022-11-04 09:03:36 +01:00
|
|
|
#ifndef ENC_RASTERTILE_H
|
|
|
|
#define ENC_RASTERTILE_H
|
|
|
|
|
|
|
|
#include <QPixmap>
|
2023-09-07 09:31:23 +02:00
|
|
|
#include "common/range.h"
|
2022-11-04 09:03:36 +01:00
|
|
|
#include "map/projection.h"
|
|
|
|
#include "map/transform.h"
|
2023-04-05 19:27:25 +02:00
|
|
|
#include "map/textpointitem.h"
|
2022-11-04 09:03:36 +01:00
|
|
|
#include "mapdata.h"
|
2023-12-21 01:13:36 +01:00
|
|
|
#include "style.h"
|
2023-09-07 09:31:23 +02:00
|
|
|
#include "atlasdata.h"
|
2022-11-04 09:03:36 +01:00
|
|
|
|
|
|
|
class TextItem;
|
|
|
|
|
|
|
|
namespace ENC {
|
|
|
|
|
|
|
|
class RasterTile
|
|
|
|
{
|
|
|
|
public:
|
2023-03-24 22:54:53 +01:00
|
|
|
RasterTile(const Projection &proj, const Transform &transform,
|
2023-12-21 16:57:11 +01:00
|
|
|
const MapData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
|
|
|
qreal ratio);
|
2023-09-07 09:31:23 +02:00
|
|
|
RasterTile(const Projection &proj, const Transform &transform,
|
2023-12-21 16:57:11 +01:00
|
|
|
AtlasData *data, int zoom, const Range &zoomRange, const QRect &rect,
|
|
|
|
qreal ratio);
|
2022-11-04 09:03:36 +01:00
|
|
|
|
|
|
|
int zoom() const {return _zoom;}
|
|
|
|
QPoint xy() const {return _rect.topLeft();}
|
|
|
|
const QPixmap &pixmap() const {return _pixmap;}
|
2022-11-06 15:26:28 +01:00
|
|
|
bool isValid() const {return _valid;}
|
2022-11-04 09:03:36 +01:00
|
|
|
|
|
|
|
void render();
|
|
|
|
|
|
|
|
private:
|
2023-09-07 09:31:23 +02:00
|
|
|
void fetchData(QList<MapData::Poly> &polygons, QList<MapData::Line> &lines,
|
|
|
|
QList<MapData::Point> &points);
|
2022-11-04 09:03:36 +01:00
|
|
|
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;
|
2023-09-07 09:31:23 +02:00
|
|
|
QVector<QPolygonF> polylineM(const QVector<Coordinates> &path) const;
|
2022-12-08 00:29:39 +01:00
|
|
|
QPolygonF tsslptArrow(const Coordinates &c, qreal angle) const;
|
2023-09-07 09:31:23 +02:00
|
|
|
void processPoints(QList<MapData::Point> &points,
|
2023-05-19 19:33:22 +02:00
|
|
|
QList<TextItem*> &textItems, QList<TextItem *> &lights);
|
2023-09-07 09:31:23 +02:00
|
|
|
void processLines(const QList<MapData::Line> &lines,
|
2023-05-19 19:33:22 +02:00
|
|
|
QList<TextItem*> &textItems);
|
2023-09-07 09:31:23 +02:00
|
|
|
void processPolygons(const QList<MapData::Poly> &polygons,
|
2023-05-19 19:33:22 +02:00
|
|
|
QList<TextItem*> &textItems);
|
2022-11-04 09:03:36 +01:00
|
|
|
void drawBitmapPath(QPainter *painter, const QImage &img,
|
|
|
|
const Polygon &polygon);
|
2023-09-07 09:31:23 +02:00
|
|
|
void drawArrows(QPainter *painter, const QList<MapData::Poly> &polygons);
|
|
|
|
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons);
|
|
|
|
void drawLines(QPainter *painter, const QList<MapData::Line> &lines);
|
2022-11-04 09:03:36 +01:00
|
|
|
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
|
|
|
|
|
2023-09-07 09:31:23 +02:00
|
|
|
static bool polyCb(MapData *data, void *context);
|
|
|
|
static bool pointCb(MapData *data, void *context);
|
|
|
|
|
2022-11-04 09:03:36 +01:00
|
|
|
Projection _proj;
|
|
|
|
Transform _transform;
|
2023-12-21 01:13:36 +01:00
|
|
|
const Style *_style;
|
2023-09-07 09:31:23 +02:00
|
|
|
const MapData *_map;
|
|
|
|
AtlasData *_atlas;
|
2022-11-04 09:03:36 +01:00
|
|
|
int _zoom;
|
2023-09-07 09:31:23 +02:00
|
|
|
Range _zoomRange;
|
2022-11-04 09:03:36 +01:00
|
|
|
QRect _rect;
|
|
|
|
qreal _ratio;
|
|
|
|
QPixmap _pixmap;
|
2022-11-06 15:26:28 +01:00
|
|
|
bool _valid;
|
2022-11-04 09:03:36 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // ENC_RASTERTILE_H
|