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"
|
|
|
|
#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,
|
2024-02-12 10:02:19 +01:00
|
|
|
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
2024-02-23 09:45:41 +01:00
|
|
|
const QRect &rect, qreal ratio) :
|
|
|
|
_proj(proj), _transform(transform), _style(style), _map(data), _atlas(0),
|
|
|
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio) {}
|
2023-09-07 09:31:23 +02:00
|
|
|
RasterTile(const Projection &proj, const Transform &transform,
|
2024-02-12 10:02:19 +01:00
|
|
|
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
2024-02-23 09:45:41 +01:00
|
|
|
const QRect &rect, qreal ratio) :
|
|
|
|
_proj(proj), _transform(transform), _style(style), _map(0), _atlas(data),
|
|
|
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(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;}
|
|
|
|
|
|
|
|
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;
|
2024-06-24 08:47:46 +02:00
|
|
|
QPolygonF tsslptArrow(const QPointF &p, qreal angle) const;
|
|
|
|
QPointF centroid(const QVector<Coordinates> &polygon) 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // ENC_RASTERTILE_H
|