mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-03-14 02:57:45 +01:00
Overlay two consecutive layers when drawing ENC atlases
This commit is contained in:
parent
66693cd5c9
commit
2595926b7f
@ -118,6 +118,7 @@ HEADERS += src/common/config.h \
|
|||||||
src/data/style.h \
|
src/data/style.h \
|
||||||
src/data/twonavparser.h \
|
src/data/twonavparser.h \
|
||||||
src/data/txtparser.h \
|
src/data/txtparser.h \
|
||||||
|
src/map/ENC/data.h \
|
||||||
src/map/IMG/light.h \
|
src/map/IMG/light.h \
|
||||||
src/map/downloader.h \
|
src/map/downloader.h \
|
||||||
src/map/demloader.h \
|
src/map/demloader.h \
|
||||||
|
@ -39,15 +39,12 @@ bool AtlasData::polyCb(MapEntry *map, void *context)
|
|||||||
ctx->cacheLock.unlock();
|
ctx->cacheLock.unlock();
|
||||||
|
|
||||||
MapData *data = new MapData(map->path);
|
MapData *data = new MapData(map->path);
|
||||||
data->polygons(ctx->rect, ctx->polygons);
|
data->polys(ctx->rect, ctx->polygons, ctx->lines);
|
||||||
data->lines(ctx->rect, ctx->lines);
|
|
||||||
|
|
||||||
ctx->cacheLock.lock();
|
ctx->cacheLock.lock();
|
||||||
ctx->cache.insert(map->path, data);
|
ctx->cache.insert(map->path, data);
|
||||||
} else {
|
} else
|
||||||
cached->polygons(ctx->rect, ctx->polygons);
|
cached->polys(ctx->rect, ctx->polygons, ctx->lines);
|
||||||
cached->lines(ctx->rect, ctx->lines);
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx->cacheLock.unlock();
|
ctx->cacheLock.unlock();
|
||||||
map->lock.unlock();
|
map->lock.unlock();
|
||||||
|
@ -10,18 +10,18 @@ namespace ENC {
|
|||||||
|
|
||||||
typedef QCache<QString, MapData> MapCache;
|
typedef QCache<QString, MapData> MapCache;
|
||||||
|
|
||||||
class AtlasData
|
class AtlasData : public Data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AtlasData(MapCache &cache, QMutex &cacheLock)
|
AtlasData(MapCache &cache, QMutex &cacheLock)
|
||||||
: _cache(cache), _cacheLock(cacheLock) {}
|
: _cache(cache), _cacheLock(cacheLock) {}
|
||||||
~AtlasData();
|
virtual ~AtlasData();
|
||||||
|
|
||||||
void addMap(const RectC &bounds, const QString &path);
|
void addMap(const RectC &bounds, const QString &path);
|
||||||
|
|
||||||
void polys(const RectC &rect, QList<MapData::Poly> *polygons,
|
virtual void polys(const RectC &rect, QList<MapData::Poly> *polygons,
|
||||||
QList<MapData::Line> *lines);
|
QList<MapData::Line> *lines);
|
||||||
void points(const RectC &rect, QList<MapData::Point> *points);
|
virtual void points(const RectC &rect, QList<MapData::Point> *points);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct MapEntry {
|
struct MapEntry {
|
||||||
|
79
src/map/ENC/data.h
Normal file
79
src/map/ENC/data.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#ifndef ENC_DATA_H
|
||||||
|
#define ENC_DATA_H
|
||||||
|
|
||||||
|
#include "common/rectc.h"
|
||||||
|
#include "common/polygon.h"
|
||||||
|
|
||||||
|
namespace ENC {
|
||||||
|
|
||||||
|
class Data
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef QMap<uint, QByteArray> Attributes;
|
||||||
|
|
||||||
|
class Poly {
|
||||||
|
public:
|
||||||
|
Poly(uint type, const Polygon &path, const Attributes &attr, uint HUNI);
|
||||||
|
|
||||||
|
RectC bounds() const {return _path.boundingRect();}
|
||||||
|
const Polygon &path() const {return _path;}
|
||||||
|
uint type() const {return _type;}
|
||||||
|
const Attributes &attributes() const {return _attr;}
|
||||||
|
uint HUNI() const {return _HUNI;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint _type;
|
||||||
|
Polygon _path;
|
||||||
|
Attributes _attr;
|
||||||
|
uint _HUNI;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Line {
|
||||||
|
public:
|
||||||
|
Line(uint type, const QVector<Coordinates> &path, const Attributes &attr);
|
||||||
|
|
||||||
|
RectC bounds() const;
|
||||||
|
const QVector<Coordinates> &path() const {return _path;}
|
||||||
|
uint type() const {return _type;}
|
||||||
|
const QString &label() const {return _label;}
|
||||||
|
const Attributes &attributes() const {return _attr;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint _type;
|
||||||
|
QVector<Coordinates> _path;
|
||||||
|
QString _label;
|
||||||
|
Attributes _attr;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Point {
|
||||||
|
public:
|
||||||
|
Point(uint type, const Coordinates &c, const Attributes &attr,
|
||||||
|
uint HUNI, bool polygon = false);
|
||||||
|
Point(uint type, const Coordinates &s, const QString &label);
|
||||||
|
|
||||||
|
const Coordinates &pos() const {return _pos;}
|
||||||
|
uint type() const {return _type;}
|
||||||
|
const QString &label() const {return _label;}
|
||||||
|
const Attributes &attributes() const {return _attr;}
|
||||||
|
bool polygon() const {return _polygon;}
|
||||||
|
|
||||||
|
bool operator<(const Point &other) const
|
||||||
|
{return _id < other._id;}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint _type;
|
||||||
|
Coordinates _pos;
|
||||||
|
QString _label;
|
||||||
|
quint64 _id;
|
||||||
|
Attributes _attr;
|
||||||
|
bool _polygon;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void polys(const RectC &rect, QList<Data::Poly> *polygons,
|
||||||
|
QList<Data::Line> *lines) = 0;
|
||||||
|
virtual void points(const RectC &rect, QList<Data::Point> *points) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // ENC_DATA_H
|
@ -866,7 +866,7 @@ MapData::~MapData()
|
|||||||
delete _points.GetAt(pit);
|
delete _points.GetAt(pit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapData::points(const RectC &rect, QList<Point> *points) const
|
void MapData::points(const RectC &rect, QList<Point> *points)
|
||||||
{
|
{
|
||||||
double min[2], max[2];
|
double min[2], max[2];
|
||||||
|
|
||||||
@ -876,18 +876,12 @@ void MapData::points(const RectC &rect, QList<Point> *points) const
|
|||||||
_lines.Search(min, max, linePointCb, points);
|
_lines.Search(min, max, linePointCb, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapData::lines(const RectC &rect, QList<Line> *lines) const
|
void MapData::polys(const RectC &rect, QList<Poly> *polygons,
|
||||||
|
QList<Line> *lines)
|
||||||
{
|
{
|
||||||
double min[2], max[2];
|
double min[2], max[2];
|
||||||
|
|
||||||
rectcBounds(rect, min, max);
|
rectcBounds(rect, min, max);
|
||||||
_lines.Search(min, max, lineCb, lines);
|
_lines.Search(min, max, lineCb, lines);
|
||||||
}
|
|
||||||
|
|
||||||
void MapData::polygons(const RectC &rect, QList<Poly> *polygons) const
|
|
||||||
{
|
|
||||||
double min[2], max[2];
|
|
||||||
|
|
||||||
rectcBounds(rect, min, max);
|
|
||||||
_areas.Search(min, max, polygonCb, polygons);
|
_areas.Search(min, max, polygonCb, polygons);
|
||||||
}
|
}
|
||||||
|
@ -1,82 +1,21 @@
|
|||||||
#ifndef ENC_MAPDATA_H
|
#ifndef ENC_MAPDATA_H
|
||||||
#define ENC_MAPDATA_H
|
#define ENC_MAPDATA_H
|
||||||
|
|
||||||
#include "common/rectc.h"
|
|
||||||
#include "common/rtree.h"
|
#include "common/rtree.h"
|
||||||
#include "common/polygon.h"
|
|
||||||
#include "iso8211.h"
|
#include "iso8211.h"
|
||||||
|
#include "data.h"
|
||||||
|
|
||||||
namespace ENC {
|
namespace ENC {
|
||||||
|
|
||||||
class MapData
|
class MapData : public Data
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef QMap<uint, QByteArray> Attributes;
|
|
||||||
|
|
||||||
class Poly {
|
|
||||||
public:
|
|
||||||
Poly(uint type, const Polygon &path, const Attributes &attr, uint HUNI);
|
|
||||||
|
|
||||||
RectC bounds() const {return _path.boundingRect();}
|
|
||||||
const Polygon &path() const {return _path;}
|
|
||||||
uint type() const {return _type;}
|
|
||||||
const Attributes &attributes() const {return _attr;}
|
|
||||||
uint HUNI() const {return _HUNI;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint _type;
|
|
||||||
Polygon _path;
|
|
||||||
Attributes _attr;
|
|
||||||
uint _HUNI;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Line {
|
|
||||||
public:
|
|
||||||
Line(uint type, const QVector<Coordinates> &path, const Attributes &attr);
|
|
||||||
|
|
||||||
RectC bounds() const;
|
|
||||||
const QVector<Coordinates> &path() const {return _path;}
|
|
||||||
uint type() const {return _type;}
|
|
||||||
const QString &label() const {return _label;}
|
|
||||||
const Attributes &attributes() const {return _attr;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint _type;
|
|
||||||
QVector<Coordinates> _path;
|
|
||||||
QString _label;
|
|
||||||
Attributes _attr;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Point {
|
|
||||||
public:
|
|
||||||
Point(uint type, const Coordinates &c, const Attributes &attr,
|
|
||||||
uint HUNI, bool polygon = false);
|
|
||||||
Point(uint type, const Coordinates &s, const QString &label);
|
|
||||||
|
|
||||||
const Coordinates &pos() const {return _pos;}
|
|
||||||
uint type() const {return _type;}
|
|
||||||
const QString &label() const {return _label;}
|
|
||||||
const Attributes &attributes() const {return _attr;}
|
|
||||||
bool polygon() const {return _polygon;}
|
|
||||||
|
|
||||||
bool operator<(const Point &other) const
|
|
||||||
{return _id < other._id;}
|
|
||||||
|
|
||||||
private:
|
|
||||||
uint _type;
|
|
||||||
Coordinates _pos;
|
|
||||||
QString _label;
|
|
||||||
quint64 _id;
|
|
||||||
Attributes _attr;
|
|
||||||
bool _polygon;
|
|
||||||
};
|
|
||||||
|
|
||||||
MapData(const QString &path);
|
MapData(const QString &path);
|
||||||
~MapData();
|
virtual ~MapData();
|
||||||
|
|
||||||
void polygons(const RectC &rect, QList<Poly> *polygons) const;
|
virtual void polys(const RectC &rect, QList<Poly> *polygons,
|
||||||
void lines(const RectC &rect, QList<Line> *lines) const;
|
QList<Line> *lines);
|
||||||
void points(const RectC &rect, QList<Point> *points) const;
|
virtual void points(const RectC &rect, QList<Point> *points);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Sounding {
|
struct Sounding {
|
||||||
|
@ -28,14 +28,14 @@ static double angle(uint type, const QVariant ¶m)
|
|||||||
? 90 + param.toDouble() : NAN;
|
? 90 + param.toDouble() : NAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool showLabel(const QImage *img, const Range &range, int zoom, int type)
|
bool RasterTile::showLabel(const QImage *img, int type) const
|
||||||
{
|
{
|
||||||
if (type>>16 == I_DISMAR)
|
if (type>>16 == I_DISMAR)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int limit = (!range.size())
|
int limit = (!_zoomRange.size())
|
||||||
? range.min() : range.min() + (range.size() + 1) / 2;
|
? _zoomRange.min() : _zoomRange.min() + (_zoomRange.size() + 1) / 2;
|
||||||
if ((img || (type>>16 == SOUNDG)) && (zoom < limit))
|
if ((img || (type>>16 == SOUNDG)) && (_zoom < limit))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -139,10 +139,10 @@ static void drawArrow(QPainter *painter, const QPolygonF &polygon, uint type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::drawArrows(QPainter *painter,
|
void RasterTile::drawArrows(QPainter *painter,
|
||||||
const QList<MapData::Point> &points) const
|
const QList<Data::Point> &points) const
|
||||||
{
|
{
|
||||||
for (int i = 0; i < points.size(); i++) {
|
for (int i = 0; i < points.size(); i++) {
|
||||||
const MapData::Point &point = points.at(i);
|
const Data::Point &point = points.at(i);
|
||||||
|
|
||||||
if (point.type()>>16 == TSSLPT || point.type()>>16 == RCTLPT) {
|
if (point.type()>>16 == TSSLPT || point.type()>>16 == RCTLPT) {
|
||||||
QPolygonF polygon(tsslptArrow(ll2xy(point.pos()),
|
QPolygonF polygon(tsslptArrow(ll2xy(point.pos()),
|
||||||
@ -153,11 +153,11 @@ void RasterTile::drawArrows(QPainter *painter,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::drawPolygons(QPainter *painter,
|
void RasterTile::drawPolygons(QPainter *painter,
|
||||||
const QList<MapData::Poly> &polygons) const
|
const QList<Data::Poly> &polygons) const
|
||||||
{
|
{
|
||||||
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
||||||
for (int i = 0; i < polygons.size(); i++) {
|
for (int i = 0; i < polygons.size(); i++) {
|
||||||
const MapData::Poly &poly = polygons.at(i);
|
const Data::Poly &poly = polygons.at(i);
|
||||||
if (poly.type() != _style->drawOrder().at(n))
|
if (poly.type() != _style->drawOrder().at(n))
|
||||||
continue;
|
continue;
|
||||||
const Style::Polygon &style = _style->polygon(poly.type());
|
const Style::Polygon &style = _style->polygon(poly.type());
|
||||||
@ -185,12 +185,12 @@ void RasterTile::drawPolygons(QPainter *painter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::drawLines(QPainter *painter, const QList<MapData::Line> &lines) const
|
void RasterTile::drawLines(QPainter *painter, const QList<Data::Line> &lines) const
|
||||||
{
|
{
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
const MapData::Line &line = lines.at(i);
|
const Data::Line &line = lines.at(i);
|
||||||
const Style::Line &style = _style->line(line.type());
|
const Style::Line &style = _style->line(line.type());
|
||||||
|
|
||||||
if (!style.img().isNull()) {
|
if (!style.img().isNull()) {
|
||||||
@ -257,9 +257,9 @@ void RasterTile::drawSectorLights(QPainter *painter,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::processPoints(QList<MapData::Point> &points,
|
void RasterTile::processPoints(QList<Data::Point> &points,
|
||||||
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
QList<TextItem*> &textItems, QList<TextItem*> &lights,
|
||||||
QList<SectorLight> §orLights)
|
QList<SectorLight> §orLights, bool overZoom)
|
||||||
{
|
{
|
||||||
LightMap lightsMap;
|
LightMap lightsMap;
|
||||||
SignalSet signalsSet;
|
SignalSet signalsSet;
|
||||||
@ -270,10 +270,10 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
|||||||
|
|
||||||
/* Lights & Signals */
|
/* Lights & Signals */
|
||||||
for (i = 0; i < points.size(); i++) {
|
for (i = 0; i < points.size(); i++) {
|
||||||
const MapData::Point &point = points.at(i);
|
const Data::Point &point = points.at(i);
|
||||||
|
|
||||||
if (point.type()>>16 == LIGHTS) {
|
if (point.type()>>16 == LIGHTS) {
|
||||||
const MapData::Attributes &attr = point.attributes();
|
const Data::Attributes &attr = point.attributes();
|
||||||
Style::Color color = (Style::Color)(attr.value(COLOUR).toUInt());
|
Style::Color color = (Style::Color)(attr.value(COLOUR).toUInt());
|
||||||
double range = attr.value(VALNMR).toDouble();
|
double range = attr.value(VALNMR).toDouble();
|
||||||
|
|
||||||
@ -293,13 +293,13 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
|||||||
|
|
||||||
/* Everything else */
|
/* Everything else */
|
||||||
for ( ; i < points.size(); i++) {
|
for ( ; i < points.size(); i++) {
|
||||||
const MapData::Point &point = points.at(i);
|
const Data::Point &point = points.at(i);
|
||||||
QPoint pos(ll2xy(point.pos()).toPoint());
|
QPoint pos(ll2xy(point.pos()).toPoint());
|
||||||
const Style::Point &style = _style->point(point.type());
|
const Style::Point &style = _style->point(point.type());
|
||||||
|
|
||||||
const QString *label = point.label().isEmpty() ? 0 : &(point.label());
|
const QString *label = point.label().isEmpty() ? 0 : &(point.label());
|
||||||
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
const QImage *img = style.img().isNull() ? 0 : &style.img();
|
||||||
const QFont *fnt = showLabel(img, _zoomRange, _zoom, point.type())
|
const QFont *fnt = (overZoom || showLabel(img, point.type()))
|
||||||
? _style->font(style.textFontSize()) : 0;
|
? _style->font(style.textFontSize()) : 0;
|
||||||
const QColor *color = &style.textColor();
|
const QColor *color = &style.textColor();
|
||||||
const QColor *hColor = style.haloColor().isValid()
|
const QColor *hColor = style.haloColor().isValid()
|
||||||
@ -327,11 +327,11 @@ void RasterTile::processPoints(QList<MapData::Point> &points,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::processLines(const QList<MapData::Line> &lines,
|
void RasterTile::processLines(const QList<Data::Line> &lines,
|
||||||
QList<TextItem*> &textItems)
|
QList<TextItem*> &textItems)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < lines.size(); i++) {
|
for (int i = 0; i < lines.size(); i++) {
|
||||||
const MapData::Line &line = lines.at(i);
|
const Data::Line &line = lines.at(i);
|
||||||
const Style::Line &style = _style->line(line.type());
|
const Style::Line &style = _style->line(line.type());
|
||||||
|
|
||||||
if (style.img().isNull() && style.pen() == Qt::NoPen)
|
if (style.img().isNull() && style.pen() == Qt::NoPen)
|
||||||
@ -351,11 +351,20 @@ void RasterTile::processLines(const QList<MapData::Line> &lines,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterTile::fetchData(QList<MapData::Poly> &polygons,
|
void RasterTile::render()
|
||||||
QList<MapData::Line> &lines, QList<MapData::Point> &points)
|
|
||||||
{
|
{
|
||||||
QPoint ttl(_rect.topLeft());
|
QImage img(_rect.width() * _ratio, _rect.height() * _ratio,
|
||||||
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
|
|
||||||
|
img.setDevicePixelRatio(_ratio);
|
||||||
|
img.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter painter(&img);
|
||||||
|
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.translate(-_rect.x(), -_rect.y());
|
||||||
|
|
||||||
|
QPoint ttl(_rect.topLeft());
|
||||||
QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y()
|
QRectF polyRect(ttl, QPointF(ttl.x() + _rect.width(), ttl.y()
|
||||||
+ _rect.height()));
|
+ _rect.height()));
|
||||||
RectD polyRectD(_transform.img2proj(polyRect.topLeft()),
|
RectD polyRectD(_transform.img2proj(polyRect.topLeft()),
|
||||||
@ -368,50 +377,31 @@ void RasterTile::fetchData(QList<MapData::Poly> &polygons,
|
|||||||
_transform.img2proj(pointRect.bottomRight()));
|
_transform.img2proj(pointRect.bottomRight()));
|
||||||
RectC pointRectC(pointRectD.toRectC(_proj, 20));
|
RectC pointRectC(pointRectD.toRectC(_proj, 20));
|
||||||
|
|
||||||
if (_map) {
|
for (int i = 0; i < _data.size(); i++) {
|
||||||
_map->lines(polyRectC, &lines);
|
QList<Data::Line> lines;
|
||||||
_map->polygons(polyRectC, &polygons);
|
QList<Data::Poly> polygons;
|
||||||
_map->points(pointRectC, &points);
|
QList<Data::Point> points;
|
||||||
} else {
|
QList<TextItem*> textItems, lights;
|
||||||
_atlas->polys(polyRectC, &polygons, &lines);
|
QList<SectorLight> sectorLights;
|
||||||
_atlas->points(pointRectC, &points);
|
|
||||||
|
_data.at(i)->polys(polyRectC, &polygons, &lines);
|
||||||
|
_data.at(i)->points(pointRectC, &points);
|
||||||
|
|
||||||
|
processPoints(points, textItems, lights, sectorLights,
|
||||||
|
_data.size() > 1 && i == 0);
|
||||||
|
processLines(lines, textItems);
|
||||||
|
|
||||||
|
drawPolygons(&painter, polygons);
|
||||||
|
drawLines(&painter, lines);
|
||||||
|
drawArrows(&painter, points);
|
||||||
|
|
||||||
|
drawTextItems(&painter, lights);
|
||||||
|
drawSectorLights(&painter, sectorLights);
|
||||||
|
drawTextItems(&painter, textItems);
|
||||||
|
|
||||||
|
qDeleteAll(textItems);
|
||||||
|
qDeleteAll(lights);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void RasterTile::render()
|
|
||||||
{
|
|
||||||
QImage img(_rect.width() * _ratio, _rect.height() * _ratio,
|
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
|
||||||
QList<MapData::Line> lines;
|
|
||||||
QList<MapData::Poly> polygons;
|
|
||||||
QList<MapData::Point> points;
|
|
||||||
QList<TextItem*> textItems, lights;
|
|
||||||
QList<SectorLight> sectorLights;
|
|
||||||
|
|
||||||
img.setDevicePixelRatio(_ratio);
|
|
||||||
img.fill(Qt::transparent);
|
|
||||||
|
|
||||||
fetchData(polygons, lines, points);
|
|
||||||
|
|
||||||
processPoints(points, textItems, lights, sectorLights);
|
|
||||||
processLines(lines, textItems);
|
|
||||||
|
|
||||||
QPainter painter(&img);
|
|
||||||
painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
|
||||||
painter.translate(-_rect.x(), -_rect.y());
|
|
||||||
|
|
||||||
drawPolygons(&painter, polygons);
|
|
||||||
drawLines(&painter, lines);
|
|
||||||
drawArrows(&painter, points);
|
|
||||||
|
|
||||||
|
|
||||||
drawTextItems(&painter, lights);
|
|
||||||
drawSectorLights(&painter, sectorLights);
|
|
||||||
drawTextItems(&painter, textItems);
|
|
||||||
|
|
||||||
qDeleteAll(textItems);
|
|
||||||
qDeleteAll(lights);
|
|
||||||
|
|
||||||
//painter.setPen(Qt::red);
|
//painter.setPen(Qt::red);
|
||||||
//painter.setBrush(Qt::NoBrush);
|
//painter.setBrush(Qt::NoBrush);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "common/range.h"
|
#include "common/range.h"
|
||||||
#include "map/projection.h"
|
#include "map/projection.h"
|
||||||
#include "map/transform.h"
|
#include "map/transform.h"
|
||||||
#include "mapdata.h"
|
#include "data.h"
|
||||||
#include "style.h"
|
#include "style.h"
|
||||||
#include "atlasdata.h"
|
#include "atlasdata.h"
|
||||||
|
|
||||||
@ -17,14 +17,17 @@ class RasterTile
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const Style *style, const MapData *data, int zoom, const Range &zoomRange,
|
const Style *style, Data *data, int zoom,
|
||||||
const QRect &rect, qreal ratio) :
|
const Range &zoomRange, const QRect &rect, qreal ratio) :
|
||||||
_proj(proj), _transform(transform), _style(style), _map(data), _atlas(0),
|
_proj(proj), _transform(transform), _style(style),
|
||||||
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio) {}
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio)
|
||||||
|
{
|
||||||
|
_data.append(data);
|
||||||
|
}
|
||||||
RasterTile(const Projection &proj, const Transform &transform,
|
RasterTile(const Projection &proj, const Transform &transform,
|
||||||
const Style *style, AtlasData *data, int zoom, const Range &zoomRange,
|
const Style *style, const QList<Data*> &data, int zoom,
|
||||||
const QRect &rect, qreal ratio) :
|
const Range &zoomRange, const QRect &rect, qreal ratio) :
|
||||||
_proj(proj), _transform(transform), _style(style), _map(0), _atlas(data),
|
_proj(proj), _transform(transform), _style(style), _data(data),
|
||||||
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio) {}
|
_zoom(zoom), _zoomRange(zoomRange), _rect(rect), _ratio(ratio) {}
|
||||||
|
|
||||||
int zoom() const {return _zoom;}
|
int zoom() const {return _zoom;}
|
||||||
@ -51,8 +54,6 @@ private:
|
|||||||
typedef QMap<Coordinates, Style::Color> LightMap;
|
typedef QMap<Coordinates, Style::Color> LightMap;
|
||||||
typedef QSet<Coordinates> SignalSet;
|
typedef QSet<Coordinates> SignalSet;
|
||||||
|
|
||||||
void fetchData(QList<MapData::Poly> &polygons, QList<MapData::Line> &lines,
|
|
||||||
QList<MapData::Point> &points);
|
|
||||||
QPointF ll2xy(const Coordinates &c) const
|
QPointF ll2xy(const Coordinates &c) const
|
||||||
{return _transform.proj2img(_proj.ll2xy(c));}
|
{return _transform.proj2img(_proj.ll2xy(c));}
|
||||||
QPainterPath painterPath(const Polygon &polygon) const;
|
QPainterPath painterPath(const Polygon &polygon) const;
|
||||||
@ -60,25 +61,21 @@ private:
|
|||||||
QVector<QPolygonF> polylineM(const QVector<Coordinates> &path) const;
|
QVector<QPolygonF> polylineM(const QVector<Coordinates> &path) const;
|
||||||
QPolygonF tsslptArrow(const QPointF &p, qreal angle) const;
|
QPolygonF tsslptArrow(const QPointF &p, qreal angle) const;
|
||||||
QPointF centroid(const QVector<Coordinates> &polygon) const;
|
QPointF centroid(const QVector<Coordinates> &polygon) const;
|
||||||
void processPoints(QList<MapData::Point> &points,
|
void processPoints(QList<Data::Point> &points,
|
||||||
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
QList<TextItem*> &textItems, QList<TextItem *> &lights,
|
||||||
QList<SectorLight> §orLights);
|
QList<SectorLight> §orLights, bool overZoom);
|
||||||
void processLines(const QList<MapData::Line> &lines,
|
void processLines(const QList<Data::Line> &lines, QList<TextItem*> &textItems);
|
||||||
QList<TextItem*> &textItems);
|
void drawArrows(QPainter *painter, const QList<Data::Point> &points) const;
|
||||||
void drawArrows(QPainter *painter, const QList<MapData::Point> &points) const;
|
void drawPolygons(QPainter *painter, const QList<Data::Poly> &polygons) const;
|
||||||
void drawPolygons(QPainter *painter, const QList<MapData::Poly> &polygons) const;
|
void drawLines(QPainter *painter, const QList<Data::Line> &lines) const;
|
||||||
void drawLines(QPainter *painter, const QList<MapData::Line> &lines) const;
|
|
||||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems) const;
|
||||||
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
|
void drawSectorLights(QPainter *painter, const QList<SectorLight> &lights) const;
|
||||||
|
bool showLabel(const QImage *img, int type) const;
|
||||||
static bool polyCb(MapData *data, void *context);
|
|
||||||
static bool pointCb(MapData *data, void *context);
|
|
||||||
|
|
||||||
Projection _proj;
|
Projection _proj;
|
||||||
Transform _transform;
|
Transform _transform;
|
||||||
const Style *_style;
|
const Style *_style;
|
||||||
const MapData *_map;
|
QList<Data *> _data;
|
||||||
AtlasData *_atlas;
|
|
||||||
int _zoom;
|
int _zoom;
|
||||||
Range _zoomRange;
|
Range _zoomRange;
|
||||||
QRect _rect;
|
QRect _rect;
|
||||||
|
@ -27,7 +27,6 @@ static QFont pixelSizeFont(int pixelSize)
|
|||||||
|
|
||||||
void Style::polygonStyle()
|
void Style::polygonStyle()
|
||||||
{
|
{
|
||||||
_polygons[TYPE(M_COVR)] = Polygon(QBrush(QColor(0xff, 0xff, 0xff)));
|
|
||||||
_polygons[TYPE(LNDARE)] = Polygon(QBrush(QColor(0xe8, 0xe0, 0x64)));
|
_polygons[TYPE(LNDARE)] = Polygon(QBrush(QColor(0xe8, 0xe0, 0x64)));
|
||||||
_polygons[TYPE(BUAARE)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)));
|
_polygons[TYPE(BUAARE)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)));
|
||||||
_polygons[TYPE(BUISGL)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)),
|
_polygons[TYPE(BUISGL)] = Polygon(QBrush(QColor(0xd9, 0x8b, 0x21)),
|
||||||
@ -153,19 +152,19 @@ void Style::polygonStyle()
|
|||||||
1, Qt::DashDotLine));
|
1, Qt::DashDotLine));
|
||||||
|
|
||||||
_drawOrder
|
_drawOrder
|
||||||
<< TYPE(M_COVR) << TYPE(LNDARE) << SUBTYPE(DEPARE, 0)
|
<< TYPE(LNDARE) << SUBTYPE(DEPARE, 0) << SUBTYPE(DEPARE, 1)
|
||||||
<< SUBTYPE(DEPARE, 1) << SUBTYPE(DEPARE, 2) << SUBTYPE(DEPARE, 3)
|
<< SUBTYPE(DEPARE, 2) << SUBTYPE(DEPARE, 3) << TYPE(UNSARE)
|
||||||
<< TYPE(UNSARE) << SUBTYPE(DEPARE, 4) << SUBTYPE(DEPARE, 5)
|
<< SUBTYPE(DEPARE, 4) << SUBTYPE(DEPARE, 5) << SUBTYPE(DEPARE, 6)
|
||||||
<< SUBTYPE(DEPARE, 6) << TYPE(LAKARE) << TYPE(CANALS) << TYPE(DYKCON)
|
<< TYPE(LAKARE) << TYPE(CANALS) << TYPE(DYKCON) << TYPE(RIVERS)
|
||||||
<< TYPE(RIVERS) << TYPE(DRGARE) << TYPE(FAIRWY) << TYPE(LOKBSN)
|
<< TYPE(DRGARE) << TYPE(FAIRWY) << TYPE(LOKBSN) << TYPE(I_LOKBSN)
|
||||||
<< TYPE(I_LOKBSN) << TYPE(BUAARE) << TYPE(BUISGL) << TYPE(SILTNK)
|
<< TYPE(BUAARE) << TYPE(BUISGL) << TYPE(SILTNK) << TYPE(AIRARE)
|
||||||
<< TYPE(AIRARE) << TYPE(BRIDGE) << TYPE(I_BRIDGE) << TYPE(TUNNEL)
|
<< TYPE(BRIDGE) << TYPE(I_BRIDGE) << TYPE(TUNNEL) << TYPE(I_TERMNL)
|
||||||
<< TYPE(I_TERMNL) << TYPE(SLCONS) << TYPE(I_SLCONS) << TYPE(PONTON)
|
<< TYPE(SLCONS) << TYPE(I_SLCONS) << TYPE(PONTON) << TYPE(I_PONTON)
|
||||||
<< TYPE(I_PONTON) << TYPE(HULKES) << TYPE(I_HULKES) << TYPE(FLODOC)
|
<< TYPE(HULKES) << TYPE(I_HULKES) << TYPE(FLODOC) << TYPE(I_FLODOC)
|
||||||
<< TYPE(I_FLODOC) << TYPE(DRYDOC) << TYPE(DAMCON) << TYPE(PYLONS)
|
<< TYPE(DRYDOC) << TYPE(DAMCON) << TYPE(PYLONS) << TYPE(MORFAC)
|
||||||
<< TYPE(MORFAC) << TYPE(GATCON) << TYPE(I_GATCON) << TYPE(BERTHS)
|
<< TYPE(GATCON) << TYPE(I_GATCON) << TYPE(BERTHS) << TYPE(I_BERTHS)
|
||||||
<< TYPE(I_BERTHS) << SUBTYPE(I_BERTHS, 6) << TYPE(DMPGRD) << TYPE(TSEZNE)
|
<< SUBTYPE(I_BERTHS, 6) << TYPE(DMPGRD) << TYPE(TSEZNE) << TYPE(OBSTRN)
|
||||||
<< TYPE(OBSTRN) << TYPE(UWTROC) << TYPE(DWRTPT) << SUBTYPE(ACHARE, 1)
|
<< TYPE(UWTROC) << TYPE(DWRTPT) << SUBTYPE(ACHARE, 1)
|
||||||
<< SUBTYPE(ACHARE, 2) << SUBTYPE(ACHARE, 3) << SUBTYPE(ACHARE, 4)
|
<< SUBTYPE(ACHARE, 2) << SUBTYPE(ACHARE, 3) << SUBTYPE(ACHARE, 4)
|
||||||
<< SUBTYPE(ACHARE, 5) << SUBTYPE(ACHARE, 6) << SUBTYPE(ACHARE, 7)
|
<< SUBTYPE(ACHARE, 5) << SUBTYPE(ACHARE, 6) << SUBTYPE(ACHARE, 7)
|
||||||
<< SUBTYPE(ACHARE, 8) << SUBTYPE(ACHARE, 9) << SUBTYPE(I_ACHARE, 1)
|
<< SUBTYPE(ACHARE, 8) << SUBTYPE(ACHARE, 9) << SUBTYPE(I_ACHARE, 1)
|
||||||
|
@ -154,7 +154,7 @@ ENCAtlas::ENCAtlas(const QString &fileName, QObject *parent)
|
|||||||
_zoom = zooms(_usage).min();
|
_zoom = zooms(_usage).min();
|
||||||
updateTransform();
|
updateTransform();
|
||||||
|
|
||||||
_cache.setMaxCost(10);
|
_cache.setMaxCost(16);
|
||||||
|
|
||||||
_valid = true;
|
_valid = true;
|
||||||
}
|
}
|
||||||
@ -345,9 +345,21 @@ QString ENCAtlas::key(int zoom, const QPoint &xy) const
|
|||||||
+ QString::number(xy.x()) + "_" + QString::number(xy.y());
|
+ QString::number(xy.x()) + "_" + QString::number(xy.y());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<Data*> ENCAtlas::levels() const
|
||||||
|
{
|
||||||
|
QList<Data*> list;
|
||||||
|
QMap<IntendedUsage, ENC::AtlasData*>::const_iterator it = _data.find(_usage);
|
||||||
|
|
||||||
|
list.append(it.value());
|
||||||
|
if (it != _data.cbegin())
|
||||||
|
list.prepend((--it).value());
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
void ENCAtlas::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
void ENCAtlas::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||||
{
|
{
|
||||||
AtlasData *data = _data.value(_usage);
|
QList<Data*> data(levels());
|
||||||
Range zr(zooms(_usage));
|
Range zr(zooms(_usage));
|
||||||
QPointF tl(floor(rect.left() / TILE_SIZE) * TILE_SIZE,
|
QPointF tl(floor(rect.left() / TILE_SIZE) * TILE_SIZE,
|
||||||
floor(rect.top() / TILE_SIZE) * TILE_SIZE);
|
floor(rect.top() / TILE_SIZE) * TILE_SIZE);
|
||||||
|
@ -74,6 +74,7 @@ private:
|
|||||||
void cancelJobs(bool wait);
|
void cancelJobs(bool wait);
|
||||||
QString key(int zoom, const QPoint &xy) const;
|
QString key(int zoom, const QPoint &xy) const;
|
||||||
void addMap(const QDir &dir, const QByteArray &file, const RectC &bounds);
|
void addMap(const QDir &dir, const QByteArray &file, const RectC &bounds);
|
||||||
|
QList<ENC::Data*> levels() const;
|
||||||
|
|
||||||
static bool processRecord(const ENC::ISO8211::Record &record,
|
static bool processRecord(const ENC::ISO8211::Record &record,
|
||||||
QByteArray &file, RectC &bounds);
|
QByteArray &file, RectC &bounds);
|
||||||
|
@ -338,7 +338,7 @@ void ENCMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
|||||||
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
if (QPixmapCache::find(key(_zoom, ttl), &pm))
|
||||||
painter->drawPixmap(ttl, pm);
|
painter->drawPixmap(ttl, pm);
|
||||||
else
|
else
|
||||||
tiles.append(RasterTile(_projection, _transform, _style, _data,
|
tiles.append(RasterTile(_projection, _transform, _style, _data,
|
||||||
_zoom, _zooms, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)),
|
_zoom, _zooms, QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)),
|
||||||
_tileRatio));
|
_tileRatio));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user