mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Process all the ll2xy operations in parallel
This commit is contained in:
parent
3635a7dfdc
commit
baf574b68b
@ -1,5 +1,6 @@
|
||||
#include <QFont>
|
||||
#include <QPainter>
|
||||
#include "map/imgmap.h"
|
||||
#include "textpathitem.h"
|
||||
#include "textpointitem.h"
|
||||
#include "bitmapline.h"
|
||||
@ -166,6 +167,10 @@ void RasterTile::render()
|
||||
{
|
||||
QList<TextItem*> textItems;
|
||||
|
||||
ll2xy(_polygons);
|
||||
ll2xy(_lines);
|
||||
ll2xy(_points);
|
||||
|
||||
processPoints(textItems);
|
||||
processPolygons(textItems);
|
||||
processLines(textItems);
|
||||
@ -186,6 +191,25 @@ void RasterTile::render()
|
||||
qDeleteAll(textItems);
|
||||
}
|
||||
|
||||
void RasterTile::ll2xy(QList<MapData::Poly> &polys)
|
||||
{
|
||||
for (int i = 0; i < polys.size(); i++) {
|
||||
MapData::Poly &poly = polys[i];
|
||||
for (int j = 0; j < poly.points.size(); j++) {
|
||||
QPointF &p = poly.points[j];
|
||||
p = _map->ll2xy(Coordinates(p.x(), p.y()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::ll2xy(QList<MapData::Point> &points)
|
||||
{
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
QPointF p(_map->ll2xy(points.at(i).coordinates));
|
||||
points[i].coordinates = Coordinates(p.x(), p.y());
|
||||
}
|
||||
}
|
||||
|
||||
void RasterTile::drawPolygons(QPainter *painter)
|
||||
{
|
||||
for (int n = 0; n < _style->drawOrder().size(); n++) {
|
||||
|
@ -7,14 +7,15 @@
|
||||
class QPainter;
|
||||
class TextItem;
|
||||
class Style;
|
||||
class IMGMap;
|
||||
|
||||
class RasterTile
|
||||
{
|
||||
public:
|
||||
RasterTile(const Style *style, int zoom, const QRect &rect,
|
||||
RasterTile(IMGMap *map, const Style *style, int zoom, const QRect &rect,
|
||||
const QString &key, const QList<MapData::Poly> &polygons,
|
||||
const QList<MapData::Poly> &lines, QList<MapData::Point> &points)
|
||||
: _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
||||
: _map(map), _style(style), _zoom(zoom), _xy(rect.topLeft()),
|
||||
_key(key), _img(rect.size(), QImage::Format_ARGB32_Premultiplied),
|
||||
_polygons(polygons), _lines(lines), _points(points) {}
|
||||
|
||||
@ -25,6 +26,9 @@ public:
|
||||
void render();
|
||||
|
||||
private:
|
||||
void ll2xy(QList<MapData::Poly> &polys);
|
||||
void ll2xy(QList<MapData::Point> &points);
|
||||
|
||||
void drawPolygons(QPainter *painter);
|
||||
void drawLines(QPainter *painter);
|
||||
void drawTextItems(QPainter *painter, const QList<TextItem*> &textItems);
|
||||
@ -35,6 +39,7 @@ private:
|
||||
void processShields(const QRect &tileRect, QList<TextItem*> &textItems);
|
||||
void processStreetNames(const QRect &tileRect, QList<TextItem*> &textItems);
|
||||
|
||||
IMGMap *_map;
|
||||
const Style *_style;
|
||||
int _zoom;
|
||||
QPoint _xy;
|
||||
|
@ -141,35 +141,6 @@ void IMGMap::updateTransform()
|
||||
_bounds.adjust(0.5, 0, -0.5, 0);
|
||||
}
|
||||
|
||||
QPointF IMGMap::ll2xy(const Coordinates &c)
|
||||
{
|
||||
return _transform.proj2img(_projection.ll2xy(c));
|
||||
}
|
||||
|
||||
Coordinates IMGMap::xy2ll(const QPointF &p)
|
||||
{
|
||||
return _projection.xy2ll(_transform.img2proj(p));
|
||||
}
|
||||
|
||||
void IMGMap::ll2xy(QList<MapData::Poly> &polys)
|
||||
{
|
||||
for (int i = 0; i < polys.size(); i++) {
|
||||
MapData::Poly &poly = polys[i];
|
||||
for (int j = 0; j < poly.points.size(); j++) {
|
||||
QPointF &p = poly.points[j];
|
||||
p = ll2xy(Coordinates(p.x(), p.y()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IMGMap::ll2xy(QList<MapData::Point> &points)
|
||||
{
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
QPointF p(ll2xy(points.at(i).coordinates));
|
||||
points[i].coordinates = Coordinates(p.x(), p.y());
|
||||
}
|
||||
}
|
||||
|
||||
void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
{
|
||||
Q_UNUSED(flags);
|
||||
@ -202,7 +173,6 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
_transform.img2proj(polyRect.bottomRight()));
|
||||
_data.at(n)->polys(polyRectD.toRectC(_projection, 4), _zoom,
|
||||
&polygons, &lines);
|
||||
ll2xy(polygons); ll2xy(lines);
|
||||
|
||||
QRectF pointRect(QPointF(ttl.x() - TEXT_EXTENT,
|
||||
ttl.y() - TEXT_EXTENT), QPointF(ttl.x() + TILE_SIZE
|
||||
@ -212,9 +182,8 @@ void IMGMap::draw(QPainter *painter, const QRectF &rect, Flags flags)
|
||||
_transform.img2proj(pointRect.bottomRight()));
|
||||
_data.at(n)->points(pointRectD.toRectC(_projection, 4),
|
||||
_zoom, &points);
|
||||
ll2xy(points);
|
||||
|
||||
tiles.append(RasterTile(_data.at(n)->style(), _zoom,
|
||||
tiles.append(RasterTile(this, _data.at(n)->style(), _zoom,
|
||||
QRect(ttl, QSize(TILE_SIZE, TILE_SIZE)), key, polygons,
|
||||
lines, points));
|
||||
}
|
||||
|
@ -19,14 +19,16 @@ public:
|
||||
|
||||
QRectF bounds() {return _bounds;}
|
||||
|
||||
virtual int zoom() const {return _zoom;}
|
||||
virtual void setZoom(int zoom);
|
||||
virtual int zoomFit(const QSize &, const RectC &);
|
||||
virtual int zoomIn();
|
||||
virtual int zoomOut();
|
||||
int zoom() const {return _zoom;}
|
||||
void setZoom(int zoom);
|
||||
int zoomFit(const QSize &, const RectC &);
|
||||
int zoomIn();
|
||||
int zoomOut();
|
||||
|
||||
QPointF ll2xy(const Coordinates &c);
|
||||
Coordinates xy2ll(const QPointF &p);
|
||||
QPointF ll2xy(const Coordinates &c)
|
||||
{return _transform.proj2img(_projection.ll2xy(c));}
|
||||
Coordinates xy2ll(const QPointF &p)
|
||||
{return _projection.xy2ll(_transform.img2proj(p));}
|
||||
|
||||
void draw(QPainter *painter, const QRectF &rect, Flags flags);
|
||||
|
||||
@ -39,8 +41,6 @@ public:
|
||||
QString errorString() const {return _errorString;}
|
||||
|
||||
private:
|
||||
void ll2xy(QList<MapData::Poly> &polys);
|
||||
void ll2xy(QList<MapData::Point> &points);
|
||||
Transform transform(int zoom) const;
|
||||
void updateTransform();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user