4 #include <QtConcurrent>
6 #include "projection.h"
8 #include "ENC/mapdata.h"
9 #include "ENC/rastertile.h"
11 class ENCMapJob
: public QObject
16 ENCMapJob(const QList
<ENC::RasterTile
> &tiles
)
21 connect(&_watcher
, &QFutureWatcher
<void>::finished
, this,
22 &ENCMapJob::handleFinished
);
23 _future
= QtConcurrent::map(_tiles
, &ENC::RasterTile::render
);
24 _watcher
.setFuture(_future
);
26 void cancel(bool wait
)
30 _future
.waitForFinished();
32 const QList
<ENC::RasterTile
> &tiles() const {return _tiles
;}
35 void finished(ENCMapJob
*job
);
38 void handleFinished() {emit
finished(this);}
41 QFutureWatcher
<void> _watcher
;
42 QFuture
<void> _future
;
43 QList
<ENC::RasterTile
> _tiles
;
46 class ENCMap
: public Map
51 ENCMap(const QString
&fileName
, QObject
*parent
= 0);
53 QString
name() const {return _data
.name();}
55 QRectF
bounds() {return _bounds
;}
56 RectC
llBounds(const Projection
&) {return _llBounds
;}
58 int zoom() const {return _zoom
;}
59 void setZoom(int zoom
);
60 int zoomFit(const QSize
&size
, const RectC
&rect
);
64 void load(const Projection
&in
, const Projection
&out
, qreal deviceRatio
,
68 QPointF
ll2xy(const Coordinates
&c
)
69 {return _transform
.proj2img(_projection
.ll2xy(c
));}
70 Coordinates
xy2ll(const QPointF
&p
)
71 {return _projection
.xy2ll(_transform
.img2proj(p
));}
73 void draw(QPainter
*painter
, const QRectF
&rect
, Flags flags
);
75 bool isValid() const {return _data
.isValid();}
76 QString
errorString() const {return _data
.errorString();}
78 static Map
*create(const QString
&path
, bool *isMap
);
81 void jobFinished(ENCMapJob
*job
);
84 Transform
transform(int zoom
) const;
85 void updateTransform();
86 bool isRunning(int zoom
, const QPoint
&xy
) const;
87 void runJob(ENCMapJob
*job
);
88 void removeJob(ENCMapJob
*job
);
89 void cancelJobs(bool wait
);
90 QString
key(int zoom
, const QPoint
&xy
) const;
93 Projection _projection
;
100 QList
<ENCMapJob
*> _jobs
;
103 QString _errorString
;