diff --git a/src/map/mapsforge/rastertile.cpp b/src/map/mapsforge/rastertile.cpp index c6dd89b5..780064ee 100644 --- a/src/map/mapsforge/rastertile.cpp +++ b/src/map/mapsforge/rastertile.cpp @@ -171,7 +171,7 @@ void RasterTile::processAreaLabels(QList &textItems) continue; if (!path.path.elementCount()) - path.path = painterPath(path.poly); + path.path = painterPath(path.poly, false); const QImage *img = si ? &si->img() : 0; const QFont *font = ti ? &ti->font() : 0; @@ -232,16 +232,31 @@ void RasterTile::drawTextItems(QPainter *painter, textItems.at(i)->paint(painter); } -QPainterPath RasterTile::painterPath(const Polygon &polygon) const +QPainterPath RasterTile::painterPath(const Polygon &polygon, bool curve) const { QPainterPath path; for (int i = 0; i < polygon.size(); i++) { const QVector &subpath = polygon.at(i); - path.moveTo(ll2xy(subpath.first())); - for (int j = 1; j < subpath.size(); j++) - path.lineTo(ll2xy(subpath.at(j))); + if (curve) { + QPointF p1(ll2xy(subpath.first())); + QPointF p2(0, 0); + QPointF p3(0, 0); + + path.moveTo(p1); + for (int j = 1; j < subpath.size(); j++) { + p3 = ll2xy(subpath.at(j)); + p2 = QPointF((p1.x() + p3.x()) / 2.0, (p1.y() + p3.y()) / 2.0); + path.quadTo(p1, p2); + p1 = p3; + } + path.quadTo(p2, p3); + } else { + path.moveTo(ll2xy(subpath.first())); + for (int j = 1; j < subpath.size(); j++) + path.lineTo(ll2xy(subpath.at(j))); + } } return path; @@ -300,7 +315,7 @@ void RasterTile::drawPaths(QPainter *painter) } if (!is.path()->path.elementCount()) - is.path()->path = painterPath(is.path()->poly); + is.path()->path = painterPath(is.path()->poly, ri->curve()); if (ri->area()) { lp.setPen(ri->pen(_zoom)); diff --git a/src/map/mapsforge/rastertile.h b/src/map/mapsforge/rastertile.h index e9185f85..0cdb97d0 100644 --- a/src/map/mapsforge/rastertile.h +++ b/src/map/mapsforge/rastertile.h @@ -76,7 +76,7 @@ private: void processPointLabels(QList &textItems); void processAreaLabels(QList &textItems); void processLineLabels(QList &textItems); - QPainterPath painterPath(const Polygon &polygon) const; + QPainterPath painterPath(const Polygon &polygon, bool curve) const; void drawTextItems(QPainter *painter, const QList &textItems); void drawPaths(QPainter *painter); diff --git a/src/map/mapsforge/style.cpp b/src/map/mapsforge/style.cpp index 31bc90a1..8973ce3f 100644 --- a/src/map/mapsforge/style.cpp +++ b/src/map/mapsforge/style.cpp @@ -169,6 +169,11 @@ void Style::line(QXmlStreamReader &reader, const Rule &rule) else if (join == "bevel") ri._strokeJoin = Qt::BevelJoin; } + if (attr.hasAttribute("curve")) { + QString curve(attr.value("curve").toString()); + if (curve == "cubic") + ri._curve = true; + } _paths.append(ri); diff --git a/src/map/mapsforge/style.h b/src/map/mapsforge/style.h index 06b2bd72..392dfe2b 100644 --- a/src/map/mapsforge/style.h +++ b/src/map/mapsforge/style.h @@ -163,12 +163,13 @@ public: public: PathRender(const Rule &rule, int zOrder) : Render(rule), _zOrder(zOrder), _strokeWidth(0), _strokeCap(Qt::RoundCap), - _strokeJoin(Qt::RoundJoin), _area(false) {} + _strokeJoin(Qt::RoundJoin), _area(false), _curve(false) {} int zOrder() const {return _zOrder;} QPen pen(int zoom) const; QBrush brush() const; bool area() const {return _area;} + bool curve() const {return _curve;} private: friend class Style; @@ -180,7 +181,7 @@ public: Qt::PenCapStyle _strokeCap; Qt::PenJoinStyle _strokeJoin; QImage _fillImage; - bool _area; + bool _area, _curve; }; class TextRender : public Render