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"
|
2025-03-06 07:55:01 +01:00
|
|
|
#include "data.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,
|
2025-03-06 07:55:01 +01:00
|
|
|
const Style *style, Data *data, int zoom,
|
|
|
|
const Range &zoomRange, const QRect &rect, qreal ratio) :
|
|
|
|
_proj(proj), _transform(transform), _style(style),
|
|
|
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio)
|
|
|
|
{
|
|
|
|
_data.append(data);
|
|
|
|
}
|
2023-09-07 09:31:23 +02:00
|
|
|
RasterTile(const Projection &proj, const Transform &transform,
|
2025-03-06 07:55:01 +01:00
|
|
|
const Style *style, const QList<Data*> &data, int zoom,
|
|
|
|
const Range &zoomRange, const QRect &rect, qreal ratio) :
|
|
|
|
_proj(proj), _transform(transform), _style(style), _data(data),
|
2024-02-23 09:45:41 +01:00
|
|
|
_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:
|
2025-02-06 01:10:44 +01:00
|
|
|
struct SectorLight
|
|
|
|
{
|
2025-02-09 23:00:45 +01:00
|
|
|
SectorLight(const Coordinates &pos, Style::Color color, uint visibility,
|
2025-02-10 20:25:53 +01:00
|
|
|
double range, double start, double end) : pos(pos), color(color),
|
|
|
|
visibility(visibility), range(range), start(start), end(end) {}
|
2025-02-06 01:10:44 +01:00
|
|
|
|
|
|
|
Coordinates pos;
|
|
|
|
Style::Color color;
|
|
|
|
uint visibility;
|
2025-02-10 20:25:53 +01:00
|
|
|
double range;
|
2025-02-06 01:10:44 +01:00
|
|
|
double start;
|
|
|
|
double end;
|
|
|
|
};
|
|
|
|
|
2025-03-07 21:13:54 +01:00
|
|
|
struct Level {
|
|
|
|
QList<Data::Line> lines;
|
|
|
|
QList<Data::Poly> polygons;
|
|
|
|
QList<Data::Point> points;
|
|
|
|
bool overZoom;
|
|
|
|
|
|
|
|
bool isNull() const
|
|
|
|
{return lines.isEmpty() && polygons.isEmpty() && points.isEmpty();}
|
|
|
|
};
|
|
|
|
|
2025-02-06 01:10:44 +01:00
|
|
|
typedef QMap<Coordinates, Style::Color> LightMap;
|
|
|
|
typedef QSet<Coordinates> SignalSet;
|
|
|
|
|
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;
|
2025-03-07 21:13:54 +01:00
|
|
|
void processPoints(const QList<Data::Point> &points,
|
2025-02-06 01:10:44 +01:00
|
|
|
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
2025-03-07 21:13:54 +01:00
|
|
|
QList<SectorLight> §orLights, bool overZoom) const;
|
|
|
|
void processLines(const QList<Data::Line> &lines,
|
|
|
|
QList<TextItem*> &textItems) const;
|
2025-03-06 07:55:01 +01:00
|
|
|
void drawArrows(QPainter *painter, const QList<Data::Point> &points) const;
|
|
|
|
void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const;
|
|
|
|
void drawLines(QPainter *painter, const QList<Data::Line> &lines) const;
|
2025-02-09 23:00:45 +01:00
|
|
|
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
|
|
|
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
|
2025-03-06 07:55:01 +01:00
|
|
|
bool showLabel(const QImage *img, int type) const;
|
2025-03-07 21:13:54 +01:00
|
|
|
void drawLevels(QPainter *painter, const QList<Level> &levels);
|
|
|
|
QList<Level> fetchLevels();
|
|
|
|
QPainterPath shape(const QList<Data::Poly> &polygons) const;
|
2023-09-07 09:31:23 +02:00
|
|
|
|
2022-11-04 09:03:36 +01:00
|
|
|
Projection _proj;
|
|
|
|
Transform _transform;
|
2023-12-21 01:13:36 +01:00
|
|
|
const Style *_style;
|
2025-03-06 07:55:01 +01:00
|
|
|
QList<Data *> _data;
|
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
|