diff --git a/src/map/IMG/rastertile.cpp b/src/map/IMG/rastertile.cpp index 2c0495e0..da4dcb5f 100644 --- a/src/map/IMG/rastertile.cpp +++ b/src/map/IMG/rastertile.cpp @@ -1,5 +1,6 @@ #include #include +#include "map/imgmap.h" #include "textpathitem.h" #include "textpointitem.h" #include "bitmapline.h" @@ -166,6 +167,10 @@ void RasterTile::render() { QList 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 &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 &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++) { diff --git a/src/map/IMG/rastertile.h b/src/map/IMG/rastertile.h index e37a371d..03e1f6ed 100644 --- a/src/map/IMG/rastertile.h +++ b/src/map/IMG/rastertile.h @@ -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 &polygons, const QList &lines, QList &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 &polys); + void ll2xy(QList &points); + void drawPolygons(QPainter *painter); void drawLines(QPainter *painter); void drawTextItems(QPainter *painter, const QList &textItems); @@ -35,6 +39,7 @@ private: void processShields(const QRect &tileRect, QList &textItems); void processStreetNames(const QRect &tileRect, QList &textItems); + IMGMap *_map; const Style *_style; int _zoom; QPoint _xy; diff --git a/src/map/imgmap.cpp b/src/map/imgmap.cpp index 0607bf2d..1f53d64e 100644 --- a/src/map/imgmap.cpp +++ b/src/map/imgmap.cpp @@ -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 &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 &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)); } diff --git a/src/map/imgmap.h b/src/map/imgmap.h index c8a1934e..134db68d 100644 --- a/src/map/imgmap.h +++ b/src/map/imgmap.h @@ -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 &polys); - void ll2xy(QList &points); Transform transform(int zoom) const; void updateTransform();